]> git.ipfire.org Git - thirdparty/man-pages.git/blob - man3/strsep.3
mount_namespaces.7: SEE ALSO: add mount(8), umount(8)
[thirdparty/man-pages.git] / man3 / strsep.3
1 .\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk)
2 .\"
3 .\" %%%LICENSE_START(VERBATIM)
4 .\" Permission is granted to make and distribute verbatim copies of this
5 .\" manual provided the copyright notice and this permission notice are
6 .\" preserved on all copies.
7 .\"
8 .\" Permission is granted to copy and distribute modified versions of this
9 .\" manual under the conditions for verbatim copying, provided that the
10 .\" entire resulting derived work is distributed under the terms of a
11 .\" permission notice identical to this one.
12 .\"
13 .\" Since the Linux kernel and libraries are constantly changing, this
14 .\" manual page may be incorrect or out-of-date. The author(s) assume no
15 .\" responsibility for errors or omissions, or for damages resulting from
16 .\" the use of the information contained herein. The author(s) may not
17 .\" have taken the same level of care in the production of this manual,
18 .\" which is licensed free of charge, as they might when working
19 .\" professionally.
20 .\"
21 .\" Formatted or processed versions of this manual, if unaccompanied by
22 .\" the source, must acknowledge the copyright and authors of this work.
23 .\" %%%LICENSE_END
24 .\"
25 .\" References consulted:
26 .\" Linux libc source code
27 .\" Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991)
28 .\" 386BSD man pages
29 .\" Modified Sat Jul 24 18:00:10 1993 by Rik Faith (faith@cs.unc.edu)
30 .\" Modified Mon Jan 20 12:04:18 1997 by Andries Brouwer (aeb@cwi.nl)
31 .\" Modified Tue Jan 23 20:23:07 2001 by Andries Brouwer (aeb@cwi.nl)
32 .\"
33 .TH STRSEP 3 2019-03-06 "GNU" "Linux Programmer's Manual"
34 .SH NAME
35 strsep \- extract token from string
36 .SH SYNOPSIS
37 .nf
38 .B #include <string.h>
39 .PP
40 .BI "char *strsep(char **" stringp ", const char *" delim );
41 .fi
42 .PP
43 .in -4n
44 Feature Test Macro Requirements for glibc (see
45 .BR feature_test_macros (7)):
46 .in
47 .PP
48 .BR strsep ():
49 Since glibc 2.19:
50 _DEFAULT_SOURCE
51 Glibc 2.19 and earlier:
52 _BSD_SOURCE
53 .SH DESCRIPTION
54 If
55 .I *stringp
56 is NULL, the
57 .BR strsep ()
58 function returns NULL
59 and does nothing else.
60 Otherwise, this function finds the first token
61 in the string
62 .IR *stringp ,
63 that is delimited by one of the bytes in the string
64 .IR delim .
65 This token is terminated by overwriting the delimiter
66 with a null byte (\(aq\e0\(aq),
67 and
68 .I *stringp
69 is updated to point past the token.
70 In case no delimiter was found, the token is taken to be
71 the entire string
72 .IR *stringp ,
73 and
74 .I *stringp
75 is made NULL.
76 .SH RETURN VALUE
77 The
78 .BR strsep ()
79 function returns a pointer to the token,
80 that is, it returns the original value of
81 .IR *stringp .
82 .SH ATTRIBUTES
83 For an explanation of the terms used in this section, see
84 .BR attributes (7).
85 .TS
86 allbox;
87 lb lb lb
88 l l l.
89 Interface Attribute Value
90 T{
91 .BR strsep ()
92 T} Thread safety MT-Safe
93 .TE
94 .SH CONFORMING TO
95 4.4BSD.
96 .SH NOTES
97 The
98 .BR strsep ()
99 function was introduced as a replacement for
100 .BR strtok (3),
101 since the latter cannot handle empty fields.
102 However,
103 .BR strtok (3)
104 conforms to C89/C99 and hence is more portable.
105 .SH BUGS
106 Be cautious when using this function.
107 If you do use it, note that:
108 .IP * 2
109 This function modifies its first argument.
110 .IP *
111 This function cannot be used on constant strings.
112 .IP *
113 The identity of the delimiting character is lost.
114 .SH SEE ALSO
115 .BR index (3),
116 .BR memchr (3),
117 .BR rindex (3),
118 .BR strchr (3),
119 .BR string (3),
120 .BR strpbrk (3),
121 .BR strspn (3),
122 .BR strstr (3),
123 .BR strtok (3)