]>
Commit | Line | Data |
---|---|---|
fea681da MK |
1 | .\" Copyright (c) Bruno Haible <haible@clisp.cons.org> |
2 | .\" | |
e4a74ca8 | 3 | .\" SPDX-License-Identifier: GPL-2.0-or-later |
fea681da MK |
4 | .\" |
5 | .\" References consulted: | |
6 | .\" GNU glibc-2 source code and manual | |
7 | .\" Dinkumware C library reference http://www.dinkumware.com/ | |
008f1ecc | 8 | .\" OpenGroup's Single UNIX specification http://www.UNIX-systems.org/online.html |
fea681da MK |
9 | .\" ISO/IEC 9899:1999 |
10 | .\" | |
4c1c5274 | 11 | .TH wcstok 3 (date) "Linux man-pages (unreleased)" |
fea681da MK |
12 | .SH NAME |
13 | wcstok \- split wide-character string into tokens | |
21a12069 AC |
14 | .SH LIBRARY |
15 | Standard C library | |
8fc3b2cf | 16 | .RI ( libc ", " \-lc ) |
fea681da MK |
17 | .SH SYNOPSIS |
18 | .nf | |
19 | .B #include <wchar.h> | |
68e4db0a | 20 | .PP |
21a4b17e AC |
21 | .BI "wchar_t *wcstok(wchar_t *restrict " wcs \ |
22 | ", const wchar_t *restrict " delim , | |
23 | .BI " wchar_t **restrict " ptr ); | |
fea681da MK |
24 | .fi |
25 | .SH DESCRIPTION | |
60a90ecd MK |
26 | The |
27 | .BR wcstok () | |
28 | function is the wide-character equivalent of the | |
29 | .BR strtok (3) | |
30 | function, | |
c13182ef | 31 | with an added argument to make it multithread-safe. |
35478399 | 32 | It can be used |
40aa0db0 MK |
33 | to split a wide-character string |
34 | .I wcs | |
35 | into tokens, where a token is | |
36 | defined as a substring not containing any wide-characters from | |
37 | .IR delim . | |
fea681da | 38 | .PP |
40aa0db0 MK |
39 | The search starts at |
40 | .IR wcs , | |
41 | if | |
42 | .I wcs | |
43 | is not NULL, | |
44 | or at | |
45 | .IR *ptr , | |
46 | if | |
47 | .I wcs | |
48 | is NULL. | |
75b94dc3 | 49 | First, any delimiter wide-characters are skipped, that is, the |
40aa0db0 MK |
50 | pointer is advanced beyond any wide-characters which occur in |
51 | .IR delim . | |
1c44bd5b | 52 | If the end of the wide-character string is now |
60a90ecd MK |
53 | reached, |
54 | .BR wcstok () | |
55 | returns NULL, to indicate that no tokens | |
40aa0db0 MK |
56 | were found, and stores an appropriate value in |
57 | .IR *ptr , | |
60a90ecd MK |
58 | so that subsequent calls to |
59 | .BR wcstok () | |
60 | will continue to return NULL. | |
61 | Otherwise, the | |
62 | .BR wcstok () | |
63 | function recognizes the beginning of a token | |
fea681da | 64 | and returns a pointer to it, but before doing that, it zero-terminates the |
40aa0db0 MK |
65 | token by replacing the next wide-character which occurs in |
66 | .I delim | |
67 | with | |
d1a71985 | 68 | a null wide character (L\(aq\e0\(aq), |
40aa0db0 MK |
69 | and it updates |
70 | .I *ptr | |
71 | so that subsequent calls will | |
fea681da | 72 | continue searching after the end of recognized token. |
47297adb | 73 | .SH RETURN VALUE |
60a90ecd MK |
74 | The |
75 | .BR wcstok () | |
76 | function returns a pointer to the next token, | |
1c44bd5b | 77 | or NULL if no further token was found. |
2721cf12 | 78 | .SH ATTRIBUTES |
54b8b922 PH |
79 | For an explanation of the terms used in this section, see |
80 | .BR attributes (7). | |
c466875e MK |
81 | .ad l |
82 | .nh | |
54b8b922 PH |
83 | .TS |
84 | allbox; | |
c466875e | 85 | lbx lb lb |
54b8b922 PH |
86 | l l l. |
87 | Interface Attribute Value | |
88 | T{ | |
2721cf12 | 89 | .BR wcstok () |
54b8b922 PH |
90 | T} Thread safety MT-Safe |
91 | .TE | |
c466875e MK |
92 | .hy |
93 | .ad | |
94 | .sp 1 | |
3113c7f3 | 95 | .SH STANDARDS |
789a49fa | 96 | POSIX.1-2001, POSIX.1-2008, C99. |
fea681da | 97 | .SH NOTES |
40aa0db0 MK |
98 | The original |
99 | .I wcs | |
100 | wide-character string is destructively modified during | |
fea681da | 101 | the operation. |
a14af333 | 102 | .SH EXAMPLES |
fea681da | 103 | The following code loops over the tokens contained in a wide-character string. |
bdd915e2 MK |
104 | .PP |
105 | .EX | |
fea681da MK |
106 | wchar_t *wcs = ...; |
107 | wchar_t *token; | |
108 | wchar_t *state; | |
c61a1c39 | 109 | for (token = wcstok(wcs, L" \et\en", &state); |
b9f02710 | 110 | token != NULL; |
c61a1c39 | 111 | token = wcstok(NULL, L" \et\en", &state)) { |
b9f02710 | 112 | ... |
fea681da | 113 | } |
bdd915e2 | 114 | .EE |
47297adb | 115 | .SH SEE ALSO |
fea681da MK |
116 | .BR strtok (3), |
117 | .BR wcschr (3) |