]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/strsep.3
getauxval.3: wfix
[thirdparty/man-pages.git] / man3 / strsep.3
CommitLineData
fea681da
MK
1.\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk)
2.\"
93015253 3.\" %%%LICENSE_START(VERBATIM)
fea681da
MK
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.
c13182ef 12.\"
fea681da
MK
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.
c13182ef 20.\"
fea681da
MK
21.\" Formatted or processed versions of this manual, if unaccompanied by
22.\" the source, must acknowledge the copyright and authors of this work.
4b72fb64 23.\" %%%LICENSE_END
fea681da
MK
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.\"
fe0fefbf 33.TH STRSEP 3 2015-03-02 "GNU" "Linux Programmer's Manual"
fea681da
MK
34.SH NAME
35strsep \- extract token from string
36.SH SYNOPSIS
37.nf
38.B #include <string.h>
39.sp
40.BI "char *strsep(char **" stringp ", const char *" delim );
41.fi
cc4615cc
MK
42.sp
43.in -4n
44Feature Test Macro Requirements for glibc (see
45.BR feature_test_macros (7)):
46.in
47.sp
48.BR strsep ():
49_BSD_SOURCE
fea681da 50.SH DESCRIPTION
46d8df8e
MK
51If
52.I *stringp
53is NULL, the
60a90ecd
MK
54.BR strsep ()
55function returns NULL
c13182ef
MK
56and does nothing else.
57Otherwise, this function finds the first token
46d8df8e
MK
58in the string
59.IR *stringp ,
4d9fbd4e 60that is delimited by one of the bytes in the string
46d8df8e 61.IR delim .
71d9e7ae 62This token is terminated by overwriting the delimiter
4d9fbd4e 63with a null byte (\(aq\\0\(aq),
46d8df8e
MK
64and
65.I *stringp
66is updated to point past the token.
fea681da 67In case no delimiter was found, the token is taken to be
46d8df8e
MK
68the entire string
69.IR *stringp ,
70and
71.I *stringp
72is made NULL.
47297adb 73.SH RETURN VALUE
60a90ecd
MK
74The
75.BR strsep ()
76function returns a pointer to the token,
46d8df8e
MK
77that is, it returns the original value of
78.IR *stringp .
178c91f4 79.SH ATTRIBUTES
0c5deb50
PH
80For an explanation of the terms used in this section, see
81.BR attributes (7).
82.TS
83allbox;
84lb lb lb
85l l l.
86Interface Attribute Value
87T{
178c91f4 88.BR strsep ()
0c5deb50
PH
89T} Thread safety MT-Safe
90.TE
47297adb 91.SH CONFORMING TO
44a2c328 924.4BSD.
fea681da 93.SH NOTES
60a90ecd
MK
94The
95.BR strsep ()
96function was introduced as a replacement for
97.BR strtok (3),
98since the latter cannot handle empty fields.
99However,
100.BR strtok (3)
101conforms to C89/C99 and hence is more portable.
fea681da 102.SH BUGS
d1a7f7d9
MK
103Be cautious when using this function.
104If you do use it, note that:
105.IP * 2
106This function modifies its first argument.
107.IP *
108This function cannot be used on constant strings.
109.IP *
110The identity of the delimiting character is lost.
47297adb 111.SH SEE ALSO
fea681da
MK
112.BR index (3),
113.BR memchr (3),
114.BR rindex (3),
115.BR strchr (3),
d095200e 116.BR string (3),
fea681da
MK
117.BR strpbrk (3),
118.BR strspn (3),
119.BR strstr (3),
120.BR strtok (3)