]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/strsep.3
isatty.3: Most non-tty files nowadays result in the error ENOTTY
[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.\"
97986708 33.TH STRSEP 3 2016-03-15 "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>
68e4db0a 39.PP
fea681da
MK
40.BI "char *strsep(char **" stringp ", const char *" delim );
41.fi
68e4db0a 42.PP
cc4615cc
MK
43.in -4n
44Feature Test Macro Requirements for glibc (see
45.BR feature_test_macros (7)):
46.in
68e4db0a 47.PP
cc4615cc 48.BR strsep ():
51c612fb
MK
49 Since glibc 2.19:
50 _DEFAULT_SOURCE
51 Glibc 2.19 and earlier:
52 _BSD_SOURCE
fea681da 53.SH DESCRIPTION
46d8df8e
MK
54If
55.I *stringp
56is NULL, the
60a90ecd
MK
57.BR strsep ()
58function returns NULL
c13182ef
MK
59and does nothing else.
60Otherwise, this function finds the first token
46d8df8e
MK
61in the string
62.IR *stringp ,
4d9fbd4e 63that is delimited by one of the bytes in the string
46d8df8e 64.IR delim .
71d9e7ae 65This token is terminated by overwriting the delimiter
4d9fbd4e 66with a null byte (\(aq\\0\(aq),
46d8df8e
MK
67and
68.I *stringp
69is updated to point past the token.
fea681da 70In case no delimiter was found, the token is taken to be
46d8df8e
MK
71the entire string
72.IR *stringp ,
73and
74.I *stringp
75is made NULL.
47297adb 76.SH RETURN VALUE
60a90ecd
MK
77The
78.BR strsep ()
79function returns a pointer to the token,
46d8df8e
MK
80that is, it returns the original value of
81.IR *stringp .
178c91f4 82.SH ATTRIBUTES
0c5deb50
PH
83For an explanation of the terms used in this section, see
84.BR attributes (7).
85.TS
86allbox;
87lb lb lb
88l l l.
89Interface Attribute Value
90T{
178c91f4 91.BR strsep ()
0c5deb50
PH
92T} Thread safety MT-Safe
93.TE
47297adb 94.SH CONFORMING TO
44a2c328 954.4BSD.
fea681da 96.SH NOTES
60a90ecd
MK
97The
98.BR strsep ()
99function was introduced as a replacement for
100.BR strtok (3),
101since the latter cannot handle empty fields.
102However,
103.BR strtok (3)
104conforms to C89/C99 and hence is more portable.
fea681da 105.SH BUGS
d1a7f7d9
MK
106Be cautious when using this function.
107If you do use it, note that:
108.IP * 2
109This function modifies its first argument.
110.IP *
111This function cannot be used on constant strings.
112.IP *
113The identity of the delimiting character is lost.
47297adb 114.SH SEE ALSO
fea681da
MK
115.BR index (3),
116.BR memchr (3),
117.BR rindex (3),
118.BR strchr (3),
d095200e 119.BR string (3),
fea681da
MK
120.BR strpbrk (3),
121.BR strspn (3),
122.BR strstr (3),
123.BR strtok (3)