]>
Commit | Line | Data |
---|---|---|
fea681da MK |
1 | .\" Copyright (c) Bruno Haible <haible@clisp.cons.org> |
2 | .\" | |
3 | .\" This is free documentation; you can redistribute it and/or | |
4 | .\" modify it under the terms of the GNU General Public License as | |
5 | .\" published by the Free Software Foundation; either version 2 of | |
6 | .\" the License, or (at your option) any later version. | |
7 | .\" | |
8 | .\" References consulted: | |
9 | .\" GNU glibc-2 source code and manual | |
10 | .\" Dinkumware C library reference http://www.dinkumware.com/ | |
11 | .\" OpenGroup's Single Unix specification http://www.UNIX-systems.org/online.html | |
12 | .\" ISO/IEC 9899:1999 | |
13 | .\" | |
14 | .TH WCSTOK 3 1999-07-25 "GNU" "Linux Programmer's Manual" | |
15 | .SH NAME | |
16 | wcstok \- split wide-character string into tokens | |
17 | .SH SYNOPSIS | |
18 | .nf | |
19 | .B #include <wchar.h> | |
20 | .sp | |
21 | .BI "wchar_t *wcstok(wchar_t *" wcs ", const wchar_t *" delim ", wchar_t **" ptr ); | |
22 | .fi | |
23 | .SH DESCRIPTION | |
c13182ef MK |
24 | The \fBwcstok\fP() function is the wide-character equivalent of the |
25 | \fBstrtok\fP() function, | |
26 | with an added argument to make it multithread-safe. | |
35478399 | 27 | It can be used |
fea681da MK |
28 | to split a wide-character string \fIwcs\fP into tokens, where a token is |
29 | defined as a substring not containing any wide-characters from \fIdelim\fP. | |
30 | .PP | |
1c44bd5b MK |
31 | The search starts at \fIwcs\fP, if \fIwcs\fP is not NULL, |
32 | or at \fI*ptr\fP, if \fIwcs\fP is NULL. | |
33 | First, any delimiter wide-characters are skipped, i.e. the | |
fea681da | 34 | pointer is advanced beyond any wide-characters which occur in \fIdelim\fP. |
1c44bd5b MK |
35 | If the end of the wide-character string is now |
36 | reached, \fBwcstok\fP() returns NULL, to indicate that no tokens | |
37 | were found, and stores an appropriate value in \fI*ptr\fP, | |
c13182ef | 38 | so that subsequent calls to \fBwcstok\fP() will continue to return NULL. |
35478399 | 39 | Otherwise, the \fBwcstok\fP() function recognizes the beginning of a token |
fea681da MK |
40 | and returns a pointer to it, but before doing that, it zero-terminates the |
41 | token by replacing the next wide-character which occurs in \fIdelim\fP with | |
42 | a L'\\0' character, and it updates \fI*ptr\fP so that subsequent calls will | |
43 | continue searching after the end of recognized token. | |
44 | .SH "RETURN VALUE" | |
1c44bd5b MK |
45 | The \fBwcstok\fP() function returns a pointer to the next token, |
46 | or NULL if no further token was found. | |
fea681da MK |
47 | .SH NOTES |
48 | The original \fIwcs\fP wide-character string is destructively modified during | |
49 | the operation. | |
50 | .SH EXAMPLE | |
51 | The following code loops over the tokens contained in a wide-character string. | |
52 | .sp | |
53 | .nf | |
54 | wchar_t *wcs = ...; | |
55 | wchar_t *token; | |
56 | wchar_t *state; | |
57 | for (token = wcstok(wcs, " \\t\\n", &state); | |
b9f02710 MK |
58 | token != NULL; |
59 | token = wcstok(NULL, " \\t\\n", &state)) { | |
60 | ... | |
fea681da MK |
61 | } |
62 | .fi | |
63 | .SH "CONFORMING TO" | |
68e1685c | 64 | C99. |
fea681da MK |
65 | .SH "SEE ALSO" |
66 | .BR strtok (3), | |
67 | .BR wcschr (3) |