]>
Commit | Line | Data |
---|---|---|
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 | .\" | |
460495ca | 16 | .TH WCSTOK 3 2015-08-08 "GNU" "Linux Programmer's Manual" |
fea681da MK |
17 | .SH NAME |
18 | wcstok \- 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 |
27 | The |
28 | .BR wcstok () | |
29 | function is the wide-character equivalent of the | |
30 | .BR strtok (3) | |
31 | function, | |
c13182ef | 32 | with an added argument to make it multithread-safe. |
35478399 | 33 | It can be used |
40aa0db0 MK |
34 | to split a wide-character string |
35 | .I wcs | |
36 | into tokens, where a token is | |
37 | defined as a substring not containing any wide-characters from | |
38 | .IR delim . | |
fea681da | 39 | .PP |
40aa0db0 MK |
40 | The search starts at |
41 | .IR wcs , | |
42 | if | |
43 | .I wcs | |
44 | is not NULL, | |
45 | or at | |
46 | .IR *ptr , | |
47 | if | |
48 | .I wcs | |
49 | is NULL. | |
75b94dc3 | 50 | First, any delimiter wide-characters are skipped, that is, the |
40aa0db0 MK |
51 | pointer is advanced beyond any wide-characters which occur in |
52 | .IR delim . | |
1c44bd5b | 53 | If the end of the wide-character string is now |
60a90ecd MK |
54 | reached, |
55 | .BR wcstok () | |
56 | returns NULL, to indicate that no tokens | |
40aa0db0 MK |
57 | were found, and stores an appropriate value in |
58 | .IR *ptr , | |
60a90ecd MK |
59 | so that subsequent calls to |
60 | .BR wcstok () | |
61 | will continue to return NULL. | |
62 | Otherwise, the | |
63 | .BR wcstok () | |
64 | function recognizes the beginning of a token | |
fea681da | 65 | and returns a pointer to it, but before doing that, it zero-terminates the |
40aa0db0 MK |
66 | token by replacing the next wide-character which occurs in |
67 | .I delim | |
68 | with | |
e9c23bc6 | 69 | a null wide character (L\(aq\\0\(aq), |
40aa0db0 MK |
70 | and it updates |
71 | .I *ptr | |
72 | so that subsequent calls will | |
fea681da | 73 | continue searching after the end of recognized token. |
47297adb | 74 | .SH RETURN VALUE |
60a90ecd MK |
75 | The |
76 | .BR wcstok () | |
77 | function returns a pointer to the next token, | |
1c44bd5b | 78 | or NULL if no further token was found. |
2721cf12 | 79 | .SH ATTRIBUTES |
54b8b922 PH |
80 | For an explanation of the terms used in this section, see |
81 | .BR attributes (7). | |
82 | .TS | |
83 | allbox; | |
84 | lb lb lb | |
85 | l l l. | |
86 | Interface Attribute Value | |
87 | T{ | |
2721cf12 | 88 | .BR wcstok () |
54b8b922 PH |
89 | T} Thread safety MT-Safe |
90 | .TE | |
47297adb | 91 | .SH CONFORMING TO |
789a49fa | 92 | POSIX.1-2001, POSIX.1-2008, C99. |
fea681da | 93 | .SH NOTES |
40aa0db0 MK |
94 | The original |
95 | .I wcs | |
96 | wide-character string is destructively modified during | |
fea681da MK |
97 | the operation. |
98 | .SH EXAMPLE | |
99 | The following code loops over the tokens contained in a wide-character string. | |
bdd915e2 MK |
100 | .PP |
101 | .EX | |
fea681da MK |
102 | wchar_t *wcs = ...; |
103 | wchar_t *token; | |
104 | wchar_t *state; | |
105 | for (token = wcstok(wcs, " \\t\\n", &state); | |
b9f02710 MK |
106 | token != NULL; |
107 | token = wcstok(NULL, " \\t\\n", &state)) { | |
108 | ... | |
fea681da | 109 | } |
bdd915e2 | 110 | .EE |
47297adb | 111 | .SH SEE ALSO |
fea681da MK |
112 | .BR strtok (3), |
113 | .BR wcschr (3) |