]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/wcstok.3
user_namespaces.7: Minor rewordings of recently added text
[thirdparty/man-pages.git] / man3 / wcstok.3
CommitLineData
fea681da
MK
1.\" Copyright (c) Bruno Haible <haible@clisp.cons.org>
2.\"
89e3ffe9 3.\" %%%LICENSE_START(GPLv2+_DOC_ONEPARA)
fea681da
MK
4.\" This is free documentation; you can redistribute it and/or
5.\" modify it under the terms of the GNU General Public License as
6.\" published by the Free Software Foundation; either version 2 of
7.\" the License, or (at your option) any later version.
fe382ebf 8.\" %%%LICENSE_END
fea681da
MK
9.\"
10.\" References consulted:
11.\" GNU glibc-2 source code and manual
12.\" Dinkumware C library reference http://www.dinkumware.com/
008f1ecc 13.\" OpenGroup's Single UNIX specification http://www.UNIX-systems.org/online.html
fea681da
MK
14.\" ISO/IEC 9899:1999
15.\"
9ba01802 16.TH WCSTOK 3 2019-03-06 "GNU" "Linux Programmer's Manual"
fea681da
MK
17.SH NAME
18wcstok \- split wide-character string into tokens
19.SH SYNOPSIS
20.nf
21.B #include <wchar.h>
68e4db0a 22.PP
3d54a910
MK
23.BI "wchar_t *wcstok(wchar_t *" wcs ", const wchar_t *" delim \
24", wchar_t **" ptr );
fea681da
MK
25.fi
26.SH DESCRIPTION
60a90ecd
MK
27The
28.BR wcstok ()
29function is the wide-character equivalent of the
30.BR strtok (3)
31function,
c13182ef 32with an added argument to make it multithread-safe.
35478399 33It can be used
40aa0db0
MK
34to split a wide-character string
35.I wcs
36into tokens, where a token is
37defined as a substring not containing any wide-characters from
38.IR delim .
fea681da 39.PP
40aa0db0
MK
40The search starts at
41.IR wcs ,
42if
43.I wcs
44is not NULL,
45or at
46.IR *ptr ,
47if
48.I wcs
49is NULL.
75b94dc3 50First, any delimiter wide-characters are skipped, that is, the
40aa0db0
MK
51pointer is advanced beyond any wide-characters which occur in
52.IR delim .
1c44bd5b 53If the end of the wide-character string is now
60a90ecd
MK
54reached,
55.BR wcstok ()
56returns NULL, to indicate that no tokens
40aa0db0
MK
57were found, and stores an appropriate value in
58.IR *ptr ,
60a90ecd
MK
59so that subsequent calls to
60.BR wcstok ()
61will continue to return NULL.
62Otherwise, the
63.BR wcstok ()
64function recognizes the beginning of a token
fea681da 65and returns a pointer to it, but before doing that, it zero-terminates the
40aa0db0
MK
66token by replacing the next wide-character which occurs in
67.I delim
68with
d1a71985 69a null wide character (L\(aq\e0\(aq),
40aa0db0
MK
70and it updates
71.I *ptr
72so that subsequent calls will
fea681da 73continue searching after the end of recognized token.
47297adb 74.SH RETURN VALUE
60a90ecd
MK
75The
76.BR wcstok ()
77function returns a pointer to the next token,
1c44bd5b 78or NULL if no further token was found.
2721cf12 79.SH ATTRIBUTES
54b8b922
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{
2721cf12 88.BR wcstok ()
54b8b922
PH
89T} Thread safety MT-Safe
90.TE
47297adb 91.SH CONFORMING TO
789a49fa 92POSIX.1-2001, POSIX.1-2008, C99.
fea681da 93.SH NOTES
40aa0db0
MK
94The original
95.I wcs
96wide-character string is destructively modified during
fea681da
MK
97the operation.
98.SH EXAMPLE
99The following code loops over the tokens contained in a wide-character string.
bdd915e2
MK
100.PP
101.EX
fea681da
MK
102wchar_t *wcs = ...;
103wchar_t *token;
104wchar_t *state;
d1a71985 105for (token = wcstok(wcs, " \et\en", &state);
b9f02710 106 token != NULL;
d1a71985 107 token = wcstok(NULL, " \et\en", &state)) {
b9f02710 108 ...
fea681da 109}
bdd915e2 110.EE
47297adb 111.SH SEE ALSO
fea681da
MK
112.BR strtok (3),
113.BR wcschr (3)