]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - lib/libc/string/wcstok.3
Remove $FreeBSD$: two-line nroff pattern
[FreeBSD/FreeBSD.git] / lib / libc / string / wcstok.3
1 .\" Copyright (c) 1998 Softweyr LLC.  All rights reserved.
2 .\"
3 .\" strtok_r, from Berkeley strtok
4 .\" Oct 13, 1998 by Wes Peters <wes@softweyr.com>
5 .\"
6 .\" Copyright (c) 1988, 1991, 1993
7 .\"     The Regents of the University of California.  All rights reserved.
8 .\"
9 .\" This code is derived from software contributed to Berkeley by
10 .\" the American National Standards Committee X3, on Information
11 .\" Processing Systems.
12 .\"
13 .\" Redistribution and use in source and binary forms, with or without
14 .\" modification, are permitted provided that the following conditions
15 .\" are met:
16 .\"
17 .\" 1. Redistributions of source code must retain the above copyright
18 .\"    notices, this list of conditions and the following disclaimer.
19 .\"
20 .\" 2. Redistributions in binary form must reproduce the above
21 .\"    copyright notices, this list of conditions and the following
22 .\"    disclaimer in the documentation and/or other materials provided
23 .\"    with the distribution.
24 .\"
25 .\" 3. All advertising materials mentioning features or use of this
26 .\"    software must display the following acknowledgement:
27 .\"
28 .\"     This product includes software developed by Softweyr LLC, the
29 .\"      University of California, Berkeley, and its contributors.
30 .\"
31 .\" 4. Neither the name of Softweyr LLC, the University nor the names
32 .\"    of its contributors may be used to endorse or promote products
33 .\"    derived from this software without specific prior written
34 .\"    permission.
35 .\"
36 .\" THIS SOFTWARE IS PROVIDED BY SOFTWEYR LLC, THE REGENTS AND
37 .\" CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
38 .\" INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
39 .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
40 .\" DISCLAIMED.  IN NO EVENT SHALL SOFTWEYR LLC, THE REGENTS, OR
41 .\" CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
42 .\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
43 .\" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
44 .\" USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
45 .\" ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
46 .\" OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
47 .\" OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
48 .\" SUCH DAMAGE.
49 .\"
50 .Dd October 3, 2002
51 .Dt WCSTOK 3
52 .Os
53 .Sh NAME
54 .Nm wcstok
55 .Nd split wide-character string into tokens
56 .Sh LIBRARY
57 .Lb libc
58 .Sh SYNOPSIS
59 .In wchar.h
60 .Ft wchar_t *
61 .Fn wcstok "wchar_t * restrict str" "const wchar_t * restrict sep" "wchar_t ** restrict last"
62 .Sh DESCRIPTION
63 The
64 .Fn wcstok
65 function
66 is used to isolate sequential tokens in a null-terminated wide character
67 string,
68 .Fa str .
69 These tokens are separated in the string by at least one of the
70 characters in
71 .Fa sep .
72 The first time that
73 .Fn wcstok
74 is called,
75 .Fa str
76 should be specified; subsequent calls, wishing to obtain further tokens
77 from the same string, should pass a null pointer instead.
78 The separator string,
79 .Fa sep ,
80 must be supplied each time, and may change between calls.
81 The context pointer
82 .Fa last
83 must be provided on each call.
84 .Pp
85 The
86 .Fn wcstok
87 function is the wide character counterpart of the
88 .Fn strtok_r
89 function.
90 .Sh RETURN VALUES
91 The
92 .Fn wcstok
93 function
94 returns a pointer to the beginning of each subsequent token in the string,
95 after replacing the token itself with a null wide character (L'\e0').
96 When no more tokens remain, a null pointer is returned.
97 .Sh EXAMPLES
98 The following code fragment splits a wide character string on
99 .Tn ASCII
100 space, tab and newline characters and writes the tokens to
101 standard output:
102 .Bd -literal -offset indent
103 const wchar_t *seps = L" \et\en";
104 wchar_t *last, *tok, text[] = L" \enone\ettwo\et\etthree  \en";
105
106 for (tok = wcstok(text, seps, &last); tok != NULL;
107     tok = wcstok(NULL, seps, &last))
108         wprintf(L"%ls\en", tok);
109 .Ed
110 .Sh COMPATIBILITY
111 Some early implementations of
112 .Fn wcstok
113 omit the
114 context pointer argument,
115 .Fa last ,
116 and maintain state across calls in a static variable like
117 .Fn strtok
118 does.
119 .Sh SEE ALSO
120 .Xr strtok 3 ,
121 .Xr wcschr 3 ,
122 .Xr wcscspn 3 ,
123 .Xr wcspbrk 3 ,
124 .Xr wcsrchr 3 ,
125 .Xr wcsspn 3
126 .Sh STANDARDS
127 The
128 .Fn wcstok
129 function
130 conforms to
131 .St -isoC-99 .