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