3 <<strtok>>,<<strtok_r>>,<<strsep>>---get next token from a string
16 char *strtok(char *<[source]>, const char *<[delimiters]>)
17 char *strtok_r(char *<[source]>, const char *<[delimiters]>,
19 char *strsep(char **<[source_ptr]>, const char *<[delimiters]>)
23 char *strtok(<[source]>, <[delimiters]>)
27 char *strtok_r(<[source]>, <[delimiters]>, <[lasts]>)
32 char *strsep(<[source_ptr]>, <[delimiters]>)
33 char **<[source_ptr]>;
37 The <<strtok>> function is used to isolate sequential tokens in a
38 null-terminated string, <<*<[source]>>>. These tokens are delimited
39 in the string by at least one of the characters in <<*<[delimiters]>>>.
40 The first time that <<strtok>> is called, <<*<[source]>>> should be
41 specified; subsequent calls, wishing to obtain further tokens from
42 the same string, should pass a null pointer instead. The separator
43 string, <<*<[delimiters]>>>, must be supplied each time, and may
46 The <<strtok>> function returns a pointer to the beginning of each
47 subsequent token in the string, after replacing the separator
48 character itself with a NUL character. When no more tokens remain,
49 a null pointer is returned.
51 The <<strtok_r>> function has the same behavior as <<strtok>>, except
52 a pointer to placeholder <<*[lasts]>> must be supplied by the caller.
54 The <<strsep>> function is similar in behavior to <<strtok>>, except
55 a pointer to the string pointer must be supplied <<[source_ptr]>> and
56 the function does not skip leading delimeters. When the string starts
57 with a delimeter, the delimeter is changed to the NUL character and
58 the empty string is returned. Like <<strtok_r>> and <<strtok>>, the
59 <<*[source_ptr]>> is updated to the next character following the
60 last delimeter found or NULL if the end of string is reached with
64 <<strtok>>, <<strtok_r>>, and <<strsep>> all return a pointer to the
65 next token, or <<NULL>> if no more tokens can be found. For
66 <<strsep>>, a token may be the empty string.
69 <<strtok>> is unsafe for multi-thread applications. <<strtok_r>>
70 and <<strsep>> are MT-Safe and should be used instead.
74 <<strtok_r>> is POSIX.
75 <<strsep>> is a BSD-extension.
77 <<strtok>>, <<strtok_r>>, and <<strsep>> require no supporting OS subroutines.
83 /* undef STRICT_ANSI so that strtok_r prototype will be defined */
84 #undef __STRICT_ANSI__
91 extern char *__strtok_r (char *, const char *, char **, int);
94 _DEFUN (strtok
, (s
, delim
),
96 register const char *delim
)
98 _REENT_CHECK_MISC(_REENT
);
99 return __strtok_r (s
, delim
, &(_REENT_STRTOK_LAST(_REENT
)), 1);