OSDN Git Service

(split) LDP: Update original to LDP v3.50.
[linuxjm/LDP_man-pages.git] / original / man3 / wcstok.3
1 .\" Copyright (c) Bruno Haible <haible@clisp.cons.org>
2 .\"
3 .\" %%%LICENSE_START(GPLv2+_DOC_ONEPARA)
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.
8 .\" %%%LICENSE_END
9 .\"
10 .\" References consulted:
11 .\"   GNU glibc-2 source code and manual
12 .\"   Dinkumware C library reference http://www.dinkumware.com/
13 .\"   OpenGroup's Single UNIX specification http://www.UNIX-systems.org/online.html
14 .\"   ISO/IEC 9899:1999
15 .\"
16 .TH WCSTOK 3  2011-09-28 "GNU" "Linux Programmer's Manual"
17 .SH NAME
18 wcstok \- split wide-character string into tokens
19 .SH SYNOPSIS
20 .nf
21 .B #include <wchar.h>
22 .sp
23 .BI "wchar_t *wcstok(wchar_t *" wcs ", const wchar_t *" delim \
24 ", wchar_t **" ptr );
25 .fi
26 .SH DESCRIPTION
27 The
28 .BR wcstok ()
29 function is the wide-character equivalent of the
30 .BR strtok (3)
31 function,
32 with an added argument to make it multithread-safe.
33 It can be used
34 to split a wide-character string \fIwcs\fP into tokens, where a token is
35 defined as a substring not containing any wide-characters from \fIdelim\fP.
36 .PP
37 The search starts at \fIwcs\fP, if \fIwcs\fP is not NULL,
38 or at \fI*ptr\fP, if \fIwcs\fP is NULL.
39 First, any delimiter wide-characters are skipped, that is, the
40 pointer is advanced beyond any wide-characters which occur in \fIdelim\fP.
41 If the end of the wide-character string is now
42 reached,
43 .BR wcstok ()
44 returns NULL, to indicate that no tokens
45 were found, and stores an appropriate value in \fI*ptr\fP,
46 so that subsequent calls to
47 .BR wcstok ()
48 will continue to return NULL.
49 Otherwise, the
50 .BR wcstok ()
51 function recognizes the beginning of a token
52 and returns a pointer to it, but before doing that, it zero-terminates the
53 token by replacing the next wide-character which occurs in \fIdelim\fP with
54 a null wide character (L\(aq\\0\(aq),
55 and it updates \fI*ptr\fP so that subsequent calls will
56 continue searching after the end of recognized token.
57 .SH RETURN VALUE
58 The
59 .BR wcstok ()
60 function returns a pointer to the next token,
61 or NULL if no further token was found.
62 .SH CONFORMING TO
63 C99.
64 .SH NOTES
65 The original \fIwcs\fP wide-character string is destructively modified during
66 the operation.
67 .SH EXAMPLE
68 The following code loops over the tokens contained in a wide-character string.
69 .sp
70 .nf
71 wchar_t *wcs = ...;
72 wchar_t *token;
73 wchar_t *state;
74 for (token = wcstok(wcs, " \\t\\n", &state);
75     token != NULL;
76     token = wcstok(NULL, " \\t\\n", &state)) {
77     ...
78 }
79 .fi
80 .SH SEE ALSO
81 .BR strtok (3),
82 .BR wcschr (3)