diff options
Diffstat (limited to '')
-rw-r--r-- | src/lib/libc/string/strtok.3 | 169 |
1 files changed, 0 insertions, 169 deletions
diff --git a/src/lib/libc/string/strtok.3 b/src/lib/libc/string/strtok.3 deleted file mode 100644 index a28f72d6f2..0000000000 --- a/src/lib/libc/string/strtok.3 +++ /dev/null | |||
@@ -1,169 +0,0 @@ | |||
1 | .\" $OpenBSD: strtok.3,v 1.24 2024/12/11 23:28:20 jsg Exp $ | ||
2 | .\" | ||
3 | .\" Copyright (c) 1988, 1991 The Regents of the University of California. | ||
4 | .\" All rights reserved. | ||
5 | .\" | ||
6 | .\" This code is derived from software contributed to Berkeley by | ||
7 | .\" the American National Standards Committee X3, on Information | ||
8 | .\" Processing Systems. | ||
9 | .\" | ||
10 | .\" Redistribution and use in source and binary forms, with or without | ||
11 | .\" modification, are permitted provided that the following conditions | ||
12 | .\" are met: | ||
13 | .\" 1. Redistributions of source code must retain the above copyright | ||
14 | .\" notice, this list of conditions and the following disclaimer. | ||
15 | .\" 2. Redistributions in binary form must reproduce the above copyright | ||
16 | .\" notice, this list of conditions and the following disclaimer in the | ||
17 | .\" documentation and/or other materials provided with the distribution. | ||
18 | .\" 3. Neither the name of the University nor the names of its contributors | ||
19 | .\" may be used to endorse or promote products derived from this software | ||
20 | .\" without specific prior written permission. | ||
21 | .\" | ||
22 | .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | ||
23 | .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
24 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
25 | .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | ||
26 | .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
27 | .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
28 | .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
29 | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
30 | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
31 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
32 | .\" SUCH DAMAGE. | ||
33 | .\" | ||
34 | .Dd $Mdocdate: December 11 2024 $ | ||
35 | .Dt STRTOK 3 | ||
36 | .Os | ||
37 | .Sh NAME | ||
38 | .Nm strtok , | ||
39 | .Nm strtok_r | ||
40 | .Nd string token operations | ||
41 | .Sh SYNOPSIS | ||
42 | .In string.h | ||
43 | .Ft char * | ||
44 | .Fn strtok "char *str" "const char *sep" | ||
45 | .Ft char * | ||
46 | .Fn strtok_r "char *str" "const char *sep" "char **last" | ||
47 | .Sh DESCRIPTION | ||
48 | .Bf -symbolic | ||
49 | This interface is obsoleted by | ||
50 | .Xr strsep 3 . | ||
51 | .Ef | ||
52 | .Pp | ||
53 | The | ||
54 | .Fn strtok | ||
55 | function is used to isolate sequential tokens in a NUL-terminated string, | ||
56 | .Fa str . | ||
57 | These tokens are separated in the string by at least one of the | ||
58 | characters in | ||
59 | .Fa sep . | ||
60 | The first time that | ||
61 | .Fn strtok | ||
62 | is called, | ||
63 | .Fa str | ||
64 | should be specified; subsequent calls, wishing to obtain further tokens | ||
65 | from the same string, should pass a null pointer instead. | ||
66 | The separator string, | ||
67 | .Fa sep , | ||
68 | must be supplied each time, and may change between calls. | ||
69 | .Pp | ||
70 | The | ||
71 | .Fn strtok_r | ||
72 | function is a version of | ||
73 | .Fn strtok | ||
74 | that takes an explicit context argument and is reentrant. | ||
75 | .Pp | ||
76 | Since | ||
77 | .Fn strtok | ||
78 | and | ||
79 | .Fn strtok_r | ||
80 | modify the string, | ||
81 | .Fa str | ||
82 | should not point to an area in the initialized data segment. | ||
83 | .Sh RETURN VALUES | ||
84 | The | ||
85 | .Fn strtok | ||
86 | and | ||
87 | .Fn strtok_r | ||
88 | functions return a pointer to the beginning of each subsequent token | ||
89 | in the string, after replacing the separator character itself with | ||
90 | a NUL character. | ||
91 | When no more tokens remain, a null pointer is returned. | ||
92 | .Sh EXAMPLES | ||
93 | The following will construct an array of pointers to each individual word in | ||
94 | the string | ||
95 | .Va s : | ||
96 | .Bd -literal -offset indent | ||
97 | #define MAXTOKENS 128 | ||
98 | |||
99 | char s[512], *p, *tokens[MAXTOKENS]; | ||
100 | char *last; | ||
101 | int i = 0; | ||
102 | |||
103 | snprintf(s, sizeof(s), "cat dog horse cow"); | ||
104 | |||
105 | for ((p = strtok_r(s, " ", &last)); p; | ||
106 | (p = strtok_r(NULL, " ", &last))) { | ||
107 | if (i < MAXTOKENS - 1) | ||
108 | tokens[i++] = p; | ||
109 | } | ||
110 | tokens[i] = NULL; | ||
111 | .Ed | ||
112 | .Pp | ||
113 | That is, | ||
114 | .Li tokens[0] | ||
115 | will point to | ||
116 | .Qq cat , | ||
117 | .Li tokens[1] | ||
118 | will point to | ||
119 | .Qq dog , | ||
120 | .Li tokens[2] | ||
121 | will point to | ||
122 | .Qq horse , | ||
123 | and | ||
124 | .Li tokens[3] | ||
125 | will point to | ||
126 | .Qq cow . | ||
127 | .Sh SEE ALSO | ||
128 | .Xr memchr 3 , | ||
129 | .Xr strchr 3 , | ||
130 | .Xr strcspn 3 , | ||
131 | .Xr strpbrk 3 , | ||
132 | .Xr strrchr 3 , | ||
133 | .Xr strsep 3 , | ||
134 | .Xr strspn 3 , | ||
135 | .Xr strstr 3 , | ||
136 | .Xr wcstok 3 | ||
137 | .Sh STANDARDS | ||
138 | The | ||
139 | .Fn strtok | ||
140 | function conforms to | ||
141 | .St -ansiC . | ||
142 | The | ||
143 | .Fn strtok_r | ||
144 | function conforms to | ||
145 | .St -p1003.1-2001 . | ||
146 | .Sh HISTORY | ||
147 | The | ||
148 | .Fn strtok | ||
149 | function first appeared in | ||
150 | .At III | ||
151 | and was reimplemented for | ||
152 | .Bx 4.3 . | ||
153 | The | ||
154 | .Fn strtok_r | ||
155 | function first appeared in | ||
156 | .Nx 1.3 | ||
157 | and was reimplemented for | ||
158 | .Ox 2.7 . | ||
159 | .Sh BUGS | ||
160 | The System V | ||
161 | .Fn strtok , | ||
162 | if handed a string containing only delimiter characters, | ||
163 | will not alter the next starting point, so that a call to | ||
164 | .Fn strtok | ||
165 | with a different (or empty) delimiter string | ||
166 | may return a non-null value. | ||
167 | Since this implementation always alters the next starting point, | ||
168 | such a sequence of calls would always return | ||
169 | .Dv NULL . | ||