xref: /dflybsd-src/lib/libc/string/wcstok.3 (revision 0d5acd7467c4e95f792ef49fceb3ab8e917ce86b)
1716024cdSPeter Avalos.\" Copyright (c) 1998 Softweyr LLC.  All rights reserved.
2716024cdSPeter Avalos.\"
3716024cdSPeter Avalos.\" strtok_r, from Berkeley strtok
4716024cdSPeter Avalos.\" Oct 13, 1998 by Wes Peters <wes@softweyr.com>
5716024cdSPeter Avalos.\"
6716024cdSPeter Avalos.\" Copyright (c) 1988, 1991, 1993
7716024cdSPeter Avalos.\"	The Regents of the University of California.  All rights reserved.
8716024cdSPeter Avalos.\"
9716024cdSPeter Avalos.\" This code is derived from software contributed to Berkeley by
10716024cdSPeter Avalos.\" the American National Standards Committee X3, on Information
11716024cdSPeter Avalos.\" Processing Systems.
12716024cdSPeter Avalos.\"
13716024cdSPeter Avalos.\" Redistribution and use in source and binary forms, with or without
14716024cdSPeter Avalos.\" modification, are permitted provided that the following conditions
15716024cdSPeter Avalos.\" are met:
16716024cdSPeter Avalos.\"
17716024cdSPeter Avalos.\" 1. Redistributions of source code must retain the above copyright
18716024cdSPeter Avalos.\"    notices, this list of conditions and the following disclaimer.
19716024cdSPeter Avalos.\"
20716024cdSPeter Avalos.\" 2. Redistributions in binary form must reproduce the above
21716024cdSPeter Avalos.\"    copyright notices, this list of conditions and the following
22716024cdSPeter Avalos.\"    disclaimer in the documentation and/or other materials provided
23716024cdSPeter Avalos.\"    with the distribution.
24716024cdSPeter Avalos.\"
25716024cdSPeter Avalos.\" 3. All advertising materials mentioning features or use of this
26716024cdSPeter Avalos.\"    software must display the following acknowledgement:
27716024cdSPeter Avalos.\"
28716024cdSPeter Avalos.\"	This product includes software developed by Softweyr LLC, the
29716024cdSPeter Avalos.\"      University of California, Berkeley, and its contributors.
30716024cdSPeter Avalos.\"
31716024cdSPeter Avalos.\" 4. Neither the name of Softweyr LLC, the University nor the names
32716024cdSPeter Avalos.\"    of its contributors may be used to endorse or promote products
33716024cdSPeter Avalos.\"    derived from this software without specific prior written
34716024cdSPeter Avalos.\"    permission.
35716024cdSPeter Avalos.\"
36716024cdSPeter Avalos.\" THIS SOFTWARE IS PROVIDED BY SOFTWEYR LLC, THE REGENTS AND
37716024cdSPeter Avalos.\" CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
38716024cdSPeter Avalos.\" INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
39716024cdSPeter Avalos.\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
40716024cdSPeter Avalos.\" DISCLAIMED.  IN NO EVENT SHALL SOFTWEYR LLC, THE REGENTS, OR
41716024cdSPeter Avalos.\" CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
42716024cdSPeter Avalos.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
43716024cdSPeter Avalos.\" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
44716024cdSPeter Avalos.\" USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
45716024cdSPeter Avalos.\" ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
46716024cdSPeter Avalos.\" OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
47716024cdSPeter Avalos.\" OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
48716024cdSPeter Avalos.\" SUCH DAMAGE.
49716024cdSPeter Avalos.\"
50*0d5acd74SJohn Marino.\" $FreeBSD: head/lib/libc/string/wcstok.3 105148 2002-10-15 09:49:54Z tjr $
51716024cdSPeter Avalos.\"
52716024cdSPeter Avalos.Dd October 3, 2002
53716024cdSPeter Avalos.Dt WCSTOK 3
54716024cdSPeter Avalos.Os
55716024cdSPeter Avalos.Sh NAME
56716024cdSPeter Avalos.Nm wcstok
57716024cdSPeter Avalos.Nd split wide-character string into tokens
58716024cdSPeter Avalos.Sh LIBRARY
59716024cdSPeter Avalos.Lb libc
60716024cdSPeter Avalos.Sh SYNOPSIS
61716024cdSPeter Avalos.In wchar.h
62716024cdSPeter Avalos.Ft wchar_t *
63716024cdSPeter Avalos.Fn wcstok "wchar_t * restrict str" "const wchar_t * restrict sep" "wchar_t ** restrict last"
64716024cdSPeter Avalos.Sh DESCRIPTION
65716024cdSPeter AvalosThe
66716024cdSPeter Avalos.Fn wcstok
67716024cdSPeter Avalosfunction
68716024cdSPeter Avalosis used to isolate sequential tokens in a null-terminated wide character
69716024cdSPeter Avalosstring,
70716024cdSPeter Avalos.Fa str .
71716024cdSPeter AvalosThese tokens are separated in the string by at least one of the
72716024cdSPeter Avaloscharacters in
73716024cdSPeter Avalos.Fa sep .
74716024cdSPeter AvalosThe first time that
75716024cdSPeter Avalos.Fn wcstok
76716024cdSPeter Avalosis called,
77716024cdSPeter Avalos.Fa str
78716024cdSPeter Avalosshould be specified; subsequent calls, wishing to obtain further tokens
79716024cdSPeter Avalosfrom the same string, should pass a null pointer instead.
80716024cdSPeter AvalosThe separator string,
81716024cdSPeter Avalos.Fa sep ,
82716024cdSPeter Avalosmust be supplied each time, and may change between calls.
83716024cdSPeter AvalosThe context pointer
84716024cdSPeter Avalos.Fa last
85716024cdSPeter Avalosmust be provided on each call.
86716024cdSPeter Avalos.Pp
87716024cdSPeter AvalosThe
88716024cdSPeter Avalos.Fn wcstok
89716024cdSPeter Avalosfunction is the wide character counterpart of the
90716024cdSPeter Avalos.Fn strtok_r
91716024cdSPeter Avalosfunction.
92716024cdSPeter Avalos.Sh RETURN VALUES
93716024cdSPeter AvalosThe
94716024cdSPeter Avalos.Fn wcstok
95716024cdSPeter Avalosfunction
96716024cdSPeter Avalosreturns a pointer to the beginning of each subsequent token in the string,
97716024cdSPeter Avalosafter replacing the token itself with a null wide character (L'\e0').
98716024cdSPeter AvalosWhen no more tokens remain, a null pointer is returned.
99716024cdSPeter Avalos.Sh EXAMPLES
100716024cdSPeter AvalosThe following code fragment splits a wide character string on
101716024cdSPeter Avalos.Tn ASCII
102716024cdSPeter Avalosspace, tab and newline characters and writes the tokens to
103716024cdSPeter Avalosstandard output:
104716024cdSPeter Avalos.Bd -literal -offset indent
105716024cdSPeter Avalosconst wchar_t *seps = L" \et\en";
106716024cdSPeter Avaloswchar_t *last, *tok, text[] = L" \enone\ettwo\et\etthree  \en";
107716024cdSPeter Avalos
108716024cdSPeter Avalosfor (tok = wcstok(text, seps, &last); tok != NULL;
109716024cdSPeter Avalos    tok = wcstok(NULL, seps, &last))
110716024cdSPeter Avalos	wprintf(L"%ls\en", tok);
111716024cdSPeter Avalos.Ed
112716024cdSPeter Avalos.Sh COMPATIBILITY
113716024cdSPeter AvalosSome early implementations of
114716024cdSPeter Avalos.Fn wcstok
115716024cdSPeter Avalosomit the
116716024cdSPeter Avaloscontext pointer argument,
117716024cdSPeter Avalos.Fa last ,
118716024cdSPeter Avalosand maintain state across calls in a static variable like
119716024cdSPeter Avalos.Fn strtok
120716024cdSPeter Avalosdoes.
121716024cdSPeter Avalos.Sh SEE ALSO
122716024cdSPeter Avalos.Xr strtok 3 ,
123716024cdSPeter Avalos.Xr wcschr 3 ,
124716024cdSPeter Avalos.Xr wcscspn 3 ,
125716024cdSPeter Avalos.Xr wcspbrk 3 ,
126716024cdSPeter Avalos.Xr wcsrchr 3 ,
127716024cdSPeter Avalos.Xr wcsspn 3
128716024cdSPeter Avalos.Sh STANDARDS
129716024cdSPeter AvalosThe
130716024cdSPeter Avalos.Fn wcstok
131716024cdSPeter Avalosfunction
132716024cdSPeter Avalosconforms to
133716024cdSPeter Avalos.St -isoC-99 .
134