1 .\" $NetBSD: wcstok.3,v 1.6 2010/12/16 17:42:28 wiz Exp $
3 .\" Copyright (c) 1998 Softweyr LLC. All rights reserved.
5 .\" strtok_r, from Berkeley strtok
6 .\" Oct 13, 1998 by Wes Peters <wes@softweyr.com>
8 .\" Copyright (c) 1988, 1991, 1993
9 .\" The Regents of the University of California. All rights reserved.
11 .\" This code is derived from software contributed to Berkeley by
12 .\" the American National Standards Committee X3, on Information
13 .\" Processing Systems.
15 .\" Redistribution and use in source and binary forms, with or without
16 .\" modification, are permitted provided that the following conditions
19 .\" 1. Redistributions of source code must retain the above copyright
20 .\" notices, this list of conditions and the following disclaimer.
22 .\" 2. Redistributions in binary form must reproduce the above
23 .\" copyright notices, this list of conditions and the following
24 .\" disclaimer in the documentation and/or other materials provided
25 .\" with the distribution.
27 .\" 3. All advertising materials mentioning features or use of this
28 .\" software must display the following acknowledgement:
30 .\" This product includes software developed by Softweyr LLC, the
31 .\" University of California, Berkeley, and its contributors.
33 .\" 4. Neither the name of Softweyr LLC, the University nor the names
34 .\" of its contributors may be used to endorse or promote products
35 .\" derived from this software without specific prior written
38 .\" THIS SOFTWARE IS PROVIDED BY SOFTWEYR LLC, THE REGENTS AND
39 .\" CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
40 .\" INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
41 .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
42 .\" DISCLAIMED. IN NO EVENT SHALL SOFTWEYR LLC, THE REGENTS, OR
43 .\" CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
44 .\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
45 .\" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
46 .\" USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
47 .\" ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
48 .\" OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
49 .\" OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
52 .\" Original version ID:
53 .\" FreeBSD: src/lib/libc/string/wcstok.3,v 1.4 2002/10/15 09:49:54 tjr Exp
60 .Nd split wide-character string into tokens
66 .Fn wcstok "wchar_t * restrict str" "const wchar_t * restrict sep" "wchar_t ** restrict last"
71 is used to isolate sequential tokens in a nul-terminated wide-character
74 These tokens are separated in the string by at least one of the
81 should be specified; subsequent calls, wishing to obtain further tokens
82 from the same string, should pass a null pointer instead.
85 must be supplied each time, and may change between calls.
88 must be provided on each call.
92 function is the wide-character counterpart of the
99 returns a pointer to the beginning of each subsequent token in the string,
100 after replacing the token itself with a nul wide character (L'\e0').
101 When no more tokens remain, a null pointer is returned.
103 The following code fragment splits a wide-character string on
105 space, tab and newline characters and writes the tokens to
107 .Bd -literal -offset indent
108 const wchar_t *seps = L" \et\en";
109 wchar_t *last, *tok, text[] = L" \enone\ettwo\et\etthree \en";
111 for (tok = wcstok(text, seps, &last); tok != NULL;
112 tok = wcstok(NULL, seps, &last))
113 wprintf(L"%ls\en", tok);
129 Some early implementations of
131 omit the context pointer argument,
133 and maintain state across calls in a static variable like