diff options
Diffstat (limited to '')
134 files changed, 0 insertions, 10106 deletions
diff --git a/src/lib/libc/string/Makefile.inc b/src/lib/libc/string/Makefile.inc deleted file mode 100644 index 204ca1b266..0000000000 --- a/src/lib/libc/string/Makefile.inc +++ /dev/null | |||
@@ -1,35 +0,0 @@ | |||
1 | # $OpenBSD: Makefile.inc,v 1.40 2024/07/14 09:51:18 jca Exp $ | ||
2 | |||
3 | # string sources | ||
4 | .PATH: ${LIBCSRCDIR}/arch/${MACHINE_CPU}/string ${LIBCSRCDIR}/string | ||
5 | |||
6 | SRCS+= explicit_bzero.c memccpy.c memmem.c memrchr.c stpcpy.c stpncpy.c \ | ||
7 | strcasecmp.c strcasecmp_l.c strcasestr.c strcoll.c strcoll_l.c \ | ||
8 | strdup.c strerror.c strerror_l.c strerror_r.c strmode.c \ | ||
9 | strndup.c strnlen.c strsignal.c strtok.c strxfrm.c strxfrm_l.c \ | ||
10 | timingsafe_bcmp.c timingsafe_memcmp.c \ | ||
11 | wcscat.c wcschr.c wcscmp.c wcscpy.c wcscspn.c wcslcat.c wcslcpy.c \ | ||
12 | wcslen.c wcsncat.c wcsncmp.c wcsncpy.c wcsnlen.c wcspbrk.c wcsrchr.c \ | ||
13 | wcsspn.c wcsstr.c wcstok.c wcswcs.c wcswidth.c wmemchr.c wmemcmp.c \ | ||
14 | wmemcpy.c wmemmove.c wmemset.c wcsdup.c wcscasecmp.c wcscasecmp_l.c | ||
15 | |||
16 | # machine-dependent net sources | ||
17 | # ../arch/ARCH/Makefile.inc must include sources for: | ||
18 | # bcmp() bcopy() bzero() ffs() index() memchr() memcmp() memset() | ||
19 | # memcpy() memmove() memset() rindex() strcat() strchr() | ||
20 | # strcmp() strcpy() strcspn() strlen() strlcat() strlcpy() | ||
21 | # strncat() strncmp() strncpy() strpbrk() strrchr() strsep() | ||
22 | # strspn() strstr() swab() | ||
23 | |||
24 | .include "${LIBCSRCDIR}/arch/${MACHINE_CPU}/string/Makefile.inc" | ||
25 | |||
26 | MAN+= bcmp.3 bcopy.3 bzero.3 ffs.3 memccpy.3 memchr.3 \ | ||
27 | memcmp.3 memcpy.3 memmem.3 memmove.3 memset.3 stpcpy.3 strcasecmp.3 \ | ||
28 | strcat.3 strchr.3 strcmp.3 strcoll.3 strcpy.3 strcspn.3 strdup.3 \ | ||
29 | strerror.3 strlen.3 strmode.3 strncat.3 strncpy.3 strpbrk.3 \ | ||
30 | strrchr.3 strsep.3 strsignal.3 strspn.3 strstr.3 strtok.3 strxfrm.3 \ | ||
31 | swab.3 strlcpy.3 timingsafe_bcmp.3 \ | ||
32 | wcscasecmp.3 wcscat.3 wcschr.3 wcscmp.3 wcscpy.3 \ | ||
33 | wcscspn.3 wcsdup.3 wcslcpy.3 wcslen.3 wcspbrk.3 wcsrchr.3 wcsspn.3 \ | ||
34 | wcsstr.3 wcstok.3 wcswidth.3 wmemchr.3 wmemcmp.3 wmemcpy.3 wmemmove.3 \ | ||
35 | wmemset.3 | ||
diff --git a/src/lib/libc/string/bcmp.3 b/src/lib/libc/string/bcmp.3 deleted file mode 100644 index a3cb1dfb74..0000000000 --- a/src/lib/libc/string/bcmp.3 +++ /dev/null | |||
@@ -1,67 +0,0 @@ | |||
1 | .\" Copyright (c) 1990, 1991 The Regents of the University of California. | ||
2 | .\" All rights reserved. | ||
3 | .\" | ||
4 | .\" This code is derived from software contributed to Berkeley by | ||
5 | .\" Chris Torek. | ||
6 | .\" Redistribution and use in source and binary forms, with or without | ||
7 | .\" modification, are permitted provided that the following conditions | ||
8 | .\" are met: | ||
9 | .\" 1. Redistributions of source code must retain the above copyright | ||
10 | .\" notice, this list of conditions and the following disclaimer. | ||
11 | .\" 2. Redistributions in binary form must reproduce the above copyright | ||
12 | .\" notice, this list of conditions and the following disclaimer in the | ||
13 | .\" documentation and/or other materials provided with the distribution. | ||
14 | .\" 3. Neither the name of the University nor the names of its contributors | ||
15 | .\" may be used to endorse or promote products derived from this software | ||
16 | .\" without specific prior written permission. | ||
17 | .\" | ||
18 | .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | ||
19 | .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
20 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
21 | .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | ||
22 | .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
23 | .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
24 | .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
25 | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
26 | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
27 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
28 | .\" SUCH DAMAGE. | ||
29 | .\" | ||
30 | .\" $OpenBSD: bcmp.3,v 1.12 2015/11/24 09:14:35 daniel Exp $ | ||
31 | .\" | ||
32 | .Dd $Mdocdate: November 24 2015 $ | ||
33 | .Dt BCMP 3 | ||
34 | .Os | ||
35 | .Sh NAME | ||
36 | .Nm bcmp | ||
37 | .Nd compare byte string | ||
38 | .Sh SYNOPSIS | ||
39 | .In strings.h | ||
40 | .Ft int | ||
41 | .Fn bcmp "const void *b1" "const void *b2" "size_t len" | ||
42 | .Sh DESCRIPTION | ||
43 | The | ||
44 | .Fn bcmp | ||
45 | function compares byte string | ||
46 | .Fa b1 | ||
47 | against byte string | ||
48 | .Fa b2 , | ||
49 | returning zero if they are identical, non-zero otherwise. | ||
50 | Both strings are assumed to be | ||
51 | .Fa len | ||
52 | bytes long. | ||
53 | Zero-length strings are always identical. | ||
54 | .Pp | ||
55 | The strings may overlap. | ||
56 | .Sh SEE ALSO | ||
57 | .Xr memcmp 3 , | ||
58 | .Xr strcasecmp 3 , | ||
59 | .Xr strcmp 3 , | ||
60 | .Xr strcoll 3 , | ||
61 | .Xr strxfrm 3 , | ||
62 | .Xr timingsafe_bcmp 3 | ||
63 | .Sh HISTORY | ||
64 | The | ||
65 | .Fn bcmp | ||
66 | function first appeared in | ||
67 | .Bx 4.2 . | ||
diff --git a/src/lib/libc/string/bcmp.c b/src/lib/libc/string/bcmp.c deleted file mode 100644 index 5d446bf096..0000000000 --- a/src/lib/libc/string/bcmp.c +++ /dev/null | |||
@@ -1,52 +0,0 @@ | |||
1 | /* $OpenBSD: bcmp.c,v 1.11 2015/08/31 02:53:57 guenther Exp $ */ | ||
2 | |||
3 | /* | ||
4 | * Copyright (c) 1987 Regents of the University of California. | ||
5 | * All rights reserved. | ||
6 | * | ||
7 | * Redistribution and use in source and binary forms, with or without | ||
8 | * modification, are permitted provided that the following conditions | ||
9 | * are met: | ||
10 | * 1. Redistributions of source code must retain the above copyright | ||
11 | * notice, this list of conditions and the following disclaimer. | ||
12 | * 2. Redistributions in binary form must reproduce the above copyright | ||
13 | * notice, this list of conditions and the following disclaimer in the | ||
14 | * documentation and/or other materials provided with the distribution. | ||
15 | * 3. Neither the name of the University nor the names of its contributors | ||
16 | * may be used to endorse or promote products derived from this software | ||
17 | * without specific prior written permission. | ||
18 | * | ||
19 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | ||
20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
21 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
22 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | ||
23 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
24 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
25 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
26 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
27 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
28 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
29 | * SUCH DAMAGE. | ||
30 | */ | ||
31 | |||
32 | #include <string.h> | ||
33 | |||
34 | /* | ||
35 | * bcmp -- vax cmpc3 instruction | ||
36 | */ | ||
37 | int | ||
38 | bcmp(const void *b1, const void *b2, size_t length) | ||
39 | { | ||
40 | char *p1, *p2; | ||
41 | |||
42 | if (length == 0) | ||
43 | return (0); | ||
44 | p1 = (char *)b1; | ||
45 | p2 = (char *)b2; | ||
46 | do | ||
47 | if (*p1++ != *p2++) | ||
48 | return (1); | ||
49 | while (--length); | ||
50 | return (0); | ||
51 | } | ||
52 | DEF_WEAK(bcmp); | ||
diff --git a/src/lib/libc/string/bcopy.3 b/src/lib/libc/string/bcopy.3 deleted file mode 100644 index 68c63f92ec..0000000000 --- a/src/lib/libc/string/bcopy.3 +++ /dev/null | |||
@@ -1,67 +0,0 @@ | |||
1 | .\" Copyright (c) 1990, 1991 The Regents of the University of California. | ||
2 | .\" All rights reserved. | ||
3 | .\" | ||
4 | .\" This code is derived from software contributed to Berkeley by | ||
5 | .\" Chris Torek. | ||
6 | .\" | ||
7 | .\" Redistribution and use in source and binary forms, with or without | ||
8 | .\" modification, are permitted provided that the following conditions | ||
9 | .\" are met: | ||
10 | .\" 1. Redistributions of source code must retain the above copyright | ||
11 | .\" notice, this list of conditions and the following disclaimer. | ||
12 | .\" 2. Redistributions in binary form must reproduce the above copyright | ||
13 | .\" notice, this list of conditions and the following disclaimer in the | ||
14 | .\" documentation and/or other materials provided with the distribution. | ||
15 | .\" 3. Neither the name of the University nor the names of its contributors | ||
16 | .\" may be used to endorse or promote products derived from this software | ||
17 | .\" without specific prior written permission. | ||
18 | .\" | ||
19 | .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | ||
20 | .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
21 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
22 | .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | ||
23 | .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
24 | .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
25 | .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
26 | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
27 | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
28 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
29 | .\" SUCH DAMAGE. | ||
30 | .\" | ||
31 | .\" $OpenBSD: bcopy.3,v 1.12 2015/11/24 09:14:35 daniel Exp $ | ||
32 | .\" | ||
33 | .Dd $Mdocdate: November 24 2015 $ | ||
34 | .Dt BCOPY 3 | ||
35 | .Os | ||
36 | .Sh NAME | ||
37 | .Nm bcopy | ||
38 | .Nd copy bytes | ||
39 | .Sh SYNOPSIS | ||
40 | .In strings.h | ||
41 | .Ft void | ||
42 | .Fn bcopy "const void *src" "void *dst" "size_t len" | ||
43 | .Sh DESCRIPTION | ||
44 | The | ||
45 | .Fn bcopy | ||
46 | function copies | ||
47 | .Fa len | ||
48 | bytes from buffer | ||
49 | .Fa src | ||
50 | to buffer | ||
51 | .Fa dst . | ||
52 | The two buffers may overlap. | ||
53 | If | ||
54 | .Fa len | ||
55 | is zero, no bytes are copied. | ||
56 | .Sh SEE ALSO | ||
57 | .Xr memccpy 3 , | ||
58 | .Xr memcpy 3 , | ||
59 | .Xr memmove 3 , | ||
60 | .Xr strcpy 3 , | ||
61 | .Xr strlcpy 3 , | ||
62 | .Xr strncpy 3 | ||
63 | .Sh HISTORY | ||
64 | The | ||
65 | .Fn bcopy | ||
66 | function first appeared in | ||
67 | .Bx 4.2 . | ||
diff --git a/src/lib/libc/string/bcopy.c b/src/lib/libc/string/bcopy.c deleted file mode 100644 index ef0d368053..0000000000 --- a/src/lib/libc/string/bcopy.c +++ /dev/null | |||
@@ -1,113 +0,0 @@ | |||
1 | /* $OpenBSD: bcopy.c,v 1.7 2015/08/31 02:53:57 guenther Exp $ */ | ||
2 | /*- | ||
3 | * Copyright (c) 1990 The Regents of the University of California. | ||
4 | * All rights reserved. | ||
5 | * | ||
6 | * This code is derived from software contributed to Berkeley by | ||
7 | * Chris Torek. | ||
8 | * | ||
9 | * Redistribution and use in source and binary forms, with or without | ||
10 | * modification, are permitted provided that the following conditions | ||
11 | * are met: | ||
12 | * 1. Redistributions of source code must retain the above copyright | ||
13 | * notice, this list of conditions and the following disclaimer. | ||
14 | * 2. Redistributions in binary form must reproduce the above copyright | ||
15 | * notice, this list of conditions and the following disclaimer in the | ||
16 | * documentation and/or other materials provided with the distribution. | ||
17 | * 3. Neither the name of the University nor the names of its contributors | ||
18 | * may be used to endorse or promote products derived from this software | ||
19 | * without specific prior written permission. | ||
20 | * | ||
21 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | ||
22 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | ||
25 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
26 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
27 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
28 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
29 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
30 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
31 | * SUCH DAMAGE. | ||
32 | */ | ||
33 | |||
34 | #include <string.h> | ||
35 | |||
36 | /* | ||
37 | * sizeof(word) MUST BE A POWER OF TWO | ||
38 | * SO THAT wmask BELOW IS ALL ONES | ||
39 | */ | ||
40 | typedef long word; /* "word" used for optimal copy speed */ | ||
41 | |||
42 | #define wsize sizeof(word) | ||
43 | #define wmask (wsize - 1) | ||
44 | |||
45 | /* | ||
46 | * Copy a block of memory, handling overlap. | ||
47 | */ | ||
48 | void | ||
49 | bcopy(const void *src0, void *dst0, size_t length) | ||
50 | { | ||
51 | char *dst = dst0; | ||
52 | const char *src = src0; | ||
53 | size_t t; | ||
54 | |||
55 | if (length == 0 || dst == src) /* nothing to do */ | ||
56 | goto done; | ||
57 | |||
58 | /* | ||
59 | * Macros: loop-t-times; and loop-t-times, t>0 | ||
60 | */ | ||
61 | #define TLOOP(s) if (t) TLOOP1(s) | ||
62 | #define TLOOP1(s) do { s; } while (--t) | ||
63 | |||
64 | if ((unsigned long)dst < (unsigned long)src) { | ||
65 | /* | ||
66 | * Copy forward. | ||
67 | */ | ||
68 | t = (long)src; /* only need low bits */ | ||
69 | if ((t | (long)dst) & wmask) { | ||
70 | /* | ||
71 | * Try to align operands. This cannot be done | ||
72 | * unless the low bits match. | ||
73 | */ | ||
74 | if ((t ^ (long)dst) & wmask || length < wsize) | ||
75 | t = length; | ||
76 | else | ||
77 | t = wsize - (t & wmask); | ||
78 | length -= t; | ||
79 | TLOOP1(*dst++ = *src++); | ||
80 | } | ||
81 | /* | ||
82 | * Copy whole words, then mop up any trailing bytes. | ||
83 | */ | ||
84 | t = length / wsize; | ||
85 | TLOOP(*(word *)dst = *(word *)src; src += wsize; dst += wsize); | ||
86 | t = length & wmask; | ||
87 | TLOOP(*dst++ = *src++); | ||
88 | } else { | ||
89 | /* | ||
90 | * Copy backwards. Otherwise essentially the same. | ||
91 | * Alignment works as before, except that it takes | ||
92 | * (t&wmask) bytes to align, not wsize-(t&wmask). | ||
93 | */ | ||
94 | src += length; | ||
95 | dst += length; | ||
96 | t = (long)src; | ||
97 | if ((t | (long)dst) & wmask) { | ||
98 | if ((t ^ (long)dst) & wmask || length <= wsize) | ||
99 | t = length; | ||
100 | else | ||
101 | t &= wmask; | ||
102 | length -= t; | ||
103 | TLOOP1(*--dst = *--src); | ||
104 | } | ||
105 | t = length / wsize; | ||
106 | TLOOP(src -= wsize; dst -= wsize; *(word *)dst = *(word *)src); | ||
107 | t = length & wmask; | ||
108 | TLOOP(*--dst = *--src); | ||
109 | } | ||
110 | done: | ||
111 | return; | ||
112 | } | ||
113 | DEF_WEAK(bcopy); | ||
diff --git a/src/lib/libc/string/bzero.3 b/src/lib/libc/string/bzero.3 deleted file mode 100644 index 87a23e20bb..0000000000 --- a/src/lib/libc/string/bzero.3 +++ /dev/null | |||
@@ -1,92 +0,0 @@ | |||
1 | .\" Copyright (c) 1990, 1991 The Regents of the University of California. | ||
2 | .\" All rights reserved. | ||
3 | .\" | ||
4 | .\" This code is derived from software contributed to Berkeley by | ||
5 | .\" Chris Torek. | ||
6 | .\" Redistribution and use in source and binary forms, with or without | ||
7 | .\" modification, are permitted provided that the following conditions | ||
8 | .\" are met: | ||
9 | .\" 1. Redistributions of source code must retain the above copyright | ||
10 | .\" notice, this list of conditions and the following disclaimer. | ||
11 | .\" 2. Redistributions in binary form must reproduce the above copyright | ||
12 | .\" notice, this list of conditions and the following disclaimer in the | ||
13 | .\" documentation and/or other materials provided with the distribution. | ||
14 | .\" 3. Neither the name of the University nor the names of its contributors | ||
15 | .\" may be used to endorse or promote products derived from this software | ||
16 | .\" without specific prior written permission. | ||
17 | .\" | ||
18 | .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | ||
19 | .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
20 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
21 | .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | ||
22 | .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
23 | .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
24 | .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
25 | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
26 | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
27 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
28 | .\" SUCH DAMAGE. | ||
29 | .\" | ||
30 | .\" $OpenBSD: bzero.3,v 1.13 2017/10/12 15:22:32 schwarze Exp $ | ||
31 | .\" | ||
32 | .Dd $Mdocdate: October 12 2017 $ | ||
33 | .Dt BZERO 3 | ||
34 | .Os | ||
35 | .Sh NAME | ||
36 | .Nm bzero , | ||
37 | .Nm explicit_bzero | ||
38 | .Nd write zeroes to a byte string | ||
39 | .Sh SYNOPSIS | ||
40 | .In strings.h | ||
41 | .Ft void | ||
42 | .Fn bzero "void *b" "size_t len" | ||
43 | .In string.h | ||
44 | .Ft void | ||
45 | .Fn explicit_bzero "void *b" "size_t len" | ||
46 | .Sh DESCRIPTION | ||
47 | The | ||
48 | .Fn bzero | ||
49 | function writes | ||
50 | .Fa len | ||
51 | zero bytes to the string | ||
52 | .Fa b . | ||
53 | If | ||
54 | .Fa len | ||
55 | is zero, | ||
56 | .Fn bzero | ||
57 | does nothing. | ||
58 | .Pp | ||
59 | The | ||
60 | .Fn explicit_bzero | ||
61 | variant behaves the same, but will not be removed by a compiler's dead store | ||
62 | optimization pass, making it useful for clearing sensitive memory such as a | ||
63 | password. | ||
64 | .Sh SEE ALSO | ||
65 | .Xr memset 3 , | ||
66 | .Xr swab 3 | ||
67 | .Sh STANDARDS | ||
68 | The | ||
69 | .Fn bzero | ||
70 | function conforms to the X/Open System Interfaces option of the | ||
71 | .St -p1003.1-2004 | ||
72 | specification. | ||
73 | It was removed from the standard in | ||
74 | .St -p1003.1-2008 , | ||
75 | which recommends using | ||
76 | .Xr memset 3 | ||
77 | instead. | ||
78 | .Pp | ||
79 | The | ||
80 | .Fn explicit_bzero | ||
81 | function is an | ||
82 | .Ox | ||
83 | extension. | ||
84 | .Sh HISTORY | ||
85 | The | ||
86 | .Fn bzero | ||
87 | function first appeared in | ||
88 | .Bx 4.2 . | ||
89 | The | ||
90 | .Fn explicit_bzero | ||
91 | function first appeared in | ||
92 | .Ox 5.5 . | ||
diff --git a/src/lib/libc/string/bzero.c b/src/lib/libc/string/bzero.c deleted file mode 100644 index 5173de26dd..0000000000 --- a/src/lib/libc/string/bzero.c +++ /dev/null | |||
@@ -1,45 +0,0 @@ | |||
1 | /* $OpenBSD: bzero.c,v 1.9 2015/08/31 02:53:57 guenther Exp $ */ | ||
2 | |||
3 | /* | ||
4 | * Copyright (c) 1987 Regents of the University of California. | ||
5 | * All rights reserved. | ||
6 | * | ||
7 | * Redistribution and use in source and binary forms, with or without | ||
8 | * modification, are permitted provided that the following conditions | ||
9 | * are met: | ||
10 | * 1. Redistributions of source code must retain the above copyright | ||
11 | * notice, this list of conditions and the following disclaimer. | ||
12 | * 2. Redistributions in binary form must reproduce the above copyright | ||
13 | * notice, this list of conditions and the following disclaimer in the | ||
14 | * documentation and/or other materials provided with the distribution. | ||
15 | * 3. Neither the name of the University nor the names of its contributors | ||
16 | * may be used to endorse or promote products derived from this software | ||
17 | * without specific prior written permission. | ||
18 | * | ||
19 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | ||
20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
21 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
22 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | ||
23 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
24 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
25 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
26 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
27 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
28 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
29 | * SUCH DAMAGE. | ||
30 | */ | ||
31 | |||
32 | #include <string.h> | ||
33 | |||
34 | /* | ||
35 | * bzero -- vax movc5 instruction | ||
36 | */ | ||
37 | void | ||
38 | bzero(void *b, size_t length) | ||
39 | { | ||
40 | char *p; | ||
41 | |||
42 | for (p = b; length--;) | ||
43 | *p++ = '\0'; | ||
44 | } | ||
45 | DEF_WEAK(bzero); | ||
diff --git a/src/lib/libc/string/explicit_bzero.c b/src/lib/libc/string/explicit_bzero.c deleted file mode 100644 index 003ea7cc4c..0000000000 --- a/src/lib/libc/string/explicit_bzero.c +++ /dev/null | |||
@@ -1,20 +0,0 @@ | |||
1 | /* $OpenBSD: explicit_bzero.c,v 1.4 2015/08/31 02:53:57 guenther Exp $ */ | ||
2 | /* | ||
3 | * Public domain. | ||
4 | * Written by Matthew Dempsky. | ||
5 | */ | ||
6 | |||
7 | #include <string.h> | ||
8 | |||
9 | __attribute__((weak)) void | ||
10 | __explicit_bzero_hook(void *buf, size_t len) | ||
11 | { | ||
12 | } | ||
13 | |||
14 | void | ||
15 | explicit_bzero(void *buf, size_t len) | ||
16 | { | ||
17 | memset(buf, 0, len); | ||
18 | __explicit_bzero_hook(buf, len); | ||
19 | } | ||
20 | DEF_WEAK(explicit_bzero); | ||
diff --git a/src/lib/libc/string/ffs.3 b/src/lib/libc/string/ffs.3 deleted file mode 100644 index e78ab99e8f..0000000000 --- a/src/lib/libc/string/ffs.3 +++ /dev/null | |||
@@ -1,61 +0,0 @@ | |||
1 | .\" Copyright (c) 1990, 1991 The Regents of the University of California. | ||
2 | .\" All rights reserved. | ||
3 | .\" | ||
4 | .\" This code is derived from software contributed to Berkeley by | ||
5 | .\" Chris Torek. | ||
6 | .\" Redistribution and use in source and binary forms, with or without | ||
7 | .\" modification, are permitted provided that the following conditions | ||
8 | .\" are met: | ||
9 | .\" 1. Redistributions of source code must retain the above copyright | ||
10 | .\" notice, this list of conditions and the following disclaimer. | ||
11 | .\" 2. Redistributions in binary form must reproduce the above copyright | ||
12 | .\" notice, this list of conditions and the following disclaimer in the | ||
13 | .\" documentation and/or other materials provided with the distribution. | ||
14 | .\" 3. Neither the name of the University nor the names of its contributors | ||
15 | .\" may be used to endorse or promote products derived from this software | ||
16 | .\" without specific prior written permission. | ||
17 | .\" | ||
18 | .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | ||
19 | .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
20 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
21 | .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | ||
22 | .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
23 | .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
24 | .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
25 | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
26 | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
27 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
28 | .\" SUCH DAMAGE. | ||
29 | .\" | ||
30 | .\" $OpenBSD: ffs.3,v 1.11 2019/08/30 18:35:03 deraadt Exp $ | ||
31 | .\" | ||
32 | .Dd $Mdocdate: August 30 2019 $ | ||
33 | .Dt FFS 3 | ||
34 | .Os | ||
35 | .Sh NAME | ||
36 | .Nm ffs | ||
37 | .Nd find first bit set in a bit string | ||
38 | .Sh SYNOPSIS | ||
39 | .In strings.h | ||
40 | .Ft int | ||
41 | .Fn ffs "int value" | ||
42 | .Sh DESCRIPTION | ||
43 | The | ||
44 | .Fn ffs | ||
45 | function finds the first bit set in | ||
46 | .Fa value | ||
47 | and returns the index of that bit. | ||
48 | Bits are numbered starting from 1, starting at the rightmost bit. | ||
49 | A return value of 0 means that the argument was zero. | ||
50 | .Sh SEE ALSO | ||
51 | .Xr bit_ffs 3 | ||
52 | .Sh STANDARDS | ||
53 | The | ||
54 | .Fn ffs | ||
55 | function conforms to | ||
56 | .St -p1003.1-2008 . | ||
57 | .Sh HISTORY | ||
58 | The | ||
59 | .Fn ffs | ||
60 | function first appeared in | ||
61 | .Bx 4.2 . | ||
diff --git a/src/lib/libc/string/ffs.c b/src/lib/libc/string/ffs.c deleted file mode 100644 index 09d6e35eca..0000000000 --- a/src/lib/libc/string/ffs.c +++ /dev/null | |||
@@ -1,40 +0,0 @@ | |||
1 | /* $OpenBSD: ffs.c,v 1.10 2018/01/18 08:23:44 guenther Exp $ */ | ||
2 | |||
3 | /* | ||
4 | * Public domain. | ||
5 | * Written by Dale Rahn. | ||
6 | */ | ||
7 | |||
8 | #include <string.h> | ||
9 | |||
10 | /* | ||
11 | * ffs -- vax ffs instruction | ||
12 | */ | ||
13 | int | ||
14 | ffs(int mask) | ||
15 | { | ||
16 | int bit; | ||
17 | unsigned int r = mask; | ||
18 | static const signed char t[16] = { | ||
19 | -28, 1, 2, 1, | ||
20 | 3, 1, 2, 1, | ||
21 | 4, 1, 2, 1, | ||
22 | 3, 1, 2, 1 | ||
23 | }; | ||
24 | |||
25 | bit = 0; | ||
26 | if (!(r & 0xffff)) { | ||
27 | bit += 16; | ||
28 | r >>= 16; | ||
29 | } | ||
30 | if (!(r & 0xff)) { | ||
31 | bit += 8; | ||
32 | r >>= 8; | ||
33 | } | ||
34 | if (!(r & 0xf)) { | ||
35 | bit += 4; | ||
36 | r >>= 4; | ||
37 | } | ||
38 | |||
39 | return (bit + t[ r & 0xf ]); | ||
40 | } | ||
diff --git a/src/lib/libc/string/memccpy.3 b/src/lib/libc/string/memccpy.3 deleted file mode 100644 index 49b8ab5d26..0000000000 --- a/src/lib/libc/string/memccpy.3 +++ /dev/null | |||
@@ -1,81 +0,0 @@ | |||
1 | .\" $OpenBSD: memccpy.3,v 1.14 2024/12/11 23:28:20 jsg Exp $ | ||
2 | .\" | ||
3 | .\" Copyright (c) 1990, 1991, 1993 | ||
4 | .\" The Regents of the University of California. All rights reserved. | ||
5 | .\" | ||
6 | .\" Redistribution and use in source and binary forms, with or without | ||
7 | .\" modification, are permitted provided that the following conditions | ||
8 | .\" are met: | ||
9 | .\" 1. Redistributions of source code must retain the above copyright | ||
10 | .\" notice, this list of conditions and the following disclaimer. | ||
11 | .\" 2. Redistributions in binary form must reproduce the above copyright | ||
12 | .\" notice, this list of conditions and the following disclaimer in the | ||
13 | .\" documentation and/or other materials provided with the distribution. | ||
14 | .\" 3. Neither the name of the University nor the names of its contributors | ||
15 | .\" may be used to endorse or promote products derived from this software | ||
16 | .\" without specific prior written permission. | ||
17 | .\" | ||
18 | .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | ||
19 | .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
20 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
21 | .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | ||
22 | .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
23 | .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
24 | .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
25 | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
26 | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
27 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
28 | .\" SUCH DAMAGE. | ||
29 | .\" | ||
30 | .\" @(#)memccpy.3 8.1 (Berkeley) 6/9/93 | ||
31 | .\" | ||
32 | .Dd $Mdocdate: December 11 2024 $ | ||
33 | .Dt MEMCCPY 3 | ||
34 | .Os | ||
35 | .Sh NAME | ||
36 | .Nm memccpy | ||
37 | .Nd copy string until character found | ||
38 | .Sh SYNOPSIS | ||
39 | .In string.h | ||
40 | .Ft void * | ||
41 | .Fn memccpy "void *dst" "const void *src" "int c" "size_t len" | ||
42 | .Sh DESCRIPTION | ||
43 | The | ||
44 | .Fn memccpy | ||
45 | function copies bytes from string | ||
46 | .Fa src | ||
47 | to string | ||
48 | .Fa dst . | ||
49 | If the character | ||
50 | .Fa c | ||
51 | (as converted to an | ||
52 | .Vt unsigned char ) | ||
53 | occurs in the string | ||
54 | .Fa src , | ||
55 | the copy stops and a pointer to the byte after the copy of | ||
56 | .Fa c | ||
57 | in the string | ||
58 | .Fa dst | ||
59 | is returned. | ||
60 | Otherwise, | ||
61 | .Fa len | ||
62 | bytes are copied, and a null pointer is returned. | ||
63 | .Pp | ||
64 | If the | ||
65 | .Fa src | ||
66 | and | ||
67 | .Fa dst | ||
68 | strings overlap, the behavior is undefined. | ||
69 | .Sh SEE ALSO | ||
70 | .Xr bcopy 3 , | ||
71 | .Xr memcpy 3 , | ||
72 | .Xr memmove 3 , | ||
73 | .Xr strcpy 3 , | ||
74 | .Xr strlcpy 3 | ||
75 | .Sh HISTORY | ||
76 | The | ||
77 | .Fn memccpy | ||
78 | function first appeared in | ||
79 | .At V | ||
80 | and was reimplemented for | ||
81 | .Bx 4.3 . | ||
diff --git a/src/lib/libc/string/memccpy.c b/src/lib/libc/string/memccpy.c deleted file mode 100644 index 635061b8cb..0000000000 --- a/src/lib/libc/string/memccpy.c +++ /dev/null | |||
@@ -1,49 +0,0 @@ | |||
1 | /* $OpenBSD: memccpy.c,v 1.7 2015/08/31 02:53:57 guenther Exp $ */ | ||
2 | |||
3 | /*- | ||
4 | * Copyright (c) 1990, 1993 | ||
5 | * The Regents of the University of California. All rights reserved. | ||
6 | * | ||
7 | * Redistribution and use in source and binary forms, with or without | ||
8 | * modification, are permitted provided that the following conditions | ||
9 | * are met: | ||
10 | * 1. Redistributions of source code must retain the above copyright | ||
11 | * notice, this list of conditions and the following disclaimer. | ||
12 | * 2. Redistributions in binary form must reproduce the above copyright | ||
13 | * notice, this list of conditions and the following disclaimer in the | ||
14 | * documentation and/or other materials provided with the distribution. | ||
15 | * 3. Neither the name of the University nor the names of its contributors | ||
16 | * may be used to endorse or promote products derived from this software | ||
17 | * without specific prior written permission. | ||
18 | * | ||
19 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | ||
20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
21 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
22 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | ||
23 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
24 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
25 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
26 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
27 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
28 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
29 | * SUCH DAMAGE. | ||
30 | */ | ||
31 | |||
32 | #include <string.h> | ||
33 | |||
34 | void * | ||
35 | memccpy(void *t, const void *f, int c, size_t n) | ||
36 | { | ||
37 | |||
38 | if (n) { | ||
39 | unsigned char *tp = t; | ||
40 | const unsigned char *fp = f; | ||
41 | unsigned char uc = c; | ||
42 | do { | ||
43 | if ((*tp++ = *fp++) == uc) | ||
44 | return (tp); | ||
45 | } while (--n != 0); | ||
46 | } | ||
47 | return (0); | ||
48 | } | ||
49 | DEF_WEAK(memccpy); | ||
diff --git a/src/lib/libc/string/memchr.3 b/src/lib/libc/string/memchr.3 deleted file mode 100644 index fa5809fa98..0000000000 --- a/src/lib/libc/string/memchr.3 +++ /dev/null | |||
@@ -1,102 +0,0 @@ | |||
1 | .\" $OpenBSD: memchr.3,v 1.14 2024/12/11 23:28:20 jsg Exp $ | ||
2 | .\" | ||
3 | .\" Copyright (c) 1990, 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 | .\" Chris Torek and the American National Standards Committee X3, | ||
8 | .\" on Information 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 MEMCHR 3 | ||
36 | .Os | ||
37 | .Sh NAME | ||
38 | .Nm memchr , | ||
39 | .Nm memrchr | ||
40 | .Nd locate byte in byte string | ||
41 | .Sh SYNOPSIS | ||
42 | .In string.h | ||
43 | .Ft void * | ||
44 | .Fn memchr "const void *b" "int c" "size_t len" | ||
45 | .Ft void * | ||
46 | .Fn memrchr "const void *b" "int c" "size_t len" | ||
47 | .Sh DESCRIPTION | ||
48 | The | ||
49 | .Fn memchr | ||
50 | function locates the first occurrence of | ||
51 | .Fa c | ||
52 | (converted to an | ||
53 | .Vt unsigned char ) | ||
54 | in string | ||
55 | .Fa b . | ||
56 | .Pp | ||
57 | The | ||
58 | .Fn memrchr | ||
59 | function behaves like | ||
60 | .Fn memchr , | ||
61 | except that it locates the last occurrence of | ||
62 | .Fa c | ||
63 | in string | ||
64 | .Fa b . | ||
65 | .Sh RETURN VALUES | ||
66 | The | ||
67 | .Fn memchr | ||
68 | and | ||
69 | .Fn memrchr | ||
70 | functions return a pointer to the byte located, or | ||
71 | .Dv NULL | ||
72 | if no such byte exists within | ||
73 | .Fa len | ||
74 | bytes. | ||
75 | .Sh SEE ALSO | ||
76 | .Xr strchr 3 , | ||
77 | .Xr strcspn 3 , | ||
78 | .Xr strpbrk 3 , | ||
79 | .Xr strrchr 3 , | ||
80 | .Xr strsep 3 , | ||
81 | .Xr strspn 3 , | ||
82 | .Xr strstr 3 , | ||
83 | .Xr strtok 3 , | ||
84 | .Xr wmemchr 3 | ||
85 | .Sh STANDARDS | ||
86 | The | ||
87 | .Fn memchr | ||
88 | function conforms to | ||
89 | .St -ansiC . | ||
90 | .Pp | ||
91 | The | ||
92 | .Fn memrchr | ||
93 | function is an | ||
94 | .Ox | ||
95 | extension. | ||
96 | .Sh HISTORY | ||
97 | The | ||
98 | .Fn memchr | ||
99 | function first appeared in | ||
100 | .At V | ||
101 | and was reimplemented for | ||
102 | .Bx 4.3 . | ||
diff --git a/src/lib/libc/string/memchr.c b/src/lib/libc/string/memchr.c deleted file mode 100644 index a6a4bd60d0..0000000000 --- a/src/lib/libc/string/memchr.c +++ /dev/null | |||
@@ -1,49 +0,0 @@ | |||
1 | /* $OpenBSD: memchr.c,v 1.8 2015/08/31 02:53:57 guenther Exp $ */ | ||
2 | /*- | ||
3 | * Copyright (c) 1990 The Regents of the University of California. | ||
4 | * All rights reserved. | ||
5 | * | ||
6 | * This code is derived from software contributed to Berkeley by | ||
7 | * Chris Torek. | ||
8 | * | ||
9 | * Redistribution and use in source and binary forms, with or without | ||
10 | * modification, are permitted provided that the following conditions | ||
11 | * are met: | ||
12 | * 1. Redistributions of source code must retain the above copyright | ||
13 | * notice, this list of conditions and the following disclaimer. | ||
14 | * 2. Redistributions in binary form must reproduce the above copyright | ||
15 | * notice, this list of conditions and the following disclaimer in the | ||
16 | * documentation and/or other materials provided with the distribution. | ||
17 | * 3. Neither the name of the University nor the names of its contributors | ||
18 | * may be used to endorse or promote products derived from this software | ||
19 | * without specific prior written permission. | ||
20 | * | ||
21 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | ||
22 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | ||
25 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
26 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
27 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
28 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
29 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
30 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
31 | * SUCH DAMAGE. | ||
32 | */ | ||
33 | |||
34 | #include <string.h> | ||
35 | |||
36 | void * | ||
37 | memchr(const void *s, int c, size_t n) | ||
38 | { | ||
39 | if (n != 0) { | ||
40 | const unsigned char *p = s; | ||
41 | |||
42 | do { | ||
43 | if (*p++ == (unsigned char)c) | ||
44 | return ((void *)(p - 1)); | ||
45 | } while (--n != 0); | ||
46 | } | ||
47 | return (NULL); | ||
48 | } | ||
49 | DEF_STRONG(memchr); | ||
diff --git a/src/lib/libc/string/memcmp.3 b/src/lib/libc/string/memcmp.3 deleted file mode 100644 index ace8f79255..0000000000 --- a/src/lib/libc/string/memcmp.3 +++ /dev/null | |||
@@ -1,86 +0,0 @@ | |||
1 | .\" $OpenBSD: memcmp.3,v 1.11 2024/12/11 23:28:20 jsg Exp $ | ||
2 | .\" | ||
3 | .\" Copyright (c) 1990, 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 | .\" Chris Torek and the American National Standards Committee X3, | ||
8 | .\" on Information 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 MEMCMP 3 | ||
36 | .Os | ||
37 | .Sh NAME | ||
38 | .Nm memcmp | ||
39 | .Nd compare byte string | ||
40 | .Sh SYNOPSIS | ||
41 | .In string.h | ||
42 | .Ft int | ||
43 | .Fn memcmp "const void *b1" "const void *b2" "size_t len" | ||
44 | .Sh DESCRIPTION | ||
45 | The | ||
46 | .Fn memcmp | ||
47 | function compares byte string | ||
48 | .Fa b1 | ||
49 | against byte string | ||
50 | .Fa b2 . | ||
51 | Both strings are assumed to be | ||
52 | .Fa len | ||
53 | bytes long. | ||
54 | .Sh RETURN VALUES | ||
55 | The | ||
56 | .Fn memcmp | ||
57 | function returns zero if the two strings are identical, | ||
58 | otherwise returns the difference between the first two differing bytes | ||
59 | (treated as | ||
60 | .Vt unsigned char | ||
61 | values, so that | ||
62 | .Sq Li \e200 | ||
63 | is greater than | ||
64 | .Sq Li \&\e0 , | ||
65 | for example). | ||
66 | Zero-length strings are always identical. | ||
67 | .Sh SEE ALSO | ||
68 | .Xr bcmp 3 , | ||
69 | .Xr strcasecmp 3 , | ||
70 | .Xr strcmp 3 , | ||
71 | .Xr strcoll 3 , | ||
72 | .Xr strxfrm 3 , | ||
73 | .Xr timingsafe_memcmp 3 , | ||
74 | .Xr wmemcmp 3 | ||
75 | .Sh STANDARDS | ||
76 | The | ||
77 | .Fn memcmp | ||
78 | function conforms to | ||
79 | .St -ansiC . | ||
80 | .Sh HISTORY | ||
81 | The | ||
82 | .Fn memcmp | ||
83 | function first appeared in | ||
84 | .At V | ||
85 | and was reimplemented for | ||
86 | .Bx 4.3 . | ||
diff --git a/src/lib/libc/string/memcmp.c b/src/lib/libc/string/memcmp.c deleted file mode 100644 index 0df2c54d2a..0000000000 --- a/src/lib/libc/string/memcmp.c +++ /dev/null | |||
@@ -1,52 +0,0 @@ | |||
1 | /* $OpenBSD: memcmp.c,v 1.6 2015/08/31 02:53:57 guenther Exp $ */ | ||
2 | /*- | ||
3 | * Copyright (c) 1990 The Regents of the University of California. | ||
4 | * All rights reserved. | ||
5 | * | ||
6 | * This code is derived from software contributed to Berkeley by | ||
7 | * Chris Torek. | ||
8 | * | ||
9 | * Redistribution and use in source and binary forms, with or without | ||
10 | * modification, are permitted provided that the following conditions | ||
11 | * are met: | ||
12 | * 1. Redistributions of source code must retain the above copyright | ||
13 | * notice, this list of conditions and the following disclaimer. | ||
14 | * 2. Redistributions in binary form must reproduce the above copyright | ||
15 | * notice, this list of conditions and the following disclaimer in the | ||
16 | * documentation and/or other materials provided with the distribution. | ||
17 | * 3. Neither the name of the University nor the names of its contributors | ||
18 | * may be used to endorse or promote products derived from this software | ||
19 | * without specific prior written permission. | ||
20 | * | ||
21 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | ||
22 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | ||
25 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
26 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
27 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
28 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
29 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
30 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
31 | * SUCH DAMAGE. | ||
32 | */ | ||
33 | |||
34 | #include <string.h> | ||
35 | |||
36 | /* | ||
37 | * Compare memory regions. | ||
38 | */ | ||
39 | int | ||
40 | memcmp(const void *s1, const void *s2, size_t n) | ||
41 | { | ||
42 | if (n != 0) { | ||
43 | const unsigned char *p1 = s1, *p2 = s2; | ||
44 | |||
45 | do { | ||
46 | if (*p1++ != *p2++) | ||
47 | return (*--p1 - *--p2); | ||
48 | } while (--n != 0); | ||
49 | } | ||
50 | return (0); | ||
51 | } | ||
52 | DEF_STRONG(memcmp); | ||
diff --git a/src/lib/libc/string/memcpy.3 b/src/lib/libc/string/memcpy.3 deleted file mode 100644 index b093afc919..0000000000 --- a/src/lib/libc/string/memcpy.3 +++ /dev/null | |||
@@ -1,79 +0,0 @@ | |||
1 | .\" $OpenBSD: memcpy.3,v 1.11 2024/12/11 23:28:20 jsg Exp $ | ||
2 | .\" | ||
3 | .\" Copyright (c) 1990, 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 | .\" Chris Torek and the American National Standards Committee X3, | ||
8 | .\" on Information 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 MEMCPY 3 | ||
36 | .Os | ||
37 | .Sh NAME | ||
38 | .Nm memcpy | ||
39 | .Nd copy bytes | ||
40 | .Sh SYNOPSIS | ||
41 | .In string.h | ||
42 | .Ft void * | ||
43 | .Fn memcpy "void *dst" "const void *src" "size_t len" | ||
44 | .Sh DESCRIPTION | ||
45 | The | ||
46 | .Fn memcpy | ||
47 | function copies | ||
48 | .Fa len | ||
49 | bytes from buffer | ||
50 | .Fa src | ||
51 | to buffer | ||
52 | .Fa dst . | ||
53 | If the two buffers may overlap, | ||
54 | .Xr memmove 3 | ||
55 | must be used instead. | ||
56 | .Sh RETURN VALUES | ||
57 | The | ||
58 | .Fn memcpy | ||
59 | function returns the original value of | ||
60 | .Fa dst . | ||
61 | .Sh SEE ALSO | ||
62 | .Xr bcopy 3 , | ||
63 | .Xr memccpy 3 , | ||
64 | .Xr memmove 3 , | ||
65 | .Xr strcpy 3 , | ||
66 | .Xr strlcpy 3 , | ||
67 | .Xr wmemcpy 3 | ||
68 | .Sh STANDARDS | ||
69 | The | ||
70 | .Fn memcpy | ||
71 | function conforms to | ||
72 | .St -ansiC . | ||
73 | .Sh HISTORY | ||
74 | The | ||
75 | .Fn memcpy | ||
76 | function first appeared in | ||
77 | .At V | ||
78 | and was reimplemented for | ||
79 | .Bx 4.3 . | ||
diff --git a/src/lib/libc/string/memcpy.c b/src/lib/libc/string/memcpy.c deleted file mode 100644 index 19fddc0ab5..0000000000 --- a/src/lib/libc/string/memcpy.c +++ /dev/null | |||
@@ -1,109 +0,0 @@ | |||
1 | /* $OpenBSD: memcpy.c,v 1.4 2017/11/29 05:13:57 guenther Exp $ */ | ||
2 | /*- | ||
3 | * Copyright (c) 1990 The Regents of the University of California. | ||
4 | * All rights reserved. | ||
5 | * | ||
6 | * This code is derived from software contributed to Berkeley by | ||
7 | * Chris Torek. | ||
8 | * | ||
9 | * Redistribution and use in source and binary forms, with or without | ||
10 | * modification, are permitted provided that the following conditions | ||
11 | * are met: | ||
12 | * 1. Redistributions of source code must retain the above copyright | ||
13 | * notice, this list of conditions and the following disclaimer. | ||
14 | * 2. Redistributions in binary form must reproduce the above copyright | ||
15 | * notice, this list of conditions and the following disclaimer in the | ||
16 | * documentation and/or other materials provided with the distribution. | ||
17 | * 3. Neither the name of the University nor the names of its contributors | ||
18 | * may be used to endorse or promote products derived from this software | ||
19 | * without specific prior written permission. | ||
20 | * | ||
21 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | ||
22 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | ||
25 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
26 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
27 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
28 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
29 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
30 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
31 | * SUCH DAMAGE. | ||
32 | */ | ||
33 | |||
34 | #include <string.h> | ||
35 | #include <stdlib.h> | ||
36 | #include <syslog.h> | ||
37 | |||
38 | /* | ||
39 | * sizeof(word) MUST BE A POWER OF TWO | ||
40 | * SO THAT wmask BELOW IS ALL ONES | ||
41 | */ | ||
42 | typedef long word; /* "word" used for optimal copy speed */ | ||
43 | |||
44 | #define wsize sizeof(word) | ||
45 | #define wmask (wsize - 1) | ||
46 | |||
47 | static const char backwards_msg[] = ": backwards memcpy"; | ||
48 | |||
49 | /* | ||
50 | * Copy a block of memory, not handling overlap. | ||
51 | */ | ||
52 | void * | ||
53 | memcpy(void *dst0, const void *src0, size_t length) | ||
54 | { | ||
55 | char *dst = dst0; | ||
56 | const char *src = src0; | ||
57 | size_t t; | ||
58 | |||
59 | if (length == 0 || dst == src) /* nothing to do */ | ||
60 | goto done; | ||
61 | |||
62 | if ((dst < src && dst + length > src) || | ||
63 | (src < dst && src + length > dst)) { | ||
64 | char buf[1024]; | ||
65 | |||
66 | /* <10> is LOG_CRIT */ | ||
67 | strlcpy(buf, "<10>", sizeof buf); | ||
68 | |||
69 | /* Make sure progname does not fill the whole buffer */ | ||
70 | strlcat(buf, __progname, sizeof(buf) - sizeof backwards_msg); | ||
71 | strlcat(buf, backwards_msg, sizeof buf); | ||
72 | |||
73 | sendsyslog(buf, strlen(buf), LOG_CONS); | ||
74 | abort(); | ||
75 | } | ||
76 | |||
77 | /* | ||
78 | * Macros: loop-t-times; and loop-t-times, t>0 | ||
79 | */ | ||
80 | #define TLOOP(s) if (t) TLOOP1(s) | ||
81 | #define TLOOP1(s) do { s; } while (--t) | ||
82 | |||
83 | /* | ||
84 | * Copy forward. | ||
85 | */ | ||
86 | t = (long)src; /* only need low bits */ | ||
87 | if ((t | (long)dst) & wmask) { | ||
88 | /* | ||
89 | * Try to align operands. This cannot be done | ||
90 | * unless the low bits match. | ||
91 | */ | ||
92 | if ((t ^ (long)dst) & wmask || length < wsize) | ||
93 | t = length; | ||
94 | else | ||
95 | t = wsize - (t & wmask); | ||
96 | length -= t; | ||
97 | TLOOP1(*dst++ = *src++); | ||
98 | } | ||
99 | /* | ||
100 | * Copy whole words, then mop up any trailing bytes. | ||
101 | */ | ||
102 | t = length / wsize; | ||
103 | TLOOP(*(word *)dst = *(word *)src; src += wsize; dst += wsize); | ||
104 | t = length & wmask; | ||
105 | TLOOP(*dst++ = *src++); | ||
106 | done: | ||
107 | return (dst0); | ||
108 | } | ||
109 | DEF_BUILTIN(memcpy); | ||
diff --git a/src/lib/libc/string/memmem.3 b/src/lib/libc/string/memmem.3 deleted file mode 100644 index de62d738de..0000000000 --- a/src/lib/libc/string/memmem.3 +++ /dev/null | |||
@@ -1,77 +0,0 @@ | |||
1 | .\" $OpenBSD: memmem.3,v 1.4 2024/08/03 20:13:23 guenther Exp $ | ||
2 | .\" | ||
3 | .\" Copyright (c) 2005 Pascal Gloor <pascal.gloor@spale.com> | ||
4 | .\" | ||
5 | .\" Redistribution and use in source and binary forms, with or without | ||
6 | .\" modification, are permitted provided that the following conditions | ||
7 | .\" are met: | ||
8 | .\" 1. Redistributions of source code must retain the above copyright | ||
9 | .\" notice, this list of conditions and the following disclaimer. | ||
10 | .\" 2. Redistributions in binary form must reproduce the above copyright | ||
11 | .\" notice, this list of conditions and the following disclaimer in the | ||
12 | .\" documentation and/or other materials provided with the distribution. | ||
13 | .\" 3. The name of the author may not be used to endorse or promote | ||
14 | .\" products derived from this software without specific prior written | ||
15 | .\" permission. | ||
16 | .\" | ||
17 | .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND | ||
18 | .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
19 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
20 | .\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
21 | .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
22 | .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
23 | .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
24 | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
25 | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
26 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
27 | .\" SUCH DAMAGE. | ||
28 | .\" | ||
29 | .Dd $Mdocdate: August 3 2024 $ | ||
30 | .Dt MEMMEM 3 | ||
31 | .Os | ||
32 | .Sh NAME | ||
33 | .Nm memmem | ||
34 | .Nd locate a byte substring in a byte string | ||
35 | .Sh SYNOPSIS | ||
36 | .In string.h | ||
37 | .Ft "void *" | ||
38 | .Fo memmem | ||
39 | .Fa "const void *big" "size_t big_len" | ||
40 | .Fa "const void *little" "size_t little_len" | ||
41 | .Fc | ||
42 | .Sh DESCRIPTION | ||
43 | The | ||
44 | .Fn memmem | ||
45 | function | ||
46 | locates the first occurrence of the byte string | ||
47 | .Fa little | ||
48 | in the byte string | ||
49 | .Fa big . | ||
50 | .Sh RETURN VALUES | ||
51 | If | ||
52 | .Fa little | ||
53 | is zero length, | ||
54 | .Fa big | ||
55 | is returned; if | ||
56 | .Fa little | ||
57 | occurs nowhere in | ||
58 | .Fa big , | ||
59 | .Dv NULL | ||
60 | is returned; | ||
61 | otherwise a pointer to the first character of the first occurrence of | ||
62 | .Fa little | ||
63 | is returned. | ||
64 | .Sh SEE ALSO | ||
65 | .Xr memchr 3 , | ||
66 | .Xr strchr 3 , | ||
67 | .Xr strstr 3 | ||
68 | .Sh STANDARDS | ||
69 | The | ||
70 | .Fn memmem | ||
71 | function conforms to | ||
72 | .St -p1003.1-2024 . | ||
73 | .Sh HISTORY | ||
74 | The | ||
75 | .Fn memmem | ||
76 | function first appeared in | ||
77 | .Ox 5.4 . | ||
diff --git a/src/lib/libc/string/memmem.c b/src/lib/libc/string/memmem.c deleted file mode 100644 index 3b180b4a62..0000000000 --- a/src/lib/libc/string/memmem.c +++ /dev/null | |||
@@ -1,184 +0,0 @@ | |||
1 | /* $OpenBSD: memmem.c,v 1.5 2020/04/16 12:39:28 claudio Exp $ */ | ||
2 | |||
3 | /* | ||
4 | * Copyright (c) 2005-2020 Rich Felker, et al. | ||
5 | * | ||
6 | * Permission is hereby granted, free of charge, to any person obtaining | ||
7 | * a copy of this software and associated documentation files (the | ||
8 | * "Software"), to deal in the Software without restriction, including | ||
9 | * without limitation the rights to use, copy, modify, merge, publish, | ||
10 | * distribute, sublicense, and/or sell copies of the Software, and to | ||
11 | * permit persons to whom the Software is furnished to do so, subject to | ||
12 | * the following conditions: | ||
13 | * | ||
14 | * The above copyright notice and this permission notice shall be | ||
15 | * included in all copies or substantial portions of the Software. | ||
16 | * | ||
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | ||
20 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY | ||
21 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, | ||
22 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE | ||
23 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
24 | */ | ||
25 | |||
26 | #include <string.h> | ||
27 | #include <stdint.h> | ||
28 | |||
29 | static char * | ||
30 | twobyte_memmem(const unsigned char *h, size_t k, const unsigned char *n) | ||
31 | { | ||
32 | uint16_t nw = n[0]<<8 | n[1], hw = h[0]<<8 | h[1]; | ||
33 | for (h+=2, k-=2; k; k--, hw = hw<<8 | *h++) | ||
34 | if (hw == nw) return (char *)h-2; | ||
35 | return hw == nw ? (char *)h-2 : 0; | ||
36 | } | ||
37 | |||
38 | static char * | ||
39 | threebyte_memmem(const unsigned char *h, size_t k, const unsigned char *n) | ||
40 | { | ||
41 | uint32_t nw = n[0]<<24 | n[1]<<16 | n[2]<<8; | ||
42 | uint32_t hw = h[0]<<24 | h[1]<<16 | h[2]<<8; | ||
43 | for (h+=3, k-=3; k; k--, hw = (hw|*h++)<<8) | ||
44 | if (hw == nw) return (char *)h-3; | ||
45 | return hw == nw ? (char *)h-3 : 0; | ||
46 | } | ||
47 | |||
48 | static char * | ||
49 | fourbyte_memmem(const unsigned char *h, size_t k, const unsigned char *n) | ||
50 | { | ||
51 | uint32_t nw = n[0]<<24 | n[1]<<16 | n[2]<<8 | n[3]; | ||
52 | uint32_t hw = h[0]<<24 | h[1]<<16 | h[2]<<8 | h[3]; | ||
53 | for (h+=4, k-=4; k; k--, hw = hw<<8 | *h++) | ||
54 | if (hw == nw) return (char *)h-4; | ||
55 | return hw == nw ? (char *)h-4 : 0; | ||
56 | } | ||
57 | |||
58 | #define MAX(a,b) ((a)>(b)?(a):(b)) | ||
59 | #define MIN(a,b) ((a)<(b)?(a):(b)) | ||
60 | |||
61 | #define BITOP(a,b,op) \ | ||
62 | ((a)[(size_t)(b)/(8*sizeof *(a))] op (size_t)1<<((size_t)(b)%(8*sizeof *(a)))) | ||
63 | |||
64 | /* | ||
65 | * Maxime Crochemore and Dominique Perrin, Two-way string-matching, | ||
66 | * Journal of the ACM, 38(3):651-675, July 1991. | ||
67 | */ | ||
68 | static char * | ||
69 | twoway_memmem(const unsigned char *h, const unsigned char *z, | ||
70 | const unsigned char *n, size_t l) | ||
71 | { | ||
72 | size_t i, ip, jp, k, p, ms, p0, mem, mem0; | ||
73 | size_t byteset[32 / sizeof(size_t)] = { 0 }; | ||
74 | size_t shift[256]; | ||
75 | |||
76 | /* Computing length of needle and fill shift table */ | ||
77 | for (i=0; i<l; i++) | ||
78 | BITOP(byteset, n[i], |=), shift[n[i]] = i+1; | ||
79 | |||
80 | /* Compute maximal suffix */ | ||
81 | ip = -1; jp = 0; k = p = 1; | ||
82 | while (jp+k<l) { | ||
83 | if (n[ip+k] == n[jp+k]) { | ||
84 | if (k == p) { | ||
85 | jp += p; | ||
86 | k = 1; | ||
87 | } else k++; | ||
88 | } else if (n[ip+k] > n[jp+k]) { | ||
89 | jp += k; | ||
90 | k = 1; | ||
91 | p = jp - ip; | ||
92 | } else { | ||
93 | ip = jp++; | ||
94 | k = p = 1; | ||
95 | } | ||
96 | } | ||
97 | ms = ip; | ||
98 | p0 = p; | ||
99 | |||
100 | /* And with the opposite comparison */ | ||
101 | ip = -1; jp = 0; k = p = 1; | ||
102 | while (jp+k<l) { | ||
103 | if (n[ip+k] == n[jp+k]) { | ||
104 | if (k == p) { | ||
105 | jp += p; | ||
106 | k = 1; | ||
107 | } else k++; | ||
108 | } else if (n[ip+k] < n[jp+k]) { | ||
109 | jp += k; | ||
110 | k = 1; | ||
111 | p = jp - ip; | ||
112 | } else { | ||
113 | ip = jp++; | ||
114 | k = p = 1; | ||
115 | } | ||
116 | } | ||
117 | if (ip+1 > ms+1) ms = ip; | ||
118 | else p = p0; | ||
119 | |||
120 | /* Periodic needle? */ | ||
121 | if (memcmp(n, n+p, ms+1)) { | ||
122 | mem0 = 0; | ||
123 | p = MAX(ms, l-ms-1) + 1; | ||
124 | } else mem0 = l-p; | ||
125 | mem = 0; | ||
126 | |||
127 | /* Search loop */ | ||
128 | for (;;) { | ||
129 | /* If remainder of haystack is shorter than needle, done */ | ||
130 | if (z-h < l) return 0; | ||
131 | |||
132 | /* Check last byte first; advance by shift on mismatch */ | ||
133 | if (BITOP(byteset, h[l-1], &)) { | ||
134 | k = l-shift[h[l-1]]; | ||
135 | if (k) { | ||
136 | if (k < mem) k = mem; | ||
137 | h += k; | ||
138 | mem = 0; | ||
139 | continue; | ||
140 | } | ||
141 | } else { | ||
142 | h += l; | ||
143 | mem = 0; | ||
144 | continue; | ||
145 | } | ||
146 | |||
147 | /* Compare right half */ | ||
148 | for (k=MAX(ms+1,mem); k<l && n[k] == h[k]; k++); | ||
149 | if (k < l) { | ||
150 | h += k-ms; | ||
151 | mem = 0; | ||
152 | continue; | ||
153 | } | ||
154 | /* Compare left half */ | ||
155 | for (k=ms+1; k>mem && n[k-1] == h[k-1]; k--); | ||
156 | if (k <= mem) return (char *)h; | ||
157 | h += p; | ||
158 | mem = mem0; | ||
159 | } | ||
160 | } | ||
161 | |||
162 | void * | ||
163 | memmem(const void *h0, size_t k, const void *n0, size_t l) | ||
164 | { | ||
165 | const unsigned char *h = h0, *n = n0; | ||
166 | |||
167 | /* Return immediately on empty needle */ | ||
168 | if (!l) return (void *)h; | ||
169 | |||
170 | /* Return immediately when needle is longer than haystack */ | ||
171 | if (k<l) return 0; | ||
172 | |||
173 | /* Use faster algorithms for short needles */ | ||
174 | h = memchr(h0, *n, k); | ||
175 | if (!h || l==1) return (void *)h; | ||
176 | k -= h - (const unsigned char *)h0; | ||
177 | if (k<l) return 0; | ||
178 | if (l==2) return twobyte_memmem(h, k, n); | ||
179 | if (l==3) return threebyte_memmem(h, k, n); | ||
180 | if (l==4) return fourbyte_memmem(h, k, n); | ||
181 | |||
182 | return twoway_memmem(h, h+k, n, l); | ||
183 | } | ||
184 | DEF_WEAK(memmem); | ||
diff --git a/src/lib/libc/string/memmove.3 b/src/lib/libc/string/memmove.3 deleted file mode 100644 index 8665e4abcf..0000000000 --- a/src/lib/libc/string/memmove.3 +++ /dev/null | |||
@@ -1,76 +0,0 @@ | |||
1 | .\" $OpenBSD: memmove.3,v 1.9 2013/06/05 03:39:23 tedu Exp $ | ||
2 | .\" | ||
3 | .\" Copyright (c) 1990, 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 | .\" Chris Torek and the American National Standards Committee X3, | ||
8 | .\" on Information 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: June 5 2013 $ | ||
35 | .Dt MEMMOVE 3 | ||
36 | .Os | ||
37 | .Sh NAME | ||
38 | .Nm memmove | ||
39 | .Nd copy bytes | ||
40 | .Sh SYNOPSIS | ||
41 | .In string.h | ||
42 | .Ft void * | ||
43 | .Fn memmove "void *dst" "const void *src" "size_t len" | ||
44 | .Sh DESCRIPTION | ||
45 | The | ||
46 | .Fn memmove | ||
47 | function copies | ||
48 | .Fa len | ||
49 | bytes from buffer | ||
50 | .Fa src | ||
51 | to buffer | ||
52 | .Fa dst . | ||
53 | The two buffers may overlap; | ||
54 | the copy is always done in a non-destructive manner. | ||
55 | .Sh RETURN VALUES | ||
56 | The | ||
57 | .Fn memmove | ||
58 | function returns the original value of | ||
59 | .Fa dst . | ||
60 | .Sh SEE ALSO | ||
61 | .Xr bcopy 3 , | ||
62 | .Xr memccpy 3 , | ||
63 | .Xr memcpy 3 , | ||
64 | .Xr strcpy 3 , | ||
65 | .Xr strlcpy 3 , | ||
66 | .Xr wmemmove 3 | ||
67 | .Sh STANDARDS | ||
68 | The | ||
69 | .Fn memmove | ||
70 | function conforms to | ||
71 | .St -ansiC . | ||
72 | .Sh HISTORY | ||
73 | The | ||
74 | .Fn memmove | ||
75 | function first appeared in | ||
76 | .Bx 4.3 Reno . | ||
diff --git a/src/lib/libc/string/memmove.c b/src/lib/libc/string/memmove.c deleted file mode 100644 index 1cd1086ab9..0000000000 --- a/src/lib/libc/string/memmove.c +++ /dev/null | |||
@@ -1,113 +0,0 @@ | |||
1 | /* $OpenBSD: memmove.c,v 1.3 2017/11/29 05:13:57 guenther Exp $ */ | ||
2 | /*- | ||
3 | * Copyright (c) 1990 The Regents of the University of California. | ||
4 | * All rights reserved. | ||
5 | * | ||
6 | * This code is derived from software contributed to Berkeley by | ||
7 | * Chris Torek. | ||
8 | * | ||
9 | * Redistribution and use in source and binary forms, with or without | ||
10 | * modification, are permitted provided that the following conditions | ||
11 | * are met: | ||
12 | * 1. Redistributions of source code must retain the above copyright | ||
13 | * notice, this list of conditions and the following disclaimer. | ||
14 | * 2. Redistributions in binary form must reproduce the above copyright | ||
15 | * notice, this list of conditions and the following disclaimer in the | ||
16 | * documentation and/or other materials provided with the distribution. | ||
17 | * 3. Neither the name of the University nor the names of its contributors | ||
18 | * may be used to endorse or promote products derived from this software | ||
19 | * without specific prior written permission. | ||
20 | * | ||
21 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | ||
22 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | ||
25 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
26 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
27 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
28 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
29 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
30 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
31 | * SUCH DAMAGE. | ||
32 | */ | ||
33 | |||
34 | #include <string.h> | ||
35 | |||
36 | /* | ||
37 | * sizeof(word) MUST BE A POWER OF TWO | ||
38 | * SO THAT wmask BELOW IS ALL ONES | ||
39 | */ | ||
40 | typedef long word; /* "word" used for optimal copy speed */ | ||
41 | |||
42 | #define wsize sizeof(word) | ||
43 | #define wmask (wsize - 1) | ||
44 | |||
45 | /* | ||
46 | * Copy a block of memory, handling overlap. | ||
47 | */ | ||
48 | void * | ||
49 | memmove(void *dst0, const void *src0, size_t length) | ||
50 | { | ||
51 | char *dst = dst0; | ||
52 | const char *src = src0; | ||
53 | size_t t; | ||
54 | |||
55 | if (length == 0 || dst == src) /* nothing to do */ | ||
56 | goto done; | ||
57 | |||
58 | /* | ||
59 | * Macros: loop-t-times; and loop-t-times, t>0 | ||
60 | */ | ||
61 | #define TLOOP(s) if (t) TLOOP1(s) | ||
62 | #define TLOOP1(s) do { s; } while (--t) | ||
63 | |||
64 | if ((unsigned long)dst < (unsigned long)src) { | ||
65 | /* | ||
66 | * Copy forward. | ||
67 | */ | ||
68 | t = (long)src; /* only need low bits */ | ||
69 | if ((t | (long)dst) & wmask) { | ||
70 | /* | ||
71 | * Try to align operands. This cannot be done | ||
72 | * unless the low bits match. | ||
73 | */ | ||
74 | if ((t ^ (long)dst) & wmask || length < wsize) | ||
75 | t = length; | ||
76 | else | ||
77 | t = wsize - (t & wmask); | ||
78 | length -= t; | ||
79 | TLOOP1(*dst++ = *src++); | ||
80 | } | ||
81 | /* | ||
82 | * Copy whole words, then mop up any trailing bytes. | ||
83 | */ | ||
84 | t = length / wsize; | ||
85 | TLOOP(*(word *)dst = *(word *)src; src += wsize; dst += wsize); | ||
86 | t = length & wmask; | ||
87 | TLOOP(*dst++ = *src++); | ||
88 | } else { | ||
89 | /* | ||
90 | * Copy backwards. Otherwise essentially the same. | ||
91 | * Alignment works as before, except that it takes | ||
92 | * (t&wmask) bytes to align, not wsize-(t&wmask). | ||
93 | */ | ||
94 | src += length; | ||
95 | dst += length; | ||
96 | t = (long)src; | ||
97 | if ((t | (long)dst) & wmask) { | ||
98 | if ((t ^ (long)dst) & wmask || length <= wsize) | ||
99 | t = length; | ||
100 | else | ||
101 | t &= wmask; | ||
102 | length -= t; | ||
103 | TLOOP1(*--dst = *--src); | ||
104 | } | ||
105 | t = length / wsize; | ||
106 | TLOOP(src -= wsize; dst -= wsize; *(word *)dst = *(word *)src); | ||
107 | t = length & wmask; | ||
108 | TLOOP(*--dst = *--src); | ||
109 | } | ||
110 | done: | ||
111 | return (dst0); | ||
112 | } | ||
113 | DEF_BUILTIN(memmove); | ||
diff --git a/src/lib/libc/string/memrchr.c b/src/lib/libc/string/memrchr.c deleted file mode 100644 index e123bc1737..0000000000 --- a/src/lib/libc/string/memrchr.c +++ /dev/null | |||
@@ -1,39 +0,0 @@ | |||
1 | /* $OpenBSD: memrchr.c,v 1.4 2019/01/25 00:19:25 millert Exp $ */ | ||
2 | |||
3 | /* | ||
4 | * Copyright (c) 2007 Todd C. Miller <millert@openbsd.org> | ||
5 | * | ||
6 | * Permission to use, copy, modify, and distribute this software for any | ||
7 | * purpose with or without fee is hereby granted, provided that the above | ||
8 | * copyright notice and this permission notice appear in all copies. | ||
9 | * | ||
10 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
11 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
12 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | ||
13 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
14 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
15 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | ||
16 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
17 | */ | ||
18 | |||
19 | #include <string.h> | ||
20 | |||
21 | /* | ||
22 | * Reverse memchr() | ||
23 | * Find the last occurrence of 'c' in the buffer 's' of size 'n'. | ||
24 | */ | ||
25 | void * | ||
26 | memrchr(const void *s, int c, size_t n) | ||
27 | { | ||
28 | const unsigned char *cp; | ||
29 | |||
30 | if (n != 0) { | ||
31 | cp = (unsigned char *)s + n; | ||
32 | do { | ||
33 | if (*(--cp) == (unsigned char)c) | ||
34 | return((void *)cp); | ||
35 | } while (--n != 0); | ||
36 | } | ||
37 | return(NULL); | ||
38 | } | ||
39 | DEF_WEAK(memrchr); | ||
diff --git a/src/lib/libc/string/memset.3 b/src/lib/libc/string/memset.3 deleted file mode 100644 index 34f2ca7888..0000000000 --- a/src/lib/libc/string/memset.3 +++ /dev/null | |||
@@ -1,75 +0,0 @@ | |||
1 | .\" $OpenBSD: memset.3,v 1.10 2024/12/11 23:28:20 jsg Exp $ | ||
2 | .\" | ||
3 | .\" Copyright (c) 1990, 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 | .\" Chris Torek and the American National Standards Committee X3, | ||
8 | .\" on Information 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 MEMSET 3 | ||
36 | .Os | ||
37 | .Sh NAME | ||
38 | .Nm memset | ||
39 | .Nd write a byte to byte string | ||
40 | .Sh SYNOPSIS | ||
41 | .In string.h | ||
42 | .Ft void * | ||
43 | .Fn memset "void *b" "int c" "size_t len" | ||
44 | .Sh DESCRIPTION | ||
45 | The | ||
46 | .Fn memset | ||
47 | function writes | ||
48 | .Fa len | ||
49 | bytes of value | ||
50 | .Fa c | ||
51 | (converted to an | ||
52 | .Vt unsigned char ) | ||
53 | to the string | ||
54 | .Fa b . | ||
55 | .Sh RETURN VALUES | ||
56 | The | ||
57 | .Fn memset | ||
58 | function returns the original value of | ||
59 | .Fa b . | ||
60 | .Sh SEE ALSO | ||
61 | .Xr bzero 3 , | ||
62 | .Xr swab 3 , | ||
63 | .Xr wmemset 3 | ||
64 | .Sh STANDARDS | ||
65 | The | ||
66 | .Fn memset | ||
67 | function conforms to | ||
68 | .St -ansiC . | ||
69 | .Sh HISTORY | ||
70 | The | ||
71 | .Fn memset | ||
72 | function first appeared in | ||
73 | .At V | ||
74 | and was reimplemented for | ||
75 | .Bx 4.3 . | ||
diff --git a/src/lib/libc/string/memset.c b/src/lib/libc/string/memset.c deleted file mode 100644 index 0c261f0965..0000000000 --- a/src/lib/libc/string/memset.c +++ /dev/null | |||
@@ -1,48 +0,0 @@ | |||
1 | /* $OpenBSD: memset.c,v 1.8 2017/11/29 05:13:57 guenther Exp $ */ | ||
2 | /*- | ||
3 | * Copyright (c) 1990 The Regents of the University of California. | ||
4 | * All rights reserved. | ||
5 | * | ||
6 | * This code is derived from software contributed to Berkeley by | ||
7 | * Chris Torek. | ||
8 | * | ||
9 | * Redistribution and use in source and binary forms, with or without | ||
10 | * modification, are permitted provided that the following conditions | ||
11 | * are met: | ||
12 | * 1. Redistributions of source code must retain the above copyright | ||
13 | * notice, this list of conditions and the following disclaimer. | ||
14 | * 2. Redistributions in binary form must reproduce the above copyright | ||
15 | * notice, this list of conditions and the following disclaimer in the | ||
16 | * documentation and/or other materials provided with the distribution. | ||
17 | * 3. Neither the name of the University nor the names of its contributors | ||
18 | * may be used to endorse or promote products derived from this software | ||
19 | * without specific prior written permission. | ||
20 | * | ||
21 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | ||
22 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | ||
25 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
26 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
27 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
28 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
29 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
30 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
31 | * SUCH DAMAGE. | ||
32 | */ | ||
33 | |||
34 | #include <string.h> | ||
35 | |||
36 | void * | ||
37 | memset(void *dst, int c, size_t n) | ||
38 | { | ||
39 | if (n != 0) { | ||
40 | unsigned char *d = dst; | ||
41 | |||
42 | do | ||
43 | *d++ = (unsigned char)c; | ||
44 | while (--n != 0); | ||
45 | } | ||
46 | return (dst); | ||
47 | } | ||
48 | DEF_BUILTIN(memset); | ||
diff --git a/src/lib/libc/string/stpcpy.3 b/src/lib/libc/string/stpcpy.3 deleted file mode 100644 index 973eebecdd..0000000000 --- a/src/lib/libc/string/stpcpy.3 +++ /dev/null | |||
@@ -1,184 +0,0 @@ | |||
1 | .\" $OpenBSD: stpcpy.3,v 1.6 2014/02/23 23:09:34 schwarze Exp $ | ||
2 | .\" | ||
3 | .\" Copyright (c) 1990, 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 | .\" Chris Torek and the American National Standards Committee X3, | ||
8 | .\" on Information 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: February 23 2014 $ | ||
35 | .Dt STPCPY 3 | ||
36 | .Os | ||
37 | .Sh NAME | ||
38 | .Nm stpcpy , | ||
39 | .Nm stpncpy | ||
40 | .Nd copy strings | ||
41 | .Sh SYNOPSIS | ||
42 | .In string.h | ||
43 | .Ft char * | ||
44 | .Fn stpcpy "char *dst" "const char *src" | ||
45 | .Ft char * | ||
46 | .Fn stpncpy "char *dst" "const char *src" "size_t len" | ||
47 | .Sh DESCRIPTION | ||
48 | The | ||
49 | .Fn stpcpy | ||
50 | and | ||
51 | .Fn stpncpy | ||
52 | functions copy the string | ||
53 | .Fa src | ||
54 | to | ||
55 | .Fa dst | ||
56 | (including the terminating | ||
57 | .Ql \e0 | ||
58 | character). | ||
59 | .Pp | ||
60 | The | ||
61 | .Fn stpncpy | ||
62 | function copies not more than | ||
63 | .Fa len | ||
64 | characters into | ||
65 | .Fa dst , | ||
66 | appending | ||
67 | .Ql \e0 | ||
68 | characters if | ||
69 | .Fa src | ||
70 | is less than | ||
71 | .Fa len | ||
72 | characters long, and | ||
73 | .Em not | ||
74 | terminating | ||
75 | .Fa dst | ||
76 | if the length of | ||
77 | .Fa src | ||
78 | is greater than or equal to | ||
79 | .Fa len . | ||
80 | .Pp | ||
81 | If the | ||
82 | .Fa src | ||
83 | and | ||
84 | .Fa dst | ||
85 | strings overlap, the behavior is undefined. | ||
86 | .Sh RETURN VALUES | ||
87 | The | ||
88 | .Fn stpcpy | ||
89 | function returns a pointer to the terminating | ||
90 | .Ql \e0 | ||
91 | character written into | ||
92 | .Fa dst . | ||
93 | .Pp | ||
94 | The | ||
95 | .Fn stpncpy | ||
96 | function returns a pointer to the first | ||
97 | .Ql \e0 | ||
98 | character written into | ||
99 | .Fa dst , | ||
100 | or to | ||
101 | .Fa &dst[len] | ||
102 | if the length of | ||
103 | .Fa src | ||
104 | is greater than or equal to | ||
105 | .Fa len . | ||
106 | .Sh EXAMPLES | ||
107 | The most common use of | ||
108 | .Fn stpcpy | ||
109 | is to build up a string from multiple elements. | ||
110 | The following example builds up a pathname from | ||
111 | directory and file components using | ||
112 | .Fn stpcpy : | ||
113 | .Bd -literal -offset indent | ||
114 | char *dir, *file, pname[PATH_MAX]; | ||
115 | |||
116 | \&... | ||
117 | |||
118 | if (strlen(dir) + strlen("/") + strlen(file) >= sizeof(pname)) | ||
119 | goto toolong; | ||
120 | stpcpy(stpcpy(stpcpy(pname, dir), "/"), file); | ||
121 | .Ed | ||
122 | .Pp | ||
123 | However, the size check required to avoid a buffer overflow is error | ||
124 | prone since the check can become out of sync with the code that | ||
125 | performs the copy. | ||
126 | .Pp | ||
127 | One might expect that | ||
128 | .Fn stpncpy | ||
129 | could be safely used instead, but it suffers from the same defects as | ||
130 | .Fn strncpy . | ||
131 | The example below using | ||
132 | .Fn stpncpy | ||
133 | is even more prone to error and will not detect when truncation occurs: | ||
134 | .Bd -literal -offset indent | ||
135 | char *dir, *file, pname[PATH_MAX]; | ||
136 | char *p1, *p2; | ||
137 | |||
138 | \&... | ||
139 | |||
140 | p1 = stpncpy(pname, dir, sizeof(pname) - 1); | ||
141 | p2 = stpncpy(p1, "/", sizeof(pname) - 1 - (p1 - pname)); | ||
142 | stpncpy(p2, file, sizeof(pname) - 1 - (p2 - pname)); | ||
143 | pname[sizeof(pname) - 1] = '\e0'; | ||
144 | .Ed | ||
145 | .Pp | ||
146 | A safer (and simpler) approach is to use | ||
147 | .Fn snprintf : | ||
148 | .Bd -literal -offset indent | ||
149 | char *dir, *file, pname[PATH_MAX]; | ||
150 | int len; | ||
151 | |||
152 | \&... | ||
153 | |||
154 | len = snprintf(pname, sizeof(pname), "%s/%s", dir, file); | ||
155 | if (len >= sizeof(pname)) | ||
156 | goto toolong; | ||
157 | .Ed | ||
158 | .Pp | ||
159 | In most cases, it is better to use | ||
160 | .Fn snprintf , | ||
161 | .Fn strlcpy , | ||
162 | or | ||
163 | .Fn strlcat . | ||
164 | .Sh SEE ALSO | ||
165 | .Xr snprintf 3 , | ||
166 | .Xr strcpy 3 , | ||
167 | .Xr strlcpy 3 , | ||
168 | .Xr strncpy 3 | ||
169 | .Sh STANDARDS | ||
170 | The | ||
171 | .Fn stpcpy | ||
172 | and | ||
173 | .Fn stpncpy | ||
174 | functions conform to | ||
175 | .St -p1003.1-2008 . | ||
176 | .Sh HISTORY | ||
177 | The function | ||
178 | .Fn stpcpy | ||
179 | first appeared in the Lattice C AmigaDOS compiler (1986 or earlier). | ||
180 | The function | ||
181 | .Fn stpncpy | ||
182 | first appeared in the GNU C library version 1.07 (1993). | ||
183 | Both functions have been available since | ||
184 | .Ox 5.1 . | ||
diff --git a/src/lib/libc/string/stpcpy.c b/src/lib/libc/string/stpcpy.c deleted file mode 100644 index 5a86541f08..0000000000 --- a/src/lib/libc/string/stpcpy.c +++ /dev/null | |||
@@ -1,44 +0,0 @@ | |||
1 | /* $OpenBSD: stpcpy.c,v 1.3 2017/11/28 06:55:49 tb Exp $ */ | ||
2 | |||
3 | /* | ||
4 | * Copyright (c) 1988 Regents of the University of California. | ||
5 | * All rights reserved. | ||
6 | * | ||
7 | * Redistribution and use in source and binary forms, with or without | ||
8 | * modification, are permitted provided that the following conditions | ||
9 | * are met: | ||
10 | * 1. Redistributions of source code must retain the above copyright | ||
11 | * notice, this list of conditions and the following disclaimer. | ||
12 | * 2. Redistributions in binary form must reproduce the above copyright | ||
13 | * notice, this list of conditions and the following disclaimer in the | ||
14 | * documentation and/or other materials provided with the distribution. | ||
15 | * 3. Neither the name of the University nor the names of its contributors | ||
16 | * may be used to endorse or promote products derived from this software | ||
17 | * without specific prior written permission. | ||
18 | * | ||
19 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | ||
20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
21 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
22 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | ||
23 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
24 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
25 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
26 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
27 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
28 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
29 | * SUCH DAMAGE. | ||
30 | */ | ||
31 | |||
32 | #include <string.h> | ||
33 | |||
34 | #if defined(APIWARN) | ||
35 | __warn_references(stpcpy, | ||
36 | "stpcpy() is dangerous; do not use it"); | ||
37 | #endif | ||
38 | |||
39 | char * | ||
40 | stpcpy(char *to, const char *from) | ||
41 | { | ||
42 | for (; (*to = *from) != '\0'; ++from, ++to); | ||
43 | return(to); | ||
44 | } | ||
diff --git a/src/lib/libc/string/stpncpy.c b/src/lib/libc/string/stpncpy.c deleted file mode 100644 index 6bdee5de16..0000000000 --- a/src/lib/libc/string/stpncpy.c +++ /dev/null | |||
@@ -1,57 +0,0 @@ | |||
1 | /* $OpenBSD: stpncpy.c,v 1.3 2015/08/31 02:53:57 guenther Exp $ */ | ||
2 | |||
3 | /*- | ||
4 | * Copyright (c) 1990 The Regents of the University of California. | ||
5 | * All rights reserved. | ||
6 | * | ||
7 | * This code is derived from software contributed to Berkeley by | ||
8 | * Chris Torek. | ||
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 | |||
35 | #include <string.h> | ||
36 | |||
37 | char * | ||
38 | stpncpy(char *dst, const char *src, size_t n) | ||
39 | { | ||
40 | if (n != 0) { | ||
41 | char *d = dst; | ||
42 | const char *s = src; | ||
43 | |||
44 | dst = &dst[n]; | ||
45 | do { | ||
46 | if ((*d++ = *s++) == 0) { | ||
47 | dst = d - 1; | ||
48 | /* NUL pad the remaining n-1 bytes */ | ||
49 | while (--n != 0) | ||
50 | *d++ = 0; | ||
51 | break; | ||
52 | } | ||
53 | } while (--n != 0); | ||
54 | } | ||
55 | return (dst); | ||
56 | } | ||
57 | DEF_WEAK(stpncpy); | ||
diff --git a/src/lib/libc/string/strcasecmp.3 b/src/lib/libc/string/strcasecmp.3 deleted file mode 100644 index bb39df895a..0000000000 --- a/src/lib/libc/string/strcasecmp.3 +++ /dev/null | |||
@@ -1,128 +0,0 @@ | |||
1 | .\" $OpenBSD: strcasecmp.3,v 1.14 2017/09/05 03:16:13 schwarze Exp $ | ||
2 | .\" | ||
3 | .\" Copyright (c) 1990, 1991, 1993 | ||
4 | .\" The Regents of the University of California. All rights reserved. | ||
5 | .\" Copyright (c) 2017 Ingo Schwarze <schwarze@openbsd.org> | ||
6 | .\" | ||
7 | .\" This code is derived from software contributed to Berkeley by | ||
8 | .\" Chris Torek. | ||
9 | .\" Redistribution and use in source and binary forms, with or without | ||
10 | .\" modification, are permitted provided that the following conditions | ||
11 | .\" are met: | ||
12 | .\" 1. Redistributions of source code must retain the above copyright | ||
13 | .\" notice, this list of conditions and the following disclaimer. | ||
14 | .\" 2. Redistributions in binary form must reproduce the above copyright | ||
15 | .\" notice, this list of conditions and the following disclaimer in the | ||
16 | .\" documentation and/or other materials provided with the distribution. | ||
17 | .\" 3. Neither the name of the University nor the names of its contributors | ||
18 | .\" may be used to endorse or promote products derived from this software | ||
19 | .\" without specific prior written permission. | ||
20 | .\" | ||
21 | .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | ||
22 | .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
23 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
24 | .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | ||
25 | .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
26 | .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
27 | .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
28 | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
29 | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
30 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
31 | .\" SUCH DAMAGE. | ||
32 | .\" | ||
33 | .\" @(#)strcasecmp.3 8.1 (Berkeley) 6/9/93 | ||
34 | .\" | ||
35 | .Dd $Mdocdate: September 5 2017 $ | ||
36 | .Dt STRCASECMP 3 | ||
37 | .Os | ||
38 | .Sh NAME | ||
39 | .Nm strcasecmp , | ||
40 | .Nm strcasecmp_l , | ||
41 | .Nm strncasecmp , | ||
42 | .Nm strncasecmp_l | ||
43 | .Nd compare strings, ignoring case | ||
44 | .Sh SYNOPSIS | ||
45 | .In strings.h | ||
46 | .Ft int | ||
47 | .Fo strcasecmp | ||
48 | .Fa "const char *s1" | ||
49 | .Fa "const char *s2" | ||
50 | .Fc | ||
51 | .Ft int | ||
52 | .Fo strcasecmp_l | ||
53 | .Fa "const char *s1" | ||
54 | .Fa "const char *s2" | ||
55 | .Fa "locale_t locale" | ||
56 | .Fc | ||
57 | .Ft int | ||
58 | .Fo strncasecmp | ||
59 | .Fa "const char *s1" | ||
60 | .Fa "const char *s2" | ||
61 | .Fa "size_t len" | ||
62 | .Fc | ||
63 | .Ft int | ||
64 | .Fo strncasecmp_l | ||
65 | .Fa "const char *s1" | ||
66 | .Fa "const char *s2" | ||
67 | .Fa "size_t len" | ||
68 | .Fa "locale_t locale" | ||
69 | .Fc | ||
70 | .Sh DESCRIPTION | ||
71 | These functions compare the NUL-terminated strings | ||
72 | .Fa s1 | ||
73 | and | ||
74 | .Fa s2 | ||
75 | and return an integer greater than, equal to, or less than 0, | ||
76 | according to whether | ||
77 | .Fa s1 | ||
78 | is lexicographically greater than, equal to, or less than | ||
79 | .Fa s2 | ||
80 | after translation of each corresponding character to lower-case. | ||
81 | The strings themselves are not modified. | ||
82 | The comparison is done using unsigned characters, so that | ||
83 | .Sq Li \e200 | ||
84 | is greater than | ||
85 | .Ql \e0 . | ||
86 | .Pp | ||
87 | .Fn strncasecmp | ||
88 | and | ||
89 | .Fn strncasecmp_l | ||
90 | compare at most | ||
91 | .Fa len | ||
92 | characters. | ||
93 | .Pp | ||
94 | On | ||
95 | .Ox , | ||
96 | these functions always use the C locale and ignore | ||
97 | the global locale, the thread-specific locale, and the | ||
98 | .Fa locale | ||
99 | argument. | ||
100 | .Sh ENVIRONMENT | ||
101 | On other operating systems, the behaviour of | ||
102 | .Fn strcasecmp | ||
103 | and | ||
104 | .Fn strncasecmp | ||
105 | may depend on the | ||
106 | .Dv LC_CTYPE | ||
107 | .Xr locale 1 . | ||
108 | .Sh SEE ALSO | ||
109 | .Xr strcmp 3 , | ||
110 | .Xr strcoll 3 , | ||
111 | .Xr strxfrm 3 , | ||
112 | .Xr wcscasecmp 3 | ||
113 | .Sh STANDARDS | ||
114 | These functions conform to | ||
115 | .St -p1003.1-2008 . | ||
116 | .Sh HISTORY | ||
117 | The | ||
118 | .Fn strcasecmp | ||
119 | and | ||
120 | .Fn strncasecmp | ||
121 | functions have been available since | ||
122 | .Bx 4.3 Tahoe , | ||
123 | and | ||
124 | .Fn strcasecmp_l | ||
125 | and | ||
126 | .Fn strncasecmp_l | ||
127 | since | ||
128 | .Ox 6.2 . | ||
diff --git a/src/lib/libc/string/strcasecmp.c b/src/lib/libc/string/strcasecmp.c deleted file mode 100644 index edbd638722..0000000000 --- a/src/lib/libc/string/strcasecmp.c +++ /dev/null | |||
@@ -1,107 +0,0 @@ | |||
1 | /* $OpenBSD: strcasecmp.c,v 1.7 2015/08/31 02:53:57 guenther Exp $ */ | ||
2 | |||
3 | /* | ||
4 | * Copyright (c) 1987, 1993 | ||
5 | * The Regents of the University of California. All rights reserved. | ||
6 | * | ||
7 | * Redistribution and use in source and binary forms, with or without | ||
8 | * modification, are permitted provided that the following conditions | ||
9 | * are met: | ||
10 | * 1. Redistributions of source code must retain the above copyright | ||
11 | * notice, this list of conditions and the following disclaimer. | ||
12 | * 2. Redistributions in binary form must reproduce the above copyright | ||
13 | * notice, this list of conditions and the following disclaimer in the | ||
14 | * documentation and/or other materials provided with the distribution. | ||
15 | * 3. Neither the name of the University nor the names of its contributors | ||
16 | * may be used to endorse or promote products derived from this software | ||
17 | * without specific prior written permission. | ||
18 | * | ||
19 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | ||
20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
21 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
22 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | ||
23 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
24 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
25 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
26 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
27 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
28 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
29 | * SUCH DAMAGE. | ||
30 | */ | ||
31 | |||
32 | #include <string.h> | ||
33 | |||
34 | typedef unsigned char u_char; | ||
35 | |||
36 | /* | ||
37 | * This array is designed for mapping upper and lower case letter | ||
38 | * together for a case independent comparison. The mappings are | ||
39 | * based upon ascii character sequences. | ||
40 | */ | ||
41 | static const u_char charmap[] = { | ||
42 | '\000', '\001', '\002', '\003', '\004', '\005', '\006', '\007', | ||
43 | '\010', '\011', '\012', '\013', '\014', '\015', '\016', '\017', | ||
44 | '\020', '\021', '\022', '\023', '\024', '\025', '\026', '\027', | ||
45 | '\030', '\031', '\032', '\033', '\034', '\035', '\036', '\037', | ||
46 | '\040', '\041', '\042', '\043', '\044', '\045', '\046', '\047', | ||
47 | '\050', '\051', '\052', '\053', '\054', '\055', '\056', '\057', | ||
48 | '\060', '\061', '\062', '\063', '\064', '\065', '\066', '\067', | ||
49 | '\070', '\071', '\072', '\073', '\074', '\075', '\076', '\077', | ||
50 | '\100', '\141', '\142', '\143', '\144', '\145', '\146', '\147', | ||
51 | '\150', '\151', '\152', '\153', '\154', '\155', '\156', '\157', | ||
52 | '\160', '\161', '\162', '\163', '\164', '\165', '\166', '\167', | ||
53 | '\170', '\171', '\172', '\133', '\134', '\135', '\136', '\137', | ||
54 | '\140', '\141', '\142', '\143', '\144', '\145', '\146', '\147', | ||
55 | '\150', '\151', '\152', '\153', '\154', '\155', '\156', '\157', | ||
56 | '\160', '\161', '\162', '\163', '\164', '\165', '\166', '\167', | ||
57 | '\170', '\171', '\172', '\173', '\174', '\175', '\176', '\177', | ||
58 | '\200', '\201', '\202', '\203', '\204', '\205', '\206', '\207', | ||
59 | '\210', '\211', '\212', '\213', '\214', '\215', '\216', '\217', | ||
60 | '\220', '\221', '\222', '\223', '\224', '\225', '\226', '\227', | ||
61 | '\230', '\231', '\232', '\233', '\234', '\235', '\236', '\237', | ||
62 | '\240', '\241', '\242', '\243', '\244', '\245', '\246', '\247', | ||
63 | '\250', '\251', '\252', '\253', '\254', '\255', '\256', '\257', | ||
64 | '\260', '\261', '\262', '\263', '\264', '\265', '\266', '\267', | ||
65 | '\270', '\271', '\272', '\273', '\274', '\275', '\276', '\277', | ||
66 | '\300', '\301', '\302', '\303', '\304', '\305', '\306', '\307', | ||
67 | '\310', '\311', '\312', '\313', '\314', '\315', '\316', '\317', | ||
68 | '\320', '\321', '\322', '\323', '\324', '\325', '\326', '\327', | ||
69 | '\330', '\331', '\332', '\333', '\334', '\335', '\336', '\337', | ||
70 | '\340', '\341', '\342', '\343', '\344', '\345', '\346', '\347', | ||
71 | '\350', '\351', '\352', '\353', '\354', '\355', '\356', '\357', | ||
72 | '\360', '\361', '\362', '\363', '\364', '\365', '\366', '\367', | ||
73 | '\370', '\371', '\372', '\373', '\374', '\375', '\376', '\377', | ||
74 | }; | ||
75 | |||
76 | int | ||
77 | strcasecmp(const char *s1, const char *s2) | ||
78 | { | ||
79 | const u_char *cm = charmap; | ||
80 | const u_char *us1 = (const u_char *)s1; | ||
81 | const u_char *us2 = (const u_char *)s2; | ||
82 | |||
83 | while (cm[*us1] == cm[*us2++]) | ||
84 | if (*us1++ == '\0') | ||
85 | return (0); | ||
86 | return (cm[*us1] - cm[*--us2]); | ||
87 | } | ||
88 | DEF_WEAK(strcasecmp); | ||
89 | |||
90 | int | ||
91 | strncasecmp(const char *s1, const char *s2, size_t n) | ||
92 | { | ||
93 | if (n != 0) { | ||
94 | const u_char *cm = charmap; | ||
95 | const u_char *us1 = (const u_char *)s1; | ||
96 | const u_char *us2 = (const u_char *)s2; | ||
97 | |||
98 | do { | ||
99 | if (cm[*us1] != cm[*us2++]) | ||
100 | return (cm[*us1] - cm[*--us2]); | ||
101 | if (*us1++ == '\0') | ||
102 | break; | ||
103 | } while (--n != 0); | ||
104 | } | ||
105 | return (0); | ||
106 | } | ||
107 | DEF_WEAK(strncasecmp); | ||
diff --git a/src/lib/libc/string/strcasecmp_l.c b/src/lib/libc/string/strcasecmp_l.c deleted file mode 100644 index a9543dda11..0000000000 --- a/src/lib/libc/string/strcasecmp_l.c +++ /dev/null | |||
@@ -1,21 +0,0 @@ | |||
1 | /* $OpenBSD: strcasecmp_l.c,v 1.1 2017/09/05 03:16:13 schwarze Exp $ */ | ||
2 | /* | ||
3 | * Written in 2017 by Ingo Schwarze <schwarze@openbsd.org>. | ||
4 | * Released into the public domain. | ||
5 | */ | ||
6 | |||
7 | #include <string.h> | ||
8 | |||
9 | int | ||
10 | strcasecmp_l(const char *s1, const char *s2, | ||
11 | locale_t locale __attribute__((__unused__))) | ||
12 | { | ||
13 | return strcasecmp(s1, s2); | ||
14 | } | ||
15 | |||
16 | int | ||
17 | strncasecmp_l(const char *s1, const char *s2, size_t n, | ||
18 | locale_t locale __attribute__((__unused__))) | ||
19 | { | ||
20 | return strncasecmp(s1, s2, n); | ||
21 | } | ||
diff --git a/src/lib/libc/string/strcasestr.c b/src/lib/libc/string/strcasestr.c deleted file mode 100644 index abb3e15549..0000000000 --- a/src/lib/libc/string/strcasestr.c +++ /dev/null | |||
@@ -1,61 +0,0 @@ | |||
1 | /* $OpenBSD: strcasestr.c,v 1.4 2015/08/31 02:53:57 guenther Exp $ */ | ||
2 | /* $NetBSD: strcasestr.c,v 1.2 2005/02/09 21:35:47 kleink Exp $ */ | ||
3 | |||
4 | /*- | ||
5 | * Copyright (c) 1990, 1993 | ||
6 | * The Regents of the University of California. All rights reserved. | ||
7 | * | ||
8 | * This code is derived from software contributed to Berkeley by | ||
9 | * Chris Torek. | ||
10 | * | ||
11 | * Redistribution and use in source and binary forms, with or without | ||
12 | * modification, are permitted provided that the following conditions | ||
13 | * are met: | ||
14 | * 1. Redistributions of source code must retain the above copyright | ||
15 | * notice, this list of conditions and the following disclaimer. | ||
16 | * 2. Redistributions in binary form must reproduce the above copyright | ||
17 | * notice, this list of conditions and the following disclaimer in the | ||
18 | * documentation and/or other materials provided with the distribution. | ||
19 | * 3. Neither the name of the University nor the names of its contributors | ||
20 | * may be used to endorse or promote products derived from this software | ||
21 | * without specific prior written permission. | ||
22 | * | ||
23 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | ||
24 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
25 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
26 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | ||
27 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
28 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
29 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
30 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
31 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
32 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
33 | * SUCH DAMAGE. | ||
34 | */ | ||
35 | |||
36 | #include <ctype.h> | ||
37 | #include <string.h> | ||
38 | |||
39 | /* | ||
40 | * Find the first occurrence of find in s, ignore case. | ||
41 | */ | ||
42 | char * | ||
43 | strcasestr(const char *s, const char *find) | ||
44 | { | ||
45 | char c, sc; | ||
46 | size_t len; | ||
47 | |||
48 | if ((c = *find++) != 0) { | ||
49 | c = (char)tolower((unsigned char)c); | ||
50 | len = strlen(find); | ||
51 | do { | ||
52 | do { | ||
53 | if ((sc = *s++) == 0) | ||
54 | return (NULL); | ||
55 | } while ((char)tolower((unsigned char)sc) != c); | ||
56 | } while (strncasecmp(s, find, len) != 0); | ||
57 | s--; | ||
58 | } | ||
59 | return ((char *)s); | ||
60 | } | ||
61 | DEF_WEAK(strcasestr); | ||
diff --git a/src/lib/libc/string/strcat.3 b/src/lib/libc/string/strcat.3 deleted file mode 100644 index 68da4ed4a5..0000000000 --- a/src/lib/libc/string/strcat.3 +++ /dev/null | |||
@@ -1,76 +0,0 @@ | |||
1 | .\" $OpenBSD: strcat.3,v 1.19 2022/08/01 00:04:46 jsg Exp $ | ||
2 | .\" | ||
3 | .\" Copyright (c) 1990, 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 | .\" Chris Torek and the American National Standards Committee X3, | ||
8 | .\" on Information 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: August 1 2022 $ | ||
35 | .Dt STRCAT 3 | ||
36 | .Os | ||
37 | .Sh NAME | ||
38 | .Nm strcat | ||
39 | .Nd concatenate two strings without bounds checking | ||
40 | .Sh SYNOPSIS | ||
41 | .In string.h | ||
42 | .Ft char * | ||
43 | .Fn strcat "char *dst" "const char *append" | ||
44 | .Sh DESCRIPTION | ||
45 | The | ||
46 | .Fn strcat | ||
47 | function appends a copy of the NUL-terminated string | ||
48 | .Fa append | ||
49 | to the end of the NUL-terminated string | ||
50 | .Fa dst , | ||
51 | then adds a terminating | ||
52 | .Ql \e0 . | ||
53 | .Pp | ||
54 | No bounds checking is performed. | ||
55 | If the buffer | ||
56 | .Fa dst | ||
57 | is not large enough to hold the result, | ||
58 | subsequent memory will be damaged. | ||
59 | .Sh RETURN VALUES | ||
60 | The | ||
61 | .Fn strcat | ||
62 | function return the pointer | ||
63 | .Fa dst . | ||
64 | .Sh SEE ALSO | ||
65 | .Xr strlcpy 3 , | ||
66 | .Xr wcscat 3 , | ||
67 | .Xr wcslcpy 3 | ||
68 | .Sh STANDARDS | ||
69 | The | ||
70 | .Fn strcat | ||
71 | function conforms to | ||
72 | .St -ansiC . | ||
73 | .Sh HISTORY | ||
74 | The | ||
75 | .Fn strcat | ||
76 | function first appeared outside of Bell Labs in PWB/UNIX 1.0. | ||
diff --git a/src/lib/libc/string/strcat.c b/src/lib/libc/string/strcat.c deleted file mode 100644 index 73da22f75d..0000000000 --- a/src/lib/libc/string/strcat.c +++ /dev/null | |||
@@ -1,47 +0,0 @@ | |||
1 | /* $OpenBSD: strcat.c,v 1.10 2017/11/28 06:55:49 tb Exp $ */ | ||
2 | |||
3 | /* | ||
4 | * Copyright (c) 1988 Regents of the University of California. | ||
5 | * All rights reserved. | ||
6 | * | ||
7 | * Redistribution and use in source and binary forms, with or without | ||
8 | * modification, are permitted provided that the following conditions | ||
9 | * are met: | ||
10 | * 1. Redistributions of source code must retain the above copyright | ||
11 | * notice, this list of conditions and the following disclaimer. | ||
12 | * 2. Redistributions in binary form must reproduce the above copyright | ||
13 | * notice, this list of conditions and the following disclaimer in the | ||
14 | * documentation and/or other materials provided with the distribution. | ||
15 | * 3. Neither the name of the University nor the names of its contributors | ||
16 | * may be used to endorse or promote products derived from this software | ||
17 | * without specific prior written permission. | ||
18 | * | ||
19 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | ||
20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
21 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
22 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | ||
23 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
24 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
25 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
26 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
27 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
28 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
29 | * SUCH DAMAGE. | ||
30 | */ | ||
31 | |||
32 | #include <string.h> | ||
33 | |||
34 | #if defined(APIWARN) | ||
35 | __warn_references(strcat, | ||
36 | "strcat() is almost always misused, please use strlcat()"); | ||
37 | #endif | ||
38 | |||
39 | char * | ||
40 | strcat(char *s, const char *append) | ||
41 | { | ||
42 | char *save = s; | ||
43 | |||
44 | for (; *s; ++s); | ||
45 | while ((*s++ = *append++) != '\0'); | ||
46 | return(save); | ||
47 | } | ||
diff --git a/src/lib/libc/string/strchr.3 b/src/lib/libc/string/strchr.3 deleted file mode 100644 index d1dc67e5ec..0000000000 --- a/src/lib/libc/string/strchr.3 +++ /dev/null | |||
@@ -1,116 +0,0 @@ | |||
1 | .\" $OpenBSD: strchr.3,v 1.14 2024/12/11 23:28:20 jsg Exp $ | ||
2 | .\" | ||
3 | .\" Copyright (c) 1990, 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 | .\" Chris Torek and the American National Standards Committee X3, | ||
8 | .\" on Information 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 STRCHR 3 | ||
36 | .Os | ||
37 | .Sh NAME | ||
38 | .Nm strchr , | ||
39 | .Nm index | ||
40 | .Nd locate first occurrence of a character in a string | ||
41 | .Sh SYNOPSIS | ||
42 | .In string.h | ||
43 | .Ft char * | ||
44 | .Fn strchr "const char *s" "int c" | ||
45 | .In strings.h | ||
46 | .Ft char * | ||
47 | .Fn index "const char *s" "int c" | ||
48 | .Sh DESCRIPTION | ||
49 | The | ||
50 | .Fn strchr | ||
51 | function locates the first occurrence of the character | ||
52 | .Fa c | ||
53 | .Pq converted to a char | ||
54 | in the string | ||
55 | .Fa s . | ||
56 | The terminating NUL character is considered part of the string. | ||
57 | If | ||
58 | .Fa c | ||
59 | is | ||
60 | .Ql \e0 , | ||
61 | .Fn strchr | ||
62 | locates the terminating | ||
63 | .Ql \e0 . | ||
64 | .Pp | ||
65 | The | ||
66 | .Fn index | ||
67 | function is an old synonym for | ||
68 | .Fn strchr . | ||
69 | .Sh RETURN VALUES | ||
70 | The | ||
71 | .Fn strchr | ||
72 | function returns a pointer to the located character or | ||
73 | .Dv NULL | ||
74 | if the character does not appear in the string. | ||
75 | .Sh EXAMPLES | ||
76 | After the following call to | ||
77 | .Fn strchr , | ||
78 | .Va p | ||
79 | will point to the string | ||
80 | .Qq oobar : | ||
81 | .Bd -literal -offset indent | ||
82 | char *p; | ||
83 | char *s = "foobar"; | ||
84 | |||
85 | p = strchr(s, 'o'); | ||
86 | .Ed | ||
87 | .Sh SEE ALSO | ||
88 | .Xr memchr 3 , | ||
89 | .Xr strcspn 3 , | ||
90 | .Xr strpbrk 3 , | ||
91 | .Xr strrchr 3 , | ||
92 | .Xr strsep 3 , | ||
93 | .Xr strspn 3 , | ||
94 | .Xr strstr 3 , | ||
95 | .Xr strtok 3 , | ||
96 | .Xr wcschr 3 | ||
97 | .Sh STANDARDS | ||
98 | The | ||
99 | .Fn strchr | ||
100 | function conforms to | ||
101 | .St -ansiC . | ||
102 | .Pp | ||
103 | The | ||
104 | .Fn index | ||
105 | function is deprecated and shouldn't be used in new code. | ||
106 | .Sh HISTORY | ||
107 | The | ||
108 | .Fn index | ||
109 | function first appeared in | ||
110 | .At v7 . | ||
111 | The | ||
112 | .Fn strchr | ||
113 | function first appeared in | ||
114 | .At III | ||
115 | and was reimplemented for | ||
116 | .Bx 4.3 . | ||
diff --git a/src/lib/libc/string/strchr.c b/src/lib/libc/string/strchr.c deleted file mode 100644 index 8bfa7ac3aa..0000000000 --- a/src/lib/libc/string/strchr.c +++ /dev/null | |||
@@ -1,46 +0,0 @@ | |||
1 | /* $OpenBSD: strchr.c,v 1.4 2018/10/01 06:37:37 martijn Exp $ */ | ||
2 | /*- | ||
3 | * Copyright (c) 1990 The Regents of the University of California. | ||
4 | * All rights reserved. | ||
5 | * | ||
6 | * Redistribution and use in source and binary forms, with or without | ||
7 | * modification, are permitted provided that the following conditions | ||
8 | * are met: | ||
9 | * 1. Redistributions of source code must retain the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer. | ||
11 | * 2. Redistributions in binary form must reproduce the above copyright | ||
12 | * notice, this list of conditions and the following disclaimer in the | ||
13 | * documentation and/or other materials provided with the distribution. | ||
14 | * 3. Neither the name of the University nor the names of its contributors | ||
15 | * may be used to endorse or promote products derived from this software | ||
16 | * without specific prior written permission. | ||
17 | * | ||
18 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | ||
19 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
20 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
21 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | ||
22 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
23 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
24 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
25 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
26 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
27 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
28 | * SUCH DAMAGE. | ||
29 | */ | ||
30 | |||
31 | #include <string.h> | ||
32 | |||
33 | __weak_alias(index, strchr); | ||
34 | |||
35 | char * | ||
36 | strchr(const char *p, int ch) | ||
37 | { | ||
38 | for (;; ++p) { | ||
39 | if (*p == (char) ch) | ||
40 | return((char *)p); | ||
41 | if (!*p) | ||
42 | return((char *)NULL); | ||
43 | } | ||
44 | /* NOTREACHED */ | ||
45 | } | ||
46 | DEF_STRONG(strchr); | ||
diff --git a/src/lib/libc/string/strcmp.3 b/src/lib/libc/string/strcmp.3 deleted file mode 100644 index 4ef341e53e..0000000000 --- a/src/lib/libc/string/strcmp.3 +++ /dev/null | |||
@@ -1,95 +0,0 @@ | |||
1 | .\" $OpenBSD: strcmp.3,v 1.15 2022/08/01 00:04:46 jsg Exp $ | ||
2 | .\" | ||
3 | .\" Copyright (c) 1990, 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 | .\" Chris Torek and the American National Standards Committee X3, | ||
8 | .\" on Information 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: August 1 2022 $ | ||
35 | .Dt STRCMP 3 | ||
36 | .Os | ||
37 | .Sh NAME | ||
38 | .Nm strcmp , | ||
39 | .Nm strncmp | ||
40 | .Nd compare strings | ||
41 | .Sh SYNOPSIS | ||
42 | .In string.h | ||
43 | .Ft int | ||
44 | .Fn strcmp "const char *s1" "const char *s2" | ||
45 | .Ft int | ||
46 | .Fn strncmp "const char *s1" "const char *s2" "size_t len" | ||
47 | .Sh DESCRIPTION | ||
48 | The | ||
49 | .Fn strcmp | ||
50 | and | ||
51 | .Fn strncmp | ||
52 | functions lexicographically compare the NUL-terminated strings | ||
53 | .Fa s1 | ||
54 | and | ||
55 | .Fa s2 . | ||
56 | The | ||
57 | .Fn strncmp | ||
58 | function compares at most | ||
59 | .Fa len | ||
60 | characters. | ||
61 | .Sh RETURN VALUES | ||
62 | The | ||
63 | .Fn strcmp | ||
64 | and | ||
65 | .Fn strncmp | ||
66 | functions return an integer greater than, equal to, or less than 0, according | ||
67 | to whether the string | ||
68 | .Fa s1 | ||
69 | is greater than, equal to, or less than the string | ||
70 | .Fa s2 . | ||
71 | The comparison is done using unsigned characters, so that | ||
72 | .Ql \e200 | ||
73 | is greater than | ||
74 | .Ql \e0 . | ||
75 | .Sh SEE ALSO | ||
76 | .Xr bcmp 3 , | ||
77 | .Xr memcmp 3 , | ||
78 | .Xr strcasecmp 3 , | ||
79 | .Xr strcoll 3 , | ||
80 | .Xr strxfrm 3 , | ||
81 | .Xr wcscmp 3 | ||
82 | .Sh STANDARDS | ||
83 | The | ||
84 | .Fn strcmp | ||
85 | and | ||
86 | .Fn strncmp | ||
87 | functions conform to | ||
88 | .St -ansiC . | ||
89 | .Sh HISTORY | ||
90 | The | ||
91 | .Fn strcmp | ||
92 | function first appeared outside of Bell Labs in PWB/UNIX 1.0. | ||
93 | .Fn strncmp | ||
94 | first appeared in | ||
95 | .At v7 . | ||
diff --git a/src/lib/libc/string/strcmp.c b/src/lib/libc/string/strcmp.c deleted file mode 100644 index be175563d4..0000000000 --- a/src/lib/libc/string/strcmp.c +++ /dev/null | |||
@@ -1,48 +0,0 @@ | |||
1 | /* $OpenBSD: strcmp.c,v 1.9 2015/08/31 02:53:57 guenther Exp $ */ | ||
2 | |||
3 | /*- | ||
4 | * Copyright (c) 1990 The Regents of the University of California. | ||
5 | * All rights reserved. | ||
6 | * | ||
7 | * This code is derived from software contributed to Berkeley by | ||
8 | * Chris Torek. | ||
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 | |||
35 | #include <string.h> | ||
36 | |||
37 | /* | ||
38 | * Compare strings. | ||
39 | */ | ||
40 | int | ||
41 | strcmp(const char *s1, const char *s2) | ||
42 | { | ||
43 | while (*s1 == *s2++) | ||
44 | if (*s1++ == 0) | ||
45 | return (0); | ||
46 | return (*(unsigned char *)s1 - *(unsigned char *)--s2); | ||
47 | } | ||
48 | DEF_STRONG(strcmp); | ||
diff --git a/src/lib/libc/string/strcoll.3 b/src/lib/libc/string/strcoll.3 deleted file mode 100644 index 9daa6cd93f..0000000000 --- a/src/lib/libc/string/strcoll.3 +++ /dev/null | |||
@@ -1,103 +0,0 @@ | |||
1 | .\" $OpenBSD: strcoll.3,v 1.11 2019/01/18 07:43:36 schwarze Exp $ | ||
2 | .\" | ||
3 | .\" Copyright (c) 1990, 1991 The Regents of the University of California. | ||
4 | .\" Copyright (c) 2017 Ingo Schwarze <schwarze@openbsd.org> | ||
5 | .\" All rights reserved. | ||
6 | .\" | ||
7 | .\" This code is derived from software contributed to Berkeley by | ||
8 | .\" Chris Torek and the American National Standards Committee X3, | ||
9 | .\" on Information Processing Systems. | ||
10 | .\" | ||
11 | .\" Redistribution and use in source and binary forms, with or without | ||
12 | .\" modification, are permitted provided that the following conditions | ||
13 | .\" are met: | ||
14 | .\" 1. Redistributions of source code must retain the above copyright | ||
15 | .\" notice, this list of conditions and the following disclaimer. | ||
16 | .\" 2. Redistributions in binary form must reproduce the above copyright | ||
17 | .\" notice, this list of conditions and the following disclaimer in the | ||
18 | .\" documentation and/or other materials provided with the distribution. | ||
19 | .\" 3. Neither the name of the University nor the names of its contributors | ||
20 | .\" may be used to endorse or promote products derived from this software | ||
21 | .\" without specific prior written permission. | ||
22 | .\" | ||
23 | .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | ||
24 | .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
25 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
26 | .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | ||
27 | .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
28 | .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
29 | .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
30 | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
31 | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
32 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
33 | .\" SUCH DAMAGE. | ||
34 | .\" | ||
35 | .Dd $Mdocdate: January 18 2019 $ | ||
36 | .Dt STRCOLL 3 | ||
37 | .Os | ||
38 | .Sh NAME | ||
39 | .Nm strcoll , | ||
40 | .Nm strcoll_l | ||
41 | .Nd compare strings according to current collation | ||
42 | .Sh SYNOPSIS | ||
43 | .In string.h | ||
44 | .Ft int | ||
45 | .Fn strcoll "const char *s1" "const char *s2" | ||
46 | .Ft int | ||
47 | .Fn strcoll_l "const char *s1" "const char *s2" "locale_t locale" | ||
48 | .Sh DESCRIPTION | ||
49 | The | ||
50 | .Fn strcoll | ||
51 | and | ||
52 | .Fn strcoll_l | ||
53 | functions lexicographically compare the NUL-terminated strings | ||
54 | .Fa s1 | ||
55 | and | ||
56 | .Fa s2 | ||
57 | according to the current locale collation | ||
58 | and return an integer greater than, equal to, or less than 0, | ||
59 | according to whether | ||
60 | .Fa s1 | ||
61 | is greater than, equal to, or less than | ||
62 | .Fa s2 . | ||
63 | .Pp | ||
64 | On | ||
65 | .Ox , | ||
66 | they have the same effect as | ||
67 | .Xr strcmp 3 , | ||
68 | and the global locale, the thread-specific locale, and the | ||
69 | .Fa locale | ||
70 | argument are ignored. | ||
71 | On other operating systems, results may depend on the | ||
72 | .Dv LC_CTYPE | ||
73 | and | ||
74 | .Dv LC_COLLATE | ||
75 | locale categories set with | ||
76 | .Xr setlocale 3 , | ||
77 | .Xr uselocale 3 , | ||
78 | or | ||
79 | .Xr newlocale 3 . | ||
80 | .Sh SEE ALSO | ||
81 | .Xr newlocale 3 , | ||
82 | .Xr setlocale 3 , | ||
83 | .Xr strcmp 3 , | ||
84 | .Xr strxfrm 3 , | ||
85 | .Xr wcscoll 3 | ||
86 | .Sh STANDARDS | ||
87 | The | ||
88 | .Fn strcoll | ||
89 | function conforms to | ||
90 | .St -ansiC , | ||
91 | and | ||
92 | .Fn strcoll_l | ||
93 | to | ||
94 | .St -p1003.1-2008 . | ||
95 | .Sh HISTORY | ||
96 | The | ||
97 | .Fn strcoll | ||
98 | function has been available since | ||
99 | .Bx 4.3 Reno , | ||
100 | and | ||
101 | .Fn strcoll_l | ||
102 | since | ||
103 | .Ox 6.2 . | ||
diff --git a/src/lib/libc/string/strcoll.c b/src/lib/libc/string/strcoll.c deleted file mode 100644 index 47a6ea4f24..0000000000 --- a/src/lib/libc/string/strcoll.c +++ /dev/null | |||
@@ -1,45 +0,0 @@ | |||
1 | /* $OpenBSD: strcoll.c,v 1.6 2015/08/31 02:53:57 guenther Exp $ */ | ||
2 | /*- | ||
3 | * Copyright (c) 1990 The Regents of the University of California. | ||
4 | * All rights reserved. | ||
5 | * | ||
6 | * This code is derived from software contributed to Berkeley by | ||
7 | * Chris Torek. | ||
8 | * | ||
9 | * Redistribution and use in source and binary forms, with or without | ||
10 | * modification, are permitted provided that the following conditions | ||
11 | * are met: | ||
12 | * 1. Redistributions of source code must retain the above copyright | ||
13 | * notice, this list of conditions and the following disclaimer. | ||
14 | * 2. Redistributions in binary form must reproduce the above copyright | ||
15 | * notice, this list of conditions and the following disclaimer in the | ||
16 | * documentation and/or other materials provided with the distribution. | ||
17 | * 3. Neither the name of the University nor the names of its contributors | ||
18 | * may be used to endorse or promote products derived from this software | ||
19 | * without specific prior written permission. | ||
20 | * | ||
21 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | ||
22 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | ||
25 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
26 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
27 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
28 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
29 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
30 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
31 | * SUCH DAMAGE. | ||
32 | */ | ||
33 | |||
34 | #include <string.h> | ||
35 | |||
36 | /* | ||
37 | * Compare strings according to LC_COLLATE category of current locale. | ||
38 | */ | ||
39 | int | ||
40 | strcoll(const char *s1, const char *s2) | ||
41 | { | ||
42 | /* LC_COLLATE is unimplemented, hence always "C" */ | ||
43 | return (strcmp(s1, s2)); | ||
44 | } | ||
45 | DEF_STRONG(strcoll); | ||
diff --git a/src/lib/libc/string/strcoll_l.c b/src/lib/libc/string/strcoll_l.c deleted file mode 100644 index bcd5b0f417..0000000000 --- a/src/lib/libc/string/strcoll_l.c +++ /dev/null | |||
@@ -1,14 +0,0 @@ | |||
1 | /* $OpenBSD: strcoll_l.c,v 1.1 2017/09/05 03:16:13 schwarze Exp $ */ | ||
2 | /* | ||
3 | * Written in 2017 by Ingo Schwarze <schwarze@openbsd.org>. | ||
4 | * Released into the public domain. | ||
5 | */ | ||
6 | |||
7 | #include <string.h> | ||
8 | |||
9 | int | ||
10 | strcoll_l(const char *s1, const char *s2, | ||
11 | locale_t locale __attribute__((__unused__))) | ||
12 | { | ||
13 | return strcmp(s1, s2); | ||
14 | } | ||
diff --git a/src/lib/libc/string/strcpy.3 b/src/lib/libc/string/strcpy.3 deleted file mode 100644 index 4bf690ba76..0000000000 --- a/src/lib/libc/string/strcpy.3 +++ /dev/null | |||
@@ -1,82 +0,0 @@ | |||
1 | .\" $OpenBSD: strcpy.3,v 1.22 2022/08/01 00:04:46 jsg Exp $ | ||
2 | .\" | ||
3 | .\" Copyright (c) 1990, 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 | .\" Chris Torek and the American National Standards Committee X3, | ||
8 | .\" on Information 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: August 1 2022 $ | ||
35 | .Dt STRCPY 3 | ||
36 | .Os | ||
37 | .Sh NAME | ||
38 | .Nm strcpy | ||
39 | .Nd copy a string without bounds checking | ||
40 | .Sh SYNOPSIS | ||
41 | .In string.h | ||
42 | .Ft char * | ||
43 | .Fn strcpy "char *dst" "const char *src" | ||
44 | .Sh DESCRIPTION | ||
45 | The | ||
46 | .Fn strcpy | ||
47 | function copies the string | ||
48 | .Fa src | ||
49 | (including the terminating | ||
50 | .Ql \e0 | ||
51 | character) to the buffer | ||
52 | .Fa dst . | ||
53 | .Pp | ||
54 | No bounds checking is performed. | ||
55 | If the buffer | ||
56 | .Fa dst | ||
57 | is not large enough to hold the result, | ||
58 | subsequent memory will be damaged. | ||
59 | .Pp | ||
60 | If the | ||
61 | .Fa src | ||
62 | string is inside the | ||
63 | .Fa dst | ||
64 | buffer, the behavior is undefined. | ||
65 | .Sh RETURN VALUES | ||
66 | The | ||
67 | .Fn strcpy | ||
68 | function returns | ||
69 | .Fa dst . | ||
70 | .Sh SEE ALSO | ||
71 | .Xr strlcpy 3 , | ||
72 | .Xr wcscpy 3 , | ||
73 | .Xr wcslcpy 3 | ||
74 | .Sh STANDARDS | ||
75 | The | ||
76 | .Fn strcpy | ||
77 | function conforms to | ||
78 | .St -ansiC . | ||
79 | .Sh HISTORY | ||
80 | The | ||
81 | .Fn strcpy | ||
82 | function first appeared outside of Bell Labs in PWB/UNIX 1.0. | ||
diff --git a/src/lib/libc/string/strcpy.c b/src/lib/libc/string/strcpy.c deleted file mode 100644 index 290eefeabf..0000000000 --- a/src/lib/libc/string/strcpy.c +++ /dev/null | |||
@@ -1,46 +0,0 @@ | |||
1 | /* $OpenBSD: strcpy.c,v 1.10 2017/11/28 06:55:49 tb Exp $ */ | ||
2 | |||
3 | /* | ||
4 | * Copyright (c) 1988 Regents of the University of California. | ||
5 | * All rights reserved. | ||
6 | * | ||
7 | * Redistribution and use in source and binary forms, with or without | ||
8 | * modification, are permitted provided that the following conditions | ||
9 | * are met: | ||
10 | * 1. Redistributions of source code must retain the above copyright | ||
11 | * notice, this list of conditions and the following disclaimer. | ||
12 | * 2. Redistributions in binary form must reproduce the above copyright | ||
13 | * notice, this list of conditions and the following disclaimer in the | ||
14 | * documentation and/or other materials provided with the distribution. | ||
15 | * 3. Neither the name of the University nor the names of its contributors | ||
16 | * may be used to endorse or promote products derived from this software | ||
17 | * without specific prior written permission. | ||
18 | * | ||
19 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | ||
20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
21 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
22 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | ||
23 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
24 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
25 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
26 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
27 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
28 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
29 | * SUCH DAMAGE. | ||
30 | */ | ||
31 | |||
32 | #include <string.h> | ||
33 | |||
34 | #if defined(APIWARN) | ||
35 | __warn_references(strcpy, | ||
36 | "strcpy() is almost always misused, please use strlcpy()"); | ||
37 | #endif | ||
38 | |||
39 | char * | ||
40 | strcpy(char *to, const char *from) | ||
41 | { | ||
42 | char *save = to; | ||
43 | |||
44 | for (; (*to = *from) != '\0'; ++from, ++to); | ||
45 | return(save); | ||
46 | } | ||
diff --git a/src/lib/libc/string/strcspn.3 b/src/lib/libc/string/strcspn.3 deleted file mode 100644 index 91e5c3f1cc..0000000000 --- a/src/lib/libc/string/strcspn.3 +++ /dev/null | |||
@@ -1,108 +0,0 @@ | |||
1 | .\" $OpenBSD: strcspn.3,v 1.12 2024/12/11 23:28:20 jsg Exp $ | ||
2 | .\" | ||
3 | .\" Copyright (c) 1990, 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 | .\" Chris Torek and the American National Standards Committee X3, | ||
8 | .\" on Information 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 STRCSPN 3 | ||
36 | .Os | ||
37 | .Sh NAME | ||
38 | .Nm strcspn | ||
39 | .Nd span the complement of a string | ||
40 | .Sh SYNOPSIS | ||
41 | .In string.h | ||
42 | .Ft size_t | ||
43 | .Fn strcspn "const char *s" "const char *charset" | ||
44 | .Sh DESCRIPTION | ||
45 | The | ||
46 | .Fn strcspn | ||
47 | function spans the initial part of the NUL-terminated string | ||
48 | .Fa s | ||
49 | as long as the characters from | ||
50 | .Fa s | ||
51 | do not occur in string | ||
52 | .Fa charset | ||
53 | (it spans the | ||
54 | .Em complement | ||
55 | of | ||
56 | .Fa charset ) . | ||
57 | .Sh RETURN VALUES | ||
58 | The | ||
59 | .Fn strcspn | ||
60 | function returns the number of characters spanned. | ||
61 | .Sh EXAMPLES | ||
62 | The following call to | ||
63 | .Fn strcspn | ||
64 | will return 3, since the first three characters of string | ||
65 | .Fa s | ||
66 | do not occur in string | ||
67 | .Fa charset : | ||
68 | .Bd -literal -offset indent | ||
69 | char *s = "foobar"; | ||
70 | char *charset = "bar"; | ||
71 | size_t span; | ||
72 | |||
73 | span = strcspn(s, charset); | ||
74 | .Ed | ||
75 | .Pp | ||
76 | The following removes the first (if any) newline character from string | ||
77 | .Fa line . | ||
78 | This is useful for trimming the newline after a | ||
79 | .Xr fgets 3 | ||
80 | call. | ||
81 | .Bd -literal -offset indent | ||
82 | char line[BUFSIZ]; | ||
83 | |||
84 | if (fgets(line, sizeof(line), fp) != NULL) | ||
85 | line[strcspn(line, "\en")] = '\e0'; | ||
86 | .Ed | ||
87 | .Sh SEE ALSO | ||
88 | .Xr memchr 3 , | ||
89 | .Xr strchr 3 , | ||
90 | .Xr strpbrk 3 , | ||
91 | .Xr strrchr 3 , | ||
92 | .Xr strsep 3 , | ||
93 | .Xr strspn 3 , | ||
94 | .Xr strstr 3 , | ||
95 | .Xr strtok 3 , | ||
96 | .Xr wcscspn 3 | ||
97 | .Sh STANDARDS | ||
98 | The | ||
99 | .Fn strcspn | ||
100 | function conforms to | ||
101 | .St -ansiC . | ||
102 | .Sh HISTORY | ||
103 | The | ||
104 | .Fn strcspn | ||
105 | function first appeared in | ||
106 | .At III | ||
107 | and was reimplemented for | ||
108 | .Bx 4.3 . | ||
diff --git a/src/lib/libc/string/strcspn.c b/src/lib/libc/string/strcspn.c deleted file mode 100644 index 3c1f5a4cec..0000000000 --- a/src/lib/libc/string/strcspn.c +++ /dev/null | |||
@@ -1,59 +0,0 @@ | |||
1 | /* $OpenBSD: strcspn.c,v 1.6 2015/08/31 02:53:57 guenther Exp $ */ | ||
2 | /*- | ||
3 | * Copyright (c) 1990 The Regents of the University of California. | ||
4 | * All rights reserved. | ||
5 | * | ||
6 | * This code is derived from software contributed to Berkeley by | ||
7 | * Chris Torek. | ||
8 | * | ||
9 | * Redistribution and use in source and binary forms, with or without | ||
10 | * modification, are permitted provided that the following conditions | ||
11 | * are met: | ||
12 | * 1. Redistributions of source code must retain the above copyright | ||
13 | * notice, this list of conditions and the following disclaimer. | ||
14 | * 2. Redistributions in binary form must reproduce the above copyright | ||
15 | * notice, this list of conditions and the following disclaimer in the | ||
16 | * documentation and/or other materials provided with the distribution. | ||
17 | * 3. Neither the name of the University nor the names of its contributors | ||
18 | * may be used to endorse or promote products derived from this software | ||
19 | * without specific prior written permission. | ||
20 | * | ||
21 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | ||
22 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | ||
25 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
26 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
27 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
28 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
29 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
30 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
31 | * SUCH DAMAGE. | ||
32 | */ | ||
33 | |||
34 | #include <string.h> | ||
35 | |||
36 | /* | ||
37 | * Span the complement of string s2. | ||
38 | */ | ||
39 | size_t | ||
40 | strcspn(const char *s1, const char *s2) | ||
41 | { | ||
42 | const char *p, *spanp; | ||
43 | char c, sc; | ||
44 | |||
45 | /* | ||
46 | * Stop as soon as we find any character from s2. Note that there | ||
47 | * must be a NUL in s2; it suffices to stop when we find that, too. | ||
48 | */ | ||
49 | for (p = s1;;) { | ||
50 | c = *p++; | ||
51 | spanp = s2; | ||
52 | do { | ||
53 | if ((sc = *spanp++) == c) | ||
54 | return (p - 1 - s1); | ||
55 | } while (sc != 0); | ||
56 | } | ||
57 | /* NOTREACHED */ | ||
58 | } | ||
59 | DEF_STRONG(strcspn); | ||
diff --git a/src/lib/libc/string/strdup.3 b/src/lib/libc/string/strdup.3 deleted file mode 100644 index 283f3bc0ea..0000000000 --- a/src/lib/libc/string/strdup.3 +++ /dev/null | |||
@@ -1,119 +0,0 @@ | |||
1 | .\" $OpenBSD: strdup.3,v 1.22 2015/12/01 01:32:48 mmcc Exp $ | ||
2 | .\" | ||
3 | .\" Copyright (c) 1990, 1991, 1993 | ||
4 | .\" The Regents of the University of California. All rights reserved. | ||
5 | .\" | ||
6 | .\" Redistribution and use in source and binary forms, with or without | ||
7 | .\" modification, are permitted provided that the following conditions | ||
8 | .\" are met: | ||
9 | .\" 1. Redistributions of source code must retain the above copyright | ||
10 | .\" notice, this list of conditions and the following disclaimer. | ||
11 | .\" 2. Redistributions in binary form must reproduce the above copyright | ||
12 | .\" notice, this list of conditions and the following disclaimer in the | ||
13 | .\" documentation and/or other materials provided with the distribution. | ||
14 | .\" 3. Neither the name of the University nor the names of its contributors | ||
15 | .\" may be used to endorse or promote products derived from this software | ||
16 | .\" without specific prior written permission. | ||
17 | .\" | ||
18 | .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | ||
19 | .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
20 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
21 | .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | ||
22 | .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
23 | .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
24 | .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
25 | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
26 | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
27 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
28 | .\" SUCH DAMAGE. | ||
29 | .\" | ||
30 | .\" @(#)strdup.3 8.1 (Berkeley) 6/9/93 | ||
31 | .\" | ||
32 | .Dd $Mdocdate: December 1 2015 $ | ||
33 | .Dt STRDUP 3 | ||
34 | .Os | ||
35 | .Sh NAME | ||
36 | .Nm strdup , | ||
37 | .Nm strndup | ||
38 | .Nd save a copy of a string | ||
39 | .Sh SYNOPSIS | ||
40 | .In string.h | ||
41 | .Ft char * | ||
42 | .Fn strdup "const char *s" | ||
43 | .Ft char * | ||
44 | .Fn strndup "const char *s" "size_t maxlen" | ||
45 | .Sh DESCRIPTION | ||
46 | The | ||
47 | .Fn strdup | ||
48 | function allocates sufficient memory for a copy of the string | ||
49 | .Fa s , | ||
50 | does the copy, and returns a pointer to it. | ||
51 | The pointer may subsequently be used as an argument to the function | ||
52 | .Xr free 3 . | ||
53 | .Pp | ||
54 | The | ||
55 | .Fn strndup | ||
56 | function behaves similarly to | ||
57 | .Nm strdup | ||
58 | but only copies up to | ||
59 | .Fa maxlen | ||
60 | characters from | ||
61 | .Fa s . | ||
62 | The resulting string is always NUL-terminated. | ||
63 | .Pp | ||
64 | If the memory allocation fails, | ||
65 | .Dv NULL | ||
66 | is returned. | ||
67 | .Sh EXAMPLES | ||
68 | The following will point | ||
69 | .Va p | ||
70 | to an allocated area of memory containing the NUL-terminated string | ||
71 | .Qq foobar : | ||
72 | .Bd -literal -offset indent | ||
73 | char *p; | ||
74 | |||
75 | p = strdup("foobar"); | ||
76 | if (p == NULL) | ||
77 | err(1, NULL); | ||
78 | .Ed | ||
79 | .Sh ERRORS | ||
80 | The | ||
81 | .Fn strdup | ||
82 | and | ||
83 | .Fn strndup | ||
84 | functions may fail and set the external variable | ||
85 | .Va errno | ||
86 | for any of the errors specified for the library function | ||
87 | .Xr malloc 3 . | ||
88 | .Sh SEE ALSO | ||
89 | .Xr free 3 , | ||
90 | .Xr malloc 3 , | ||
91 | .Xr strcpy 3 , | ||
92 | .Xr strlcpy 3 , | ||
93 | .Xr strlen 3 , | ||
94 | .Xr wcsdup 3 | ||
95 | .Sh STANDARDS | ||
96 | The | ||
97 | .Fn strdup | ||
98 | and | ||
99 | .Fn strndup | ||
100 | functions conform to | ||
101 | .St -p1003.1-2008 . | ||
102 | .Sh HISTORY | ||
103 | A | ||
104 | .Fn strdup | ||
105 | macro was first used in the | ||
106 | .Bx 4.1c | ||
107 | debugger, | ||
108 | .Sy dbx . | ||
109 | It was rewritten as a C function for the | ||
110 | .Bx 4.3 | ||
111 | .Xr inetd 8 | ||
112 | and first appeared in the C library of | ||
113 | .Bx 4.3 Reno . | ||
114 | The | ||
115 | .Fn strndup | ||
116 | function appeared in glibc 2.0, was reimplemented for | ||
117 | .Nx 4.0 , | ||
118 | and ported to | ||
119 | .Ox 4.8 . | ||
diff --git a/src/lib/libc/string/strdup.c b/src/lib/libc/string/strdup.c deleted file mode 100644 index 9aebf399c1..0000000000 --- a/src/lib/libc/string/strdup.c +++ /dev/null | |||
@@ -1,50 +0,0 @@ | |||
1 | /* $OpenBSD: strdup.c,v 1.7 2015/08/31 02:53:57 guenther Exp $ */ | ||
2 | |||
3 | /* | ||
4 | * Copyright (c) 1988, 1993 | ||
5 | * The Regents of the University of California. All rights reserved. | ||
6 | * | ||
7 | * Redistribution and use in source and binary forms, with or without | ||
8 | * modification, are permitted provided that the following conditions | ||
9 | * are met: | ||
10 | * 1. Redistributions of source code must retain the above copyright | ||
11 | * notice, this list of conditions and the following disclaimer. | ||
12 | * 2. Redistributions in binary form must reproduce the above copyright | ||
13 | * notice, this list of conditions and the following disclaimer in the | ||
14 | * documentation and/or other materials provided with the distribution. | ||
15 | * 3. Neither the name of the University nor the names of its contributors | ||
16 | * may be used to endorse or promote products derived from this software | ||
17 | * without specific prior written permission. | ||
18 | * | ||
19 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | ||
20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
21 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
22 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | ||
23 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
24 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
25 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
26 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
27 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
28 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
29 | * SUCH DAMAGE. | ||
30 | */ | ||
31 | |||
32 | #include <sys/types.h> | ||
33 | |||
34 | #include <stddef.h> | ||
35 | #include <stdlib.h> | ||
36 | #include <string.h> | ||
37 | |||
38 | char * | ||
39 | strdup(const char *str) | ||
40 | { | ||
41 | size_t siz; | ||
42 | char *copy; | ||
43 | |||
44 | siz = strlen(str) + 1; | ||
45 | if ((copy = malloc(siz)) == NULL) | ||
46 | return(NULL); | ||
47 | (void)memcpy(copy, str, siz); | ||
48 | return(copy); | ||
49 | } | ||
50 | DEF_WEAK(strdup); | ||
diff --git a/src/lib/libc/string/strerror.3 b/src/lib/libc/string/strerror.3 deleted file mode 100644 index 6c5b890fa4..0000000000 --- a/src/lib/libc/string/strerror.3 +++ /dev/null | |||
@@ -1,154 +0,0 @@ | |||
1 | .\" $OpenBSD: strerror.3,v 1.16 2019/05/16 13:35:16 schwarze Exp $ | ||
2 | .\" | ||
3 | .\" Copyright (c) 1980, 1991 Regents of the University of California. | ||
4 | .\" Copyright (c) 2017 Ingo Schwarze <schwarze@openbsd.org> | ||
5 | .\" All rights reserved. | ||
6 | .\" | ||
7 | .\" This code is derived from software contributed to Berkeley by | ||
8 | .\" the American National Standards Committee X3, on Information | ||
9 | .\" Processing Systems. | ||
10 | .\" | ||
11 | .\" Redistribution and use in source and binary forms, with or without | ||
12 | .\" modification, are permitted provided that the following conditions | ||
13 | .\" are met: | ||
14 | .\" 1. Redistributions of source code must retain the above copyright | ||
15 | .\" notice, this list of conditions and the following disclaimer. | ||
16 | .\" 2. Redistributions in binary form must reproduce the above copyright | ||
17 | .\" notice, this list of conditions and the following disclaimer in the | ||
18 | .\" documentation and/or other materials provided with the distribution. | ||
19 | .\" 3. Neither the name of the University nor the names of its contributors | ||
20 | .\" may be used to endorse or promote products derived from this software | ||
21 | .\" without specific prior written permission. | ||
22 | .\" | ||
23 | .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | ||
24 | .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
25 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
26 | .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | ||
27 | .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
28 | .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
29 | .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
30 | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
31 | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
32 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
33 | .\" SUCH DAMAGE. | ||
34 | .\" | ||
35 | .Dd $Mdocdate: May 16 2019 $ | ||
36 | .Dt STRERROR 3 | ||
37 | .Os | ||
38 | .Sh NAME | ||
39 | .Nm strerror , | ||
40 | .Nm strerror_l , | ||
41 | .Nm strerror_r | ||
42 | .Nd get error message string | ||
43 | .Sh SYNOPSIS | ||
44 | .In string.h | ||
45 | .Ft char * | ||
46 | .Fn strerror "int errnum" | ||
47 | .Ft char * | ||
48 | .Fn strerror_l "int errnum" "locale_t locale" | ||
49 | .Ft int | ||
50 | .Fn strerror_r "int errnum" "char *strerrbuf" "size_t buflen" | ||
51 | .Sh DESCRIPTION | ||
52 | These functions map the error number | ||
53 | .Fa errnum | ||
54 | to an error message string. | ||
55 | .Pp | ||
56 | .Fn strerror | ||
57 | and | ||
58 | .Fn strerror_l | ||
59 | return a string containing a maximum of | ||
60 | .Dv NL_TEXTMAX | ||
61 | characters, including the trailing NUL. | ||
62 | This string is not to be modified by the calling program. | ||
63 | The string returned by | ||
64 | .Fn strerror | ||
65 | may be overwritten by subsequent calls to | ||
66 | .Fn strerror | ||
67 | in any thread. | ||
68 | The string returned by | ||
69 | .Fn strerror_l | ||
70 | may be overwritten by subsequent calls to | ||
71 | .Fn strerror_l | ||
72 | in the same thread. | ||
73 | .Pp | ||
74 | .Fn strerror_r | ||
75 | is a thread safe version of | ||
76 | .Fn strerror | ||
77 | that places the error message in the specified buffer | ||
78 | .Fa strerrbuf . | ||
79 | .Pp | ||
80 | On | ||
81 | .Ox , | ||
82 | the global locale, the thread-specific locale, and the | ||
83 | .Fa locale | ||
84 | argument are ignored. | ||
85 | .Sh RETURN VALUES | ||
86 | .Fn strerror | ||
87 | and | ||
88 | .Fn strerror_l | ||
89 | return a pointer to the error message string. | ||
90 | If an error occurs, the error code is stored in | ||
91 | .Va errno . | ||
92 | .Pp | ||
93 | .Fn strerror_r | ||
94 | returns zero upon successful completion. | ||
95 | If an error occurs, the error code is stored in | ||
96 | .Va errno | ||
97 | and the error code is returned. | ||
98 | .Sh ERRORS | ||
99 | All these functions may fail if: | ||
100 | .Bl -tag -width Er | ||
101 | .It Bq Er EINVAL | ||
102 | .Fa errnum | ||
103 | is not a valid error number. | ||
104 | The returned error string will consist of an error message that includes | ||
105 | .Fa errnum . | ||
106 | .El | ||
107 | .Pp | ||
108 | .Fn strerror_r | ||
109 | may also fail if: | ||
110 | .Bl -tag -width Er | ||
111 | .It Bq Er ERANGE | ||
112 | The error message is larger than | ||
113 | .Fa buflen | ||
114 | characters. | ||
115 | The message will be truncated to fit. | ||
116 | .El | ||
117 | .Sh SEE ALSO | ||
118 | .Xr intro 2 , | ||
119 | .Xr newlocale 3 , | ||
120 | .Xr perror 3 , | ||
121 | .Xr setlocale 3 | ||
122 | .Sh STANDARDS | ||
123 | The | ||
124 | .Fn strerror | ||
125 | function conforms to | ||
126 | .St -isoC-99 . | ||
127 | The | ||
128 | .Fn strerror_l | ||
129 | and | ||
130 | .Fn strerror_r | ||
131 | functions conform to | ||
132 | .St -p1003.1-2008 . | ||
133 | .Sh HISTORY | ||
134 | The | ||
135 | .Fn strerror | ||
136 | function has been available since | ||
137 | .Bx 4.3 Reno , | ||
138 | .Fn strerror_r | ||
139 | since | ||
140 | .Ox 3.3 , | ||
141 | and | ||
142 | .Fn strerror_l | ||
143 | since | ||
144 | .Ox 6.2 . | ||
145 | .Sh CAVEATS | ||
146 | On systems other than | ||
147 | .Ox , | ||
148 | the | ||
149 | .Dv LC_MESSAGES | ||
150 | .Xr locale 1 | ||
151 | category can cause different strings to be returned instead of the | ||
152 | normal error messages; see CAVEATS in | ||
153 | .Xr setlocale 3 | ||
154 | for details. | ||
diff --git a/src/lib/libc/string/strerror.c b/src/lib/libc/string/strerror.c deleted file mode 100644 index c6f05446fd..0000000000 --- a/src/lib/libc/string/strerror.c +++ /dev/null | |||
@@ -1,42 +0,0 @@ | |||
1 | /* $OpenBSD: strerror.c,v 1.8 2015/08/31 02:53:57 guenther Exp $ */ | ||
2 | /* | ||
3 | * Copyright (c) 1988 Regents of the University of California. | ||
4 | * All rights reserved. | ||
5 | * | ||
6 | * Redistribution and use in source and binary forms, with or without | ||
7 | * modification, are permitted provided that the following conditions | ||
8 | * are met: | ||
9 | * 1. Redistributions of source code must retain the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer. | ||
11 | * 2. Redistributions in binary form must reproduce the above copyright | ||
12 | * notice, this list of conditions and the following disclaimer in the | ||
13 | * documentation and/or other materials provided with the distribution. | ||
14 | * 3. Neither the name of the University nor the names of its contributors | ||
15 | * may be used to endorse or promote products derived from this software | ||
16 | * without specific prior written permission. | ||
17 | * | ||
18 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | ||
19 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
20 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
21 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | ||
22 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
23 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
24 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
25 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
26 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
27 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
28 | * SUCH DAMAGE. | ||
29 | */ | ||
30 | |||
31 | #include <string.h> | ||
32 | #include <limits.h> | ||
33 | |||
34 | char * | ||
35 | strerror(int num) | ||
36 | { | ||
37 | static char buf[NL_TEXTMAX]; | ||
38 | |||
39 | (void)strerror_r(num, buf, sizeof(buf)); | ||
40 | return (buf); | ||
41 | } | ||
42 | DEF_STRONG(strerror); | ||
diff --git a/src/lib/libc/string/strerror_l.c b/src/lib/libc/string/strerror_l.c deleted file mode 100644 index c16be7a0cc..0000000000 --- a/src/lib/libc/string/strerror_l.c +++ /dev/null | |||
@@ -1,33 +0,0 @@ | |||
1 | /* $OpenBSD: strerror_l.c,v 1.1 2017/09/05 03:16:13 schwarze Exp $ */ | ||
2 | /* | ||
3 | * Copyright (c) 2017 Ingo Schwarze <schwarze@openbsd.org> | ||
4 | * | ||
5 | * Permission to use, copy, modify, and distribute this software for any | ||
6 | * purpose with or without fee is hereby granted, provided that the above | ||
7 | * copyright notice and this permission notice appear in all copies. | ||
8 | * | ||
9 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
10 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
11 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | ||
12 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
13 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
14 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | ||
15 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
16 | */ | ||
17 | |||
18 | #include <limits.h> | ||
19 | #include <string.h> | ||
20 | |||
21 | #include "thread_private.h" | ||
22 | |||
23 | char * | ||
24 | strerror_l(int errnum, locale_t locale) | ||
25 | { | ||
26 | static char sel_buf[NL_TEXTMAX]; | ||
27 | _THREAD_PRIVATE_KEY(strerror_l); | ||
28 | char *p = _THREAD_PRIVATE(strerror_l, sel_buf, NULL); | ||
29 | |||
30 | return p == NULL ? "no buffer available in strerror_l" : | ||
31 | strerror_r(errnum, p, sizeof(sel_buf)) ? | ||
32 | "strerror_r failure" : p; | ||
33 | } | ||
diff --git a/src/lib/libc/string/strerror_r.c b/src/lib/libc/string/strerror_r.c deleted file mode 100644 index b45dee12d8..0000000000 --- a/src/lib/libc/string/strerror_r.c +++ /dev/null | |||
@@ -1,107 +0,0 @@ | |||
1 | /* $OpenBSD: strerror_r.c,v 1.13 2016/10/19 16:26:16 bluhm Exp $ */ | ||
2 | /* Public Domain <marc@snafu.org> */ | ||
3 | |||
4 | #include <errno.h> | ||
5 | #include <limits.h> | ||
6 | #include <signal.h> | ||
7 | #include <string.h> | ||
8 | |||
9 | static size_t | ||
10 | __digits10(unsigned int num) | ||
11 | { | ||
12 | size_t i = 0; | ||
13 | |||
14 | do { | ||
15 | num /= 10; | ||
16 | i++; | ||
17 | } while (num != 0); | ||
18 | |||
19 | return i; | ||
20 | } | ||
21 | |||
22 | static int | ||
23 | __itoa(int num, int sign, char *buffer, size_t start, size_t end) | ||
24 | { | ||
25 | size_t pos; | ||
26 | unsigned int a; | ||
27 | int neg; | ||
28 | |||
29 | if (sign && num < 0) { | ||
30 | a = -num; | ||
31 | neg = 1; | ||
32 | } | ||
33 | else { | ||
34 | a = num; | ||
35 | neg = 0; | ||
36 | } | ||
37 | |||
38 | pos = start + __digits10(a); | ||
39 | if (neg) | ||
40 | pos++; | ||
41 | |||
42 | if (pos < end) | ||
43 | buffer[pos] = '\0'; | ||
44 | else | ||
45 | return ERANGE; | ||
46 | pos--; | ||
47 | do { | ||
48 | buffer[pos] = (a % 10) + '0'; | ||
49 | pos--; | ||
50 | a /= 10; | ||
51 | } while (a != 0); | ||
52 | if (neg) | ||
53 | buffer[pos] = '-'; | ||
54 | return 0; | ||
55 | } | ||
56 | |||
57 | |||
58 | static int | ||
59 | __num2string(int num, int sign, int setid, char *buf, size_t buflen, | ||
60 | const char * const list[], size_t max, const char *def) | ||
61 | { | ||
62 | int ret = 0; | ||
63 | size_t len; | ||
64 | |||
65 | if (0 <= num && num < max) { | ||
66 | len = strlcpy(buf, list[num], buflen); | ||
67 | if (len >= buflen) | ||
68 | ret = ERANGE; | ||
69 | } else { | ||
70 | len = strlcpy(buf, def, buflen); | ||
71 | if (len >= buflen) | ||
72 | ret = ERANGE; | ||
73 | else { | ||
74 | ret = __itoa(num, sign, buf, len, buflen); | ||
75 | if (ret == 0) | ||
76 | ret = EINVAL; | ||
77 | } | ||
78 | } | ||
79 | |||
80 | return ret; | ||
81 | } | ||
82 | |||
83 | #define UPREFIX "Unknown error: " | ||
84 | |||
85 | int | ||
86 | strerror_r(int errnum, char *strerrbuf, size_t buflen) | ||
87 | { | ||
88 | int ret_errno; | ||
89 | |||
90 | ret_errno = __num2string(errnum, 1, 1, strerrbuf, buflen, | ||
91 | sys_errlist, sys_nerr, UPREFIX); | ||
92 | |||
93 | if (ret_errno) | ||
94 | errno = ret_errno; | ||
95 | return (ret_errno); | ||
96 | } | ||
97 | DEF_WEAK(strerror_r); | ||
98 | |||
99 | #define USIGPREFIX "Unknown signal: " | ||
100 | |||
101 | char * | ||
102 | __strsignal(int num, char *buf) | ||
103 | { | ||
104 | __num2string(num, 0, 2, buf, NL_TEXTMAX, sys_siglist, NSIG, | ||
105 | USIGPREFIX); | ||
106 | return buf; | ||
107 | } | ||
diff --git a/src/lib/libc/string/strlcat.c b/src/lib/libc/string/strlcat.c deleted file mode 100644 index aa3db7ab37..0000000000 --- a/src/lib/libc/string/strlcat.c +++ /dev/null | |||
@@ -1,56 +0,0 @@ | |||
1 | /* $OpenBSD: strlcat.c,v 1.19 2019/01/25 00:19:25 millert Exp $ */ | ||
2 | |||
3 | /* | ||
4 | * Copyright (c) 1998, 2015 Todd C. Miller <millert@openbsd.org> | ||
5 | * | ||
6 | * Permission to use, copy, modify, and distribute this software for any | ||
7 | * purpose with or without fee is hereby granted, provided that the above | ||
8 | * copyright notice and this permission notice appear in all copies. | ||
9 | * | ||
10 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
11 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
12 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | ||
13 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
14 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
15 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | ||
16 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
17 | */ | ||
18 | |||
19 | #include <sys/types.h> | ||
20 | #include <string.h> | ||
21 | |||
22 | /* | ||
23 | * Appends src to string dst of size dsize (unlike strncat, dsize is the | ||
24 | * full size of dst, not space left). At most dsize-1 characters | ||
25 | * will be copied. Always NUL terminates (unless dsize <= strlen(dst)). | ||
26 | * Returns strlen(src) + MIN(dsize, strlen(initial dst)). | ||
27 | * If retval >= dsize, truncation occurred. | ||
28 | */ | ||
29 | size_t | ||
30 | strlcat(char *dst, const char *src, size_t dsize) | ||
31 | { | ||
32 | const char *odst = dst; | ||
33 | const char *osrc = src; | ||
34 | size_t n = dsize; | ||
35 | size_t dlen; | ||
36 | |||
37 | /* Find the end of dst and adjust bytes left but don't go past end. */ | ||
38 | while (n-- != 0 && *dst != '\0') | ||
39 | dst++; | ||
40 | dlen = dst - odst; | ||
41 | n = dsize - dlen; | ||
42 | |||
43 | if (n-- == 0) | ||
44 | return(dlen + strlen(src)); | ||
45 | while (*src != '\0') { | ||
46 | if (n != 0) { | ||
47 | *dst++ = *src; | ||
48 | n--; | ||
49 | } | ||
50 | src++; | ||
51 | } | ||
52 | *dst = '\0'; | ||
53 | |||
54 | return(dlen + (src - osrc)); /* count does not include NUL */ | ||
55 | } | ||
56 | DEF_WEAK(strlcat); | ||
diff --git a/src/lib/libc/string/strlcpy.3 b/src/lib/libc/string/strlcpy.3 deleted file mode 100644 index 4607289883..0000000000 --- a/src/lib/libc/string/strlcpy.3 +++ /dev/null | |||
@@ -1,195 +0,0 @@ | |||
1 | .\" $OpenBSD: strlcpy.3,v 1.28 2024/08/03 20:13:23 guenther Exp $ | ||
2 | .\" | ||
3 | .\" Copyright (c) 1998, 2000 Todd C. Miller <millert@openbsd.org> | ||
4 | .\" | ||
5 | .\" Permission to use, copy, modify, and distribute this software for any | ||
6 | .\" purpose with or without fee is hereby granted, provided that the above | ||
7 | .\" copyright notice and this permission notice appear in all copies. | ||
8 | .\" | ||
9 | .\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
10 | .\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
11 | .\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | ||
12 | .\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
13 | .\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
14 | .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | ||
15 | .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
16 | .\" | ||
17 | .Dd $Mdocdate: August 3 2024 $ | ||
18 | .Dt STRLCPY 3 | ||
19 | .Os | ||
20 | .Sh NAME | ||
21 | .Nm strlcpy , | ||
22 | .Nm strlcat | ||
23 | .Nd size-bounded string copying and concatenation | ||
24 | .Sh SYNOPSIS | ||
25 | .In string.h | ||
26 | .Ft size_t | ||
27 | .Fn strlcpy "char * restrict dst" "const char * restrict src" "size_t dstsize" | ||
28 | .Ft size_t | ||
29 | .Fn strlcat "char * restrict dst" "const char * restrict src" "size_t dstsize" | ||
30 | .Sh DESCRIPTION | ||
31 | The | ||
32 | .Fn strlcpy | ||
33 | and | ||
34 | .Fn strlcat | ||
35 | functions copy and concatenate strings with the | ||
36 | same input parameters and output result as | ||
37 | .Xr snprintf 3 . | ||
38 | They are designed to be safer, more consistent, and less error | ||
39 | prone replacements for the easily misused functions | ||
40 | .Xr strncpy 3 | ||
41 | and | ||
42 | .Xr strncat 3 . | ||
43 | .Pp | ||
44 | .Fn strlcpy | ||
45 | and | ||
46 | .Fn strlcat | ||
47 | take the full size of the destination buffer and guarantee | ||
48 | NUL-termination if there is room. | ||
49 | Note that room for the NUL should be included in | ||
50 | .Fa dstsize . | ||
51 | .Pp | ||
52 | .Fn strlcpy | ||
53 | copies up to | ||
54 | .Fa dstsize | ||
55 | \- 1 characters from the string | ||
56 | .Fa src | ||
57 | to | ||
58 | .Fa dst , | ||
59 | NUL-terminating the result if | ||
60 | .Fa dstsize | ||
61 | is not 0. | ||
62 | .Pp | ||
63 | .Fn strlcat | ||
64 | appends string | ||
65 | .Fa src | ||
66 | to the end of | ||
67 | .Fa dst . | ||
68 | It will append at most | ||
69 | .Fa dstsize | ||
70 | \- strlen(dst) \- 1 characters. | ||
71 | It will then NUL-terminate, unless | ||
72 | .Fa dstsize | ||
73 | is 0 or the original | ||
74 | .Fa dst | ||
75 | string was longer than | ||
76 | .Fa dstsize | ||
77 | (in practice this should not happen | ||
78 | as it means that either | ||
79 | .Fa dstsize | ||
80 | is incorrect or that | ||
81 | .Fa dst | ||
82 | is not a proper string). | ||
83 | .Pp | ||
84 | If the | ||
85 | .Fa src | ||
86 | and | ||
87 | .Fa dst | ||
88 | strings overlap, the behavior is undefined. | ||
89 | .Sh RETURN VALUES | ||
90 | Besides quibbles over the return type | ||
91 | .Pf ( Va size_t | ||
92 | versus | ||
93 | .Va int ) | ||
94 | and signal handler safety | ||
95 | .Pf ( Xr snprintf 3 | ||
96 | is not entirely safe on some systems), the | ||
97 | following two are equivalent: | ||
98 | .Bd -literal -offset indent | ||
99 | n = strlcpy(dst, src, len); | ||
100 | n = snprintf(dst, len, "%s", src); | ||
101 | .Ed | ||
102 | .Pp | ||
103 | Like | ||
104 | .Xr snprintf 3 , | ||
105 | the | ||
106 | .Fn strlcpy | ||
107 | and | ||
108 | .Fn strlcat | ||
109 | functions return the total length of the string they tried to create. | ||
110 | For | ||
111 | .Fn strlcpy | ||
112 | that means the length of | ||
113 | .Fa src . | ||
114 | For | ||
115 | .Fn strlcat | ||
116 | that means the initial length of | ||
117 | .Fa dst | ||
118 | plus | ||
119 | the length of | ||
120 | .Fa src . | ||
121 | .Pp | ||
122 | If the return value is | ||
123 | .Cm >= | ||
124 | .Va dstsize , | ||
125 | the output string has been truncated. | ||
126 | It is the caller's responsibility to handle this. | ||
127 | .Sh EXAMPLES | ||
128 | The following code fragment illustrates the simple case: | ||
129 | .Bd -literal -offset indent | ||
130 | char *s, *p, buf[BUFSIZ]; | ||
131 | |||
132 | \&... | ||
133 | |||
134 | (void)strlcpy(buf, s, sizeof(buf)); | ||
135 | (void)strlcat(buf, p, sizeof(buf)); | ||
136 | .Ed | ||
137 | .Pp | ||
138 | To detect truncation, perhaps while building a pathname, something | ||
139 | like the following might be used: | ||
140 | .Bd -literal -offset indent | ||
141 | char *dir, *file, pname[PATH_MAX]; | ||
142 | |||
143 | \&... | ||
144 | |||
145 | if (strlcpy(pname, dir, sizeof(pname)) >= sizeof(pname)) | ||
146 | goto toolong; | ||
147 | if (strlcat(pname, file, sizeof(pname)) >= sizeof(pname)) | ||
148 | goto toolong; | ||
149 | .Ed | ||
150 | .Pp | ||
151 | Since it is known how many characters were copied the first time, things | ||
152 | can be sped up a bit by using a copy instead of an append: | ||
153 | .Bd -literal -offset indent | ||
154 | char *dir, *file, pname[PATH_MAX]; | ||
155 | size_t n; | ||
156 | |||
157 | \&... | ||
158 | |||
159 | n = strlcpy(pname, dir, sizeof(pname)); | ||
160 | if (n >= sizeof(pname)) | ||
161 | goto toolong; | ||
162 | if (strlcpy(pname + n, file, sizeof(pname) - n) >= sizeof(pname) - n) | ||
163 | goto toolong; | ||
164 | .Ed | ||
165 | .Pp | ||
166 | However, one may question the validity of such optimizations, as they | ||
167 | defeat the whole purpose of | ||
168 | .Fn strlcpy | ||
169 | and | ||
170 | .Fn strlcat . | ||
171 | As a matter of fact, the first version of this manual page got it wrong. | ||
172 | .Sh SEE ALSO | ||
173 | .Xr snprintf 3 , | ||
174 | .Xr strncat 3 , | ||
175 | .Xr strncpy 3 , | ||
176 | .Xr wcslcpy 3 | ||
177 | .Sh STANDARDS | ||
178 | The | ||
179 | .Fn strlcat | ||
180 | and | ||
181 | .Fn strlcpy | ||
182 | functions conform to | ||
183 | .St -p1003.1-2024 . | ||
184 | .Sh HISTORY | ||
185 | .Fn strlcpy | ||
186 | and | ||
187 | .Fn strlcat | ||
188 | first appeared in | ||
189 | .Ox 2.4 . | ||
190 | .Sh AUTHORS | ||
191 | .Fn strlcpy | ||
192 | and | ||
193 | .Fn strlcat | ||
194 | were created by | ||
195 | .An Todd C. Miller Aq Mt millert@openbsd.org . | ||
diff --git a/src/lib/libc/string/strlcpy.c b/src/lib/libc/string/strlcpy.c deleted file mode 100644 index 7e3b9aef6f..0000000000 --- a/src/lib/libc/string/strlcpy.c +++ /dev/null | |||
@@ -1,51 +0,0 @@ | |||
1 | /* $OpenBSD: strlcpy.c,v 1.16 2019/01/25 00:19:25 millert Exp $ */ | ||
2 | |||
3 | /* | ||
4 | * Copyright (c) 1998, 2015 Todd C. Miller <millert@openbsd.org> | ||
5 | * | ||
6 | * Permission to use, copy, modify, and distribute this software for any | ||
7 | * purpose with or without fee is hereby granted, provided that the above | ||
8 | * copyright notice and this permission notice appear in all copies. | ||
9 | * | ||
10 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
11 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
12 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | ||
13 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
14 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
15 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | ||
16 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
17 | */ | ||
18 | |||
19 | #include <sys/types.h> | ||
20 | #include <string.h> | ||
21 | |||
22 | /* | ||
23 | * Copy string src to buffer dst of size dsize. At most dsize-1 | ||
24 | * chars will be copied. Always NUL terminates (unless dsize == 0). | ||
25 | * Returns strlen(src); if retval >= dsize, truncation occurred. | ||
26 | */ | ||
27 | size_t | ||
28 | strlcpy(char *dst, const char *src, size_t dsize) | ||
29 | { | ||
30 | const char *osrc = src; | ||
31 | size_t nleft = dsize; | ||
32 | |||
33 | /* Copy as many bytes as will fit. */ | ||
34 | if (nleft != 0) { | ||
35 | while (--nleft != 0) { | ||
36 | if ((*dst++ = *src++) == '\0') | ||
37 | break; | ||
38 | } | ||
39 | } | ||
40 | |||
41 | /* Not enough room in dst, add NUL and traverse rest of src. */ | ||
42 | if (nleft == 0) { | ||
43 | if (dsize != 0) | ||
44 | *dst = '\0'; /* NUL-terminate dst */ | ||
45 | while (*src++) | ||
46 | ; | ||
47 | } | ||
48 | |||
49 | return(src - osrc - 1); /* count does not include NUL */ | ||
50 | } | ||
51 | DEF_WEAK(strlcpy); | ||
diff --git a/src/lib/libc/string/strlen.3 b/src/lib/libc/string/strlen.3 deleted file mode 100644 index 18569d58b9..0000000000 --- a/src/lib/libc/string/strlen.3 +++ /dev/null | |||
@@ -1,103 +0,0 @@ | |||
1 | .\" $OpenBSD: strlen.3,v 1.14 2022/07/31 14:50:32 jsg Exp $ | ||
2 | .\" | ||
3 | .\" Copyright (c) 1990, 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 | .\" Chris Torek and the American National Standards Committee X3, | ||
8 | .\" on Information 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: July 31 2022 $ | ||
35 | .Dt STRLEN 3 | ||
36 | .Os | ||
37 | .Sh NAME | ||
38 | .Nm strlen , | ||
39 | .Nm strnlen | ||
40 | .Nd find length of a string | ||
41 | .Sh SYNOPSIS | ||
42 | .In string.h | ||
43 | .Ft size_t | ||
44 | .Fn strlen "const char *s" | ||
45 | .Ft size_t | ||
46 | .Fn strnlen "const char *s" "size_t maxlen" | ||
47 | .Sh DESCRIPTION | ||
48 | The | ||
49 | .Fn strlen | ||
50 | function computes the length of the string | ||
51 | .Fa s . | ||
52 | .Pp | ||
53 | The | ||
54 | .Fn strnlen | ||
55 | function computes the length of the string | ||
56 | .Fa s , | ||
57 | up to | ||
58 | .Fa maxlen | ||
59 | characters. | ||
60 | The | ||
61 | .Fn strnlen | ||
62 | function will never attempt to address more than | ||
63 | .Fa maxlen | ||
64 | characters, making it suitable for use with character arrays that are | ||
65 | not guaranteed to be NUL-terminated. | ||
66 | .Sh RETURN VALUES | ||
67 | The | ||
68 | .Fn strlen | ||
69 | function returns the number of characters that precede the terminating | ||
70 | .Tn NUL | ||
71 | character. | ||
72 | .Pp | ||
73 | The | ||
74 | .Fn strnlen | ||
75 | function returns the number of characters that precede the terminating | ||
76 | .Tn NUL | ||
77 | or | ||
78 | .Fa maxlen , | ||
79 | whichever is smaller. | ||
80 | .Sh SEE ALSO | ||
81 | .Xr wcslen 3 | ||
82 | .Sh STANDARDS | ||
83 | The | ||
84 | .Fn strlen | ||
85 | function conforms to | ||
86 | .St -ansiC . | ||
87 | .Pp | ||
88 | The | ||
89 | .Fn strlen | ||
90 | and | ||
91 | .Fn strnlen | ||
92 | functions conform to | ||
93 | .St -p1003.1-2008 . | ||
94 | .Sh HISTORY | ||
95 | The | ||
96 | .Fn strlen | ||
97 | function first appeared in | ||
98 | .At v6 . | ||
99 | The | ||
100 | .Fn strnlen | ||
101 | function appeared in glibc 2.0 | ||
102 | and was reimplemented for | ||
103 | .Ox 4.8 . | ||
diff --git a/src/lib/libc/string/strlen.c b/src/lib/libc/string/strlen.c deleted file mode 100644 index a5721d3e7f..0000000000 --- a/src/lib/libc/string/strlen.c +++ /dev/null | |||
@@ -1,44 +0,0 @@ | |||
1 | /* $OpenBSD: strlen.c,v 1.9 2015/08/31 02:53:57 guenther Exp $ */ | ||
2 | |||
3 | /*- | ||
4 | * Copyright (c) 1990, 1993 | ||
5 | * The Regents of the University of California. All rights reserved. | ||
6 | * | ||
7 | * Redistribution and use in source and binary forms, with or without | ||
8 | * modification, are permitted provided that the following conditions | ||
9 | * are met: | ||
10 | * 1. Redistributions of source code must retain the above copyright | ||
11 | * notice, this list of conditions and the following disclaimer. | ||
12 | * 2. Redistributions in binary form must reproduce the above copyright | ||
13 | * notice, this list of conditions and the following disclaimer in the | ||
14 | * documentation and/or other materials provided with the distribution. | ||
15 | * 3. Neither the name of the University nor the names of its contributors | ||
16 | * may be used to endorse or promote products derived from this software | ||
17 | * without specific prior written permission. | ||
18 | * | ||
19 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | ||
20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
21 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
22 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | ||
23 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
24 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
25 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
26 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
27 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
28 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
29 | * SUCH DAMAGE. | ||
30 | */ | ||
31 | |||
32 | #include <string.h> | ||
33 | |||
34 | size_t | ||
35 | strlen(const char *str) | ||
36 | { | ||
37 | const char *s; | ||
38 | |||
39 | for (s = str; *s; ++s) | ||
40 | ; | ||
41 | return (s - str); | ||
42 | } | ||
43 | |||
44 | DEF_STRONG(strlen); | ||
diff --git a/src/lib/libc/string/strmode.3 b/src/lib/libc/string/strmode.3 deleted file mode 100644 index 8135d30ba1..0000000000 --- a/src/lib/libc/string/strmode.3 +++ /dev/null | |||
@@ -1,153 +0,0 @@ | |||
1 | .\" $OpenBSD: strmode.3,v 1.17 2017/07/05 11:44:35 tb Exp $ | ||
2 | .\" | ||
3 | .\" Copyright (c) 1990, 1991, 1993 | ||
4 | .\" The Regents of the University of California. All rights reserved. | ||
5 | .\" | ||
6 | .\" Redistribution and use in source and binary forms, with or without | ||
7 | .\" modification, are permitted provided that the following conditions | ||
8 | .\" are met: | ||
9 | .\" 1. Redistributions of source code must retain the above copyright | ||
10 | .\" notice, this list of conditions and the following disclaimer. | ||
11 | .\" 2. Redistributions in binary form must reproduce the above copyright | ||
12 | .\" notice, this list of conditions and the following disclaimer in the | ||
13 | .\" documentation and/or other materials provided with the distribution. | ||
14 | .\" 3. Neither the name of the University nor the names of its contributors | ||
15 | .\" may be used to endorse or promote products derived from this software | ||
16 | .\" without specific prior written permission. | ||
17 | .\" | ||
18 | .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | ||
19 | .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
20 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
21 | .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | ||
22 | .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
23 | .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
24 | .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
25 | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
26 | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
27 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
28 | .\" SUCH DAMAGE. | ||
29 | .\" | ||
30 | .\" @(#)strmode.3 8.3 (Berkeley) 7/28/94 | ||
31 | .\" | ||
32 | .Dd $Mdocdate: July 5 2017 $ | ||
33 | .Dt STRMODE 3 | ||
34 | .Os | ||
35 | .Sh NAME | ||
36 | .Nm strmode | ||
37 | .Nd convert inode status information into a symbolic string | ||
38 | .Sh SYNOPSIS | ||
39 | .In string.h | ||
40 | .Ft void | ||
41 | .Fn strmode "mode_t mode" "char *bp" | ||
42 | .Sh DESCRIPTION | ||
43 | The | ||
44 | .Fn strmode | ||
45 | function converts a file | ||
46 | .Fa mode | ||
47 | (the type and permission information associated with an inode, see | ||
48 | .Xr stat 2 ) | ||
49 | into a symbolic string which is stored in the location referenced by | ||
50 | .Fa bp . | ||
51 | This stored string is eleven characters in length plus a trailing NUL byte. | ||
52 | .Pp | ||
53 | The first character is the inode type, and will be one of the following: | ||
54 | .Pp | ||
55 | .Bl -tag -width flag -offset indent -compact | ||
56 | .It \- | ||
57 | regular file | ||
58 | .It b | ||
59 | block special | ||
60 | .It c | ||
61 | character special | ||
62 | .It d | ||
63 | directory | ||
64 | .It l | ||
65 | symbolic link | ||
66 | .It p | ||
67 | FIFO | ||
68 | .It s | ||
69 | socket | ||
70 | .It \&? | ||
71 | unknown inode type | ||
72 | .El | ||
73 | .Pp | ||
74 | The next nine characters encode three sets of permissions, in three | ||
75 | characters each. | ||
76 | The first three characters are the permissions for the owner of the | ||
77 | file, the second three for the group the file belongs to, and the | ||
78 | third for the | ||
79 | .Dq other , | ||
80 | or default, set of users. | ||
81 | .Pp | ||
82 | Permission checking is done as specifically as possible. | ||
83 | If read permission is denied to the owner of a file in the first set | ||
84 | of permissions, the owner of the file will not be able to read the file. | ||
85 | This is true even if the owner is in the file's group and the group | ||
86 | permissions allow reading or the | ||
87 | .Dq other | ||
88 | permissions allow reading. | ||
89 | .Pp | ||
90 | If the first character of the three character set is an | ||
91 | .Sq r , | ||
92 | the file is readable for that set of users; if a dash | ||
93 | .Pq Ql - , | ||
94 | it is not readable. | ||
95 | .Pp | ||
96 | If the second character of the three character set is a | ||
97 | .Sq w , | ||
98 | the file is writable for that set of users; if a dash | ||
99 | .Pq Ql - , | ||
100 | it is not writable. | ||
101 | .Pp | ||
102 | The third character is the first of the following characters that apply: | ||
103 | .Bl -tag -width xxxx | ||
104 | .It S | ||
105 | If the character is part of the owner permissions and the file is not | ||
106 | executable or the directory is not searchable by the owner, and the | ||
107 | set-user-ID bit is set. | ||
108 | .It S | ||
109 | If the character is part of the group permissions and the file is not | ||
110 | executable or the directory is not searchable by the group, and the | ||
111 | set-group-ID bit is set. | ||
112 | .It T | ||
113 | If the character is part of the other permissions and the file is not | ||
114 | executable or the directory is not searchable by others, and the | ||
115 | .Dq sticky | ||
116 | .Pq Dv S_ISVTX | ||
117 | bit is set. | ||
118 | .It s | ||
119 | If the character is part of the owner permissions and the file is | ||
120 | executable or the directory searchable by the owner, and the set-user-ID | ||
121 | bit is set. | ||
122 | .It s | ||
123 | If the character is part of the group permissions and the file is | ||
124 | executable or the directory searchable by the group, and the set-group-ID | ||
125 | bit is set. | ||
126 | .It t | ||
127 | If the character is part of the other permissions and the file is | ||
128 | executable or the directory searchable by others, and the | ||
129 | .Dq sticky | ||
130 | .Pq Dv S_ISVTX | ||
131 | bit is set. | ||
132 | .It x | ||
133 | The file is executable or the directory is searchable. | ||
134 | .It \- | ||
135 | None of the above apply. | ||
136 | .El | ||
137 | .Pp | ||
138 | The last character is a plus sign | ||
139 | .Pq Ql + | ||
140 | if there are any alternate | ||
141 | or additional access control methods associated with the inode, otherwise | ||
142 | it will be a space. | ||
143 | .Sh SEE ALSO | ||
144 | .Xr chmod 1 , | ||
145 | .Xr find 1 , | ||
146 | .Xr stat 2 , | ||
147 | .Xr getmode 3 , | ||
148 | .Xr setmode 3 | ||
149 | .Sh HISTORY | ||
150 | The | ||
151 | .Fn strmode | ||
152 | function first appeared in | ||
153 | .Bx 4.3 Reno . | ||
diff --git a/src/lib/libc/string/strmode.c b/src/lib/libc/string/strmode.c deleted file mode 100644 index c57fe74b23..0000000000 --- a/src/lib/libc/string/strmode.c +++ /dev/null | |||
@@ -1,139 +0,0 @@ | |||
1 | /* $OpenBSD: strmode.c,v 1.9 2024/06/23 07:08:26 otto Exp $ */ | ||
2 | /*- | ||
3 | * Copyright (c) 1990 The Regents of the University of California. | ||
4 | * All rights reserved. | ||
5 | * | ||
6 | * Redistribution and use in source and binary forms, with or without | ||
7 | * modification, are permitted provided that the following conditions | ||
8 | * are met: | ||
9 | * 1. Redistributions of source code must retain the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer. | ||
11 | * 2. Redistributions in binary form must reproduce the above copyright | ||
12 | * notice, this list of conditions and the following disclaimer in the | ||
13 | * documentation and/or other materials provided with the distribution. | ||
14 | * 3. Neither the name of the University nor the names of its contributors | ||
15 | * may be used to endorse or promote products derived from this software | ||
16 | * without specific prior written permission. | ||
17 | * | ||
18 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | ||
19 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
20 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
21 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | ||
22 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
23 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
24 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
25 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
26 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
27 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
28 | * SUCH DAMAGE. | ||
29 | */ | ||
30 | |||
31 | #include <sys/types.h> | ||
32 | #include <sys/stat.h> | ||
33 | #include <string.h> | ||
34 | |||
35 | void | ||
36 | strmode(mode_t mode, char *p) | ||
37 | { | ||
38 | /* print type */ | ||
39 | switch (mode & S_IFMT) { | ||
40 | case S_IFDIR: /* directory */ | ||
41 | *p++ = 'd'; | ||
42 | break; | ||
43 | case S_IFCHR: /* character special */ | ||
44 | *p++ = 'c'; | ||
45 | break; | ||
46 | case S_IFBLK: /* block special */ | ||
47 | *p++ = 'b'; | ||
48 | break; | ||
49 | case S_IFREG: /* regular */ | ||
50 | *p++ = '-'; | ||
51 | break; | ||
52 | case S_IFLNK: /* symbolic link */ | ||
53 | *p++ = 'l'; | ||
54 | break; | ||
55 | case S_IFSOCK: /* socket */ | ||
56 | *p++ = 's'; | ||
57 | break; | ||
58 | #ifdef S_IFIFO | ||
59 | case S_IFIFO: /* fifo */ | ||
60 | *p++ = 'p'; | ||
61 | break; | ||
62 | #endif | ||
63 | default: /* unknown */ | ||
64 | *p++ = '?'; | ||
65 | break; | ||
66 | } | ||
67 | /* usr */ | ||
68 | if (mode & S_IRUSR) | ||
69 | *p++ = 'r'; | ||
70 | else | ||
71 | *p++ = '-'; | ||
72 | if (mode & S_IWUSR) | ||
73 | *p++ = 'w'; | ||
74 | else | ||
75 | *p++ = '-'; | ||
76 | switch (mode & (S_IXUSR | S_ISUID)) { | ||
77 | case 0: | ||
78 | *p++ = '-'; | ||
79 | break; | ||
80 | case S_IXUSR: | ||
81 | *p++ = 'x'; | ||
82 | break; | ||
83 | case S_ISUID: | ||
84 | *p++ = 'S'; | ||
85 | break; | ||
86 | case S_IXUSR | S_ISUID: | ||
87 | *p++ = 's'; | ||
88 | break; | ||
89 | } | ||
90 | /* group */ | ||
91 | if (mode & S_IRGRP) | ||
92 | *p++ = 'r'; | ||
93 | else | ||
94 | *p++ = '-'; | ||
95 | if (mode & S_IWGRP) | ||
96 | *p++ = 'w'; | ||
97 | else | ||
98 | *p++ = '-'; | ||
99 | switch (mode & (S_IXGRP | S_ISGID)) { | ||
100 | case 0: | ||
101 | *p++ = '-'; | ||
102 | break; | ||
103 | case S_IXGRP: | ||
104 | *p++ = 'x'; | ||
105 | break; | ||
106 | case S_ISGID: | ||
107 | *p++ = 'S'; | ||
108 | break; | ||
109 | case S_IXGRP | S_ISGID: | ||
110 | *p++ = 's'; | ||
111 | break; | ||
112 | } | ||
113 | /* other */ | ||
114 | if (mode & S_IROTH) | ||
115 | *p++ = 'r'; | ||
116 | else | ||
117 | *p++ = '-'; | ||
118 | if (mode & S_IWOTH) | ||
119 | *p++ = 'w'; | ||
120 | else | ||
121 | *p++ = '-'; | ||
122 | switch (mode & (S_IXOTH | S_ISVTX)) { | ||
123 | case 0: | ||
124 | *p++ = '-'; | ||
125 | break; | ||
126 | case S_IXOTH: | ||
127 | *p++ = 'x'; | ||
128 | break; | ||
129 | case S_ISVTX: | ||
130 | *p++ = 'T'; | ||
131 | break; | ||
132 | case S_IXOTH | S_ISVTX: | ||
133 | *p++ = 't'; | ||
134 | break; | ||
135 | } | ||
136 | *p++ = ' '; /* will be a '+' if ACL's implemented */ | ||
137 | *p = '\0'; | ||
138 | } | ||
139 | DEF_WEAK(strmode); | ||
diff --git a/src/lib/libc/string/strncat.3 b/src/lib/libc/string/strncat.3 deleted file mode 100644 index d314a9999a..0000000000 --- a/src/lib/libc/string/strncat.3 +++ /dev/null | |||
@@ -1,132 +0,0 @@ | |||
1 | .\" $OpenBSD: strncat.3,v 1.4 2014/04/19 16:50:46 jmc Exp $ | ||
2 | .\" | ||
3 | .\" Copyright (c) 1990, 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 | .\" Chris Torek and the American National Standards Committee X3, | ||
8 | .\" on Information 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: April 19 2014 $ | ||
35 | .Dt STRNCAT 3 | ||
36 | .Os | ||
37 | .Sh NAME | ||
38 | .Nm strncat | ||
39 | .Nd concatenate a string with part of another | ||
40 | .Sh SYNOPSIS | ||
41 | .In string.h | ||
42 | .Ft char * | ||
43 | .Fn strncat "char *dst" "const char *append" "size_t count" | ||
44 | .Sh DESCRIPTION | ||
45 | The | ||
46 | .Fn strncat | ||
47 | function appends not more than | ||
48 | .Fa count | ||
49 | characters of the string | ||
50 | .Fa append | ||
51 | to the end of the string found in the buffer | ||
52 | .Fa dst . | ||
53 | Space for the terminating | ||
54 | .Ql \e0 | ||
55 | should not be included in | ||
56 | .Fa count . | ||
57 | .Pp | ||
58 | Bounds checking must be performed manually with great care. | ||
59 | If the buffer | ||
60 | .Fa dst | ||
61 | is not large enough to hold the result, | ||
62 | subsequent memory will be damaged. | ||
63 | .Sh RETURN VALUES | ||
64 | The | ||
65 | .Fn strncat | ||
66 | function returns the pointer | ||
67 | .Fa dst . | ||
68 | .Sh EXAMPLES | ||
69 | The following example shows how to use | ||
70 | .Fn strncat | ||
71 | in conjunction with | ||
72 | .Xr strncpy 3 : | ||
73 | .Bd -literal -offset indent | ||
74 | char buf[BUFSIZ]; | ||
75 | char *base, *suffix; | ||
76 | |||
77 | (void)strncpy(buf, base, sizeof(buf) - 1); | ||
78 | buf[sizeof(buf) - 1] = '\e0'; | ||
79 | (void)strncat(buf, suffix, sizeof(buf) - 1 - strlen(buf)); | ||
80 | .Ed | ||
81 | .Pp | ||
82 | The above will copy as many characters from | ||
83 | .Va base | ||
84 | to | ||
85 | .Va buf | ||
86 | as will fit. | ||
87 | It then appends as many characters from | ||
88 | .Va suffix | ||
89 | as will fit. | ||
90 | If either | ||
91 | .Va base | ||
92 | or | ||
93 | .Va suffix | ||
94 | are too large, truncation will occur without detection. | ||
95 | .Pp | ||
96 | The above example shows dangerous coding patterns, including an | ||
97 | inability to detect truncation. | ||
98 | .Fn strncat | ||
99 | and | ||
100 | .Fn strncpy | ||
101 | are dangerously easy to misuse. | ||
102 | The | ||
103 | .Xr strlcpy 3 | ||
104 | and | ||
105 | .Xr strlcat 3 | ||
106 | functions are safer for this kind of operation: | ||
107 | .Bd -literal -offset indent | ||
108 | if (strlcpy(buf, base, sizeof(buf)) >= sizeof(buf) || | ||
109 | strlcat(buf, suffix, sizeof(buf)) >= sizeof(buf)) | ||
110 | goto toolong; | ||
111 | |||
112 | .Ed | ||
113 | or for greatest portability, | ||
114 | .Bd -literal -offset indent | ||
115 | if (snprintf(buf, sizeof(buf), "%s%s", | ||
116 | base, suffix) >= sizeof(buf)) | ||
117 | goto toolong; | ||
118 | .Ed | ||
119 | .Sh SEE ALSO | ||
120 | .Xr strlcpy 3 , | ||
121 | .Xr wcscat 3 , | ||
122 | .Xr wcslcpy 3 | ||
123 | .Sh STANDARDS | ||
124 | The | ||
125 | .Fn strncat | ||
126 | function conforms to | ||
127 | .St -ansiC . | ||
128 | .Sh HISTORY | ||
129 | The | ||
130 | .Fn strncat | ||
131 | function first appeared in | ||
132 | .At v7 . | ||
diff --git a/src/lib/libc/string/strncat.c b/src/lib/libc/string/strncat.c deleted file mode 100644 index b3388accf3..0000000000 --- a/src/lib/libc/string/strncat.c +++ /dev/null | |||
@@ -1,58 +0,0 @@ | |||
1 | /* $OpenBSD: strncat.c,v 1.6 2015/08/31 02:53:57 guenther Exp $ */ | ||
2 | /*- | ||
3 | * Copyright (c) 1990 The Regents of the University of California. | ||
4 | * All rights reserved. | ||
5 | * | ||
6 | * This code is derived from software contributed to Berkeley by | ||
7 | * Chris Torek. | ||
8 | * | ||
9 | * Redistribution and use in source and binary forms, with or without | ||
10 | * modification, are permitted provided that the following conditions | ||
11 | * are met: | ||
12 | * 1. Redistributions of source code must retain the above copyright | ||
13 | * notice, this list of conditions and the following disclaimer. | ||
14 | * 2. Redistributions in binary form must reproduce the above copyright | ||
15 | * notice, this list of conditions and the following disclaimer in the | ||
16 | * documentation and/or other materials provided with the distribution. | ||
17 | * 3. Neither the name of the University nor the names of its contributors | ||
18 | * may be used to endorse or promote products derived from this software | ||
19 | * without specific prior written permission. | ||
20 | * | ||
21 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | ||
22 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | ||
25 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
26 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
27 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
28 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
29 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
30 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
31 | * SUCH DAMAGE. | ||
32 | */ | ||
33 | |||
34 | #include <string.h> | ||
35 | |||
36 | /* | ||
37 | * Concatenate src on the end of dst. At most strlen(dst)+n+1 bytes | ||
38 | * are written at dst (at most n+1 bytes being appended). Return dst. | ||
39 | */ | ||
40 | char * | ||
41 | strncat(char *dst, const char *src, size_t n) | ||
42 | { | ||
43 | if (n != 0) { | ||
44 | char *d = dst; | ||
45 | const char *s = src; | ||
46 | |||
47 | while (*d != 0) | ||
48 | d++; | ||
49 | do { | ||
50 | if ((*d = *s++) == 0) | ||
51 | break; | ||
52 | d++; | ||
53 | } while (--n != 0); | ||
54 | *d = 0; | ||
55 | } | ||
56 | return (dst); | ||
57 | } | ||
58 | DEF_STRONG(strncat); | ||
diff --git a/src/lib/libc/string/strncmp.c b/src/lib/libc/string/strncmp.c deleted file mode 100644 index 535d2a60fd..0000000000 --- a/src/lib/libc/string/strncmp.c +++ /dev/null | |||
@@ -1,48 +0,0 @@ | |||
1 | /* $OpenBSD: strncmp.c,v 1.9 2015/08/31 02:53:57 guenther Exp $ */ | ||
2 | |||
3 | /* | ||
4 | * Copyright (c) 1989 The Regents of the University of California. | ||
5 | * All rights reserved. | ||
6 | * | ||
7 | * Redistribution and use in source and binary forms, with or without | ||
8 | * modification, are permitted provided that the following conditions | ||
9 | * are met: | ||
10 | * 1. Redistributions of source code must retain the above copyright | ||
11 | * notice, this list of conditions and the following disclaimer. | ||
12 | * 2. Redistributions in binary form must reproduce the above copyright | ||
13 | * notice, this list of conditions and the following disclaimer in the | ||
14 | * documentation and/or other materials provided with the distribution. | ||
15 | * 3. Neither the name of the University nor the names of its contributors | ||
16 | * may be used to endorse or promote products derived from this software | ||
17 | * without specific prior written permission. | ||
18 | * | ||
19 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | ||
20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
21 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
22 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | ||
23 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
24 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
25 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
26 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
27 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
28 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
29 | * SUCH DAMAGE. | ||
30 | */ | ||
31 | |||
32 | #include <string.h> | ||
33 | |||
34 | int | ||
35 | strncmp(const char *s1, const char *s2, size_t n) | ||
36 | { | ||
37 | |||
38 | if (n == 0) | ||
39 | return (0); | ||
40 | do { | ||
41 | if (*s1 != *s2++) | ||
42 | return (*(unsigned char *)s1 - *(unsigned char *)--s2); | ||
43 | if (*s1++ == 0) | ||
44 | break; | ||
45 | } while (--n != 0); | ||
46 | return (0); | ||
47 | } | ||
48 | DEF_STRONG(strncmp); | ||
diff --git a/src/lib/libc/string/strncpy.3 b/src/lib/libc/string/strncpy.3 deleted file mode 100644 index 3a68a0bd5b..0000000000 --- a/src/lib/libc/string/strncpy.3 +++ /dev/null | |||
@@ -1,138 +0,0 @@ | |||
1 | .\" $OpenBSD: strncpy.3,v 1.2 2014/04/19 11:30:40 deraadt Exp $ | ||
2 | .\" | ||
3 | .\" Copyright (c) 1990, 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 | .\" Chris Torek and the American National Standards Committee X3, | ||
8 | .\" on Information 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: April 19 2014 $ | ||
35 | .Dt STRNCPY 3 | ||
36 | .Os | ||
37 | .Sh NAME | ||
38 | .Nm strncpy | ||
39 | .Nd copy part of a string to another | ||
40 | .Sh SYNOPSIS | ||
41 | .In string.h | ||
42 | .Ft char * | ||
43 | .Fn strncpy "char *dst" "const char *src" "size_t len" | ||
44 | .Sh DESCRIPTION | ||
45 | The | ||
46 | .Fn strncpy | ||
47 | function copies not more than | ||
48 | .Fa len | ||
49 | characters from the string | ||
50 | .Fa src | ||
51 | to the buffer | ||
52 | .Fa dst . | ||
53 | If | ||
54 | .Fa src | ||
55 | is less than | ||
56 | .Fa len | ||
57 | characters long, | ||
58 | it fills the remaining buffer with | ||
59 | .Ql \e0 | ||
60 | characters. | ||
61 | If the length of | ||
62 | .Fa src | ||
63 | is greater than or equal to | ||
64 | .Fa len , | ||
65 | .Fa dst | ||
66 | will | ||
67 | .Em not | ||
68 | be NUL-terminated. | ||
69 | .Pp | ||
70 | .Fn strncpy | ||
71 | .Em only | ||
72 | NUL terminates the destination string when the length of the source | ||
73 | string is less than the length parameter. | ||
74 | .Pp | ||
75 | If the | ||
76 | .Fa src | ||
77 | and | ||
78 | .Fa dst | ||
79 | strings overlap, the behavior is undefined. | ||
80 | .Sh RETURN VALUES | ||
81 | The | ||
82 | .Fn strncpy | ||
83 | function returns | ||
84 | .Fa dst . | ||
85 | .Sh EXAMPLES | ||
86 | The following sets | ||
87 | .Va chararray | ||
88 | to | ||
89 | .Dq abc\e0\e0\e0 : | ||
90 | .Bd -literal -offset indent | ||
91 | (void)strncpy(chararray, "abc", 6); | ||
92 | .Ed | ||
93 | .Pp | ||
94 | The following sets | ||
95 | .Va chararray | ||
96 | to | ||
97 | .Dq abcdef , | ||
98 | without a NUL-terminator: | ||
99 | .Bd -literal -offset indent | ||
100 | (void)strncpy(chararray, "abcdefgh", 6); | ||
101 | .Ed | ||
102 | .Pp | ||
103 | The following sequence copies as many characters from | ||
104 | .Va input | ||
105 | to | ||
106 | .Va buf | ||
107 | as will fit, and then NUL terminates the result by hand: | ||
108 | .Bd -literal -offset indent | ||
109 | char buf[BUFSIZ]; | ||
110 | |||
111 | (void)strncpy(buf, input, sizeof(buf) - 1); | ||
112 | buf[sizeof(buf) - 1] = '\e0'; | ||
113 | .Ed | ||
114 | .Pp | ||
115 | By now it is clear that | ||
116 | .Nm strncpy | ||
117 | is dangerously easy to misuse. | ||
118 | The | ||
119 | .Xr strlcpy 3 | ||
120 | function is safer for this kind of operation: | ||
121 | .Bd -literal -offset indent | ||
122 | if (strlcpy(buf, input, sizeof(buf)) >= sizeof(buf)) | ||
123 | goto toolong; | ||
124 | .Ed | ||
125 | .Sh SEE ALSO | ||
126 | .Xr strlcpy 3 , | ||
127 | .Xr wcscpy 3 , | ||
128 | .Xr wcslcpy 3 | ||
129 | .Sh STANDARDS | ||
130 | The | ||
131 | .Fn strncpy | ||
132 | function conforms to | ||
133 | .St -ansiC . | ||
134 | .Sh HISTORY | ||
135 | The | ||
136 | .Fn strncpy | ||
137 | function first appeared in | ||
138 | .At v7 . | ||
diff --git a/src/lib/libc/string/strncpy.c b/src/lib/libc/string/strncpy.c deleted file mode 100644 index d6d8647fc7..0000000000 --- a/src/lib/libc/string/strncpy.c +++ /dev/null | |||
@@ -1,59 +0,0 @@ | |||
1 | /* $OpenBSD: strncpy.c,v 1.8 2015/08/31 02:53:57 guenther Exp $ */ | ||
2 | |||
3 | /*- | ||
4 | * Copyright (c) 1990 The Regents of the University of California. | ||
5 | * All rights reserved. | ||
6 | * | ||
7 | * This code is derived from software contributed to Berkeley by | ||
8 | * Chris Torek. | ||
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 | |||
35 | #include <string.h> | ||
36 | |||
37 | /* | ||
38 | * Copy src to dst, truncating or null-padding to always copy n bytes. | ||
39 | * Return dst. | ||
40 | */ | ||
41 | char * | ||
42 | strncpy(char *dst, const char *src, size_t n) | ||
43 | { | ||
44 | if (n != 0) { | ||
45 | char *d = dst; | ||
46 | const char *s = src; | ||
47 | |||
48 | do { | ||
49 | if ((*d++ = *s++) == 0) { | ||
50 | /* NUL pad the remaining n-1 bytes */ | ||
51 | while (--n != 0) | ||
52 | *d++ = 0; | ||
53 | break; | ||
54 | } | ||
55 | } while (--n != 0); | ||
56 | } | ||
57 | return (dst); | ||
58 | } | ||
59 | DEF_STRONG(strncpy); | ||
diff --git a/src/lib/libc/string/strndup.c b/src/lib/libc/string/strndup.c deleted file mode 100644 index 499f9a028a..0000000000 --- a/src/lib/libc/string/strndup.c +++ /dev/null | |||
@@ -1,40 +0,0 @@ | |||
1 | /* $OpenBSD: strndup.c,v 1.3 2019/01/25 00:19:25 millert Exp $ */ | ||
2 | |||
3 | /* | ||
4 | * Copyright (c) 2010 Todd C. Miller <millert@openbsd.org> | ||
5 | * | ||
6 | * Permission to use, copy, modify, and distribute this software for any | ||
7 | * purpose with or without fee is hereby granted, provided that the above | ||
8 | * copyright notice and this permission notice appear in all copies. | ||
9 | * | ||
10 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
11 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
12 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | ||
13 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
14 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
15 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | ||
16 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
17 | */ | ||
18 | |||
19 | #include <sys/types.h> | ||
20 | |||
21 | #include <stddef.h> | ||
22 | #include <stdlib.h> | ||
23 | #include <string.h> | ||
24 | |||
25 | char * | ||
26 | strndup(const char *str, size_t maxlen) | ||
27 | { | ||
28 | char *copy; | ||
29 | size_t len; | ||
30 | |||
31 | len = strnlen(str, maxlen); | ||
32 | copy = malloc(len + 1); | ||
33 | if (copy != NULL) { | ||
34 | (void)memcpy(copy, str, len); | ||
35 | copy[len] = '\0'; | ||
36 | } | ||
37 | |||
38 | return copy; | ||
39 | } | ||
40 | DEF_WEAK(strndup); | ||
diff --git a/src/lib/libc/string/strnlen.c b/src/lib/libc/string/strnlen.c deleted file mode 100644 index d50a927f28..0000000000 --- a/src/lib/libc/string/strnlen.c +++ /dev/null | |||
@@ -1,33 +0,0 @@ | |||
1 | /* $OpenBSD: strnlen.c,v 1.9 2019/01/25 00:19:25 millert Exp $ */ | ||
2 | |||
3 | /* | ||
4 | * Copyright (c) 2010 Todd C. Miller <millert@openbsd.org> | ||
5 | * | ||
6 | * Permission to use, copy, modify, and distribute this software for any | ||
7 | * purpose with or without fee is hereby granted, provided that the above | ||
8 | * copyright notice and this permission notice appear in all copies. | ||
9 | * | ||
10 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
11 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
12 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | ||
13 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
14 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
15 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | ||
16 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
17 | */ | ||
18 | |||
19 | #include <sys/types.h> | ||
20 | |||
21 | #include <string.h> | ||
22 | |||
23 | size_t | ||
24 | strnlen(const char *str, size_t maxlen) | ||
25 | { | ||
26 | const char *cp; | ||
27 | |||
28 | for (cp = str; maxlen != 0 && *cp != '\0'; cp++, maxlen--) | ||
29 | ; | ||
30 | |||
31 | return (size_t)(cp - str); | ||
32 | } | ||
33 | DEF_WEAK(strnlen); | ||
diff --git a/src/lib/libc/string/strpbrk.3 b/src/lib/libc/string/strpbrk.3 deleted file mode 100644 index 51d2edf5b8..0000000000 --- a/src/lib/libc/string/strpbrk.3 +++ /dev/null | |||
@@ -1,80 +0,0 @@ | |||
1 | .\" $OpenBSD: strpbrk.3,v 1.11 2024/12/11 23:28:20 jsg Exp $ | ||
2 | .\" | ||
3 | .\" Copyright (c) 1990, 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 | .\" Chris Torek and the American National Standards Committee X3, | ||
8 | .\" on Information 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 STRPBRK 3 | ||
36 | .Os | ||
37 | .Sh NAME | ||
38 | .Nm strpbrk | ||
39 | .Nd locate multiple characters in string | ||
40 | .Sh SYNOPSIS | ||
41 | .In string.h | ||
42 | .Ft char * | ||
43 | .Fn strpbrk "const char *s" "const char *charset" | ||
44 | .Sh DESCRIPTION | ||
45 | The | ||
46 | .Fn strpbrk | ||
47 | function locates in the NUL-terminated string | ||
48 | .Fa s | ||
49 | the first occurrence of any character in the string | ||
50 | .Fa charset | ||
51 | and returns a pointer to this character. | ||
52 | If no characters from | ||
53 | .Fa charset | ||
54 | occur anywhere in | ||
55 | .Fa s , | ||
56 | .Fn strpbrk | ||
57 | returns | ||
58 | .Dv NULL . | ||
59 | .Sh SEE ALSO | ||
60 | .Xr memchr 3 , | ||
61 | .Xr strchr 3 , | ||
62 | .Xr strcspn 3 , | ||
63 | .Xr strrchr 3 , | ||
64 | .Xr strsep 3 , | ||
65 | .Xr strspn 3 , | ||
66 | .Xr strstr 3 , | ||
67 | .Xr strtok 3 , | ||
68 | .Xr wcspbrk 3 | ||
69 | .Sh STANDARDS | ||
70 | The | ||
71 | .Fn strpbrk | ||
72 | function conforms to | ||
73 | .St -ansiC . | ||
74 | .Sh HISTORY | ||
75 | The | ||
76 | .Fn strpbrk | ||
77 | function first appeared in | ||
78 | .At III | ||
79 | and was reimplemented for | ||
80 | .Bx 4.3 . | ||
diff --git a/src/lib/libc/string/strpbrk.c b/src/lib/libc/string/strpbrk.c deleted file mode 100644 index 336c22dedd..0000000000 --- a/src/lib/libc/string/strpbrk.c +++ /dev/null | |||
@@ -1,49 +0,0 @@ | |||
1 | /* $OpenBSD: strpbrk.c,v 1.6 2015/08/31 02:53:57 guenther Exp $ */ | ||
2 | /* | ||
3 | * Copyright (c) 1985 Regents of the University of California. | ||
4 | * All rights reserved. | ||
5 | * | ||
6 | * Redistribution and use in source and binary forms, with or without | ||
7 | * modification, are permitted provided that the following conditions | ||
8 | * are met: | ||
9 | * 1. Redistributions of source code must retain the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer. | ||
11 | * 2. Redistributions in binary form must reproduce the above copyright | ||
12 | * notice, this list of conditions and the following disclaimer in the | ||
13 | * documentation and/or other materials provided with the distribution. | ||
14 | * 3. Neither the name of the University nor the names of its contributors | ||
15 | * may be used to endorse or promote products derived from this software | ||
16 | * without specific prior written permission. | ||
17 | * | ||
18 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | ||
19 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
20 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
21 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | ||
22 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
23 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
24 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
25 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
26 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
27 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
28 | * SUCH DAMAGE. | ||
29 | */ | ||
30 | |||
31 | #include <string.h> | ||
32 | |||
33 | /* | ||
34 | * Find the first occurrence in s1 of a character in s2 (excluding NUL). | ||
35 | */ | ||
36 | char * | ||
37 | strpbrk(const char *s1, const char *s2) | ||
38 | { | ||
39 | const char *scanp; | ||
40 | int c, sc; | ||
41 | |||
42 | while ((c = *s1++) != 0) { | ||
43 | for (scanp = s2; (sc = *scanp++) != 0;) | ||
44 | if (sc == c) | ||
45 | return ((char *)(s1 - 1)); | ||
46 | } | ||
47 | return (NULL); | ||
48 | } | ||
49 | DEF_STRONG(strpbrk); | ||
diff --git a/src/lib/libc/string/strrchr.3 b/src/lib/libc/string/strrchr.3 deleted file mode 100644 index 231260f7f3..0000000000 --- a/src/lib/libc/string/strrchr.3 +++ /dev/null | |||
@@ -1,118 +0,0 @@ | |||
1 | .\" $OpenBSD: strrchr.3,v 1.13 2024/12/11 23:28:20 jsg Exp $ | ||
2 | .\" | ||
3 | .\" Copyright (c) 1990, 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 | .\" Chris Torek and the American National Standards Committee X3, | ||
8 | .\" on Information 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 STRRCHR 3 | ||
36 | .Os | ||
37 | .Sh NAME | ||
38 | .Nm strrchr , | ||
39 | .Nm rindex | ||
40 | .Nd locate last occurrence of a character in a string | ||
41 | .Sh SYNOPSIS | ||
42 | .In string.h | ||
43 | .Ft char * | ||
44 | .Fn strrchr "const char *s" "int c" | ||
45 | .In strings.h | ||
46 | .Ft char * | ||
47 | .Fn rindex "const char *s" "int c" | ||
48 | .Sh DESCRIPTION | ||
49 | The | ||
50 | .Fn strrchr | ||
51 | function locates the last occurrence of the character | ||
52 | .Fa c | ||
53 | .Pq converted to a char | ||
54 | in the string | ||
55 | .Fa s . | ||
56 | The terminating | ||
57 | .Tn NUL | ||
58 | character is considered part of the string. | ||
59 | If | ||
60 | .Fa c | ||
61 | is | ||
62 | .Ql \e0 , | ||
63 | .Fn strrchr | ||
64 | locates the terminating | ||
65 | .Ql \e0 . | ||
66 | .Pp | ||
67 | The | ||
68 | .Fn rindex | ||
69 | function is an old synonym for | ||
70 | .Fn strrchr . | ||
71 | .Sh RETURN VALUES | ||
72 | The | ||
73 | .Fn strrchr | ||
74 | function returns a pointer to the located character or | ||
75 | .Dv NULL | ||
76 | if the character does not appear in the string. | ||
77 | .Sh EXAMPLES | ||
78 | After the following call to | ||
79 | .Fn strrchr , | ||
80 | .Va p | ||
81 | will point to the string | ||
82 | .Qq obar : | ||
83 | .Bd -literal -offset indent | ||
84 | char *p; | ||
85 | char *s = "foobar"; | ||
86 | |||
87 | p = strrchr(s, 'o'); | ||
88 | .Ed | ||
89 | .Sh SEE ALSO | ||
90 | .Xr memchr 3 , | ||
91 | .Xr strchr 3 , | ||
92 | .Xr strcspn 3 , | ||
93 | .Xr strpbrk 3 , | ||
94 | .Xr strsep 3 , | ||
95 | .Xr strspn 3 , | ||
96 | .Xr strstr 3 , | ||
97 | .Xr strtok 3 , | ||
98 | .Xr wcsrchr 3 | ||
99 | .Sh STANDARDS | ||
100 | The | ||
101 | .Fn strrchr | ||
102 | function conforms to | ||
103 | .St -ansiC . | ||
104 | .Pp | ||
105 | The | ||
106 | .Fn rindex | ||
107 | function is deprecated and shouldn't be used in new code. | ||
108 | .Sh HISTORY | ||
109 | The | ||
110 | .Fn rindex | ||
111 | function first appeared in | ||
112 | .At v7 . | ||
113 | The | ||
114 | .Fn strrchr | ||
115 | function first appeared in | ||
116 | .At III | ||
117 | and was reimplemented for | ||
118 | .Bx 4.3 . | ||
diff --git a/src/lib/libc/string/strrchr.c b/src/lib/libc/string/strrchr.c deleted file mode 100644 index 848d1ad22e..0000000000 --- a/src/lib/libc/string/strrchr.c +++ /dev/null | |||
@@ -1,48 +0,0 @@ | |||
1 | /* $OpenBSD: strrchr.c,v 1.4 2018/10/01 06:37:37 martijn Exp $ */ | ||
2 | /* | ||
3 | * Copyright (c) 1988 Regents of the University of California. | ||
4 | * All rights reserved. | ||
5 | * | ||
6 | * Redistribution and use in source and binary forms, with or without | ||
7 | * modification, are permitted provided that the following conditions | ||
8 | * are met: | ||
9 | * 1. Redistributions of source code must retain the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer. | ||
11 | * 2. Redistributions in binary form must reproduce the above copyright | ||
12 | * notice, this list of conditions and the following disclaimer in the | ||
13 | * documentation and/or other materials provided with the distribution. | ||
14 | * 3. Neither the name of the University nor the names of its contributors | ||
15 | * may be used to endorse or promote products derived from this software | ||
16 | * without specific prior written permission. | ||
17 | * | ||
18 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | ||
19 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
20 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
21 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | ||
22 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
23 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
24 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
25 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
26 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
27 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
28 | * SUCH DAMAGE. | ||
29 | */ | ||
30 | |||
31 | #include <string.h> | ||
32 | |||
33 | __weak_alias(rindex, strrchr); | ||
34 | |||
35 | char * | ||
36 | strrchr(const char *p, int ch) | ||
37 | { | ||
38 | char *save; | ||
39 | |||
40 | for (save = NULL;; ++p) { | ||
41 | if (*p == (char) ch) | ||
42 | save = (char *)p; | ||
43 | if (!*p) | ||
44 | return(save); | ||
45 | } | ||
46 | /* NOTREACHED */ | ||
47 | } | ||
48 | DEF_STRONG(strrchr); | ||
diff --git a/src/lib/libc/string/strsep.3 b/src/lib/libc/string/strsep.3 deleted file mode 100644 index 77053f66d7..0000000000 --- a/src/lib/libc/string/strsep.3 +++ /dev/null | |||
@@ -1,110 +0,0 @@ | |||
1 | .\" $OpenBSD: strsep.3,v 1.14 2013/06/05 03:39:23 tedu Exp $ | ||
2 | .\" | ||
3 | .\" Copyright (c) 1990, 1991, 1993 | ||
4 | .\" The Regents of the University of California. All rights reserved. | ||
5 | .\" | ||
6 | .\" This code is derived from software contributed to Berkeley by | ||
7 | .\" Chris Torek. | ||
8 | .\" | ||
9 | .\" Redistribution and use in source and binary forms, with or without | ||
10 | .\" modification, are permitted provided that the following conditions | ||
11 | .\" are met: | ||
12 | .\" 1. Redistributions of source code must retain the above copyright | ||
13 | .\" notice, this list of conditions and the following disclaimer. | ||
14 | .\" 2. Redistributions in binary form must reproduce the above copyright | ||
15 | .\" notice, this list of conditions and the following disclaimer in the | ||
16 | .\" documentation and/or other materials provided with the distribution. | ||
17 | .\" 3. Neither the name of the University nor the names of its contributors | ||
18 | .\" may be used to endorse or promote products derived from this software | ||
19 | .\" without specific prior written permission. | ||
20 | .\" | ||
21 | .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | ||
22 | .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
23 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
24 | .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | ||
25 | .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
26 | .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
27 | .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
28 | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
29 | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
30 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
31 | .\" SUCH DAMAGE. | ||
32 | .\" | ||
33 | .\" @(#)strsep.3 8.1 (Berkeley) 6/9/93 | ||
34 | .\" | ||
35 | .Dd $Mdocdate: June 5 2013 $ | ||
36 | .Dt STRSEP 3 | ||
37 | .Os | ||
38 | .Sh NAME | ||
39 | .Nm strsep | ||
40 | .Nd separate strings | ||
41 | .Sh SYNOPSIS | ||
42 | .In string.h | ||
43 | .Ft char * | ||
44 | .Fn strsep "char **stringp" "const char *delim" | ||
45 | .Sh DESCRIPTION | ||
46 | The | ||
47 | .Fn strsep | ||
48 | function locates, in the string referenced by | ||
49 | .Fa *stringp , | ||
50 | the first occurrence of any character in the string | ||
51 | .Fa delim | ||
52 | (or the terminating | ||
53 | .Ql \e0 | ||
54 | character) and replaces it with a | ||
55 | .Ql \e0 . | ||
56 | The location of the next character after the delimiter character | ||
57 | (or | ||
58 | .Dv NULL , | ||
59 | if the end of the string was reached) is stored in | ||
60 | .Fa *stringp . | ||
61 | The original value of | ||
62 | .Fa *stringp | ||
63 | is returned. | ||
64 | .Pp | ||
65 | An | ||
66 | .Dq empty | ||
67 | field, i.e., one caused by two adjacent delimiter characters, | ||
68 | can be detected by comparing the location referenced by the pointer returned | ||
69 | by | ||
70 | .Fn strsep | ||
71 | to | ||
72 | .Ql \e0 . | ||
73 | .Pp | ||
74 | If | ||
75 | .Fa *stringp | ||
76 | is initially | ||
77 | .Dv NULL , | ||
78 | .Fn strsep | ||
79 | returns | ||
80 | .Dv NULL . | ||
81 | .Sh EXAMPLES | ||
82 | The following uses | ||
83 | .Fn strsep | ||
84 | to parse a string, containing tokens delimited by whitespace, into an | ||
85 | argument vector: | ||
86 | .Bd -literal -offset indent | ||
87 | char **ap, *argv[10], *inputstring; | ||
88 | |||
89 | for (ap = argv; ap < &argv[9] && | ||
90 | (*ap = strsep(&inputstring, " \et")) != NULL;) { | ||
91 | if (**ap != '\e0') | ||
92 | ap++; | ||
93 | } | ||
94 | *ap = NULL; | ||
95 | .Ed | ||
96 | .Sh HISTORY | ||
97 | The | ||
98 | .Fn strsep | ||
99 | function first appeared in | ||
100 | .Bx 4.3 Reno . | ||
101 | It is intended as a replacement for the | ||
102 | .Xr strtok 3 | ||
103 | function. | ||
104 | While the | ||
105 | .Xr strtok 3 | ||
106 | function should be preferred for portability reasons (it conforms to | ||
107 | .St -ansiC ) | ||
108 | it is unable to handle empty fields, i.e., detect fields delimited by | ||
109 | two adjacent delimiter characters, or to be used for more than a single | ||
110 | string at a time. | ||
diff --git a/src/lib/libc/string/strsep.c b/src/lib/libc/string/strsep.c deleted file mode 100644 index 97c3cbf1f5..0000000000 --- a/src/lib/libc/string/strsep.c +++ /dev/null | |||
@@ -1,71 +0,0 @@ | |||
1 | /* $OpenBSD: strsep.c,v 1.8 2015/08/31 02:53:57 guenther Exp $ */ | ||
2 | |||
3 | /*- | ||
4 | * Copyright (c) 1990, 1993 | ||
5 | * The Regents of the University of California. All rights reserved. | ||
6 | * | ||
7 | * Redistribution and use in source and binary forms, with or without | ||
8 | * modification, are permitted provided that the following conditions | ||
9 | * are met: | ||
10 | * 1. Redistributions of source code must retain the above copyright | ||
11 | * notice, this list of conditions and the following disclaimer. | ||
12 | * 2. Redistributions in binary form must reproduce the above copyright | ||
13 | * notice, this list of conditions and the following disclaimer in the | ||
14 | * documentation and/or other materials provided with the distribution. | ||
15 | * 3. Neither the name of the University nor the names of its contributors | ||
16 | * may be used to endorse or promote products derived from this software | ||
17 | * without specific prior written permission. | ||
18 | * | ||
19 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | ||
20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
21 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
22 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | ||
23 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
24 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
25 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
26 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
27 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
28 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
29 | * SUCH DAMAGE. | ||
30 | */ | ||
31 | |||
32 | #include <string.h> | ||
33 | |||
34 | /* | ||
35 | * Get next token from string *stringp, where tokens are possibly-empty | ||
36 | * strings separated by characters from delim. | ||
37 | * | ||
38 | * Writes NULs into the string at *stringp to end tokens. | ||
39 | * delim need not remain constant from call to call. | ||
40 | * On return, *stringp points past the last NUL written (if there might | ||
41 | * be further tokens), or is NULL (if there are definitely no more tokens). | ||
42 | * | ||
43 | * If *stringp is NULL, strsep returns NULL. | ||
44 | */ | ||
45 | char * | ||
46 | strsep(char **stringp, const char *delim) | ||
47 | { | ||
48 | char *s; | ||
49 | const char *spanp; | ||
50 | int c, sc; | ||
51 | char *tok; | ||
52 | |||
53 | if ((s = *stringp) == NULL) | ||
54 | return (NULL); | ||
55 | for (tok = s;;) { | ||
56 | c = *s++; | ||
57 | spanp = delim; | ||
58 | do { | ||
59 | if ((sc = *spanp++) == c) { | ||
60 | if (c == 0) | ||
61 | s = NULL; | ||
62 | else | ||
63 | s[-1] = 0; | ||
64 | *stringp = s; | ||
65 | return (tok); | ||
66 | } | ||
67 | } while (sc != 0); | ||
68 | } | ||
69 | /* NOTREACHED */ | ||
70 | } | ||
71 | DEF_WEAK(strsep); | ||
diff --git a/src/lib/libc/string/strsignal.3 b/src/lib/libc/string/strsignal.3 deleted file mode 100644 index b46be893b5..0000000000 --- a/src/lib/libc/string/strsignal.3 +++ /dev/null | |||
@@ -1,78 +0,0 @@ | |||
1 | .\" Copyright (c) 1980, 1991 Regents of the University of California. | ||
2 | .\" All rights reserved. | ||
3 | .\" | ||
4 | .\" This code is derived from software contributed to Berkeley by | ||
5 | .\" the American National Standards Committee X3, on Information | ||
6 | .\" Processing Systems. | ||
7 | .\" | ||
8 | .\" Redistribution and use in source and binary forms, with or without | ||
9 | .\" modification, are permitted provided that the following conditions | ||
10 | .\" are met: | ||
11 | .\" 1. Redistributions of source code must retain the above copyright | ||
12 | .\" notice, this list of conditions and the following disclaimer. | ||
13 | .\" 2. Redistributions in binary form must reproduce the above copyright | ||
14 | .\" notice, this list of conditions and the following disclaimer in the | ||
15 | .\" documentation and/or other materials provided with the distribution. | ||
16 | .\" 3. Neither the name of the University nor the names of its contributors | ||
17 | .\" may be used to endorse or promote products derived from this software | ||
18 | .\" without specific prior written permission. | ||
19 | .\" | ||
20 | .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | ||
21 | .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
22 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
23 | .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | ||
24 | .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
25 | .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
26 | .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
27 | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
28 | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
29 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
30 | .\" SUCH DAMAGE. | ||
31 | .\" | ||
32 | .\" $OpenBSD: strsignal.3,v 1.9 2019/05/16 13:35:16 schwarze Exp $ | ||
33 | .\" | ||
34 | .Dd $Mdocdate: May 16 2019 $ | ||
35 | .Dt STRSIGNAL 3 | ||
36 | .Os | ||
37 | .Sh NAME | ||
38 | .Nm strsignal | ||
39 | .Nd get signal description string | ||
40 | .Sh SYNOPSIS | ||
41 | .In string.h | ||
42 | .Ft char * | ||
43 | .Fn strsignal "int sig" | ||
44 | .Sh DESCRIPTION | ||
45 | The | ||
46 | .Fn strsignal | ||
47 | function returns a pointer to the string describing the signal | ||
48 | .Fa sig . | ||
49 | .Pp | ||
50 | The array pointed to is not to be modified by the program, but may be | ||
51 | overwritten by subsequent calls to | ||
52 | .Fn strsignal . | ||
53 | .Sh SEE ALSO | ||
54 | .Xr intro 2 , | ||
55 | .Xr psignal 3 , | ||
56 | .Xr setlocale 3 | ||
57 | .Sh STANDARDS | ||
58 | The | ||
59 | .Fn strsignal | ||
60 | function conforms to | ||
61 | .St -p1003.1-2008 . | ||
62 | .Sh HISTORY | ||
63 | The | ||
64 | .Fn strsignal | ||
65 | function first appeared in | ||
66 | .At V.4 | ||
67 | and was reimplemented for | ||
68 | .Nx 1.0 . | ||
69 | .Sh CAVEATS | ||
70 | On systems other than | ||
71 | .Ox , | ||
72 | the | ||
73 | .Dv LC_MESSAGES | ||
74 | .Xr locale 1 | ||
75 | category can cause different strings to be returned instead of the | ||
76 | normal signal descriptions; see CAVEATS in | ||
77 | .Xr setlocale 3 | ||
78 | for details. | ||
diff --git a/src/lib/libc/string/strsignal.c b/src/lib/libc/string/strsignal.c deleted file mode 100644 index fe2a747943..0000000000 --- a/src/lib/libc/string/strsignal.c +++ /dev/null | |||
@@ -1,40 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (c) 1988 Regents of the University of California. | ||
3 | * All rights reserved. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions | ||
7 | * are met: | ||
8 | * 1. Redistributions of source code must retain the above copyright | ||
9 | * notice, this list of conditions and the following disclaimer. | ||
10 | * 2. Redistributions in binary form must reproduce the above copyright | ||
11 | * notice, this list of conditions and the following disclaimer in the | ||
12 | * documentation and/or other materials provided with the distribution. | ||
13 | * 3. Neither the name of the University nor the names of its contributors | ||
14 | * may be used to endorse or promote products derived from this software | ||
15 | * without specific prior written permission. | ||
16 | * | ||
17 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | ||
18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | ||
21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
27 | * SUCH DAMAGE. | ||
28 | */ | ||
29 | |||
30 | #include <string.h> | ||
31 | #include <limits.h> | ||
32 | |||
33 | char * | ||
34 | strsignal(int sig) | ||
35 | { | ||
36 | static char buf[NL_TEXTMAX]; | ||
37 | |||
38 | return __strsignal(sig, buf); | ||
39 | } | ||
40 | DEF_WEAK(strsignal); | ||
diff --git a/src/lib/libc/string/strspn.3 b/src/lib/libc/string/strspn.3 deleted file mode 100644 index e677ba15a1..0000000000 --- a/src/lib/libc/string/strspn.3 +++ /dev/null | |||
@@ -1,92 +0,0 @@ | |||
1 | .\" $OpenBSD: strspn.3,v 1.12 2024/12/11 23:28:20 jsg Exp $ | ||
2 | .\" | ||
3 | .\" Copyright (c) 1990, 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 | .\" Chris Torek and the American National Standards Committee X3, | ||
8 | .\" on Information 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 STRSPN 3 | ||
36 | .Os | ||
37 | .Sh NAME | ||
38 | .Nm strspn | ||
39 | .Nd span a string | ||
40 | .Sh SYNOPSIS | ||
41 | .In string.h | ||
42 | .Ft size_t | ||
43 | .Fn strspn "const char *s" "const char *charset" | ||
44 | .Sh DESCRIPTION | ||
45 | The | ||
46 | .Fn strspn | ||
47 | function spans the initial part of the NUL-terminated string | ||
48 | .Fa s | ||
49 | as long as the characters from | ||
50 | .Fa s | ||
51 | occur in string | ||
52 | .Fa charset . | ||
53 | .Sh RETURN VALUES | ||
54 | The | ||
55 | .Fn strspn | ||
56 | function returns the number of characters spanned. | ||
57 | .Sh EXAMPLES | ||
58 | The following call to | ||
59 | .Fn strspn | ||
60 | will return 3, since the first three characters of string | ||
61 | .Fa s | ||
62 | are part of string | ||
63 | .Fa charset : | ||
64 | .Bd -literal -offset indent | ||
65 | char *s = "foobar"; | ||
66 | char *charset = "of"; | ||
67 | size_t span; | ||
68 | |||
69 | span = strspn(s, charset); | ||
70 | .Ed | ||
71 | .Sh SEE ALSO | ||
72 | .Xr memchr 3 , | ||
73 | .Xr strchr 3 , | ||
74 | .Xr strcspn 3 , | ||
75 | .Xr strpbrk 3 , | ||
76 | .Xr strrchr 3 , | ||
77 | .Xr strsep 3 , | ||
78 | .Xr strstr 3 , | ||
79 | .Xr strtok 3 , | ||
80 | .Xr wcsspn 3 | ||
81 | .Sh STANDARDS | ||
82 | The | ||
83 | .Fn strspn | ||
84 | function conforms to | ||
85 | .St -ansiC . | ||
86 | .Sh HISTORY | ||
87 | The | ||
88 | .Fn strspn | ||
89 | function first appeared in | ||
90 | .At III | ||
91 | and was reimplemented for | ||
92 | .Bx 4.3 . | ||
diff --git a/src/lib/libc/string/strspn.c b/src/lib/libc/string/strspn.c deleted file mode 100644 index 0ce41cbb49..0000000000 --- a/src/lib/libc/string/strspn.c +++ /dev/null | |||
@@ -1,52 +0,0 @@ | |||
1 | /* $OpenBSD: strspn.c,v 1.6 2015/08/31 02:53:57 guenther Exp $ */ | ||
2 | /* | ||
3 | * Copyright (c) 1989 The Regents of the University of California. | ||
4 | * All rights reserved. | ||
5 | * | ||
6 | * Redistribution and use in source and binary forms, with or without | ||
7 | * modification, are permitted provided that the following conditions | ||
8 | * are met: | ||
9 | * 1. Redistributions of source code must retain the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer. | ||
11 | * 2. Redistributions in binary form must reproduce the above copyright | ||
12 | * notice, this list of conditions and the following disclaimer in the | ||
13 | * documentation and/or other materials provided with the distribution. | ||
14 | * 3. Neither the name of the University nor the names of its contributors | ||
15 | * may be used to endorse or promote products derived from this software | ||
16 | * without specific prior written permission. | ||
17 | * | ||
18 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | ||
19 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
20 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
21 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | ||
22 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
23 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
24 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
25 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
26 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
27 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
28 | * SUCH DAMAGE. | ||
29 | */ | ||
30 | |||
31 | #include <string.h> | ||
32 | |||
33 | /* | ||
34 | * Span the string s2 (skip characters that are in s2). | ||
35 | */ | ||
36 | size_t | ||
37 | strspn(const char *s1, const char *s2) | ||
38 | { | ||
39 | const char *p = s1, *spanp; | ||
40 | char c, sc; | ||
41 | |||
42 | /* | ||
43 | * Skip any characters in s2, excluding the terminating \0. | ||
44 | */ | ||
45 | cont: | ||
46 | c = *p++; | ||
47 | for (spanp = s2; (sc = *spanp++) != 0;) | ||
48 | if (sc == c) | ||
49 | goto cont; | ||
50 | return (p - 1 - s1); | ||
51 | } | ||
52 | DEF_STRONG(strspn); | ||
diff --git a/src/lib/libc/string/strstr.3 b/src/lib/libc/string/strstr.3 deleted file mode 100644 index 60d2a721a7..0000000000 --- a/src/lib/libc/string/strstr.3 +++ /dev/null | |||
@@ -1,101 +0,0 @@ | |||
1 | .\" $OpenBSD: strstr.3,v 1.13 2016/05/11 17:51:50 schwarze Exp $ | ||
2 | .\" | ||
3 | .\" Copyright (c) 1990, 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 | .\" Chris Torek and the American National Standards Committee X3, | ||
8 | .\" on Information 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: May 11 2016 $ | ||
35 | .Dt STRSTR 3 | ||
36 | .Os | ||
37 | .Sh NAME | ||
38 | .Nm strstr , strcasestr | ||
39 | .Nd locate a substring in a string | ||
40 | .Sh SYNOPSIS | ||
41 | .In string.h | ||
42 | .Ft char * | ||
43 | .Fn strstr "const char *big" "const char *little" | ||
44 | .Ft char * | ||
45 | .Fn strcasestr "const char *big" "const char *little" | ||
46 | .Sh DESCRIPTION | ||
47 | The | ||
48 | .Fn strstr | ||
49 | function locates the first occurrence of the NUL-terminated string | ||
50 | .Fa little | ||
51 | in the NUL-terminated string | ||
52 | .Fa big . | ||
53 | .Pp | ||
54 | The | ||
55 | .Fn strcasestr | ||
56 | function is similar to | ||
57 | .Fn strstr | ||
58 | but ignores the case of both strings. | ||
59 | .Sh RETURN VALUES | ||
60 | If | ||
61 | .Fa little | ||
62 | is an empty string, | ||
63 | .Fa big | ||
64 | is returned; | ||
65 | if | ||
66 | .Fa little | ||
67 | occurs nowhere in | ||
68 | .Fa big , | ||
69 | .Dv NULL | ||
70 | is returned; | ||
71 | otherwise a pointer to the first character of the first occurrence of | ||
72 | .Fa little | ||
73 | is returned. | ||
74 | .Sh SEE ALSO | ||
75 | .Xr memchr 3 , | ||
76 | .Xr memmem 3 , | ||
77 | .Xr strchr 3 , | ||
78 | .Xr strcspn 3 , | ||
79 | .Xr strpbrk 3 , | ||
80 | .Xr strrchr 3 , | ||
81 | .Xr strsep 3 , | ||
82 | .Xr strspn 3 , | ||
83 | .Xr strtok 3 , | ||
84 | .Xr wcsstr 3 | ||
85 | .Sh STANDARDS | ||
86 | The | ||
87 | .Fn strstr | ||
88 | function conforms to | ||
89 | .St -ansiC . | ||
90 | .Sh HISTORY | ||
91 | The | ||
92 | .Fn strstr | ||
93 | function first appeared in | ||
94 | .Bx 4.3 Reno . | ||
95 | The | ||
96 | .Fn strcasestr | ||
97 | function appeared in glibc 2.1, | ||
98 | was reimplemented for | ||
99 | .Fx 4.5 | ||
100 | and ported to | ||
101 | .Ox 3.8 . | ||
diff --git a/src/lib/libc/string/strstr.c b/src/lib/libc/string/strstr.c deleted file mode 100644 index 241a080e7a..0000000000 --- a/src/lib/libc/string/strstr.c +++ /dev/null | |||
@@ -1,189 +0,0 @@ | |||
1 | /* $OpenBSD: strstr.c,v 1.9 2020/04/16 12:37:52 claudio Exp $ */ | ||
2 | |||
3 | /* | ||
4 | * Copyright (c) 2005-2018 Rich Felker | ||
5 | * | ||
6 | * Permission is hereby granted, free of charge, to any person obtaining | ||
7 | * a copy of this software and associated documentation files (the | ||
8 | * "Software"), to deal in the Software without restriction, including | ||
9 | * without limitation the rights to use, copy, modify, merge, publish, | ||
10 | * distribute, sublicense, and/or sell copies of the Software, and to | ||
11 | * permit persons to whom the Software is furnished to do so, subject to | ||
12 | * the following conditions: | ||
13 | * | ||
14 | * The above copyright notice and this permission notice shall be | ||
15 | * included in all copies or substantial portions of the Software. | ||
16 | * | ||
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | ||
20 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY | ||
21 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, | ||
22 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE | ||
23 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
24 | */ | ||
25 | |||
26 | #include <string.h> | ||
27 | #include <stdint.h> | ||
28 | |||
29 | static char * | ||
30 | twobyte_strstr(const unsigned char *h, const unsigned char *n) | ||
31 | { | ||
32 | uint16_t nw = n[0]<<8 | n[1], hw = h[0]<<8 | h[1]; | ||
33 | for (h++; *h && hw != nw; hw = hw<<8 | *++h); | ||
34 | return *h ? (char *)h-1 : 0; | ||
35 | } | ||
36 | |||
37 | static char * | ||
38 | threebyte_strstr(const unsigned char *h, const unsigned char *n) | ||
39 | { | ||
40 | uint32_t nw = n[0]<<24 | n[1]<<16 | n[2]<<8; | ||
41 | uint32_t hw = h[0]<<24 | h[1]<<16 | h[2]<<8; | ||
42 | for (h+=2; *h && hw != nw; hw = (hw|*++h)<<8); | ||
43 | return *h ? (char *)h-2 : 0; | ||
44 | } | ||
45 | |||
46 | static char * | ||
47 | fourbyte_strstr(const unsigned char *h, const unsigned char *n) | ||
48 | { | ||
49 | uint32_t nw = n[0]<<24 | n[1]<<16 | n[2]<<8 | n[3]; | ||
50 | uint32_t hw = h[0]<<24 | h[1]<<16 | h[2]<<8 | h[3]; | ||
51 | for (h+=3; *h && hw != nw; hw = hw<<8 | *++h); | ||
52 | return *h ? (char *)h-3 : 0; | ||
53 | } | ||
54 | |||
55 | #define MAX(a,b) ((a)>(b)?(a):(b)) | ||
56 | #define MIN(a,b) ((a)<(b)?(a):(b)) | ||
57 | |||
58 | #define BITOP(a,b,op) \ | ||
59 | ((a)[(size_t)(b)/(8*sizeof *(a))] op (size_t)1<<((size_t)(b)%(8*sizeof *(a)))) | ||
60 | |||
61 | /* | ||
62 | * Maxime Crochemore and Dominique Perrin, Two-way string-matching, | ||
63 | * Journal of the ACM, 38(3):651-675, July 1991. | ||
64 | */ | ||
65 | static char * | ||
66 | twoway_strstr(const unsigned char *h, const unsigned char *n) | ||
67 | { | ||
68 | const unsigned char *z; | ||
69 | size_t l, ip, jp, k, p, ms, p0, mem, mem0; | ||
70 | size_t byteset[32 / sizeof(size_t)] = { 0 }; | ||
71 | size_t shift[256]; | ||
72 | |||
73 | /* Computing length of needle and fill shift table */ | ||
74 | for (l=0; n[l] && h[l]; l++) | ||
75 | BITOP(byteset, n[l], |=), shift[n[l]] = l+1; | ||
76 | if (n[l]) return 0; /* hit the end of h */ | ||
77 | |||
78 | /* Compute maximal suffix */ | ||
79 | ip = -1; jp = 0; k = p = 1; | ||
80 | while (jp+k<l) { | ||
81 | if (n[ip+k] == n[jp+k]) { | ||
82 | if (k == p) { | ||
83 | jp += p; | ||
84 | k = 1; | ||
85 | } else k++; | ||
86 | } else if (n[ip+k] > n[jp+k]) { | ||
87 | jp += k; | ||
88 | k = 1; | ||
89 | p = jp - ip; | ||
90 | } else { | ||
91 | ip = jp++; | ||
92 | k = p = 1; | ||
93 | } | ||
94 | } | ||
95 | ms = ip; | ||
96 | p0 = p; | ||
97 | |||
98 | /* And with the opposite comparison */ | ||
99 | ip = -1; jp = 0; k = p = 1; | ||
100 | while (jp+k<l) { | ||
101 | if (n[ip+k] == n[jp+k]) { | ||
102 | if (k == p) { | ||
103 | jp += p; | ||
104 | k = 1; | ||
105 | } else k++; | ||
106 | } else if (n[ip+k] < n[jp+k]) { | ||
107 | jp += k; | ||
108 | k = 1; | ||
109 | p = jp - ip; | ||
110 | } else { | ||
111 | ip = jp++; | ||
112 | k = p = 1; | ||
113 | } | ||
114 | } | ||
115 | if (ip+1 > ms+1) ms = ip; | ||
116 | else p = p0; | ||
117 | |||
118 | /* Periodic needle? */ | ||
119 | if (memcmp(n, n+p, ms+1)) { | ||
120 | mem0 = 0; | ||
121 | p = MAX(ms, l-ms-1) + 1; | ||
122 | } else mem0 = l-p; | ||
123 | mem = 0; | ||
124 | |||
125 | /* Initialize incremental end-of-haystack pointer */ | ||
126 | z = h; | ||
127 | |||
128 | /* Search loop */ | ||
129 | for (;;) { | ||
130 | /* Update incremental end-of-haystack pointer */ | ||
131 | if (z-h < l) { | ||
132 | /* Fast estimate for MIN(l,63) */ | ||
133 | size_t grow = l | 63; | ||
134 | const unsigned char *z2 = memchr(z, 0, grow); | ||
135 | if (z2) { | ||
136 | z = z2; | ||
137 | if (z-h < l) return 0; | ||
138 | } else z += grow; | ||
139 | } | ||
140 | |||
141 | /* Check last byte first; advance by shift on mismatch */ | ||
142 | if (BITOP(byteset, h[l-1], &)) { | ||
143 | k = l-shift[h[l-1]]; | ||
144 | if (k) { | ||
145 | if (k < mem) k = mem; | ||
146 | h += k; | ||
147 | mem = 0; | ||
148 | continue; | ||
149 | } | ||
150 | } else { | ||
151 | h += l; | ||
152 | mem = 0; | ||
153 | continue; | ||
154 | } | ||
155 | |||
156 | /* Compare right half */ | ||
157 | for (k=MAX(ms+1,mem); n[k] && n[k] == h[k]; k++); | ||
158 | if (n[k]) { | ||
159 | h += k-ms; | ||
160 | mem = 0; | ||
161 | continue; | ||
162 | } | ||
163 | /* Compare left half */ | ||
164 | for (k=ms+1; k>mem && n[k-1] == h[k-1]; k--); | ||
165 | if (k <= mem) return (char *)h; | ||
166 | h += p; | ||
167 | mem = mem0; | ||
168 | } | ||
169 | } | ||
170 | |||
171 | char * | ||
172 | strstr(const char *h, const char *n) | ||
173 | { | ||
174 | /* Return immediately on empty needle */ | ||
175 | if (!n[0]) return (char *)h; | ||
176 | |||
177 | /* Use faster algorithms for short needles */ | ||
178 | h = strchr(h, *n); | ||
179 | if (!h || !n[1]) return (char *)h; | ||
180 | if (!h[1]) return 0; | ||
181 | if (!n[2]) return twobyte_strstr((void *)h, (void *)n); | ||
182 | if (!h[2]) return 0; | ||
183 | if (!n[3]) return threebyte_strstr((void *)h, (void *)n); | ||
184 | if (!h[3]) return 0; | ||
185 | if (!n[4]) return fourbyte_strstr((void *)h, (void *)n); | ||
186 | |||
187 | return twoway_strstr((void *)h, (void *)n); | ||
188 | } | ||
189 | DEF_STRONG(strstr); | ||
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 . | ||
diff --git a/src/lib/libc/string/strtok.c b/src/lib/libc/string/strtok.c deleted file mode 100644 index c5765756fc..0000000000 --- a/src/lib/libc/string/strtok.c +++ /dev/null | |||
@@ -1,87 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (c) 1988 Regents of the University of California. | ||
3 | * All rights reserved. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions | ||
7 | * are met: | ||
8 | * 1. Redistributions of source code must retain the above copyright | ||
9 | * notice, this list of conditions and the following disclaimer. | ||
10 | * 2. Redistributions in binary form must reproduce the above copyright | ||
11 | * notice, this list of conditions and the following disclaimer in the | ||
12 | * documentation and/or other materials provided with the distribution. | ||
13 | * 3. Neither the name of the University nor the names of its contributors | ||
14 | * may be used to endorse or promote products derived from this software | ||
15 | * without specific prior written permission. | ||
16 | * | ||
17 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | ||
18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | ||
21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
27 | * SUCH DAMAGE. | ||
28 | */ | ||
29 | |||
30 | #include <string.h> | ||
31 | |||
32 | char * | ||
33 | strtok(char *s, const char *delim) | ||
34 | { | ||
35 | static char *last; | ||
36 | |||
37 | return strtok_r(s, delim, &last); | ||
38 | } | ||
39 | DEF_STRONG(strtok); | ||
40 | |||
41 | char * | ||
42 | strtok_r(char *s, const char *delim, char **last) | ||
43 | { | ||
44 | const char *spanp; | ||
45 | int c, sc; | ||
46 | char *tok; | ||
47 | |||
48 | if (s == NULL && (s = *last) == NULL) | ||
49 | return (NULL); | ||
50 | |||
51 | /* | ||
52 | * Skip (span) leading delimiters (s += strspn(s, delim), sort of). | ||
53 | */ | ||
54 | cont: | ||
55 | c = *s++; | ||
56 | for (spanp = delim; (sc = *spanp++) != 0;) { | ||
57 | if (c == sc) | ||
58 | goto cont; | ||
59 | } | ||
60 | |||
61 | if (c == 0) { /* no non-delimiter characters */ | ||
62 | *last = NULL; | ||
63 | return (NULL); | ||
64 | } | ||
65 | tok = s - 1; | ||
66 | |||
67 | /* | ||
68 | * Scan token (scan for delimiters: s += strcspn(s, delim), sort of). | ||
69 | * Note that delim must have one NUL; we stop if we see that, too. | ||
70 | */ | ||
71 | for (;;) { | ||
72 | c = *s++; | ||
73 | spanp = delim; | ||
74 | do { | ||
75 | if ((sc = *spanp++) == c) { | ||
76 | if (c == 0) | ||
77 | s = NULL; | ||
78 | else | ||
79 | s[-1] = '\0'; | ||
80 | *last = s; | ||
81 | return (tok); | ||
82 | } | ||
83 | } while (sc != 0); | ||
84 | } | ||
85 | /* NOTREACHED */ | ||
86 | } | ||
87 | DEF_WEAK(strtok_r); | ||
diff --git a/src/lib/libc/string/strxfrm.3 b/src/lib/libc/string/strxfrm.3 deleted file mode 100644 index dab3673f38..0000000000 --- a/src/lib/libc/string/strxfrm.3 +++ /dev/null | |||
@@ -1,105 +0,0 @@ | |||
1 | .\" $OpenBSD: strxfrm.3,v 1.12 2019/01/18 07:43:36 schwarze Exp $ | ||
2 | .\" | ||
3 | .\" Copyright (c) 1990, 1991 The Regents of the University of California. | ||
4 | .\" Copyright (c) 2017 Ingo Schwarze <schwarze@openbsd.org> | ||
5 | .\" All rights reserved. | ||
6 | .\" | ||
7 | .\" This code is derived from software contributed to Berkeley by | ||
8 | .\" Chris Torek and the American National Standards Committee X3, | ||
9 | .\" on Information Processing Systems. | ||
10 | .\" | ||
11 | .\" Redistribution and use in source and binary forms, with or without | ||
12 | .\" modification, are permitted provided that the following conditions | ||
13 | .\" are met: | ||
14 | .\" 1. Redistributions of source code must retain the above copyright | ||
15 | .\" notice, this list of conditions and the following disclaimer. | ||
16 | .\" 2. Redistributions in binary form must reproduce the above copyright | ||
17 | .\" notice, this list of conditions and the following disclaimer in the | ||
18 | .\" documentation and/or other materials provided with the distribution. | ||
19 | .\" 3. Neither the name of the University nor the names of its contributors | ||
20 | .\" may be used to endorse or promote products derived from this software | ||
21 | .\" without specific prior written permission. | ||
22 | .\" | ||
23 | .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | ||
24 | .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
25 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
26 | .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | ||
27 | .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
28 | .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
29 | .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
30 | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
31 | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
32 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
33 | .\" SUCH DAMAGE. | ||
34 | .\" | ||
35 | .Dd $Mdocdate: January 18 2019 $ | ||
36 | .Dt STRXFRM 3 | ||
37 | .Os | ||
38 | .Sh NAME | ||
39 | .Nm strxfrm , | ||
40 | .Nm strxfrm_l | ||
41 | .Nd transform a string under locale | ||
42 | .Sh SYNOPSIS | ||
43 | .In string.h | ||
44 | .Ft size_t | ||
45 | .Fn strxfrm "char *dst" "const char *src" "size_t n" | ||
46 | .Ft size_t | ||
47 | .Fn strxfrm_l "char *dst" "const char *src" "size_t n" "locale_t locale" | ||
48 | .Sh DESCRIPTION | ||
49 | The idea of | ||
50 | .Fn strxfrm | ||
51 | and | ||
52 | .Fn strxfrm_l | ||
53 | is to | ||
54 | .Dq un-localize | ||
55 | a string: the functions transform | ||
56 | .Ar src , | ||
57 | storing the result in | ||
58 | .Ar dst , | ||
59 | such that | ||
60 | .Xr strcmp 3 | ||
61 | on transformed strings returns what | ||
62 | .Xr strcoll 3 | ||
63 | on the original untransformed strings would return. | ||
64 | .Pp | ||
65 | On | ||
66 | .Ox , | ||
67 | both have the same effect as | ||
68 | .Xr strlcpy 3 , | ||
69 | and the global locale, the thread-specific locale, and the | ||
70 | .Fa locale | ||
71 | argument are ignored. | ||
72 | On other operating systems, the behaviour may depend on the | ||
73 | .Dv LC_CTYPE | ||
74 | and | ||
75 | .Dv LC_COLLATE | ||
76 | locale categories set with | ||
77 | .Xr setlocale 3 , | ||
78 | .Xr uselocale 3 , | ||
79 | or | ||
80 | .Xr newlocale 3 . | ||
81 | .Sh SEE ALSO | ||
82 | .Xr newlocale 3 , | ||
83 | .Xr setlocale 3 , | ||
84 | .Xr strcmp 3 , | ||
85 | .Xr strcoll 3 , | ||
86 | .Xr strlcpy 3 , | ||
87 | .Xr wcsxfrm 3 | ||
88 | .Sh STANDARDS | ||
89 | The | ||
90 | .Fn strxfrm | ||
91 | function conforms to | ||
92 | .St -ansiC , | ||
93 | and | ||
94 | .Fn strxfrm_l | ||
95 | to | ||
96 | .St -p1003.1-2008 . | ||
97 | .Sh HISTORY | ||
98 | The | ||
99 | .Fn strxfrm | ||
100 | function has been available since | ||
101 | .Bx 4.3 Reno , | ||
102 | and | ||
103 | .Fn strxfrm_l | ||
104 | since | ||
105 | .Ox 6.2 . | ||
diff --git a/src/lib/libc/string/strxfrm.c b/src/lib/libc/string/strxfrm.c deleted file mode 100644 index 97df097b29..0000000000 --- a/src/lib/libc/string/strxfrm.c +++ /dev/null | |||
@@ -1,52 +0,0 @@ | |||
1 | /* $OpenBSD: strxfrm.c,v 1.7 2015/08/31 02:53:57 guenther Exp $ */ | ||
2 | /*- | ||
3 | * Copyright (c) 1990 The Regents of the University of California. | ||
4 | * All rights reserved. | ||
5 | * | ||
6 | * This code is derived from software contributed to Berkeley by | ||
7 | * Chris Torek. | ||
8 | * | ||
9 | * Redistribution and use in source and binary forms, with or without | ||
10 | * modification, are permitted provided that the following conditions | ||
11 | * are met: | ||
12 | * 1. Redistributions of source code must retain the above copyright | ||
13 | * notice, this list of conditions and the following disclaimer. | ||
14 | * 2. Redistributions in binary form must reproduce the above copyright | ||
15 | * notice, this list of conditions and the following disclaimer in the | ||
16 | * documentation and/or other materials provided with the distribution. | ||
17 | * 3. Neither the name of the University nor the names of its contributors | ||
18 | * may be used to endorse or promote products derived from this software | ||
19 | * without specific prior written permission. | ||
20 | * | ||
21 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | ||
22 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | ||
25 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
26 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
27 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
28 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
29 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
30 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
31 | * SUCH DAMAGE. | ||
32 | */ | ||
33 | |||
34 | #include <string.h> | ||
35 | |||
36 | /* | ||
37 | * Transform src, storing the result in dst, such that | ||
38 | * strcmp() on transformed strings returns what strcoll() | ||
39 | * on the original untransformed strings would return. | ||
40 | */ | ||
41 | size_t | ||
42 | strxfrm(char *dst, const char *src, size_t n) | ||
43 | { | ||
44 | |||
45 | /* | ||
46 | * Since locales are unimplemented, this is just a copy. | ||
47 | */ | ||
48 | if (n == 0) | ||
49 | return (strlen(src)); | ||
50 | return (strlcpy(dst, src, n)); | ||
51 | } | ||
52 | DEF_STRONG(strxfrm); | ||
diff --git a/src/lib/libc/string/strxfrm_l.c b/src/lib/libc/string/strxfrm_l.c deleted file mode 100644 index ff77947953..0000000000 --- a/src/lib/libc/string/strxfrm_l.c +++ /dev/null | |||
@@ -1,14 +0,0 @@ | |||
1 | /* $OpenBSD: strxfrm_l.c,v 1.1 2017/09/05 03:16:14 schwarze Exp $ */ | ||
2 | /* | ||
3 | * Written in 2017 by Ingo Schwarze <schwarze@openbsd.org>. | ||
4 | * Released into the public domain. | ||
5 | */ | ||
6 | |||
7 | #include <string.h> | ||
8 | |||
9 | size_t | ||
10 | strxfrm_l(char *dst, const char *src, size_t n, | ||
11 | locale_t locale __attribute__((__unused__))) | ||
12 | { | ||
13 | return strxfrm(dst, src, n); | ||
14 | } | ||
diff --git a/src/lib/libc/string/swab.3 b/src/lib/libc/string/swab.3 deleted file mode 100644 index 777f2833b6..0000000000 --- a/src/lib/libc/string/swab.3 +++ /dev/null | |||
@@ -1,79 +0,0 @@ | |||
1 | .\" Copyright (c) 1990, 1991 The Regents of the University of California. | ||
2 | .\" All rights reserved. | ||
3 | .\" | ||
4 | .\" Redistribution and use in source and binary forms, with or without | ||
5 | .\" modification, are permitted provided that the following conditions | ||
6 | .\" are met: | ||
7 | .\" 1. Redistributions of source code must retain the above copyright | ||
8 | .\" notice, this list of conditions and the following disclaimer. | ||
9 | .\" 2. Redistributions in binary form must reproduce the above copyright | ||
10 | .\" notice, this list of conditions and the following disclaimer in the | ||
11 | .\" documentation and/or other materials provided with the distribution. | ||
12 | .\" 3. Neither the name of the University nor the names of its contributors | ||
13 | .\" may be used to endorse or promote products derived from this software | ||
14 | .\" without specific prior written permission. | ||
15 | .\" | ||
16 | .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | ||
17 | .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
18 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
19 | .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | ||
20 | .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
21 | .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
22 | .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
23 | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
24 | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
25 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
26 | .\" SUCH DAMAGE. | ||
27 | .\" | ||
28 | .\" $OpenBSD: swab.3,v 1.10 2022/09/28 20:27:12 jmc Exp $ | ||
29 | .\" | ||
30 | .Dd $Mdocdate: September 28 2022 $ | ||
31 | .Dt SWAB 3 | ||
32 | .Os | ||
33 | .Sh NAME | ||
34 | .Nm swab | ||
35 | .Nd swap adjacent bytes | ||
36 | .Sh SYNOPSIS | ||
37 | .In unistd.h | ||
38 | .Ft void | ||
39 | .Fo swab | ||
40 | .Fa "const void *restrict src" | ||
41 | .Fa "void *restrict dst" | ||
42 | .Fa "ssize_t len" | ||
43 | .Fc | ||
44 | .Sh DESCRIPTION | ||
45 | The | ||
46 | .Fn swab | ||
47 | function copies | ||
48 | .Fa len | ||
49 | bytes from the location referenced by | ||
50 | .Fa src | ||
51 | to the location referenced by | ||
52 | .Fa dst , | ||
53 | swapping adjacent bytes. | ||
54 | .Pp | ||
55 | If | ||
56 | .Fa len | ||
57 | is zero or less, | ||
58 | .Fn swab | ||
59 | does nothing. | ||
60 | If it is odd, what happens to the last byte is unspecified. | ||
61 | If | ||
62 | .Fa src | ||
63 | and | ||
64 | .Fa dst | ||
65 | overlap, behaviour is undefined. | ||
66 | .Sh SEE ALSO | ||
67 | .Xr bzero 3 , | ||
68 | .Xr memset 3 | ||
69 | .Sh STANDARDS | ||
70 | The | ||
71 | .Fn swab | ||
72 | function is compliant with the X/Open System Interfaces option of the | ||
73 | .St -p1003.1-2008 | ||
74 | specification. | ||
75 | .Sh HISTORY | ||
76 | The | ||
77 | .Fn swab | ||
78 | function first appeared in | ||
79 | .At v7 . | ||
diff --git a/src/lib/libc/string/swab.c b/src/lib/libc/string/swab.c deleted file mode 100644 index c7d7d72ce0..0000000000 --- a/src/lib/libc/string/swab.c +++ /dev/null | |||
@@ -1,35 +0,0 @@ | |||
1 | /* $OpenBSD: swab.c,v 1.9 2014/12/11 23:05:38 tedu Exp $ */ | ||
2 | /* | ||
3 | * Copyright (c) 2014 Ted Unangst <tedu@openbsd.org> | ||
4 | * | ||
5 | * Permission to use, copy, modify, and distribute this software for any | ||
6 | * purpose with or without fee is hereby granted, provided that the above | ||
7 | * copyright notice and this permission notice appear in all copies. | ||
8 | * | ||
9 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
10 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
11 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | ||
12 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
13 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
14 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | ||
15 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
16 | */ | ||
17 | #include <unistd.h> | ||
18 | |||
19 | void | ||
20 | swab(const void *__restrict from, void *__restrict to, ssize_t len) | ||
21 | { | ||
22 | const unsigned char *src = from; | ||
23 | unsigned char *dst = to; | ||
24 | unsigned char t0, t1; | ||
25 | |||
26 | while (len > 1) { | ||
27 | t0 = src[0]; | ||
28 | t1 = src[1]; | ||
29 | dst[0] = t1; | ||
30 | dst[1] = t0; | ||
31 | src += 2; | ||
32 | dst += 2; | ||
33 | len -= 2; | ||
34 | } | ||
35 | } | ||
diff --git a/src/lib/libc/string/timingsafe_bcmp.3 b/src/lib/libc/string/timingsafe_bcmp.3 deleted file mode 100644 index 00da769157..0000000000 --- a/src/lib/libc/string/timingsafe_bcmp.3 +++ /dev/null | |||
@@ -1,87 +0,0 @@ | |||
1 | .\" $OpenBSD: timingsafe_bcmp.3,v 1.2 2014/06/21 20:22:15 tedu Exp $ | ||
2 | .\" | ||
3 | .\" Copyright (c) 2014 Google Inc. | ||
4 | .\" | ||
5 | .\" Permission to use, copy, modify, and distribute this software for any | ||
6 | .\" purpose with or without fee is hereby granted, provided that the above | ||
7 | .\" copyright notice and this permission notice appear in all copies. | ||
8 | .\" | ||
9 | .\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
10 | .\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
11 | .\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | ||
12 | .\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
13 | .\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
14 | .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | ||
15 | .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
16 | .Dd $Mdocdate: June 21 2014 $ | ||
17 | .Dt TIMINGSAFE_BCMP 3 | ||
18 | .Os | ||
19 | .Sh NAME | ||
20 | .Nm timingsafe_bcmp , | ||
21 | .Nm timingsafe_memcmp | ||
22 | .Nd timing-safe byte sequence comparisons | ||
23 | .Sh SYNOPSIS | ||
24 | .In string.h | ||
25 | .Ft int | ||
26 | .Fn timingsafe_bcmp "const void *b1" "const void *b2" "size_t len" | ||
27 | .Ft int | ||
28 | .Fn timingsafe_memcmp "const void *b1" "const void *b2" "size_t len" | ||
29 | .Sh DESCRIPTION | ||
30 | The | ||
31 | .Fn timingsafe_bcmp | ||
32 | and | ||
33 | .Fn timingsafe_memcmp | ||
34 | functions lexicographically compare the first | ||
35 | .Fa len | ||
36 | bytes (each interpreted as an | ||
37 | .Vt unsigned char ) | ||
38 | pointed to by | ||
39 | .Fa b1 | ||
40 | and | ||
41 | .Fa b2 . | ||
42 | .Pp | ||
43 | Additionally, their running times are independent of the byte sequences compared, | ||
44 | making them safe to use for comparing secret values such as cryptographic MACs. | ||
45 | In contrast, | ||
46 | .Xr bcmp 3 | ||
47 | and | ||
48 | .Xr memcmp 3 | ||
49 | may short-circuit after finding the first differing byte. | ||
50 | .Sh RETURN VALUES | ||
51 | The | ||
52 | .Fn timingsafe_bcmp | ||
53 | function returns 0 or not zero if the byte sequence pointed to by | ||
54 | .Fa b1 | ||
55 | compares equal to or not equal to (respectively) | ||
56 | the byte sequence pointed to by | ||
57 | .Fa b2 . | ||
58 | .Pp | ||
59 | The | ||
60 | .Fn timingsafe_memcmp | ||
61 | function returns a negative value, 0, or positive value if the byte sequence | ||
62 | pointed to by | ||
63 | .Fa b1 | ||
64 | compares less than, equal to, or greater than (respectively) | ||
65 | the byte sequence pointed to by | ||
66 | .Fa b2 . | ||
67 | .Sh SEE ALSO | ||
68 | .Xr bcmp 3 , | ||
69 | .Xr memcmp 3 | ||
70 | .Sh STANDARDS | ||
71 | The | ||
72 | .Fn timingsafe_bcmp | ||
73 | and | ||
74 | .Fn timingsafe_memcmp | ||
75 | functions are | ||
76 | .Ox | ||
77 | extensions. | ||
78 | .Sh HISTORY | ||
79 | The | ||
80 | .Fn timingsafe_bcmp | ||
81 | function first appeared in | ||
82 | .Ox 4.9 . | ||
83 | .Pp | ||
84 | The | ||
85 | .Fn timingsafe_memcmp | ||
86 | function first appeared in | ||
87 | .Ox 5.6 . | ||
diff --git a/src/lib/libc/string/timingsafe_bcmp.c b/src/lib/libc/string/timingsafe_bcmp.c deleted file mode 100644 index 0409ec3244..0000000000 --- a/src/lib/libc/string/timingsafe_bcmp.c +++ /dev/null | |||
@@ -1,30 +0,0 @@ | |||
1 | /* $OpenBSD: timingsafe_bcmp.c,v 1.3 2015/08/31 02:53:57 guenther Exp $ */ | ||
2 | /* | ||
3 | * Copyright (c) 2010 Damien Miller. All rights reserved. | ||
4 | * | ||
5 | * Permission to use, copy, modify, and distribute this software for any | ||
6 | * purpose with or without fee is hereby granted, provided that the above | ||
7 | * copyright notice and this permission notice appear in all copies. | ||
8 | * | ||
9 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
10 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
11 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | ||
12 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
13 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
14 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | ||
15 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
16 | */ | ||
17 | |||
18 | #include <string.h> | ||
19 | |||
20 | int | ||
21 | timingsafe_bcmp(const void *b1, const void *b2, size_t n) | ||
22 | { | ||
23 | const unsigned char *p1 = b1, *p2 = b2; | ||
24 | int ret = 0; | ||
25 | |||
26 | for (; n > 0; n--) | ||
27 | ret |= *p1++ ^ *p2++; | ||
28 | return (ret != 0); | ||
29 | } | ||
30 | DEF_WEAK(timingsafe_bcmp); | ||
diff --git a/src/lib/libc/string/timingsafe_memcmp.c b/src/lib/libc/string/timingsafe_memcmp.c deleted file mode 100644 index 373f8cb197..0000000000 --- a/src/lib/libc/string/timingsafe_memcmp.c +++ /dev/null | |||
@@ -1,47 +0,0 @@ | |||
1 | /* $OpenBSD: timingsafe_memcmp.c,v 1.2 2015/08/31 02:53:57 guenther Exp $ */ | ||
2 | /* | ||
3 | * Copyright (c) 2014 Google Inc. | ||
4 | * | ||
5 | * Permission to use, copy, modify, and distribute this software for any | ||
6 | * purpose with or without fee is hereby granted, provided that the above | ||
7 | * copyright notice and this permission notice appear in all copies. | ||
8 | * | ||
9 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
10 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
11 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | ||
12 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
13 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
14 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | ||
15 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
16 | */ | ||
17 | |||
18 | #include <limits.h> | ||
19 | #include <string.h> | ||
20 | |||
21 | int | ||
22 | timingsafe_memcmp(const void *b1, const void *b2, size_t len) | ||
23 | { | ||
24 | const unsigned char *p1 = b1, *p2 = b2; | ||
25 | size_t i; | ||
26 | int res = 0, done = 0; | ||
27 | |||
28 | for (i = 0; i < len; i++) { | ||
29 | /* lt is -1 if p1[i] < p2[i]; else 0. */ | ||
30 | int lt = (p1[i] - p2[i]) >> CHAR_BIT; | ||
31 | |||
32 | /* gt is -1 if p1[i] > p2[i]; else 0. */ | ||
33 | int gt = (p2[i] - p1[i]) >> CHAR_BIT; | ||
34 | |||
35 | /* cmp is 1 if p1[i] > p2[i]; -1 if p1[i] < p2[i]; else 0. */ | ||
36 | int cmp = lt - gt; | ||
37 | |||
38 | /* set res = cmp if !done. */ | ||
39 | res |= cmp & ~done; | ||
40 | |||
41 | /* set done if p1[i] != p2[i]. */ | ||
42 | done |= lt | gt; | ||
43 | } | ||
44 | |||
45 | return (res); | ||
46 | } | ||
47 | DEF_WEAK(timingsafe_memcmp); | ||
diff --git a/src/lib/libc/string/wcscasecmp.3 b/src/lib/libc/string/wcscasecmp.3 deleted file mode 100644 index 9db4a829b9..0000000000 --- a/src/lib/libc/string/wcscasecmp.3 +++ /dev/null | |||
@@ -1,134 +0,0 @@ | |||
1 | .\" $OpenBSD: wcscasecmp.3,v 1.5 2017/09/05 03:16:14 schwarze Exp $ | ||
2 | .\" | ||
3 | .\" Copyright (c) 1990, 1991, 1993 | ||
4 | .\" The Regents of the University of California. All rights reserved. | ||
5 | .\" Copyright (c) 2017 Ingo Schwarze <schwarze@openbsd.org> | ||
6 | .\" | ||
7 | .\" This code is derived from software contributed to Berkeley by | ||
8 | .\" Chris Torek. | ||
9 | .\" Redistribution and use in source and binary forms, with or without | ||
10 | .\" modification, are permitted provided that the following conditions | ||
11 | .\" are met: | ||
12 | .\" 1. Redistributions of source code must retain the above copyright | ||
13 | .\" notice, this list of conditions and the following disclaimer. | ||
14 | .\" 2. Redistributions in binary form must reproduce the above copyright | ||
15 | .\" notice, this list of conditions and the following disclaimer in the | ||
16 | .\" documentation and/or other materials provided with the distribution. | ||
17 | .\" 3. Neither the name of the University nor the names of its contributors | ||
18 | .\" may be used to endorse or promote products derived from this software | ||
19 | .\" without specific prior written permission. | ||
20 | .\" | ||
21 | .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | ||
22 | .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
23 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
24 | .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | ||
25 | .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
26 | .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
27 | .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
28 | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
29 | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
30 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
31 | .\" SUCH DAMAGE. | ||
32 | .\" | ||
33 | .\" @(#)strcasecmp.3 8.1 (Berkeley) 6/9/93 | ||
34 | .\" | ||
35 | .Dd $Mdocdate: September 5 2017 $ | ||
36 | .Dt WCSCASECMP 3 | ||
37 | .Os | ||
38 | .Sh NAME | ||
39 | .Nm wcscasecmp , | ||
40 | .Nm wcscasecmp_l , | ||
41 | .Nm wcsncasecmp , | ||
42 | .Nm wcsncasecmp_l | ||
43 | .Nd compare wide strings, ignoring case | ||
44 | .Sh SYNOPSIS | ||
45 | .In wchar.h | ||
46 | .Ft int | ||
47 | .Fo wcscasecmp | ||
48 | .Fa "const wchar_t *s1" | ||
49 | .Fa "const wchar_t *s2" | ||
50 | .Fc | ||
51 | .Ft int | ||
52 | .Fo wcscasecmp_l | ||
53 | .Fa "const wchar_t *s1" | ||
54 | .Fa "const wchar_t *s2" | ||
55 | .Fa "locale_t locale" | ||
56 | .Fc | ||
57 | .Ft int | ||
58 | .Fo wcsncasecmp | ||
59 | .Fa "const wchar_t *s1" | ||
60 | .Fa "const wchar_t *s2" | ||
61 | .Fa "size_t len" | ||
62 | .Fc | ||
63 | .Ft int | ||
64 | .Fo wcsncasecmp_l | ||
65 | .Fa "const wchar_t *s1" | ||
66 | .Fa "const wchar_t *s2" | ||
67 | .Fa "size_t len" | ||
68 | .Fa "locale_t locale" | ||
69 | .Fc | ||
70 | .Sh DESCRIPTION | ||
71 | These functions compare the wide strings | ||
72 | .Fa s1 | ||
73 | and | ||
74 | .Fa s2 | ||
75 | and return an integer greater than, equal to, or less than 0, | ||
76 | according to whether | ||
77 | .Fa s1 | ||
78 | is lexicographically greater than, equal to, or less than | ||
79 | .Fa s2 | ||
80 | after translation of each corresponding wide character to lower case. | ||
81 | The wide strings themselves are not modified. | ||
82 | .Pp | ||
83 | For the translation to lower case, | ||
84 | .Fn wcscasecmp | ||
85 | and | ||
86 | .Fn wcsncasecmp | ||
87 | use the thread-specific locale as defined with | ||
88 | .Xr uselocale 3 , | ||
89 | falling back to the global locale defined with | ||
90 | .Xr setlocale 3 . | ||
91 | .Fn wcscasecmp_l | ||
92 | and | ||
93 | .Fn wcsncasecmp_l | ||
94 | use the | ||
95 | .Fa locale | ||
96 | argument instead. | ||
97 | .Pp | ||
98 | .Fn wcsncasecmp | ||
99 | and | ||
100 | .Fn wcsncasecmp_l | ||
101 | compare at most | ||
102 | .Fa len | ||
103 | wide characters. | ||
104 | .Sh SEE ALSO | ||
105 | .Xr newlocale 3 , | ||
106 | .Xr setlocale 3 , | ||
107 | .Xr strcasecmp 3 , | ||
108 | .Xr wcscmp 3 , | ||
109 | .Xr wmemcmp 3 | ||
110 | .Sh STANDARDS | ||
111 | These functions conform to | ||
112 | .St -p1003.1-2008 . | ||
113 | .Sh HISTORY | ||
114 | The | ||
115 | .Fn wcscasecmp | ||
116 | and | ||
117 | .Fn wcsncasecmp | ||
118 | functions have been available since | ||
119 | .Ox 5.0 , | ||
120 | and | ||
121 | .Fn wcscasecmp_l | ||
122 | and | ||
123 | .Fn wcsncasecmp_l | ||
124 | since | ||
125 | .Ox 6.2 . | ||
126 | .Sh AUTHORS | ||
127 | The | ||
128 | .Ox | ||
129 | versions of | ||
130 | .Fn wcscasecmp | ||
131 | and | ||
132 | .Fn wcsncasecmp | ||
133 | were implemented by | ||
134 | .An Marc Espie Aq Mt espie@openbsd.org . | ||
diff --git a/src/lib/libc/string/wcscasecmp.c b/src/lib/libc/string/wcscasecmp.c deleted file mode 100644 index b122e720fe..0000000000 --- a/src/lib/libc/string/wcscasecmp.c +++ /dev/null | |||
@@ -1,63 +0,0 @@ | |||
1 | /* $OpenBSD: wcscasecmp.c,v 1.3 2015/09/12 16:23:14 guenther Exp $ */ | ||
2 | |||
3 | /* | ||
4 | * Copyright (c) 2011 Marc Espie | ||
5 | * | ||
6 | * Redistribution and use in source and binary forms, with or without | ||
7 | * modification, are permitted provided that the following conditions | ||
8 | * are met: | ||
9 | * 1. Redistributions of source code must retain the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer. | ||
11 | * 2. Redistributions in binary form must reproduce the above copyright | ||
12 | * notice, this list of conditions and the following disclaimer in the | ||
13 | * documentation and/or other materials provided with the distribution. | ||
14 | * | ||
15 | * THIS SOFTWARE IS PROVIDED BY THE OPENBSD PROJECT AND CONTRIBUTORS | ||
16 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
17 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
18 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OPENBSD | ||
19 | * PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
20 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
21 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
22 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
23 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
25 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | #include <wchar.h> | ||
29 | #include <wctype.h> | ||
30 | #include "locale/runetype.h" | ||
31 | |||
32 | int | ||
33 | wcscasecmp(const wchar_t *s1, const wchar_t *s2) | ||
34 | { | ||
35 | wchar_t l1, l2; | ||
36 | |||
37 | while ((l1 = towlower(*s1++)) == (l2 = towlower(*s2++))) { | ||
38 | if (l1 == 0) | ||
39 | return (0); | ||
40 | } | ||
41 | /* XXX assumes wchar_t = int */ | ||
42 | return ((rune_t)l1 - (rune_t)l2); | ||
43 | } | ||
44 | DEF_WEAK(wcscasecmp); | ||
45 | |||
46 | int | ||
47 | wcsncasecmp(const wchar_t *s1, const wchar_t *s2, size_t n) | ||
48 | { | ||
49 | wchar_t l1, l2; | ||
50 | |||
51 | if (n == 0) | ||
52 | return (0); | ||
53 | do { | ||
54 | if (((l1 = towlower(*s1++))) != (l2 = towlower(*s2++))) { | ||
55 | /* XXX assumes wchar_t = int */ | ||
56 | return ((rune_t)l1 - (rune_t)l2); | ||
57 | } | ||
58 | if (l1 == 0) | ||
59 | break; | ||
60 | } while (--n != 0); | ||
61 | return (0); | ||
62 | } | ||
63 | DEF_WEAK(wcsncasecmp); | ||
diff --git a/src/lib/libc/string/wcscasecmp_l.c b/src/lib/libc/string/wcscasecmp_l.c deleted file mode 100644 index 35b99225c1..0000000000 --- a/src/lib/libc/string/wcscasecmp_l.c +++ /dev/null | |||
@@ -1,63 +0,0 @@ | |||
1 | /* $OpenBSD: wcscasecmp_l.c,v 1.1 2017/09/05 03:16:14 schwarze Exp $ */ | ||
2 | |||
3 | /* | ||
4 | * Copyright (c) 2011 Marc Espie | ||
5 | * | ||
6 | * Redistribution and use in source and binary forms, with or without | ||
7 | * modification, are permitted provided that the following conditions | ||
8 | * are met: | ||
9 | * 1. Redistributions of source code must retain the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer. | ||
11 | * 2. Redistributions in binary form must reproduce the above copyright | ||
12 | * notice, this list of conditions and the following disclaimer in the | ||
13 | * documentation and/or other materials provided with the distribution. | ||
14 | * | ||
15 | * THIS SOFTWARE IS PROVIDED BY THE OPENBSD PROJECT AND CONTRIBUTORS | ||
16 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
17 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
18 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OPENBSD | ||
19 | * PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
20 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
21 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
22 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
23 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
25 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | #include <wchar.h> | ||
29 | #include <wctype.h> | ||
30 | #include "locale/runetype.h" | ||
31 | |||
32 | int | ||
33 | wcscasecmp_l(const wchar_t *s1, const wchar_t *s2, locale_t locale) | ||
34 | { | ||
35 | wchar_t l1, l2; | ||
36 | |||
37 | while ((l1 = towlower_l(*s1++, locale)) == | ||
38 | (l2 = towlower_l(*s2++, locale))) { | ||
39 | if (l1 == 0) | ||
40 | return (0); | ||
41 | } | ||
42 | /* XXX assumes wchar_t = int */ | ||
43 | return ((rune_t)l1 - (rune_t)l2); | ||
44 | } | ||
45 | |||
46 | int | ||
47 | wcsncasecmp_l(const wchar_t *s1, const wchar_t *s2, size_t n, locale_t locale) | ||
48 | { | ||
49 | wchar_t l1, l2; | ||
50 | |||
51 | if (n == 0) | ||
52 | return (0); | ||
53 | do { | ||
54 | if (((l1 = towlower_l(*s1++, locale))) != | ||
55 | (l2 = towlower_l(*s2++, locale))) { | ||
56 | /* XXX assumes wchar_t = int */ | ||
57 | return ((rune_t)l1 - (rune_t)l2); | ||
58 | } | ||
59 | if (l1 == 0) | ||
60 | break; | ||
61 | } while (--n != 0); | ||
62 | return (0); | ||
63 | } | ||
diff --git a/src/lib/libc/string/wcscat.3 b/src/lib/libc/string/wcscat.3 deleted file mode 100644 index 9b7588cf9e..0000000000 --- a/src/lib/libc/string/wcscat.3 +++ /dev/null | |||
@@ -1,115 +0,0 @@ | |||
1 | .\" $OpenBSD: wcscat.3,v 1.3 2013/06/05 03:39:23 tedu Exp $ | ||
2 | .\" | ||
3 | .\" Copyright (c) 1990, 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 | .\" Chris Torek and the American National Standards Committee X3, | ||
8 | .\" on Information 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: June 5 2013 $ | ||
35 | .Dt WCSCAT 3 | ||
36 | .Os | ||
37 | .Sh NAME | ||
38 | .Nm wcscat , | ||
39 | .Nm wcsncat | ||
40 | .Nd concatenate wide strings | ||
41 | .Sh SYNOPSIS | ||
42 | .In wchar.h | ||
43 | .Ft wchar_t * | ||
44 | .Fn wcscat "wchar_t * restrict s" "const wchar_t * restrict append" | ||
45 | .Ft wchar_t * | ||
46 | .Fo wcsncat | ||
47 | .Fa "wchar_t * restrict s" | ||
48 | .Fa "const wchar_t * restrict append" | ||
49 | .Fa "size_t count" | ||
50 | .Fc | ||
51 | .Sh DESCRIPTION | ||
52 | The | ||
53 | .Fn wcscat | ||
54 | and | ||
55 | .Fn wcsncat | ||
56 | functions append a copy of the wide string | ||
57 | .Fa append | ||
58 | to the end of the wide string | ||
59 | .Fa s , | ||
60 | then add a terminating null wide character (L'\e0'). | ||
61 | The wide string | ||
62 | .Fa s | ||
63 | must have sufficient space to hold the result. | ||
64 | .Pp | ||
65 | The | ||
66 | .Fn wcsncat | ||
67 | function appends not more than | ||
68 | .Fa count | ||
69 | wide characters where space for the terminating null wide character | ||
70 | should not be included in | ||
71 | .Fa count . | ||
72 | .Sh RETURN VALUES | ||
73 | The | ||
74 | .Fn wcscat | ||
75 | and | ||
76 | .Fn wcsncat | ||
77 | functions return the pointer | ||
78 | .Fa s . | ||
79 | .Sh SEE ALSO | ||
80 | .Xr strcat 3 , | ||
81 | .Xr strlcpy 3 , | ||
82 | .Xr wcscpy 3 , | ||
83 | .Xr wcslcpy 3 , | ||
84 | .Xr wmemcpy 3 , | ||
85 | .Xr wmemmove 3 | ||
86 | .Sh STANDARDS | ||
87 | The | ||
88 | .Fn wcscat | ||
89 | and | ||
90 | .Fn wcsncat | ||
91 | functions conform to | ||
92 | .St -isoC-99 | ||
93 | and were first introduced in | ||
94 | .St -isoC-amd1 . | ||
95 | .Sh HISTORY | ||
96 | The | ||
97 | .Fn wcscat | ||
98 | and | ||
99 | .Fn wcsncat | ||
100 | functions were ported from | ||
101 | .Nx | ||
102 | and first appeared in | ||
103 | .Ox 3.8 . | ||
104 | .Sh CAVEATS | ||
105 | Using the functions | ||
106 | .Fn wcscat | ||
107 | and | ||
108 | .Fn wcsncat | ||
109 | is very error-prone with respect to buffer overflows; | ||
110 | see the EXAMPLES section in | ||
111 | .Xr strcat 3 | ||
112 | for correct usage. | ||
113 | Using | ||
114 | .Xr wcslcat 3 | ||
115 | is a better choice in most cases. | ||
diff --git a/src/lib/libc/string/wcscat.c b/src/lib/libc/string/wcscat.c deleted file mode 100644 index 0525c3cb14..0000000000 --- a/src/lib/libc/string/wcscat.c +++ /dev/null | |||
@@ -1,56 +0,0 @@ | |||
1 | /* $OpenBSD: wcscat.c,v 1.5 2017/11/28 06:55:49 tb Exp $ */ | ||
2 | /* $NetBSD: wcscat.c,v 1.2 2001/01/03 14:29:36 lukem Exp $ */ | ||
3 | |||
4 | /*- | ||
5 | * Copyright (c)1999 Citrus Project, | ||
6 | * All rights reserved. | ||
7 | * | ||
8 | * Redistribution and use in source and binary forms, with or without | ||
9 | * modification, are permitted provided that the following conditions | ||
10 | * are met: | ||
11 | * 1. Redistributions of source code must retain the above copyright | ||
12 | * notice, this list of conditions and the following disclaimer. | ||
13 | * 2. Redistributions in binary form must reproduce the above copyright | ||
14 | * notice, this list of conditions and the following disclaimer in the | ||
15 | * documentation and/or other materials provided with the distribution. | ||
16 | * | ||
17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND | ||
18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
27 | * SUCH DAMAGE. | ||
28 | * | ||
29 | * citrus Id: wcscat.c,v 1.1 1999/12/29 21:47:45 tshiozak Exp | ||
30 | */ | ||
31 | |||
32 | #include <wchar.h> | ||
33 | |||
34 | #if defined(APIWARN) | ||
35 | __warn_references(wcscat, | ||
36 | "wcscat() is almost always misused, please use wcslcat()"); | ||
37 | #endif | ||
38 | |||
39 | wchar_t * | ||
40 | wcscat(wchar_t *s1, const wchar_t *s2) | ||
41 | { | ||
42 | wchar_t *p; | ||
43 | wchar_t *q; | ||
44 | const wchar_t *r; | ||
45 | |||
46 | p = s1; | ||
47 | while (*p) | ||
48 | p++; | ||
49 | q = p; | ||
50 | r = s2; | ||
51 | while (*r) | ||
52 | *q++ = *r++; | ||
53 | *q = '\0'; | ||
54 | return s1; | ||
55 | } | ||
56 | DEF_STRONG(wcscat); | ||
diff --git a/src/lib/libc/string/wcschr.3 b/src/lib/libc/string/wcschr.3 deleted file mode 100644 index bb714b2099..0000000000 --- a/src/lib/libc/string/wcschr.3 +++ /dev/null | |||
@@ -1,85 +0,0 @@ | |||
1 | .\" $OpenBSD: wcschr.3,v 1.4 2013/06/05 03:39:23 tedu Exp $ | ||
2 | .\" | ||
3 | .\" Copyright (c) 1990, 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 | .\" Chris Torek and the American National Standards Committee X3, | ||
8 | .\" on Information 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: June 5 2013 $ | ||
35 | .Dt WCSCHR 3 | ||
36 | .Os | ||
37 | .Sh NAME | ||
38 | .Nm wcschr | ||
39 | .Nd locate first occurrence of a wide character in a wide string | ||
40 | .Sh SYNOPSIS | ||
41 | .In wchar.h | ||
42 | .Ft wchar_t * | ||
43 | .Fn wcschr "const wchar_t *s" "wchar_t c" | ||
44 | .Sh DESCRIPTION | ||
45 | The | ||
46 | .Fn wcschr | ||
47 | function locates the first occurrence of the wide character | ||
48 | .Fa c | ||
49 | in the wide string | ||
50 | .Fa s . | ||
51 | The terminating null wide character is considered part of the wide string. | ||
52 | If | ||
53 | .Fa c | ||
54 | is the null wide character (L'\e0'), | ||
55 | .Fn wcschr | ||
56 | locates the terminating null wide character. | ||
57 | .Sh RETURN VALUES | ||
58 | The | ||
59 | .Fn wcschr | ||
60 | function returns a pointer to the located wide character or | ||
61 | .Dv NULL | ||
62 | if the wide character does not appear in the wide string. | ||
63 | .Sh SEE ALSO | ||
64 | .Xr strchr 3 , | ||
65 | .Xr wcscspn 3 , | ||
66 | .Xr wcspbrk 3 , | ||
67 | .Xr wcsrchr 3 , | ||
68 | .Xr wcsspn 3 , | ||
69 | .Xr wcsstr 3 , | ||
70 | .Xr wcstok 3 , | ||
71 | .Xr wmemchr 3 | ||
72 | .Sh STANDARDS | ||
73 | The | ||
74 | .Fn wcschr | ||
75 | function conforms to | ||
76 | .St -isoC-99 | ||
77 | and was first introduced in | ||
78 | .St -isoC-amd1 . | ||
79 | .Sh HISTORY | ||
80 | The | ||
81 | .Fn wcschr | ||
82 | function was ported from | ||
83 | .Nx | ||
84 | and first appeared in | ||
85 | .Ox 3.8 . | ||
diff --git a/src/lib/libc/string/wcschr.c b/src/lib/libc/string/wcschr.c deleted file mode 100644 index 709d4797bb..0000000000 --- a/src/lib/libc/string/wcschr.c +++ /dev/null | |||
@@ -1,50 +0,0 @@ | |||
1 | /* $OpenBSD: wcschr.c,v 1.6 2015/10/01 02:32:07 guenther Exp $ */ | ||
2 | /* $NetBSD: wcschr.c,v 1.2 2001/01/03 14:29:36 lukem Exp $ */ | ||
3 | |||
4 | /*- | ||
5 | * Copyright (c)1999 Citrus Project, | ||
6 | * All rights reserved. | ||
7 | * | ||
8 | * Redistribution and use in source and binary forms, with or without | ||
9 | * modification, are permitted provided that the following conditions | ||
10 | * are met: | ||
11 | * 1. Redistributions of source code must retain the above copyright | ||
12 | * notice, this list of conditions and the following disclaimer. | ||
13 | * 2. Redistributions in binary form must reproduce the above copyright | ||
14 | * notice, this list of conditions and the following disclaimer in the | ||
15 | * documentation and/or other materials provided with the distribution. | ||
16 | * | ||
17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND | ||
18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
27 | * SUCH DAMAGE. | ||
28 | * | ||
29 | * citrus Id: wcschr.c,v 1.2 2000/12/21 05:07:25 itojun Exp | ||
30 | */ | ||
31 | |||
32 | #include <wchar.h> | ||
33 | |||
34 | wchar_t * | ||
35 | wcschr(const wchar_t *s, wchar_t c) | ||
36 | { | ||
37 | const wchar_t *p; | ||
38 | |||
39 | p = s; | ||
40 | for (;;) { | ||
41 | if (*p == c) { | ||
42 | return (wchar_t *)p; | ||
43 | } | ||
44 | if (!*p) | ||
45 | return NULL; | ||
46 | p++; | ||
47 | } | ||
48 | /* NOTREACHED */ | ||
49 | } | ||
50 | DEF_STRONG(wcschr); | ||
diff --git a/src/lib/libc/string/wcscmp.3 b/src/lib/libc/string/wcscmp.3 deleted file mode 100644 index 53cd15a1f0..0000000000 --- a/src/lib/libc/string/wcscmp.3 +++ /dev/null | |||
@@ -1,92 +0,0 @@ | |||
1 | .\" $OpenBSD: wcscmp.3,v 1.3 2013/06/05 03:39:23 tedu Exp $ | ||
2 | .\" | ||
3 | .\" Copyright (c) 1990, 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 | .\" Chris Torek and the American National Standards Committee X3, | ||
8 | .\" on Information 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: June 5 2013 $ | ||
35 | .Dt WCSCMP 3 | ||
36 | .Os | ||
37 | .Sh NAME | ||
38 | .Nm wcscmp , | ||
39 | .Nm wcsncmp | ||
40 | .Nd compare wide strings | ||
41 | .Sh SYNOPSIS | ||
42 | .In wchar.h | ||
43 | .Ft int | ||
44 | .Fn wcscmp "const wchar_t *s1" "const wchar_t *s2" | ||
45 | .Ft int | ||
46 | .Fn wcsncmp "const wchar_t *s1" "const wchar_t *s2" "size_t len" | ||
47 | .Sh DESCRIPTION | ||
48 | The | ||
49 | .Fn wcscmp | ||
50 | and | ||
51 | .Fn wcsncmp | ||
52 | functions lexicographically compare the wide strings | ||
53 | .Fa s1 | ||
54 | and | ||
55 | .Fa s2 . | ||
56 | The | ||
57 | .Fn wcsncmp | ||
58 | function compares at most | ||
59 | .Fa len | ||
60 | wide characters. | ||
61 | .Sh RETURN VALUES | ||
62 | The | ||
63 | .Fn wcscmp | ||
64 | and | ||
65 | .Fn wcsncmp | ||
66 | functions return an integer greater than, equal to, or less than 0, according | ||
67 | to whether the wide string | ||
68 | .Fa s1 | ||
69 | is greater than, equal to, or less than the wide string | ||
70 | .Fa s2 . | ||
71 | .Sh SEE ALSO | ||
72 | .Xr strcmp 3 , | ||
73 | .Xr wcscasecmp 3 , | ||
74 | .Xr wmemcmp 3 | ||
75 | .Sh STANDARDS | ||
76 | The | ||
77 | .Fn wcscmp | ||
78 | and | ||
79 | .Fn wcsncmp | ||
80 | functions conform to | ||
81 | .St -isoC-99 | ||
82 | and were first introduced in | ||
83 | .St -isoC-amd1 . | ||
84 | .Sh HISTORY | ||
85 | The | ||
86 | .Fn wcscmp | ||
87 | and | ||
88 | .Fn wcsncmp | ||
89 | functions were ported from | ||
90 | .Nx | ||
91 | and first appeared in | ||
92 | .Ox 3.8 . | ||
diff --git a/src/lib/libc/string/wcscmp.c b/src/lib/libc/string/wcscmp.c deleted file mode 100644 index 42d6bca3cc..0000000000 --- a/src/lib/libc/string/wcscmp.c +++ /dev/null | |||
@@ -1,52 +0,0 @@ | |||
1 | /* $OpenBSD: wcscmp.c,v 1.5 2015/09/12 16:23:14 guenther Exp $ */ | ||
2 | /* $NetBSD: wcscmp.c,v 1.5 2003/08/07 16:43:54 agc Exp $ */ | ||
3 | |||
4 | /*- | ||
5 | * Copyright (c) 1990, 1993 | ||
6 | * The Regents of the University of California. All rights reserved. | ||
7 | * | ||
8 | * This code is derived from software contributed to Berkeley by | ||
9 | * Chris Torek. | ||
10 | * | ||
11 | * Redistribution and use in source and binary forms, with or without | ||
12 | * modification, are permitted provided that the following conditions | ||
13 | * are met: | ||
14 | * 1. Redistributions of source code must retain the above copyright | ||
15 | * notice, this list of conditions and the following disclaimer. | ||
16 | * 2. Redistributions in binary form must reproduce the above copyright | ||
17 | * notice, this list of conditions and the following disclaimer in the | ||
18 | * documentation and/or other materials provided with the distribution. | ||
19 | * 3. Neither the name of the University nor the names of its contributors | ||
20 | * may be used to endorse or promote products derived from this software | ||
21 | * without specific prior written permission. | ||
22 | * | ||
23 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | ||
24 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
25 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
26 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | ||
27 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
28 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
29 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
30 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
31 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
32 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
33 | * SUCH DAMAGE. | ||
34 | */ | ||
35 | |||
36 | #include <wchar.h> | ||
37 | #include "locale/runetype.h" | ||
38 | |||
39 | /* | ||
40 | * Compare strings. | ||
41 | */ | ||
42 | int | ||
43 | wcscmp(const wchar_t *s1, const wchar_t *s2) | ||
44 | { | ||
45 | |||
46 | while (*s1 == *s2++) | ||
47 | if (*s1++ == 0) | ||
48 | return (0); | ||
49 | /* XXX assumes wchar_t = int */ | ||
50 | return (*(const rune_t *)s1 - *(const rune_t *)--s2); | ||
51 | } | ||
52 | DEF_STRONG(wcscmp); | ||
diff --git a/src/lib/libc/string/wcscpy.3 b/src/lib/libc/string/wcscpy.3 deleted file mode 100644 index fcf01b5c57..0000000000 --- a/src/lib/libc/string/wcscpy.3 +++ /dev/null | |||
@@ -1,129 +0,0 @@ | |||
1 | .\" $OpenBSD: wcscpy.3,v 1.5 2016/11/12 08:58:43 jmc Exp $ | ||
2 | .\" | ||
3 | .\" Copyright (c) 1990, 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 | .\" Chris Torek and the American National Standards Committee X3, | ||
8 | .\" on Information 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: November 12 2016 $ | ||
35 | .Dt WCSCPY 3 | ||
36 | .Os | ||
37 | .Sh NAME | ||
38 | .Nm wcscpy , | ||
39 | .Nm wcsncpy | ||
40 | .Nd copy wide strings | ||
41 | .Sh SYNOPSIS | ||
42 | .In wchar.h | ||
43 | .Ft wchar_t * | ||
44 | .Fn wcscpy "wchar_t * restrict dst" "const wchar_t * restrict src" | ||
45 | .Ft wchar_t * | ||
46 | .Fo wcsncpy | ||
47 | .Fa "wchar_t * restrict dst" | ||
48 | .Fa "const wchar_t * restrict src" | ||
49 | .Fa "size_t len" | ||
50 | .Fc | ||
51 | .Sh DESCRIPTION | ||
52 | The | ||
53 | .Fn wcscpy | ||
54 | and | ||
55 | .Fn wcsncpy | ||
56 | functions copy the wide string | ||
57 | .Fa src | ||
58 | to | ||
59 | .Fa dst | ||
60 | (including the terminating null wide character). | ||
61 | .Pp | ||
62 | The | ||
63 | .Fn wcsncpy | ||
64 | function copies not more than | ||
65 | .Fa len | ||
66 | wide characters to | ||
67 | .Fa dst , | ||
68 | appending null wide characters if the length of | ||
69 | .Fa src | ||
70 | is less than | ||
71 | .Fa len , | ||
72 | and | ||
73 | .Em not | ||
74 | terminating | ||
75 | .Fa dst | ||
76 | if the length of | ||
77 | .Fa src | ||
78 | is greater than or equal to | ||
79 | .Fa len . | ||
80 | .Pp | ||
81 | If the | ||
82 | .Fa src | ||
83 | and | ||
84 | .Fa dst | ||
85 | strings overlap, the behavior is undefined. | ||
86 | .Sh RETURN VALUES | ||
87 | The | ||
88 | .Fn wcscpy | ||
89 | and | ||
90 | .Fn wcsncpy | ||
91 | functions return | ||
92 | .Fa dst . | ||
93 | .Sh SEE ALSO | ||
94 | .Xr strcpy 3 , | ||
95 | .Xr strlcpy 3 , | ||
96 | .Xr wcscat 3 , | ||
97 | .Xr wcslcpy 3 , | ||
98 | .Xr wmemcpy 3 , | ||
99 | .Xr wmemmove 3 | ||
100 | .Sh STANDARDS | ||
101 | The | ||
102 | .Fn wcscpy | ||
103 | and | ||
104 | .Fn wcsncpy | ||
105 | functions conform to | ||
106 | .St -isoC-99 | ||
107 | and were first introduced in | ||
108 | .St -isoC-amd1 . | ||
109 | .Sh HISTORY | ||
110 | The | ||
111 | .Fn wcscpy | ||
112 | and | ||
113 | .Fn wcsncpy | ||
114 | functions were ported from | ||
115 | .Nx | ||
116 | and first appeared in | ||
117 | .Ox 3.8 . | ||
118 | .Sh CAVEATS | ||
119 | Using the functions | ||
120 | .Fn wcscpy | ||
121 | and | ||
122 | .Fn wcsncpy | ||
123 | is very error-prone with respect to buffer overflows; | ||
124 | see the EXAMPLES section in | ||
125 | .Xr strncpy 3 | ||
126 | for correct usage. | ||
127 | Using | ||
128 | .Xr wcslcpy 3 | ||
129 | is a better choice in most cases. | ||
diff --git a/src/lib/libc/string/wcscpy.c b/src/lib/libc/string/wcscpy.c deleted file mode 100644 index f772752413..0000000000 --- a/src/lib/libc/string/wcscpy.c +++ /dev/null | |||
@@ -1,52 +0,0 @@ | |||
1 | /* $OpenBSD: wcscpy.c,v 1.5 2017/11/28 06:55:49 tb Exp $ */ | ||
2 | /* $NetBSD: wcscpy.c,v 1.2 2001/01/03 14:29:36 lukem Exp $ */ | ||
3 | |||
4 | /*- | ||
5 | * Copyright (c)1999 Citrus Project, | ||
6 | * All rights reserved. | ||
7 | * | ||
8 | * Redistribution and use in source and binary forms, with or without | ||
9 | * modification, are permitted provided that the following conditions | ||
10 | * are met: | ||
11 | * 1. Redistributions of source code must retain the above copyright | ||
12 | * notice, this list of conditions and the following disclaimer. | ||
13 | * 2. Redistributions in binary form must reproduce the above copyright | ||
14 | * notice, this list of conditions and the following disclaimer in the | ||
15 | * documentation and/or other materials provided with the distribution. | ||
16 | * | ||
17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND | ||
18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
27 | * SUCH DAMAGE. | ||
28 | * | ||
29 | * citrus Id: wcscpy.c,v 1.2 2000/12/21 04:51:09 itojun Exp | ||
30 | */ | ||
31 | |||
32 | #include <wchar.h> | ||
33 | |||
34 | #if defined(APIWARN) | ||
35 | __warn_references(wcscpy, | ||
36 | "wcscpy() is almost always misused, please use wcslcpy()"); | ||
37 | #endif | ||
38 | |||
39 | wchar_t * | ||
40 | wcscpy(wchar_t *s1, const wchar_t *s2) | ||
41 | { | ||
42 | wchar_t *p; | ||
43 | const wchar_t *q; | ||
44 | |||
45 | p = s1; | ||
46 | q = s2; | ||
47 | while (*q) | ||
48 | *p++ = *q++; | ||
49 | *p = '\0'; | ||
50 | |||
51 | return s1; | ||
52 | } | ||
diff --git a/src/lib/libc/string/wcscspn.3 b/src/lib/libc/string/wcscspn.3 deleted file mode 100644 index 520a739202..0000000000 --- a/src/lib/libc/string/wcscspn.3 +++ /dev/null | |||
@@ -1,83 +0,0 @@ | |||
1 | .\" $OpenBSD: wcscspn.3,v 1.3 2013/06/05 03:39:23 tedu Exp $ | ||
2 | .\" | ||
3 | .\" Copyright (c) 1990, 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 | .\" Chris Torek and the American National Standards Committee X3, | ||
8 | .\" on Information 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: June 5 2013 $ | ||
35 | .Dt WCSCSPN 3 | ||
36 | .Os | ||
37 | .Sh NAME | ||
38 | .Nm wcscspn | ||
39 | .Nd span the complement of a wide string | ||
40 | .Sh SYNOPSIS | ||
41 | .In wchar.h | ||
42 | .Ft size_t | ||
43 | .Fn wcscspn "const wchar_t *s" "const wchar_t *charset" | ||
44 | .Sh DESCRIPTION | ||
45 | The | ||
46 | .Fn wcscspn | ||
47 | function spans the initial part of the wide string | ||
48 | .Fa s | ||
49 | as long as the wide characters from | ||
50 | .Fa s | ||
51 | do not occur in string | ||
52 | .Fa charset | ||
53 | (it spans the | ||
54 | .Em complement | ||
55 | of | ||
56 | .Fa charset ) . | ||
57 | .Sh RETURN VALUES | ||
58 | The | ||
59 | .Fn wcscspn | ||
60 | function returns the number of wide characters spanned. | ||
61 | .Sh SEE ALSO | ||
62 | .Xr strcspn 3 , | ||
63 | .Xr wcschr 3 , | ||
64 | .Xr wcspbrk 3 , | ||
65 | .Xr wcsrchr 3 , | ||
66 | .Xr wcsspn 3 , | ||
67 | .Xr wcsstr 3 , | ||
68 | .Xr wcstok 3 , | ||
69 | .Xr wmemchr 3 | ||
70 | .Sh STANDARDS | ||
71 | The | ||
72 | .Fn wcscspn | ||
73 | function conforms to | ||
74 | .St -isoC-99 | ||
75 | and was first introduced in | ||
76 | .St -isoC-amd1 . | ||
77 | .Sh HISTORY | ||
78 | The | ||
79 | .Fn wcscspn | ||
80 | function was ported from | ||
81 | .Nx | ||
82 | and first appeared in | ||
83 | .Ox 3.8 . | ||
diff --git a/src/lib/libc/string/wcscspn.c b/src/lib/libc/string/wcscspn.c deleted file mode 100644 index 23e78ab22f..0000000000 --- a/src/lib/libc/string/wcscspn.c +++ /dev/null | |||
@@ -1,54 +0,0 @@ | |||
1 | /* $OpenBSD: wcscspn.c,v 1.4 2015/09/12 16:23:14 guenther Exp $ */ | ||
2 | /* $NetBSD: wcscspn.c,v 1.2 2001/01/03 14:29:36 lukem Exp $ */ | ||
3 | |||
4 | /*- | ||
5 | * Copyright (c)1999 Citrus Project, | ||
6 | * All rights reserved. | ||
7 | * | ||
8 | * Redistribution and use in source and binary forms, with or without | ||
9 | * modification, are permitted provided that the following conditions | ||
10 | * are met: | ||
11 | * 1. Redistributions of source code must retain the above copyright | ||
12 | * notice, this list of conditions and the following disclaimer. | ||
13 | * 2. Redistributions in binary form must reproduce the above copyright | ||
14 | * notice, this list of conditions and the following disclaimer in the | ||
15 | * documentation and/or other materials provided with the distribution. | ||
16 | * | ||
17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND | ||
18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
27 | * SUCH DAMAGE. | ||
28 | * | ||
29 | * citrus Id: wcscspn.c,v 1.1 1999/12/29 21:47:45 tshiozak Exp | ||
30 | */ | ||
31 | |||
32 | #include <wchar.h> | ||
33 | |||
34 | size_t | ||
35 | wcscspn(const wchar_t *s, const wchar_t *set) | ||
36 | { | ||
37 | const wchar_t *p; | ||
38 | const wchar_t *q; | ||
39 | |||
40 | p = s; | ||
41 | while (*p) { | ||
42 | q = set; | ||
43 | while (*q) { | ||
44 | if (*p == *q) | ||
45 | goto done; | ||
46 | q++; | ||
47 | } | ||
48 | p++; | ||
49 | } | ||
50 | |||
51 | done: | ||
52 | return (p - s); | ||
53 | } | ||
54 | DEF_STRONG(wcscspn); | ||
diff --git a/src/lib/libc/string/wcsdup.3 b/src/lib/libc/string/wcsdup.3 deleted file mode 100644 index 588a2571db..0000000000 --- a/src/lib/libc/string/wcsdup.3 +++ /dev/null | |||
@@ -1,97 +0,0 @@ | |||
1 | .\" $OpenBSD: wcsdup.3,v 1.4 2011/07/25 00:38:53 schwarze Exp $ | ||
2 | .\" $NetBSD: wcsdup.3,v 1.3 2010/12/16 17:42:28 wiz Exp $ | ||
3 | .\" | ||
4 | .\" Copyright (c) 1990, 1991, 1993 | ||
5 | .\" The Regents of the University of California. All rights reserved. | ||
6 | .\" | ||
7 | .\" Redistribution and use in source and binary forms, with or without | ||
8 | .\" modification, are permitted provided that the following conditions | ||
9 | .\" are met: | ||
10 | .\" 1. Redistributions of source code must retain the above copyright | ||
11 | .\" notice, this list of conditions and the following disclaimer. | ||
12 | .\" 2. Redistributions in binary form must reproduce the above copyright | ||
13 | .\" notice, this list of conditions and the following disclaimer in the | ||
14 | .\" documentation and/or other materials provided with the distribution. | ||
15 | .\" 3. Neither the name of the University nor the names of its contributors | ||
16 | .\" may be used to endorse or promote products derived from this software | ||
17 | .\" without specific prior written permission. | ||
18 | .\" | ||
19 | .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | ||
20 | .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
21 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
22 | .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | ||
23 | .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
24 | .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
25 | .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
26 | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
27 | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
28 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
29 | .\" SUCH DAMAGE. | ||
30 | .\" | ||
31 | .\" @(#)strdup.3 8.1 (Berkeley) 6/9/93 | ||
32 | .\" | ||
33 | .Dd $Mdocdate: July 25 2011 $ | ||
34 | .Dt WCSDUP 3 | ||
35 | .Os | ||
36 | .Sh NAME | ||
37 | .Nm wcsdup | ||
38 | .Nd save a copy of a wide string | ||
39 | .Sh SYNOPSIS | ||
40 | .In wchar.h | ||
41 | .Ft wchar_t * | ||
42 | .Fn wcsdup "const wchar_t *str" | ||
43 | .Sh DESCRIPTION | ||
44 | The | ||
45 | .Fn wcsdup | ||
46 | function | ||
47 | allocates sufficient memory for a copy | ||
48 | of the wide-character string | ||
49 | .Fa str , | ||
50 | does the copy, and returns a pointer to it. | ||
51 | The pointer may subsequently be used as an | ||
52 | argument to the function | ||
53 | .Xr free 3 . | ||
54 | .Pp | ||
55 | If insufficient memory is available, | ||
56 | .Dv NULL | ||
57 | is returned. | ||
58 | .Sh EXAMPLES | ||
59 | The following will point | ||
60 | .Va p | ||
61 | to an allocated area of memory containing the nul-terminated string | ||
62 | .Qq foobar : | ||
63 | .Bd -literal -offset indent | ||
64 | const char *o = "foobar"; | ||
65 | wchar_t *p, b[32]; | ||
66 | size_t blen; | ||
67 | |||
68 | blen = sizeof(b) / sizeof(b[0]); | ||
69 | if (mbstowcs(b, o, blen) == (size_t)-1) | ||
70 | err(1, NULL); | ||
71 | b[blen - 1] = 0; | ||
72 | if ((p = wcsdup(b)) == NULL) | ||
73 | err(1, NULL); | ||
74 | .Ed | ||
75 | .Sh ERRORS | ||
76 | The | ||
77 | .Fn wcsdup | ||
78 | function may fail and set the external variable | ||
79 | .Va errno | ||
80 | for any of the errors specified for the library function | ||
81 | .Xr malloc 3 . | ||
82 | .Sh SEE ALSO | ||
83 | .Xr free 3 , | ||
84 | .Xr malloc 3 , | ||
85 | .Xr strdup 3 | ||
86 | .Sh STANDARDS | ||
87 | The | ||
88 | .Fn wcsdup | ||
89 | function conforms to | ||
90 | .St -p1003.1-2008 . | ||
91 | .Sh HISTORY | ||
92 | The | ||
93 | .Fn wcsdup | ||
94 | function was ported from | ||
95 | .Nx | ||
96 | and first appeared in | ||
97 | .Ox 5.0 . | ||
diff --git a/src/lib/libc/string/wcsdup.c b/src/lib/libc/string/wcsdup.c deleted file mode 100644 index 36f19186ab..0000000000 --- a/src/lib/libc/string/wcsdup.c +++ /dev/null | |||
@@ -1,32 +0,0 @@ | |||
1 | /* $OpenBSD: wcsdup.c,v 1.3 2015/09/12 16:23:14 guenther Exp $ */ | ||
2 | /* $NetBSD: wcsdup.c,v 1.3 2008/05/26 13:17:48 haad Exp $ */ | ||
3 | |||
4 | /* | ||
5 | * Copyright (C) 2006 Aleksey Cheusov | ||
6 | * | ||
7 | * This material is provided "as is", with absolutely no warranty expressed | ||
8 | * or implied. Any use is at your own risk. | ||
9 | * | ||
10 | * Permission to use or copy this software for any purpose is hereby granted | ||
11 | * without fee. Permission to modify the code and to distribute modified | ||
12 | * code is also granted without any restrictions. | ||
13 | */ | ||
14 | |||
15 | #include <stdlib.h> | ||
16 | #include <wchar.h> | ||
17 | |||
18 | wchar_t * | ||
19 | wcsdup(const wchar_t *str) | ||
20 | { | ||
21 | wchar_t *copy; | ||
22 | size_t len; | ||
23 | |||
24 | len = wcslen(str) + 1; | ||
25 | copy = reallocarray(NULL, len, sizeof(wchar_t)); | ||
26 | |||
27 | if (!copy) | ||
28 | return (NULL); | ||
29 | |||
30 | return (wmemcpy(copy, str, len)); | ||
31 | } | ||
32 | DEF_WEAK(wcsdup); | ||
diff --git a/src/lib/libc/string/wcslcat.c b/src/lib/libc/string/wcslcat.c deleted file mode 100644 index 9949057df4..0000000000 --- a/src/lib/libc/string/wcslcat.c +++ /dev/null | |||
@@ -1,56 +0,0 @@ | |||
1 | /* $OpenBSD: wcslcat.c,v 1.7 2019/01/25 00:19:25 millert Exp $ */ | ||
2 | |||
3 | /* | ||
4 | * Copyright (c) 1998, 2015 Todd C. Miller <millert@openbsd.org> | ||
5 | * | ||
6 | * Permission to use, copy, modify, and distribute this software for any | ||
7 | * purpose with or without fee is hereby granted, provided that the above | ||
8 | * copyright notice and this permission notice appear in all copies. | ||
9 | * | ||
10 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
11 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
12 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | ||
13 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
14 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
15 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | ||
16 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
17 | */ | ||
18 | |||
19 | #include <sys/types.h> | ||
20 | #include <wchar.h> | ||
21 | |||
22 | /* | ||
23 | * Appends src to string dst of size dsize (unlike strncat, dsize is the | ||
24 | * full size of dst, not space left). At most dsize-1 characters | ||
25 | * will be copied. Always NUL terminates (unless dsize <= wcslen(dst)). | ||
26 | * Returns wcslen(src) + MIN(dsize, wcslen(initial dst)). | ||
27 | * If retval >= siz, truncation occurred. | ||
28 | */ | ||
29 | size_t | ||
30 | wcslcat(wchar_t *dst, const wchar_t *src, size_t dsize) | ||
31 | { | ||
32 | const wchar_t *odst = dst; | ||
33 | const wchar_t *osrc = src; | ||
34 | size_t n = dsize; | ||
35 | size_t dlen; | ||
36 | |||
37 | /* Find the end of dst and adjust bytes left but don't go past end. */ | ||
38 | while (n-- != 0 && *dst != L'\0') | ||
39 | dst++; | ||
40 | dlen = dst - odst; | ||
41 | n = dsize - dlen; | ||
42 | |||
43 | if (n-- == 0) | ||
44 | return(dlen + wcslen(src)); | ||
45 | while (*src != L'\0') { | ||
46 | if (n != 0) { | ||
47 | *dst++ = *src; | ||
48 | n--; | ||
49 | } | ||
50 | src++; | ||
51 | } | ||
52 | *dst = L'\0'; | ||
53 | |||
54 | return(dlen + (src - osrc)); /* count does not include NUL */ | ||
55 | } | ||
56 | DEF_WEAK(wcslcat); | ||
diff --git a/src/lib/libc/string/wcslcpy.3 b/src/lib/libc/string/wcslcpy.3 deleted file mode 100644 index d279038079..0000000000 --- a/src/lib/libc/string/wcslcpy.3 +++ /dev/null | |||
@@ -1,160 +0,0 @@ | |||
1 | .\" $OpenBSD: wcslcpy.3,v 1.8 2024/08/07 04:59:45 guenther Exp $ | ||
2 | .\" | ||
3 | .\" Copyright (c) 1998, 2000 Todd C. Miller <millert@openbsd.org> | ||
4 | .\" | ||
5 | .\" Permission to use, copy, modify, and distribute this software for any | ||
6 | .\" purpose with or without fee is hereby granted, provided that the above | ||
7 | .\" copyright notice and this permission notice appear in all copies. | ||
8 | .\" | ||
9 | .\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
10 | .\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
11 | .\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | ||
12 | .\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
13 | .\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
14 | .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | ||
15 | .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
16 | .\" | ||
17 | .Dd $Mdocdate: August 7 2024 $ | ||
18 | .Dt WCSLCPY 3 | ||
19 | .Os | ||
20 | .Sh NAME | ||
21 | .Nm wcslcpy , | ||
22 | .Nm wcslcat | ||
23 | .Nd size-bounded wide string copying and concatenation | ||
24 | .Sh SYNOPSIS | ||
25 | .In wchar.h | ||
26 | .Ft size_t | ||
27 | .Fn wcslcpy "wchar_t * restrict dst" "const wchar_t * restrict src" "size_t size" | ||
28 | .Ft size_t | ||
29 | .Fn wcslcat "wchar_t * restrict dst" "const wchar_t * restrict src" "size_t size" | ||
30 | .Sh DESCRIPTION | ||
31 | The | ||
32 | .Fn wcslcpy | ||
33 | and | ||
34 | .Fn wcslcat | ||
35 | functions copy and concatenate wide strings respectively. | ||
36 | They are designed to be safer, more consistent, and less error prone | ||
37 | replacements for | ||
38 | .Xr wcsncpy 3 | ||
39 | and | ||
40 | .Xr wcsncat 3 . | ||
41 | Unlike those functions, | ||
42 | .Fn wcslcpy | ||
43 | and | ||
44 | .Fn wcslcat | ||
45 | take the full size of the buffer (not just the length) and guarantee to | ||
46 | terminate the result with a null wide character (as long as | ||
47 | .Fa size | ||
48 | is larger than 0 or, in the case of | ||
49 | .Fn wcslcat , | ||
50 | as long as there is at least one wide character free in | ||
51 | .Fa dst ) . | ||
52 | Note that a wide character for the null wide character should be included in | ||
53 | .Fa size . | ||
54 | Also note that | ||
55 | .Fn wcslcpy | ||
56 | and | ||
57 | .Fn wcslcat | ||
58 | only operate on wide strings that are terminated with a null wide character | ||
59 | (L'\e0'). | ||
60 | This means that for | ||
61 | .Fn wcslcpy | ||
62 | .Fa src | ||
63 | must be terminated with a null wide character and for | ||
64 | .Fn wcslcat | ||
65 | both | ||
66 | .Fa src | ||
67 | and | ||
68 | .Fa dst | ||
69 | must be terminated with a null wide character. | ||
70 | .Pp | ||
71 | The | ||
72 | .Fn wcslcpy | ||
73 | function copies up to | ||
74 | .Fa size | ||
75 | \(mi 1 wide characters from the wide string | ||
76 | .Fa src | ||
77 | to | ||
78 | .Fa dst , | ||
79 | terminating the result with a null wide character. | ||
80 | .Pp | ||
81 | The | ||
82 | .Fn wcslcat | ||
83 | function appends the wide string | ||
84 | .Fa src | ||
85 | to the end of | ||
86 | .Fa dst . | ||
87 | It will append at most | ||
88 | .Fa size | ||
89 | \(mi wcslen(dst) \(mi 1 wide characters, terminating the result with a null | ||
90 | wide character. | ||
91 | .Pp | ||
92 | If the | ||
93 | .Fa src | ||
94 | and | ||
95 | .Fa dst | ||
96 | strings overlap, the behavior is undefined. | ||
97 | .Sh RETURN VALUES | ||
98 | The | ||
99 | .Fn wcslcpy | ||
100 | and | ||
101 | .Fn wcslcat | ||
102 | functions return the total length of the wide string they tried to create. | ||
103 | For | ||
104 | .Fn wcslcpy | ||
105 | that means the length of | ||
106 | .Fa src . | ||
107 | For | ||
108 | .Fn wcslcat | ||
109 | that means the initial length of | ||
110 | .Fa dst | ||
111 | plus | ||
112 | the length of | ||
113 | .Fa src . | ||
114 | While this may seem somewhat confusing, it was done to make | ||
115 | truncation detection simple. | ||
116 | .Pp | ||
117 | Note, however, that if | ||
118 | .Fn wcslcat | ||
119 | traverses | ||
120 | .Fa size | ||
121 | wide characters without finding a null wide character, the length of the | ||
122 | string is considered to be | ||
123 | .Fa size | ||
124 | and the destination wide string will not be terminated with a null wide | ||
125 | character (since there was no space for it). | ||
126 | This keeps | ||
127 | .Fn wcslcat | ||
128 | from running off the end of a wide string. | ||
129 | In practice this should not happen (as it means that either | ||
130 | .Fa size | ||
131 | is incorrect or that | ||
132 | .Fa dst | ||
133 | is not terminated with a null wide character). | ||
134 | The check exists to prevent potential security problems in incorrect code. | ||
135 | .Sh SEE ALSO | ||
136 | .Xr strlcpy 3 , | ||
137 | .Xr swprintf 3 , | ||
138 | .Xr wcsncat 3 , | ||
139 | .Xr wcsncpy 3 | ||
140 | .Sh STANDARDS | ||
141 | The | ||
142 | .Fn wcslcpy | ||
143 | and | ||
144 | .Fn wcslcat | ||
145 | functions conform to | ||
146 | .St -p1003.1-2024 . | ||
147 | .Sh HISTORY | ||
148 | The | ||
149 | .Fn wcslcpy | ||
150 | and | ||
151 | .Fn wcslcat | ||
152 | functions first appeared in | ||
153 | .Ox 3.8 . | ||
154 | .Sh AUTHORS | ||
155 | The | ||
156 | .Fn wcslcpy | ||
157 | and | ||
158 | .Fn wcslcat | ||
159 | functions are based on code by | ||
160 | .An Todd C. Miller Aq Mt millert@openbsd.org . | ||
diff --git a/src/lib/libc/string/wcslcpy.c b/src/lib/libc/string/wcslcpy.c deleted file mode 100644 index 9c433c83dc..0000000000 --- a/src/lib/libc/string/wcslcpy.c +++ /dev/null | |||
@@ -1,51 +0,0 @@ | |||
1 | /* $OpenBSD: wcslcpy.c,v 1.8 2019/01/25 00:19:25 millert Exp $ */ | ||
2 | |||
3 | /* | ||
4 | * Copyright (c) 1998, 2015 Todd C. Miller <millert@openbsd.org> | ||
5 | * | ||
6 | * Permission to use, copy, modify, and distribute this software for any | ||
7 | * purpose with or without fee is hereby granted, provided that the above | ||
8 | * copyright notice and this permission notice appear in all copies. | ||
9 | * | ||
10 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
11 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
12 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | ||
13 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
14 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
15 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | ||
16 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
17 | */ | ||
18 | |||
19 | #include <sys/types.h> | ||
20 | #include <wchar.h> | ||
21 | |||
22 | /* | ||
23 | * Copy string src to buffer dst of size dsize. At most dsize-1 | ||
24 | * chars will be copied. Always NUL terminates (unless dsize == 0). | ||
25 | * Returns wcslen(src); if retval >= dsize, truncation occurred. | ||
26 | */ | ||
27 | size_t | ||
28 | wcslcpy(wchar_t *dst, const wchar_t *src, size_t dsize) | ||
29 | { | ||
30 | const wchar_t *osrc = src; | ||
31 | size_t nleft = dsize; | ||
32 | |||
33 | /* Copy as many bytes as will fit. */ | ||
34 | if (nleft != 0) { | ||
35 | while (--nleft != 0) { | ||
36 | if ((*dst++ = *src++) == L'\0') | ||
37 | break; | ||
38 | } | ||
39 | } | ||
40 | |||
41 | /* Not enough room in dst, add NUL and traverse rest of src. */ | ||
42 | if (nleft == 0) { | ||
43 | if (dsize != 0) | ||
44 | *dst = L'\0'; /* NUL-terminate dst */ | ||
45 | while (*src++) | ||
46 | ; | ||
47 | } | ||
48 | |||
49 | return(src - osrc - 1); /* count does not include NUL */ | ||
50 | } | ||
51 | DEF_WEAK(wcslcpy); | ||
diff --git a/src/lib/libc/string/wcslen.3 b/src/lib/libc/string/wcslen.3 deleted file mode 100644 index b6d9aafc41..0000000000 --- a/src/lib/libc/string/wcslen.3 +++ /dev/null | |||
@@ -1,102 +0,0 @@ | |||
1 | .\" $OpenBSD: wcslen.3,v 1.4 2024/07/14 09:51:18 jca Exp $ | ||
2 | .\" | ||
3 | .\" Copyright (c) 1990, 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 | .\" Chris Torek and the American National Standards Committee X3, | ||
8 | .\" on Information 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: July 14 2024 $ | ||
35 | .Dt WCSLEN 3 | ||
36 | .Os | ||
37 | .Sh NAME | ||
38 | .Nm wcslen , | ||
39 | .Nm wcsnlen | ||
40 | .Nd find length of a wide string | ||
41 | .Sh SYNOPSIS | ||
42 | .In wchar.h | ||
43 | .Ft size_t | ||
44 | .Fn wcslen "const wchar_t *s" | ||
45 | .Ft size_t | ||
46 | .Fn wcsnlen "const wchar_t *s" "size_t maxlen" | ||
47 | .Sh DESCRIPTION | ||
48 | The | ||
49 | .Fn wcslen | ||
50 | function computes the length of the wide string | ||
51 | .Fa s . | ||
52 | The | ||
53 | .Fn wcsnlen | ||
54 | function computes the length of the wide string | ||
55 | .Fa s , | ||
56 | up to | ||
57 | .Fa maxlen | ||
58 | wide characters. | ||
59 | The | ||
60 | .Fn wcsnlen | ||
61 | function will never attempt to address more than | ||
62 | .Fa maxlen | ||
63 | wide characters, making it suitable for use with wide character arrays | ||
64 | that are not guaranteed to be NUL-terminated. | ||
65 | .Sh RETURN VALUES | ||
66 | The | ||
67 | .Fn wcslen | ||
68 | function returns the number of wide characters that precede the terminating | ||
69 | null wide character. | ||
70 | .Pp | ||
71 | The | ||
72 | .Fn wcsnlen | ||
73 | function returns the number of wide characters that precede the terminating | ||
74 | null wide character | ||
75 | or | ||
76 | .Fa maxlen , | ||
77 | whichever is smaller. | ||
78 | .Sh SEE ALSO | ||
79 | .Xr strlen 3 , | ||
80 | .Xr wcswidth 3 | ||
81 | .Sh STANDARDS | ||
82 | The | ||
83 | .Fn wcslen | ||
84 | function conforms to | ||
85 | .St -isoC-99 | ||
86 | and was first introduced in | ||
87 | .St -isoC-amd1 . | ||
88 | The | ||
89 | .Fn wcsnlen | ||
90 | function conforms to | ||
91 | .St -p1003.1-2008 . | ||
92 | .Sh HISTORY | ||
93 | The | ||
94 | .Fn wcslen | ||
95 | function was ported from | ||
96 | .Nx | ||
97 | and first appeared in | ||
98 | .Ox 3.8 . | ||
99 | The | ||
100 | .Fn wcsnlen | ||
101 | function first appeared in | ||
102 | .Ox 7.6 . | ||
diff --git a/src/lib/libc/string/wcslen.c b/src/lib/libc/string/wcslen.c deleted file mode 100644 index 16d4bba128..0000000000 --- a/src/lib/libc/string/wcslen.c +++ /dev/null | |||
@@ -1,45 +0,0 @@ | |||
1 | /* $OpenBSD: wcslen.c,v 1.4 2015/09/12 16:23:14 guenther Exp $ */ | ||
2 | /* $NetBSD: wcslen.c,v 1.2 2001/01/03 14:29:36 lukem Exp $ */ | ||
3 | |||
4 | /*- | ||
5 | * Copyright (c)1999 Citrus Project, | ||
6 | * All rights reserved. | ||
7 | * | ||
8 | * Redistribution and use in source and binary forms, with or without | ||
9 | * modification, are permitted provided that the following conditions | ||
10 | * are met: | ||
11 | * 1. Redistributions of source code must retain the above copyright | ||
12 | * notice, this list of conditions and the following disclaimer. | ||
13 | * 2. Redistributions in binary form must reproduce the above copyright | ||
14 | * notice, this list of conditions and the following disclaimer in the | ||
15 | * documentation and/or other materials provided with the distribution. | ||
16 | * | ||
17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND | ||
18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
27 | * SUCH DAMAGE. | ||
28 | * | ||
29 | * citrus Id: wcslen.c,v 1.1 1999/12/29 21:47:45 tshiozak Exp | ||
30 | */ | ||
31 | |||
32 | #include <wchar.h> | ||
33 | |||
34 | size_t | ||
35 | wcslen(const wchar_t *s) | ||
36 | { | ||
37 | const wchar_t *p; | ||
38 | |||
39 | p = s; | ||
40 | while (*p) | ||
41 | p++; | ||
42 | |||
43 | return p - s; | ||
44 | } | ||
45 | DEF_STRONG(wcslen); | ||
diff --git a/src/lib/libc/string/wcsncat.c b/src/lib/libc/string/wcsncat.c deleted file mode 100644 index 2b4b9f0d49..0000000000 --- a/src/lib/libc/string/wcsncat.c +++ /dev/null | |||
@@ -1,53 +0,0 @@ | |||
1 | /* $OpenBSD: wcsncat.c,v 1.4 2015/09/12 16:23:14 guenther Exp $ */ | ||
2 | /* $NetBSD: wcsncat.c,v 1.2 2001/01/03 14:29:36 lukem Exp $ */ | ||
3 | |||
4 | /*- | ||
5 | * Copyright (c)1999 Citrus Project, | ||
6 | * All rights reserved. | ||
7 | * | ||
8 | * Redistribution and use in source and binary forms, with or without | ||
9 | * modification, are permitted provided that the following conditions | ||
10 | * are met: | ||
11 | * 1. Redistributions of source code must retain the above copyright | ||
12 | * notice, this list of conditions and the following disclaimer. | ||
13 | * 2. Redistributions in binary form must reproduce the above copyright | ||
14 | * notice, this list of conditions and the following disclaimer in the | ||
15 | * documentation and/or other materials provided with the distribution. | ||
16 | * | ||
17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND | ||
18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
27 | * SUCH DAMAGE. | ||
28 | * | ||
29 | * citrus Id: wcsncat.c,v 1.1 1999/12/29 21:47:45 tshiozak Exp | ||
30 | */ | ||
31 | |||
32 | #include <wchar.h> | ||
33 | |||
34 | wchar_t * | ||
35 | wcsncat(wchar_t *s1, const wchar_t *s2, size_t n) | ||
36 | { | ||
37 | wchar_t *p; | ||
38 | wchar_t *q; | ||
39 | const wchar_t *r; | ||
40 | |||
41 | p = s1; | ||
42 | while (*p) | ||
43 | p++; | ||
44 | q = p; | ||
45 | r = s2; | ||
46 | while (*r && n) { | ||
47 | *q++ = *r++; | ||
48 | n--; | ||
49 | } | ||
50 | *q = '\0'; | ||
51 | return s1; | ||
52 | } | ||
53 | DEF_STRONG(wcsncat); | ||
diff --git a/src/lib/libc/string/wcsncmp.c b/src/lib/libc/string/wcsncmp.c deleted file mode 100644 index bdaab33e4c..0000000000 --- a/src/lib/libc/string/wcsncmp.c +++ /dev/null | |||
@@ -1,53 +0,0 @@ | |||
1 | /* $OpenBSD: wcsncmp.c,v 1.5 2015/09/12 16:23:14 guenther Exp $ */ | ||
2 | /* $NetBSD: wcsncmp.c,v 1.5 2003/08/07 16:43:54 agc Exp $ */ | ||
3 | |||
4 | /* | ||
5 | * Copyright (c) 1989, 1993 | ||
6 | * The Regents of the University of California. All rights reserved. | ||
7 | * | ||
8 | * Redistribution and use in source and binary forms, with or without | ||
9 | * modification, are permitted provided that the following conditions | ||
10 | * are met: | ||
11 | * 1. Redistributions of source code must retain the above copyright | ||
12 | * notice, this list of conditions and the following disclaimer. | ||
13 | * 2. Redistributions in binary form must reproduce the above copyright | ||
14 | * notice, this list of conditions and the following disclaimer in the | ||
15 | * documentation and/or other materials provided with the distribution. | ||
16 | * 3. Neither the name of the University nor the names of its contributors | ||
17 | * may be used to endorse or promote products derived from this software | ||
18 | * without specific prior written permission. | ||
19 | * | ||
20 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | ||
21 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
22 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
23 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | ||
24 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
25 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
26 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
27 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
28 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
29 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
30 | * SUCH DAMAGE. | ||
31 | */ | ||
32 | |||
33 | #include <wchar.h> | ||
34 | #include "locale/runetype.h" | ||
35 | |||
36 | int | ||
37 | wcsncmp(const wchar_t *s1, const wchar_t *s2, size_t n) | ||
38 | { | ||
39 | |||
40 | if (n == 0) | ||
41 | return (0); | ||
42 | do { | ||
43 | if (*s1 != *s2++) { | ||
44 | /* XXX assumes wchar_t = int */ | ||
45 | return (*(const rune_t *)s1 - | ||
46 | *(const rune_t *)--s2); | ||
47 | } | ||
48 | if (*s1++ == 0) | ||
49 | break; | ||
50 | } while (--n != 0); | ||
51 | return (0); | ||
52 | } | ||
53 | DEF_STRONG(wcsncmp); | ||
diff --git a/src/lib/libc/string/wcsncpy.c b/src/lib/libc/string/wcsncpy.c deleted file mode 100644 index 1be482b114..0000000000 --- a/src/lib/libc/string/wcsncpy.c +++ /dev/null | |||
@@ -1,51 +0,0 @@ | |||
1 | /* $OpenBSD: wcsncpy.c,v 1.5 2015/09/12 16:23:14 guenther Exp $ */ | ||
2 | /* $NetBSD: wcsncpy.c,v 1.2 2001/01/03 14:29:37 lukem Exp $ */ | ||
3 | |||
4 | /*- | ||
5 | * Copyright (c)1999 Citrus Project, | ||
6 | * All rights reserved. | ||
7 | * | ||
8 | * Redistribution and use in source and binary forms, with or without | ||
9 | * modification, are permitted provided that the following conditions | ||
10 | * are met: | ||
11 | * 1. Redistributions of source code must retain the above copyright | ||
12 | * notice, this list of conditions and the following disclaimer. | ||
13 | * 2. Redistributions in binary form must reproduce the above copyright | ||
14 | * notice, this list of conditions and the following disclaimer in the | ||
15 | * documentation and/or other materials provided with the distribution. | ||
16 | * | ||
17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND | ||
18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
27 | * SUCH DAMAGE. | ||
28 | * | ||
29 | * citrus Id: wcsncpy.c,v 1.1 1999/12/29 21:47:45 tshiozak Exp | ||
30 | */ | ||
31 | |||
32 | #include <wchar.h> | ||
33 | |||
34 | wchar_t * | ||
35 | wcsncpy(wchar_t *s1, const wchar_t *s2, size_t n) | ||
36 | { | ||
37 | wchar_t *p; | ||
38 | |||
39 | p = s1; | ||
40 | while (n && *s2) { | ||
41 | *p++ = *s2++; | ||
42 | n--; | ||
43 | } | ||
44 | while (n) { | ||
45 | *p++ = L'\0'; | ||
46 | n--; | ||
47 | } | ||
48 | |||
49 | return s1; | ||
50 | } | ||
51 | DEF_STRONG(wcsncpy); | ||
diff --git a/src/lib/libc/string/wcsnlen.c b/src/lib/libc/string/wcsnlen.c deleted file mode 100644 index eb1d08e85b..0000000000 --- a/src/lib/libc/string/wcsnlen.c +++ /dev/null | |||
@@ -1,45 +0,0 @@ | |||
1 | /* $OpenBSD: wcsnlen.c,v 1.1 2024/07/14 09:51:18 jca Exp $ */ | ||
2 | /* $NetBSD: wcslen.c,v 1.2 2001/01/03 14:29:36 lukem Exp $ */ | ||
3 | |||
4 | /*- | ||
5 | * Copyright (c)1999 Citrus Project, | ||
6 | * All rights reserved. | ||
7 | * | ||
8 | * Redistribution and use in source and binary forms, with or without | ||
9 | * modification, are permitted provided that the following conditions | ||
10 | * are met: | ||
11 | * 1. Redistributions of source code must retain the above copyright | ||
12 | * notice, this list of conditions and the following disclaimer. | ||
13 | * 2. Redistributions in binary form must reproduce the above copyright | ||
14 | * notice, this list of conditions and the following disclaimer in the | ||
15 | * documentation and/or other materials provided with the distribution. | ||
16 | * | ||
17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND | ||
18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
27 | * SUCH DAMAGE. | ||
28 | * | ||
29 | * citrus Id: wcslen.c,v 1.1 1999/12/29 21:47:45 tshiozak Exp | ||
30 | */ | ||
31 | |||
32 | #include <wchar.h> | ||
33 | |||
34 | size_t | ||
35 | wcsnlen(const wchar_t *s, size_t maxlen) | ||
36 | { | ||
37 | const wchar_t *p; | ||
38 | |||
39 | p = s; | ||
40 | while (maxlen-- && *p) | ||
41 | p++; | ||
42 | |||
43 | return p - s; | ||
44 | } | ||
45 | |||
diff --git a/src/lib/libc/string/wcspbrk.3 b/src/lib/libc/string/wcspbrk.3 deleted file mode 100644 index 602bfdc3d6..0000000000 --- a/src/lib/libc/string/wcspbrk.3 +++ /dev/null | |||
@@ -1,81 +0,0 @@ | |||
1 | .\" $OpenBSD: wcspbrk.3,v 1.3 2013/06/05 03:39:23 tedu Exp $ | ||
2 | .\" | ||
3 | .\" Copyright (c) 1990, 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 | .\" Chris Torek and the American National Standards Committee X3, | ||
8 | .\" on Information 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: June 5 2013 $ | ||
35 | .Dt WCSPBRK 3 | ||
36 | .Os | ||
37 | .Sh NAME | ||
38 | .Nm wcspbrk | ||
39 | .Nd locate multiple wide characters in a wide string | ||
40 | .Sh SYNOPSIS | ||
41 | .In wchar.h | ||
42 | .Ft wchar_t * | ||
43 | .Fn wcspbrk "const wchar_t *s" "const wchar_t *charset" | ||
44 | .Sh DESCRIPTION | ||
45 | The | ||
46 | .Fn wcspbrk | ||
47 | function locates in the wide string | ||
48 | .Fa s | ||
49 | the first occurrence of any wide character in the wide string | ||
50 | .Fa charset | ||
51 | and returns a pointer to this wide character. | ||
52 | If no wide characters from | ||
53 | .Fa charset | ||
54 | occur anywhere in | ||
55 | .Fa s , | ||
56 | .Fn wcspbrk | ||
57 | returns | ||
58 | .Dv NULL . | ||
59 | .Sh SEE ALSO | ||
60 | .Xr strpbrk 3 , | ||
61 | .Xr wcschr 3 , | ||
62 | .Xr wcscspn 3 , | ||
63 | .Xr wcsrchr 3 , | ||
64 | .Xr wcsspn 3 , | ||
65 | .Xr wcsstr 3 , | ||
66 | .Xr wcstok 3 , | ||
67 | .Xr wmemchr 3 | ||
68 | .Sh STANDARDS | ||
69 | The | ||
70 | .Fn wcspbrk | ||
71 | function conforms to | ||
72 | .St -isoC-99 | ||
73 | and was first introduced in | ||
74 | .St -isoC-amd1 . | ||
75 | .Sh HISTORY | ||
76 | The | ||
77 | .Fn wcspbrk | ||
78 | function was ported from | ||
79 | .Nx | ||
80 | and first appeared in | ||
81 | .Ox 3.8 . | ||
diff --git a/src/lib/libc/string/wcspbrk.c b/src/lib/libc/string/wcspbrk.c deleted file mode 100644 index f398fd92ab..0000000000 --- a/src/lib/libc/string/wcspbrk.c +++ /dev/null | |||
@@ -1,53 +0,0 @@ | |||
1 | /* $OpenBSD: wcspbrk.c,v 1.5 2015/10/01 02:32:07 guenther Exp $ */ | ||
2 | /* $NetBSD: wcspbrk.c,v 1.2 2001/01/03 14:29:37 lukem Exp $ */ | ||
3 | |||
4 | /*- | ||
5 | * Copyright (c)1999 Citrus Project, | ||
6 | * All rights reserved. | ||
7 | * | ||
8 | * Redistribution and use in source and binary forms, with or without | ||
9 | * modification, are permitted provided that the following conditions | ||
10 | * are met: | ||
11 | * 1. Redistributions of source code must retain the above copyright | ||
12 | * notice, this list of conditions and the following disclaimer. | ||
13 | * 2. Redistributions in binary form must reproduce the above copyright | ||
14 | * notice, this list of conditions and the following disclaimer in the | ||
15 | * documentation and/or other materials provided with the distribution. | ||
16 | * | ||
17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND | ||
18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
27 | * SUCH DAMAGE. | ||
28 | * | ||
29 | * citrus Id: wcspbrk.c,v 1.2 2000/12/21 05:07:25 itojun Exp | ||
30 | */ | ||
31 | |||
32 | #include <wchar.h> | ||
33 | |||
34 | wchar_t * | ||
35 | wcspbrk(const wchar_t *s, const wchar_t *set) | ||
36 | { | ||
37 | const wchar_t *p; | ||
38 | const wchar_t *q; | ||
39 | |||
40 | p = s; | ||
41 | while (*p) { | ||
42 | q = set; | ||
43 | while (*q) { | ||
44 | if (*p == *q) { | ||
45 | return (wchar_t *)p; | ||
46 | } | ||
47 | q++; | ||
48 | } | ||
49 | p++; | ||
50 | } | ||
51 | return NULL; | ||
52 | } | ||
53 | DEF_STRONG(wcspbrk); | ||
diff --git a/src/lib/libc/string/wcsrchr.3 b/src/lib/libc/string/wcsrchr.3 deleted file mode 100644 index d4a2e7cf78..0000000000 --- a/src/lib/libc/string/wcsrchr.3 +++ /dev/null | |||
@@ -1,85 +0,0 @@ | |||
1 | .\" $OpenBSD: wcsrchr.3,v 1.3 2013/06/05 03:39:23 tedu Exp $ | ||
2 | .\" | ||
3 | .\" Copyright (c) 1990, 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 | .\" Chris Torek and the American National Standards Committee X3, | ||
8 | .\" on Information 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: June 5 2013 $ | ||
35 | .Dt WCSRCHR 3 | ||
36 | .Os | ||
37 | .Sh NAME | ||
38 | .Nm wcsrchr | ||
39 | .Nd locate last occurrence of a wide character in a wide string | ||
40 | .Sh SYNOPSIS | ||
41 | .In wchar.h | ||
42 | .Ft wchar_t * | ||
43 | .Fn wcsrchr "const wchar_t *s" "wchar_t c" | ||
44 | .Sh DESCRIPTION | ||
45 | The | ||
46 | .Fn wcsrchr | ||
47 | function locates the last occurrence of the wide character | ||
48 | .Fa c | ||
49 | in the wide string | ||
50 | .Fa s . | ||
51 | The terminating null wide character is considered part of the wide string. | ||
52 | If | ||
53 | .Fa c | ||
54 | is the null wide character (L'\e0'), | ||
55 | .Fn wcsrchr | ||
56 | locates the terminating null wide character. | ||
57 | .Sh RETURN VALUES | ||
58 | The | ||
59 | .Fn wcsrchr | ||
60 | function returns a pointer to the located wide character or | ||
61 | .Dv NULL | ||
62 | if the wide character does not appear in the wide string. | ||
63 | .Sh SEE ALSO | ||
64 | .Xr strrchr 3 , | ||
65 | .Xr wcschr 3 , | ||
66 | .Xr wcscspn 3 , | ||
67 | .Xr wcspbrk 3 , | ||
68 | .Xr wcsspn 3 , | ||
69 | .Xr wcsstr 3 , | ||
70 | .Xr wcstok 3 , | ||
71 | .Xr wmemchr 3 | ||
72 | .Sh STANDARDS | ||
73 | The | ||
74 | .Fn wcsrchr | ||
75 | function conforms to | ||
76 | .St -isoC-99 | ||
77 | and was first introduced in | ||
78 | .St -isoC-amd1 . | ||
79 | .Sh HISTORY | ||
80 | The | ||
81 | .Fn wcsrchr | ||
82 | function was ported from | ||
83 | .Nx | ||
84 | and first appeared in | ||
85 | .Ox 3.8 . | ||
diff --git a/src/lib/libc/string/wcsrchr.c b/src/lib/libc/string/wcsrchr.c deleted file mode 100644 index aa936de508..0000000000 --- a/src/lib/libc/string/wcsrchr.c +++ /dev/null | |||
@@ -1,50 +0,0 @@ | |||
1 | /* $OpenBSD: wcsrchr.c,v 1.5 2015/10/01 02:32:07 guenther Exp $ */ | ||
2 | /* $NetBSD: wcsrchr.c,v 1.2 2001/01/03 14:29:37 lukem Exp $ */ | ||
3 | |||
4 | /*- | ||
5 | * Copyright (c)1999 Citrus Project, | ||
6 | * All rights reserved. | ||
7 | * | ||
8 | * Redistribution and use in source and binary forms, with or without | ||
9 | * modification, are permitted provided that the following conditions | ||
10 | * are met: | ||
11 | * 1. Redistributions of source code must retain the above copyright | ||
12 | * notice, this list of conditions and the following disclaimer. | ||
13 | * 2. Redistributions in binary form must reproduce the above copyright | ||
14 | * notice, this list of conditions and the following disclaimer in the | ||
15 | * documentation and/or other materials provided with the distribution. | ||
16 | * | ||
17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND | ||
18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
27 | * SUCH DAMAGE. | ||
28 | * | ||
29 | * citrus Id: wcsrchr.c,v 1.2 2000/12/21 05:07:25 itojun Exp | ||
30 | */ | ||
31 | |||
32 | #include <wchar.h> | ||
33 | |||
34 | wchar_t * | ||
35 | wcsrchr(const wchar_t *s, wchar_t c) | ||
36 | { | ||
37 | const wchar_t *p; | ||
38 | |||
39 | p = s; | ||
40 | while (*p) | ||
41 | p++; | ||
42 | while (s <= p) { | ||
43 | if (*p == c) { | ||
44 | return (wchar_t *)p; | ||
45 | } | ||
46 | p--; | ||
47 | } | ||
48 | return NULL; | ||
49 | } | ||
50 | DEF_STRONG(wcsrchr); | ||
diff --git a/src/lib/libc/string/wcsspn.3 b/src/lib/libc/string/wcsspn.3 deleted file mode 100644 index 3be82344dd..0000000000 --- a/src/lib/libc/string/wcsspn.3 +++ /dev/null | |||
@@ -1,79 +0,0 @@ | |||
1 | .\" $OpenBSD: wcsspn.3,v 1.3 2013/06/05 03:39:23 tedu Exp $ | ||
2 | .\" | ||
3 | .\" Copyright (c) 1990, 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 | .\" Chris Torek and the American National Standards Committee X3, | ||
8 | .\" on Information 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: June 5 2013 $ | ||
35 | .Dt WCSSPN 3 | ||
36 | .Os | ||
37 | .Sh NAME | ||
38 | .Nm wcsspn | ||
39 | .Nd span a wide string | ||
40 | .Sh SYNOPSIS | ||
41 | .In wchar.h | ||
42 | .Ft size_t | ||
43 | .Fn wcsspn "const wchar_t *s" "const wchar_t *charset" | ||
44 | .Sh DESCRIPTION | ||
45 | The | ||
46 | .Fn wcsspn | ||
47 | function spans the initial part of the wide string | ||
48 | .Fa s | ||
49 | as long as the wide characters from | ||
50 | .Fa s | ||
51 | occur in the wide string | ||
52 | .Fa charset . | ||
53 | .Sh RETURN VALUES | ||
54 | The | ||
55 | .Fn wcsspn | ||
56 | function returns the number of wide characters spanned. | ||
57 | .Sh SEE ALSO | ||
58 | .Xr strspn 3 , | ||
59 | .Xr wcschr 3 , | ||
60 | .Xr wcscspn 3 , | ||
61 | .Xr wcspbrk 3 , | ||
62 | .Xr wcsrchr 3 , | ||
63 | .Xr wcsstr 3 , | ||
64 | .Xr wcstok 3 , | ||
65 | .Xr wmemchr 3 | ||
66 | .Sh STANDARDS | ||
67 | The | ||
68 | .Fn wcsspn | ||
69 | function conforms to | ||
70 | .St -isoC-99 | ||
71 | and was first introduced in | ||
72 | .St -isoC-amd1 . | ||
73 | .Sh HISTORY | ||
74 | The | ||
75 | .Fn wcsspn | ||
76 | function was ported from | ||
77 | .Nx | ||
78 | and first appeared in | ||
79 | .Ox 3.8 . | ||
diff --git a/src/lib/libc/string/wcsspn.c b/src/lib/libc/string/wcsspn.c deleted file mode 100644 index a3f28e3a49..0000000000 --- a/src/lib/libc/string/wcsspn.c +++ /dev/null | |||
@@ -1,56 +0,0 @@ | |||
1 | /* $OpenBSD: wcsspn.c,v 1.4 2015/09/12 16:23:14 guenther Exp $ */ | ||
2 | /* $NetBSD: wcsspn.c,v 1.3 2001/09/21 16:09:15 yamt Exp $ */ | ||
3 | |||
4 | /*- | ||
5 | * Copyright (c)1999,2001 Citrus Project, | ||
6 | * All rights reserved. | ||
7 | * | ||
8 | * Redistribution and use in source and binary forms, with or without | ||
9 | * modification, are permitted provided that the following conditions | ||
10 | * are met: | ||
11 | * 1. Redistributions of source code must retain the above copyright | ||
12 | * notice, this list of conditions and the following disclaimer. | ||
13 | * 2. Redistributions in binary form must reproduce the above copyright | ||
14 | * notice, this list of conditions and the following disclaimer in the | ||
15 | * documentation and/or other materials provided with the distribution. | ||
16 | * | ||
17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND | ||
18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
27 | * SUCH DAMAGE. | ||
28 | * | ||
29 | * $Citrus: xpg4dl/FreeBSD/lib/libc/string/wcsspn.c,v 1.3 2001/09/21 16:06:43 yamt Exp $ | ||
30 | */ | ||
31 | |||
32 | #include <wchar.h> | ||
33 | |||
34 | size_t | ||
35 | wcsspn(const wchar_t *s, const wchar_t *set) | ||
36 | { | ||
37 | const wchar_t *p; | ||
38 | const wchar_t *q; | ||
39 | |||
40 | p = s; | ||
41 | while (*p) { | ||
42 | q = set; | ||
43 | while (*q) { | ||
44 | if (*p == *q) | ||
45 | break; | ||
46 | q++; | ||
47 | } | ||
48 | if (!*q) | ||
49 | goto done; | ||
50 | p++; | ||
51 | } | ||
52 | |||
53 | done: | ||
54 | return (p - s); | ||
55 | } | ||
56 | DEF_STRONG(wcsspn); | ||
diff --git a/src/lib/libc/string/wcsstr.3 b/src/lib/libc/string/wcsstr.3 deleted file mode 100644 index 203a76ded3..0000000000 --- a/src/lib/libc/string/wcsstr.3 +++ /dev/null | |||
@@ -1,88 +0,0 @@ | |||
1 | .\" $OpenBSD: wcsstr.3,v 1.3 2013/06/05 03:39:23 tedu Exp $ | ||
2 | .\" | ||
3 | .\" Copyright (c) 1990, 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 | .\" Chris Torek and the American National Standards Committee X3, | ||
8 | .\" on Information 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: June 5 2013 $ | ||
35 | .Dt WCSSTR 3 | ||
36 | .Os | ||
37 | .Sh NAME | ||
38 | .Nm wcsstr | ||
39 | .Nd locate a wide substring in a wide string | ||
40 | .Sh SYNOPSIS | ||
41 | .In wchar.h | ||
42 | .Ft wchar_t * | ||
43 | .Fn wcsstr "const wchar_t *big" "const wchar_t *little" | ||
44 | .Sh DESCRIPTION | ||
45 | The | ||
46 | .Fn wcsstr | ||
47 | function locates the first occurrence of the wide string | ||
48 | .Fa little | ||
49 | in the wide string | ||
50 | .Fa big . | ||
51 | .Pp | ||
52 | If | ||
53 | .Fa little | ||
54 | is an empty wide string, | ||
55 | .Fa big | ||
56 | is returned; | ||
57 | if | ||
58 | .Fa little | ||
59 | occurs nowhere in | ||
60 | .Fa big , | ||
61 | .Dv NULL | ||
62 | is returned; | ||
63 | otherwise a pointer to the first wide character of the first occurrence of | ||
64 | .Fa little | ||
65 | is returned. | ||
66 | .Sh SEE ALSO | ||
67 | .Xr strstr 3 , | ||
68 | .Xr wcschr 3 , | ||
69 | .Xr wcscspn 3 , | ||
70 | .Xr wcspbrk 3 , | ||
71 | .Xr wcsrchr 3 , | ||
72 | .Xr wcsspn 3 , | ||
73 | .Xr wcstok 3 , | ||
74 | .Xr wmemchr 3 | ||
75 | .Sh STANDARDS | ||
76 | The | ||
77 | .Fn wcsstr | ||
78 | function conforms to | ||
79 | .St -isoC-99 | ||
80 | and was first introduced in | ||
81 | .St -isoC-amd1 . | ||
82 | .Sh HISTORY | ||
83 | The | ||
84 | .Fn wcsstr | ||
85 | function was ported from | ||
86 | .Nx | ||
87 | and first appeared in | ||
88 | .Ox 3.8 . | ||
diff --git a/src/lib/libc/string/wcsstr.c b/src/lib/libc/string/wcsstr.c deleted file mode 100644 index 6a7b0dac4a..0000000000 --- a/src/lib/libc/string/wcsstr.c +++ /dev/null | |||
@@ -1,71 +0,0 @@ | |||
1 | /* $OpenBSD: wcsstr.c,v 1.5 2015/10/01 02:32:07 guenther Exp $ */ | ||
2 | /* $NetBSD: wcsstr.c,v 1.3 2003/03/05 20:18:17 tshiozak Exp $ */ | ||
3 | |||
4 | /*- | ||
5 | * Copyright (c)1999 Citrus Project, | ||
6 | * All rights reserved. | ||
7 | * | ||
8 | * Redistribution and use in source and binary forms, with or without | ||
9 | * modification, are permitted provided that the following conditions | ||
10 | * are met: | ||
11 | * 1. Redistributions of source code must retain the above copyright | ||
12 | * notice, this list of conditions and the following disclaimer. | ||
13 | * 2. Redistributions in binary form must reproduce the above copyright | ||
14 | * notice, this list of conditions and the following disclaimer in the | ||
15 | * documentation and/or other materials provided with the distribution. | ||
16 | * | ||
17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND | ||
18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
27 | * SUCH DAMAGE. | ||
28 | * | ||
29 | * citrus Id: wcsstr.c,v 1.2 2000/12/21 05:07:25 itojun Exp | ||
30 | */ | ||
31 | |||
32 | #include <wchar.h> | ||
33 | |||
34 | wchar_t * | ||
35 | #ifdef WCSWCS | ||
36 | wcswcs(const wchar_t *big, const wchar_t *little) | ||
37 | #else | ||
38 | wcsstr(const wchar_t *big, const wchar_t *little) | ||
39 | #endif | ||
40 | { | ||
41 | const wchar_t *p; | ||
42 | const wchar_t *q; | ||
43 | const wchar_t *r; | ||
44 | |||
45 | if (!*little) { | ||
46 | return (wchar_t *)big; | ||
47 | } | ||
48 | if (wcslen(big) < wcslen(little)) | ||
49 | return NULL; | ||
50 | |||
51 | p = big; | ||
52 | q = little; | ||
53 | while (*p) { | ||
54 | q = little; | ||
55 | r = p; | ||
56 | while (*q) { | ||
57 | if (*r != *q) | ||
58 | break; | ||
59 | q++; | ||
60 | r++; | ||
61 | } | ||
62 | if (!*q) { | ||
63 | return (wchar_t *)p; | ||
64 | } | ||
65 | p++; | ||
66 | } | ||
67 | return NULL; | ||
68 | } | ||
69 | #ifndef WCSWCS | ||
70 | DEF_STRONG(wcsstr); | ||
71 | #endif | ||
diff --git a/src/lib/libc/string/wcstok.3 b/src/lib/libc/string/wcstok.3 deleted file mode 100644 index 33ba1318a1..0000000000 --- a/src/lib/libc/string/wcstok.3 +++ /dev/null | |||
@@ -1,151 +0,0 @@ | |||
1 | .\" $OpenBSD: wcstok.3,v 1.7 2011/07/25 00:38:53 schwarze Exp $ | ||
2 | .\" | ||
3 | .\" $NetBSD: wcstok.3,v 1.3 2003/09/08 17:54:33 wiz Exp $ | ||
4 | .\" | ||
5 | .\" Copyright (c) 1998 Softweyr LLC. All rights reserved. | ||
6 | .\" | ||
7 | .\" strtok_r, from Berkeley strtok | ||
8 | .\" Oct 13, 1998 by Wes Peters <wes@softweyr.com> | ||
9 | .\" | ||
10 | .\" Copyright (c) 1988, 1991, 1993 | ||
11 | .\" The Regents of the University of California. All rights reserved. | ||
12 | .\" | ||
13 | .\" This code is derived from software contributed to Berkeley by | ||
14 | .\" the American National Standards Committee X3, on Information | ||
15 | .\" Processing Systems. | ||
16 | .\" | ||
17 | .\" Redistribution and use in source and binary forms, with or without | ||
18 | .\" modification, are permitted provided that the following conditions | ||
19 | .\" are met: | ||
20 | .\" | ||
21 | .\" 1. Redistributions of source code must retain the above copyright | ||
22 | .\" notices, this list of conditions and the following disclaimer. | ||
23 | .\" | ||
24 | .\" 2. Redistributions in binary form must reproduce the above | ||
25 | .\" copyright notices, this list of conditions and the following | ||
26 | .\" disclaimer in the documentation and/or other materials provided | ||
27 | .\" with the distribution. | ||
28 | .\" | ||
29 | .\" 3. All advertising materials mentioning features or use of this | ||
30 | .\" software must display the following acknowledgement: | ||
31 | .\" | ||
32 | .\" This product includes software developed by Softweyr LLC, the | ||
33 | .\" University of California, Berkeley, and its contributors. | ||
34 | .\" | ||
35 | .\" 4. Neither the name of Softweyr LLC, the University nor the names | ||
36 | .\" of its contributors may be used to endorse or promote products | ||
37 | .\" derived from this software without specific prior written | ||
38 | .\" permission. | ||
39 | .\" | ||
40 | .\" THIS SOFTWARE IS PROVIDED BY SOFTWEYR LLC, THE REGENTS AND | ||
41 | .\" CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, | ||
42 | .\" INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | ||
43 | .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
44 | .\" DISCLAIMED. IN NO EVENT SHALL SOFTWEYR LLC, THE REGENTS, OR | ||
45 | .\" CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
46 | .\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
47 | .\" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | ||
48 | .\" USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
49 | .\" ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | ||
50 | .\" OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT | ||
51 | .\" OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
52 | .\" SUCH DAMAGE. | ||
53 | .\" | ||
54 | .\" Original version ID: | ||
55 | .\" FreeBSD: src/lib/libc/string/wcstok.3,v 1.4 2002/10/15 09:49:54 tjr Exp | ||
56 | .\" | ||
57 | .Dd $Mdocdate: July 25 2011 $ | ||
58 | .Dt WCSTOK 3 | ||
59 | .Os | ||
60 | .Sh NAME | ||
61 | .Nm wcstok | ||
62 | .Nd split wide-character string into tokens | ||
63 | .Sh SYNOPSIS | ||
64 | .In wchar.h | ||
65 | .Ft wchar_t * | ||
66 | .Fn wcstok "wchar_t * restrict str" "const wchar_t * restrict sep" "wchar_t ** restrict last" | ||
67 | .Sh DESCRIPTION | ||
68 | The | ||
69 | .Fn wcstok | ||
70 | function | ||
71 | is used to isolate sequential tokens in a NUL-terminated wide-character | ||
72 | string, | ||
73 | .Fa str . | ||
74 | These tokens are separated in the string by at least one of the | ||
75 | characters in | ||
76 | .Fa sep . | ||
77 | The first time that | ||
78 | .Fn wcstok | ||
79 | is called, | ||
80 | .Fa str | ||
81 | should be specified; subsequent calls, wishing to obtain further tokens | ||
82 | from the same string, should pass a null pointer instead. | ||
83 | The separator string, | ||
84 | .Fa sep , | ||
85 | must be supplied each time, and may change between calls. | ||
86 | The context pointer | ||
87 | .Fa last | ||
88 | must be provided on each call. | ||
89 | .Pp | ||
90 | The | ||
91 | .Fn wcstok | ||
92 | function is the wide-character counterpart of the | ||
93 | .Xr strtok_r 3 | ||
94 | function. | ||
95 | .Pp | ||
96 | Since | ||
97 | .Fn wcstok | ||
98 | modifies the string, | ||
99 | .Fa str | ||
100 | should not point to an area in the initialized data segment. | ||
101 | .Sh RETURN VALUES | ||
102 | The | ||
103 | .Fn wcstok | ||
104 | function | ||
105 | returns a pointer to the beginning of each subsequent token in the string, | ||
106 | after replacing the token itself with a NUL wide character (L'\e0'). | ||
107 | When no more tokens remain, a null pointer is returned. | ||
108 | .Sh EXAMPLES | ||
109 | The following code fragment splits a wide-character string on | ||
110 | .Tn ASCII | ||
111 | space, tab, and newline characters and writes the tokens to | ||
112 | standard output: | ||
113 | .Bd -literal -offset indent | ||
114 | const wchar_t *seps = L" \et\en"; | ||
115 | wchar_t *last, *tok, text[] = L" \enone\ettwo\et\etthree \en"; | ||
116 | |||
117 | for (tok = wcstok(text, seps, &last); tok != NULL; | ||
118 | tok = wcstok(NULL, seps, &last)) | ||
119 | wprintf(L"%ls\en", tok); | ||
120 | .Ed | ||
121 | .Sh SEE ALSO | ||
122 | .Xr strtok 3 , | ||
123 | .Xr wcschr 3 , | ||
124 | .Xr wcscspn 3 , | ||
125 | .Xr wcspbrk 3 , | ||
126 | .Xr wcsrchr 3 , | ||
127 | .Xr wcsspn 3 , | ||
128 | .Xr wcsstr 3 , | ||
129 | .Xr wmemchr 3 | ||
130 | .Sh STANDARDS | ||
131 | The | ||
132 | .Fn wcstok | ||
133 | function | ||
134 | conforms to | ||
135 | .St -isoC-99 . | ||
136 | .Sh HISTORY | ||
137 | The | ||
138 | .Fn wcstok | ||
139 | function was ported from | ||
140 | .Nx | ||
141 | and first appeared in | ||
142 | .Ox 3.8 . | ||
143 | .Pp | ||
144 | Some early implementations of | ||
145 | .Fn wcstok | ||
146 | omit the | ||
147 | context pointer argument, | ||
148 | .Fa last , | ||
149 | and maintain state across calls in a static variable like | ||
150 | .Xr strtok 3 | ||
151 | does. | ||
diff --git a/src/lib/libc/string/wcstok.c b/src/lib/libc/string/wcstok.c deleted file mode 100644 index bc1ac3e8cb..0000000000 --- a/src/lib/libc/string/wcstok.c +++ /dev/null | |||
@@ -1,93 +0,0 @@ | |||
1 | /* $OpenBSD: wcstok.c,v 1.3 2005/08/08 08:05:37 espie Exp $ */ | ||
2 | /* $NetBSD: wcstok.c,v 1.3 2003/07/10 08:50:48 tshiozak Exp $ */ | ||
3 | |||
4 | /*- | ||
5 | * Copyright (c) 1998 Softweyr LLC. All rights reserved. | ||
6 | * | ||
7 | * strtok_r, from Berkeley strtok | ||
8 | * Oct 13, 1998 by Wes Peters <wes@softweyr.com> | ||
9 | * | ||
10 | * Copyright (c) 1988, 1993 | ||
11 | * The Regents of the University of California. All rights reserved. | ||
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 | * 1. Redistributions of source code must retain the above copyright | ||
17 | * notices, this list of conditions and the following disclaimer. | ||
18 | * 2. Redistributions in binary form must reproduce the above copyright | ||
19 | * notices, this list of conditions and the following disclaimer in the | ||
20 | * documentation and/or other materials provided with the distribution. | ||
21 | * 3. All advertising materials mentioning features or use of this software | ||
22 | * must display the following acknowledgement: | ||
23 | * This product includes software developed by Softweyr LLC, the | ||
24 | * University of California, Berkeley, and its contributors. | ||
25 | * 4. Neither the name of the University nor the names of its contributors | ||
26 | * may be used to endorse or promote products derived from this software | ||
27 | * without specific prior written permission. | ||
28 | * | ||
29 | * THIS SOFTWARE IS PROVIDED BY SOFTWEYR LLC, THE REGENTS AND CONTRIBUTORS | ||
30 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
31 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A | ||
32 | * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SOFTWEYR LLC, THE | ||
33 | * REGENTS, OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
34 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED | ||
35 | * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | ||
36 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | ||
37 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | ||
38 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
39 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
40 | * | ||
41 | * Original version ID: | ||
42 | * FreeBSD: src/lib/libc/string/wcstok.c,v 1.1 2002/09/07 08:16:57 tjr Exp | ||
43 | */ | ||
44 | |||
45 | #include <wchar.h> | ||
46 | |||
47 | wchar_t * | ||
48 | wcstok(wchar_t * __restrict s, const wchar_t * __restrict delim, | ||
49 | wchar_t ** __restrict last) | ||
50 | { | ||
51 | const wchar_t *spanp; | ||
52 | wchar_t c, sc; | ||
53 | wchar_t *tok; | ||
54 | |||
55 | if (s == NULL && (s = *last) == NULL) | ||
56 | return (NULL); | ||
57 | |||
58 | /* | ||
59 | * Skip (span) leading delimiters (s += wcsspn(s, delim), sort of). | ||
60 | */ | ||
61 | cont: | ||
62 | c = *s++; | ||
63 | for (spanp = delim; (sc = *spanp++) != L'\0';) { | ||
64 | if (c == sc) | ||
65 | goto cont; | ||
66 | } | ||
67 | |||
68 | if (c == L'\0') { /* no non-delimiter characters */ | ||
69 | *last = NULL; | ||
70 | return (NULL); | ||
71 | } | ||
72 | tok = s - 1; | ||
73 | |||
74 | /* | ||
75 | * Scan token (scan for delimiters: s += wcscspn(s, delim), sort of). | ||
76 | * Note that delim must have one NUL; we stop if we see that, too. | ||
77 | */ | ||
78 | for (;;) { | ||
79 | c = *s++; | ||
80 | spanp = delim; | ||
81 | do { | ||
82 | if ((sc = *spanp++) == c) { | ||
83 | if (c == L'\0') | ||
84 | s = NULL; | ||
85 | else | ||
86 | s[-1] = L'\0'; | ||
87 | *last = s; | ||
88 | return (tok); | ||
89 | } | ||
90 | } while (sc != L'\0'); | ||
91 | } | ||
92 | /* NOTREACHED */ | ||
93 | } | ||
diff --git a/src/lib/libc/string/wcswcs.c b/src/lib/libc/string/wcswcs.c deleted file mode 100644 index bd35605547..0000000000 --- a/src/lib/libc/string/wcswcs.c +++ /dev/null | |||
@@ -1,5 +0,0 @@ | |||
1 | /* $OpenBSD: wcswcs.c,v 1.1 2005/04/13 16:35:58 espie Exp $ */ | ||
2 | /* $NetBSD: wcswcs.c,v 1.1 2003/03/05 20:18:17 tshiozak Exp $ */ | ||
3 | |||
4 | #define WCSWCS | ||
5 | #include "wcsstr.c" | ||
diff --git a/src/lib/libc/string/wcswidth.3 b/src/lib/libc/string/wcswidth.3 deleted file mode 100644 index a2a5b2df86..0000000000 --- a/src/lib/libc/string/wcswidth.3 +++ /dev/null | |||
@@ -1,69 +0,0 @@ | |||
1 | .\" $OpenBSD: wcswidth.3,v 1.2 2011/07/25 00:38:53 schwarze Exp $ | ||
2 | .\" | ||
3 | .\" Copyright (c) 2002 Tim J. Robbins | ||
4 | .\" All rights reserved. | ||
5 | .\" | ||
6 | .\" Redistribution and use in source and binary forms, with or without | ||
7 | .\" modification, are permitted provided that the following conditions | ||
8 | .\" are met: | ||
9 | .\" 1. Redistributions of source code must retain the above copyright | ||
10 | .\" notice, this list of conditions and the following disclaimer. | ||
11 | .\" 2. Redistributions in binary form must reproduce the above copyright | ||
12 | .\" notice, this list of conditions and the following disclaimer in the | ||
13 | .\" documentation and/or other materials provided with the distribution. | ||
14 | .\" | ||
15 | .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND | ||
16 | .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
17 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
18 | .\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
19 | .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
20 | .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
21 | .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
22 | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
23 | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
24 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
25 | .\" SUCH DAMAGE. | ||
26 | .\" | ||
27 | .Dd $Mdocdate: July 25 2011 $ | ||
28 | .Dt WCSWIDTH 3 | ||
29 | .Os | ||
30 | .Sh NAME | ||
31 | .Nm wcswidth | ||
32 | .Nd number of column positions in wide-character string | ||
33 | .Sh SYNOPSIS | ||
34 | .In wchar.h | ||
35 | .Ft int | ||
36 | .Fn wcswidth "const wchar_t *pwcs" "size_t n" | ||
37 | .Sh DESCRIPTION | ||
38 | The | ||
39 | .Fn wcswidth | ||
40 | function determines the number of column positions required for the first | ||
41 | .Fa n | ||
42 | characters of | ||
43 | .Fa pwcs , | ||
44 | or until a null wide character (L'\e0') is encountered. | ||
45 | .Sh RETURN VALUES | ||
46 | The | ||
47 | .Fn wcswidth | ||
48 | function returns 0 if | ||
49 | .Fa pwcs | ||
50 | is an empty string (L""), | ||
51 | \-1 if a non-printing wide character is encountered, | ||
52 | otherwise it returns the number of column positions occupied. | ||
53 | .Sh SEE ALSO | ||
54 | .Xr iswprint 3 , | ||
55 | .Xr strlen 3 , | ||
56 | .Xr wcslen 3 , | ||
57 | .Xr wcwidth 3 | ||
58 | .Sh STANDARDS | ||
59 | The | ||
60 | .Fn wcswidth | ||
61 | function conforms to | ||
62 | .St -p1003.1-2001 . | ||
63 | .Sh HISTORY | ||
64 | The | ||
65 | .Fn wcswidth | ||
66 | function was ported from | ||
67 | .Nx | ||
68 | and first appeared in | ||
69 | .Ox 3.8 . | ||
diff --git a/src/lib/libc/string/wcswidth.c b/src/lib/libc/string/wcswidth.c deleted file mode 100644 index 9f003f96c7..0000000000 --- a/src/lib/libc/string/wcswidth.c +++ /dev/null | |||
@@ -1,51 +0,0 @@ | |||
1 | /* $OpenBSD: wcswidth.c,v 1.5 2015/09/12 16:23:14 guenther Exp $ */ | ||
2 | /* $NetBSD: wcswidth.c,v 1.2 2001/01/03 14:29:37 lukem Exp $ */ | ||
3 | |||
4 | /*- | ||
5 | * Copyright (c)1999 Citrus Project, | ||
6 | * All rights reserved. | ||
7 | * | ||
8 | * Redistribution and use in source and binary forms, with or without | ||
9 | * modification, are permitted provided that the following conditions | ||
10 | * are met: | ||
11 | * 1. Redistributions of source code must retain the above copyright | ||
12 | * notice, this list of conditions and the following disclaimer. | ||
13 | * 2. Redistributions in binary form must reproduce the above copyright | ||
14 | * notice, this list of conditions and the following disclaimer in the | ||
15 | * documentation and/or other materials provided with the distribution. | ||
16 | * | ||
17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND | ||
18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
27 | * SUCH DAMAGE. | ||
28 | * | ||
29 | * citrus Id: wcswidth.c,v 1.1 1999/12/29 21:47:45 tshiozak Exp | ||
30 | */ | ||
31 | |||
32 | #include <wchar.h> | ||
33 | |||
34 | int | ||
35 | wcswidth(const wchar_t *s, size_t n) | ||
36 | { | ||
37 | int w, q; | ||
38 | |||
39 | w = 0; | ||
40 | while (n && *s) { | ||
41 | q = wcwidth(*s); | ||
42 | if (q == -1) | ||
43 | return (-1); | ||
44 | w += q; | ||
45 | s++; | ||
46 | n--; | ||
47 | } | ||
48 | |||
49 | return w; | ||
50 | } | ||
51 | DEF_WEAK(wcswidth); | ||
diff --git a/src/lib/libc/string/wmemchr.3 b/src/lib/libc/string/wmemchr.3 deleted file mode 100644 index 17fbc9dbc5..0000000000 --- a/src/lib/libc/string/wmemchr.3 +++ /dev/null | |||
@@ -1,81 +0,0 @@ | |||
1 | .\" $OpenBSD: wmemchr.3,v 1.10 2013/06/05 03:39:23 tedu Exp $ | ||
2 | .\" | ||
3 | .\" Copyright (c) 1990, 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 | .\" Chris Torek and the American National Standards Committee X3, | ||
8 | .\" on Information 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: June 5 2013 $ | ||
35 | .Dt WMEMCHR 3 | ||
36 | .Os | ||
37 | .Sh NAME | ||
38 | .Nm wmemchr | ||
39 | .Nd locate wide character in wide string | ||
40 | .Sh SYNOPSIS | ||
41 | .In wchar.h | ||
42 | .Ft wchar_t * | ||
43 | .Fn wmemchr "const wchar_t *b" "wchar_t c" "size_t len" | ||
44 | .Sh DESCRIPTION | ||
45 | The | ||
46 | .Fn wmemchr | ||
47 | function locates the first occurrence of | ||
48 | .Fa c | ||
49 | in wide string | ||
50 | .Fa b . | ||
51 | .Sh RETURN VALUES | ||
52 | The | ||
53 | .Fn wmemchr | ||
54 | function returns a pointer to the wide character located, or | ||
55 | .Dv NULL | ||
56 | if no such wide character exists within | ||
57 | .Fa len | ||
58 | wide characters. | ||
59 | .Sh SEE ALSO | ||
60 | .Xr memchr 3 , | ||
61 | .Xr wcschr 3 , | ||
62 | .Xr wcscspn 3 , | ||
63 | .Xr wcspbrk 3 , | ||
64 | .Xr wcsrchr 3 , | ||
65 | .Xr wcsspn 3 , | ||
66 | .Xr wcsstr 3 , | ||
67 | .Xr wcstok 3 | ||
68 | .Sh STANDARDS | ||
69 | The | ||
70 | .Fn wmemchr | ||
71 | function conforms to | ||
72 | .St -isoC-99 | ||
73 | and was first introduced in | ||
74 | .St -isoC-amd1 . | ||
75 | .Sh HISTORY | ||
76 | The | ||
77 | .Fn wmemchr | ||
78 | function was ported from | ||
79 | .Nx | ||
80 | and first appeared in | ||
81 | .Ox 3.8 . | ||
diff --git a/src/lib/libc/string/wmemchr.c b/src/lib/libc/string/wmemchr.c deleted file mode 100644 index 556a0b35cc..0000000000 --- a/src/lib/libc/string/wmemchr.c +++ /dev/null | |||
@@ -1,47 +0,0 @@ | |||
1 | /* $OpenBSD: wmemchr.c,v 1.5 2015/10/01 02:32:07 guenther Exp $ */ | ||
2 | /* $NetBSD: wmemchr.c,v 1.2 2001/01/03 14:29:37 lukem Exp $ */ | ||
3 | |||
4 | /*- | ||
5 | * Copyright (c)1999 Citrus Project, | ||
6 | * All rights reserved. | ||
7 | * | ||
8 | * Redistribution and use in source and binary forms, with or without | ||
9 | * modification, are permitted provided that the following conditions | ||
10 | * are met: | ||
11 | * 1. Redistributions of source code must retain the above copyright | ||
12 | * notice, this list of conditions and the following disclaimer. | ||
13 | * 2. Redistributions in binary form must reproduce the above copyright | ||
14 | * notice, this list of conditions and the following disclaimer in the | ||
15 | * documentation and/or other materials provided with the distribution. | ||
16 | * | ||
17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND | ||
18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
27 | * SUCH DAMAGE. | ||
28 | * | ||
29 | * citrus Id: wmemchr.c,v 1.2 2000/12/20 14:08:31 itojun Exp | ||
30 | */ | ||
31 | |||
32 | #include <wchar.h> | ||
33 | |||
34 | wchar_t * | ||
35 | wmemchr(const wchar_t *s, wchar_t c, size_t n) | ||
36 | { | ||
37 | size_t i; | ||
38 | |||
39 | for (i = 0; i < n; i++) { | ||
40 | if (*s == c) { | ||
41 | return (wchar_t *)s; | ||
42 | } | ||
43 | s++; | ||
44 | } | ||
45 | return NULL; | ||
46 | } | ||
47 | DEF_STRONG(wmemchr); | ||
diff --git a/src/lib/libc/string/wmemcmp.3 b/src/lib/libc/string/wmemcmp.3 deleted file mode 100644 index bd8ddfd120..0000000000 --- a/src/lib/libc/string/wmemcmp.3 +++ /dev/null | |||
@@ -1,78 +0,0 @@ | |||
1 | .\" $OpenBSD: wmemcmp.3,v 1.3 2013/06/05 03:39:23 tedu Exp $ | ||
2 | .\" | ||
3 | .\" Copyright (c) 1990, 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 | .\" Chris Torek and the American National Standards Committee X3, | ||
8 | .\" on Information 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: June 5 2013 $ | ||
35 | .Dt WMEMCMP 3 | ||
36 | .Os | ||
37 | .Sh NAME | ||
38 | .Nm wmemcmp | ||
39 | .Nd compare wide strings | ||
40 | .Sh SYNOPSIS | ||
41 | .In wchar.h | ||
42 | .Ft int | ||
43 | .Fn wmemcmp "const wchar_t *s1" "const wchar_t *s2" "size_t len" | ||
44 | .Sh DESCRIPTION | ||
45 | The | ||
46 | .Fn wmemcmp | ||
47 | function compares the wide string | ||
48 | .Fa s1 | ||
49 | against the wide string | ||
50 | .Fa s2 . | ||
51 | Both wide strings are assumed to be | ||
52 | .Fa len | ||
53 | wide characters long. | ||
54 | .Sh RETURN VALUES | ||
55 | The | ||
56 | .Fn wmemcmp | ||
57 | function returns zero if the two wide strings are identical, | ||
58 | otherwise the difference between the first two differing wide characters is | ||
59 | returned. | ||
60 | Zero-length wide strings are always identical. | ||
61 | .Sh SEE ALSO | ||
62 | .Xr memcmp 3 , | ||
63 | .Xr wcscasecmp 3 , | ||
64 | .Xr wcscmp 3 | ||
65 | .Sh STANDARDS | ||
66 | The | ||
67 | .Fn wmemcmp | ||
68 | function conforms to | ||
69 | .St -isoC-99 | ||
70 | and was first introduced in | ||
71 | .St -isoC-amd1 . | ||
72 | .Sh HISTORY | ||
73 | The | ||
74 | .Fn wmemcmp | ||
75 | function was ported from | ||
76 | .Nx | ||
77 | and first appeared in | ||
78 | .Ox 3.8 . | ||
diff --git a/src/lib/libc/string/wmemcmp.c b/src/lib/libc/string/wmemcmp.c deleted file mode 100644 index 46617e29cf..0000000000 --- a/src/lib/libc/string/wmemcmp.c +++ /dev/null | |||
@@ -1,51 +0,0 @@ | |||
1 | /* $OpenBSD: wmemcmp.c,v 1.5 2015/09/12 16:23:14 guenther Exp $ */ | ||
2 | /* $NetBSD: wmemcmp.c,v 1.3 2003/04/06 18:33:23 tshiozak Exp $ */ | ||
3 | |||
4 | /*- | ||
5 | * Copyright (c)1999 Citrus Project, | ||
6 | * All rights reserved. | ||
7 | * | ||
8 | * Redistribution and use in source and binary forms, with or without | ||
9 | * modification, are permitted provided that the following conditions | ||
10 | * are met: | ||
11 | * 1. Redistributions of source code must retain the above copyright | ||
12 | * notice, this list of conditions and the following disclaimer. | ||
13 | * 2. Redistributions in binary form must reproduce the above copyright | ||
14 | * notice, this list of conditions and the following disclaimer in the | ||
15 | * documentation and/or other materials provided with the distribution. | ||
16 | * | ||
17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND | ||
18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
27 | * SUCH DAMAGE. | ||
28 | * | ||
29 | * citrus Id: wmemcmp.c,v 1.2 2000/12/20 14:08:31 itojun Exp | ||
30 | */ | ||
31 | |||
32 | #include <wchar.h> | ||
33 | #include "locale/runetype.h" | ||
34 | |||
35 | int | ||
36 | wmemcmp(const wchar_t *s1, const wchar_t *s2, size_t n) | ||
37 | { | ||
38 | size_t i; | ||
39 | |||
40 | for (i = 0; i < n; i++) { | ||
41 | if (*s1 != *s2) { | ||
42 | /* wchar might be unsigned */ | ||
43 | return *(const rune_t *)s1 > | ||
44 | *(const rune_t *)s2 ? 1 : -1; | ||
45 | } | ||
46 | s1++; | ||
47 | s2++; | ||
48 | } | ||
49 | return 0; | ||
50 | } | ||
51 | DEF_STRONG(wmemcmp); | ||
diff --git a/src/lib/libc/string/wmemcpy.3 b/src/lib/libc/string/wmemcpy.3 deleted file mode 100644 index 2a6d528a1a..0000000000 --- a/src/lib/libc/string/wmemcpy.3 +++ /dev/null | |||
@@ -1,79 +0,0 @@ | |||
1 | .\" $OpenBSD: wmemcpy.3,v 1.5 2013/06/05 03:39:23 tedu Exp $ | ||
2 | .\" | ||
3 | .\" Copyright (c) 1990, 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 | .\" Chris Torek and the American National Standards Committee X3, | ||
8 | .\" on Information 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: June 5 2013 $ | ||
35 | .Dt WMEMCPY 3 | ||
36 | .Os | ||
37 | .Sh NAME | ||
38 | .Nm wmemcpy | ||
39 | .Nd copy wide characters | ||
40 | .Sh SYNOPSIS | ||
41 | .In wchar.h | ||
42 | .Ft wchar_t * | ||
43 | .Fn wmemcpy "wchar_t * restrict dst" "const wchar_t * restrict src" "size_t len" | ||
44 | .Sh DESCRIPTION | ||
45 | The | ||
46 | .Fn wmemcpy | ||
47 | function copies | ||
48 | .Fa len | ||
49 | wide characters from buffer | ||
50 | .Fa src | ||
51 | to buffer | ||
52 | .Fa dst . | ||
53 | If the two buffers may overlap, | ||
54 | .Xr wmemmove 3 | ||
55 | must be used instead. | ||
56 | .Sh RETURN VALUES | ||
57 | The | ||
58 | .Fn wmemcpy | ||
59 | function returns the original value of | ||
60 | .Fa dst . | ||
61 | .Sh SEE ALSO | ||
62 | .Xr memcpy 3 , | ||
63 | .Xr wcscpy 3 , | ||
64 | .Xr wcslcpy 3 , | ||
65 | .Xr wmemmove 3 | ||
66 | .Sh STANDARDS | ||
67 | The | ||
68 | .Fn wmemcpy | ||
69 | function conforms to | ||
70 | .St -isoC-99 | ||
71 | and was first introduced in | ||
72 | .St -isoC-amd1 . | ||
73 | .Sh HISTORY | ||
74 | The | ||
75 | .Fn wmemcpy | ||
76 | function was ported from | ||
77 | .Nx | ||
78 | and first appeared in | ||
79 | .Ox 3.8 . | ||
diff --git a/src/lib/libc/string/wmemcpy.c b/src/lib/libc/string/wmemcpy.c deleted file mode 100644 index cf02ab9d56..0000000000 --- a/src/lib/libc/string/wmemcpy.c +++ /dev/null | |||
@@ -1,41 +0,0 @@ | |||
1 | /* $OpenBSD: wmemcpy.c,v 1.4 2015/09/12 16:23:14 guenther Exp $ */ | ||
2 | /* $NetBSD: wmemcpy.c,v 1.2 2001/01/03 14:29:37 lukem Exp $ */ | ||
3 | |||
4 | /*- | ||
5 | * Copyright (c)1999 Citrus Project, | ||
6 | * All rights reserved. | ||
7 | * | ||
8 | * Redistribution and use in source and binary forms, with or without | ||
9 | * modification, are permitted provided that the following conditions | ||
10 | * are met: | ||
11 | * 1. Redistributions of source code must retain the above copyright | ||
12 | * notice, this list of conditions and the following disclaimer. | ||
13 | * 2. Redistributions in binary form must reproduce the above copyright | ||
14 | * notice, this list of conditions and the following disclaimer in the | ||
15 | * documentation and/or other materials provided with the distribution. | ||
16 | * | ||
17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND | ||
18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
27 | * SUCH DAMAGE. | ||
28 | * | ||
29 | * citrus Id: wmemcpy.c,v 1.2 2000/12/20 14:08:31 itojun Exp | ||
30 | */ | ||
31 | |||
32 | #include <string.h> | ||
33 | #include <wchar.h> | ||
34 | |||
35 | wchar_t * | ||
36 | wmemcpy(wchar_t *d, const wchar_t *s, size_t n) | ||
37 | { | ||
38 | |||
39 | return (wchar_t *)memcpy(d, s, n * sizeof(wchar_t)); | ||
40 | } | ||
41 | DEF_STRONG(wmemcpy); | ||
diff --git a/src/lib/libc/string/wmemmove.3 b/src/lib/libc/string/wmemmove.3 deleted file mode 100644 index 46942e7928..0000000000 --- a/src/lib/libc/string/wmemmove.3 +++ /dev/null | |||
@@ -1,78 +0,0 @@ | |||
1 | .\" $OpenBSD: wmemmove.3,v 1.3 2013/06/05 03:39:23 tedu Exp $ | ||
2 | .\" | ||
3 | .\" Copyright (c) 1990, 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 | .\" Chris Torek and the American National Standards Committee X3, | ||
8 | .\" on Information 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: June 5 2013 $ | ||
35 | .Dt WMEMMOVE 3 | ||
36 | .Os | ||
37 | .Sh NAME | ||
38 | .Nm wmemmove | ||
39 | .Nd copy wide characters | ||
40 | .Sh SYNOPSIS | ||
41 | .In wchar.h | ||
42 | .Ft wchar_t * | ||
43 | .Fn wmemmove "wchar_t *dst" "const wchar_t *src" "size_t len" | ||
44 | .Sh DESCRIPTION | ||
45 | The | ||
46 | .Fn wmemmove | ||
47 | function copies | ||
48 | .Fa len | ||
49 | wide characters from buffer | ||
50 | .Fa src | ||
51 | to buffer | ||
52 | .Fa dst . | ||
53 | The two buffers may overlap; | ||
54 | the copy is always done in a non-destructive manner. | ||
55 | .Sh RETURN VALUES | ||
56 | The | ||
57 | .Fn wmemmove | ||
58 | function returns the original value of | ||
59 | .Fa dst . | ||
60 | .Sh SEE ALSO | ||
61 | .Xr memmove 3 , | ||
62 | .Xr wcscpy 3 , | ||
63 | .Xr wcslcpy 3 , | ||
64 | .Xr wmemcpy 3 | ||
65 | .Sh STANDARDS | ||
66 | The | ||
67 | .Fn wmemmove | ||
68 | function conforms to | ||
69 | .St -isoC-99 | ||
70 | and was first introduced in | ||
71 | .St -isoC-amd1 . | ||
72 | .Sh HISTORY | ||
73 | The | ||
74 | .Fn wmemmove | ||
75 | function was ported from | ||
76 | .Nx | ||
77 | and first appeared in | ||
78 | .Ox 3.8 . | ||
diff --git a/src/lib/libc/string/wmemmove.c b/src/lib/libc/string/wmemmove.c deleted file mode 100644 index 8bf8011064..0000000000 --- a/src/lib/libc/string/wmemmove.c +++ /dev/null | |||
@@ -1,41 +0,0 @@ | |||
1 | /* $OpenBSD: wmemmove.c,v 1.4 2015/09/12 16:23:14 guenther Exp $ */ | ||
2 | /* $NetBSD: wmemmove.c,v 1.2 2001/01/03 14:29:37 lukem Exp $ */ | ||
3 | |||
4 | /*- | ||
5 | * Copyright (c)1999 Citrus Project, | ||
6 | * All rights reserved. | ||
7 | * | ||
8 | * Redistribution and use in source and binary forms, with or without | ||
9 | * modification, are permitted provided that the following conditions | ||
10 | * are met: | ||
11 | * 1. Redistributions of source code must retain the above copyright | ||
12 | * notice, this list of conditions and the following disclaimer. | ||
13 | * 2. Redistributions in binary form must reproduce the above copyright | ||
14 | * notice, this list of conditions and the following disclaimer in the | ||
15 | * documentation and/or other materials provided with the distribution. | ||
16 | * | ||
17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND | ||
18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
27 | * SUCH DAMAGE. | ||
28 | * | ||
29 | * citrus Id: wmemmove.c,v 1.2 2000/12/20 14:08:31 itojun Exp | ||
30 | */ | ||
31 | |||
32 | #include <string.h> | ||
33 | #include <wchar.h> | ||
34 | |||
35 | wchar_t * | ||
36 | wmemmove(wchar_t *d, const wchar_t *s, size_t n) | ||
37 | { | ||
38 | |||
39 | return (wchar_t *)memmove(d, s, n * sizeof(wchar_t)); | ||
40 | } | ||
41 | DEF_STRONG(wmemmove); | ||
diff --git a/src/lib/libc/string/wmemset.3 b/src/lib/libc/string/wmemset.3 deleted file mode 100644 index 2655d68bcb..0000000000 --- a/src/lib/libc/string/wmemset.3 +++ /dev/null | |||
@@ -1,73 +0,0 @@ | |||
1 | .\" $OpenBSD: wmemset.3,v 1.4 2013/06/05 03:39:23 tedu Exp $ | ||
2 | .\" | ||
3 | .\" Copyright (c) 1990, 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 | .\" Chris Torek and the American National Standards Committee X3, | ||
8 | .\" on Information 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: June 5 2013 $ | ||
35 | .Dt WMEMSET 3 | ||
36 | .Os | ||
37 | .Sh NAME | ||
38 | .Nm wmemset | ||
39 | .Nd write a wide string | ||
40 | .Sh SYNOPSIS | ||
41 | .In wchar.h | ||
42 | .Ft wchar_t * | ||
43 | .Fn wmemset "wchar_t *s" "wchar_t c" "size_t len" | ||
44 | .Sh DESCRIPTION | ||
45 | The | ||
46 | .Fn wmemset | ||
47 | function writes | ||
48 | .Fa len | ||
49 | wide characters of value | ||
50 | .Fa c | ||
51 | to the wide string | ||
52 | .Fa s . | ||
53 | .Sh RETURN VALUES | ||
54 | The | ||
55 | .Fn wmemset | ||
56 | function returns the original value of | ||
57 | .Fa s . | ||
58 | .Sh SEE ALSO | ||
59 | .Xr memset 3 | ||
60 | .Sh STANDARDS | ||
61 | The | ||
62 | .Fn wmemset | ||
63 | function conforms to | ||
64 | .St -isoC-99 | ||
65 | and was first introduced in | ||
66 | .St -isoC-amd1 . | ||
67 | .Sh HISTORY | ||
68 | The | ||
69 | .Fn wmemset | ||
70 | function was ported from | ||
71 | .Nx | ||
72 | and first appeared in | ||
73 | .Ox 3.8 . | ||
diff --git a/src/lib/libc/string/wmemset.c b/src/lib/libc/string/wmemset.c deleted file mode 100644 index a2d3295170..0000000000 --- a/src/lib/libc/string/wmemset.c +++ /dev/null | |||
@@ -1,47 +0,0 @@ | |||
1 | /* $OpenBSD: wmemset.c,v 1.4 2015/09/12 16:23:14 guenther Exp $ */ | ||
2 | /* $NetBSD: wmemset.c,v 1.2 2001/01/03 14:29:37 lukem Exp $ */ | ||
3 | |||
4 | /*- | ||
5 | * Copyright (c)1999 Citrus Project, | ||
6 | * All rights reserved. | ||
7 | * | ||
8 | * Redistribution and use in source and binary forms, with or without | ||
9 | * modification, are permitted provided that the following conditions | ||
10 | * are met: | ||
11 | * 1. Redistributions of source code must retain the above copyright | ||
12 | * notice, this list of conditions and the following disclaimer. | ||
13 | * 2. Redistributions in binary form must reproduce the above copyright | ||
14 | * notice, this list of conditions and the following disclaimer in the | ||
15 | * documentation and/or other materials provided with the distribution. | ||
16 | * | ||
17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND | ||
18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
27 | * SUCH DAMAGE. | ||
28 | * | ||
29 | * citrus Id: wmemset.c,v 1.2 2000/12/20 14:08:31 itojun Exp | ||
30 | */ | ||
31 | |||
32 | #include <wchar.h> | ||
33 | |||
34 | wchar_t * | ||
35 | wmemset(wchar_t *s, wchar_t c, size_t n) | ||
36 | { | ||
37 | size_t i; | ||
38 | wchar_t *p; | ||
39 | |||
40 | p = s; | ||
41 | for (i = 0; i < n; i++) { | ||
42 | *p = c; | ||
43 | p++; | ||
44 | } | ||
45 | return s; | ||
46 | } | ||
47 | DEF_STRONG(wmemset); | ||