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