]> git.ipfire.org Git - thirdparty/man-pages.git/blob - man3/wcstok.3
d530c0a6371173b480dd49d1c97e265cd51d9781
[thirdparty/man-pages.git] / man3 / wcstok.3
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
24 The
25 .BR wcstok ()
26 function is the wide-character equivalent of the
27 .BR strtok (3)
28 function,
29 with an added argument to make it multithread-safe.
30 It can be used
31 to split a wide-character string \fIwcs\fP into tokens, where a token is
32 defined as a substring not containing any wide-characters from \fIdelim\fP.
33 .PP
34 The search starts at \fIwcs\fP, if \fIwcs\fP is not NULL,
35 or at \fI*ptr\fP, if \fIwcs\fP is NULL.
36 First, any delimiter wide-characters are skipped, i.e. the
37 pointer is advanced beyond any wide-characters which occur in \fIdelim\fP.
38 If the end of the wide-character string is now
39 reached,
40 .BR wcstok ()
41 returns NULL, to indicate that no tokens
42 were found, and stores an appropriate value in \fI*ptr\fP,
43 so that subsequent calls to
44 .BR wcstok ()
45 will continue to return NULL.
46 Otherwise, the
47 .BR wcstok ()
48 function recognizes the beginning of a token
49 and returns a pointer to it, but before doing that, it zero-terminates the
50 token by replacing the next wide-character which occurs in \fIdelim\fP with
51 a L'\\0' character, and it updates \fI*ptr\fP so that subsequent calls will
52 continue searching after the end of recognized token.
53 .SH "RETURN VALUE"
54 The
55 .BR wcstok ()
56 function returns a pointer to the next token,
57 or NULL if no further token was found.
58 .SH "CONFORMING TO"
59 C99.
60 .SH NOTES
61 The original \fIwcs\fP wide-character string is destructively modified during
62 the operation.
63 .SH EXAMPLE
64 The following code loops over the tokens contained in a wide-character string.
65 .sp
66 .nf
67 wchar_t *wcs = ...;
68 wchar_t *token;
69 wchar_t *state;
70 for (token = wcstok(wcs, " \\t\\n", &state);
71 token != NULL;
72 token = wcstok(NULL, " \\t\\n", &state)) {
73 ...
74 }
75 .fi
76 .SH "SEE ALSO"
77 .BR strtok (3),
78 .BR wcschr (3)