summaryrefslogtreecommitdiff
path: root/src/lib/libc/string
diff options
context:
space:
mode:
authorcvs2svn <admin@example.com>2012-07-13 17:49:56 +0000
committercvs2svn <admin@example.com>2012-07-13 17:49:56 +0000
commit6f82d0e8f9756938f04071892206a5af85e676f0 (patch)
tree821921a1dd0a5a3cece91121e121cc63c4b68128 /src/lib/libc/string
parent9204e59073bcf27e1487ec4ac46e981902ddd904 (diff)
downloadopenbsd-eric_g2k12.tar.gz
openbsd-eric_g2k12.tar.bz2
openbsd-eric_g2k12.zip
This commit was manufactured by cvs2git to create tag 'eric_g2k12'.eric_g2k12
Diffstat (limited to 'src/lib/libc/string')
-rw-r--r--src/lib/libc/string/Makefile.inc172
-rw-r--r--src/lib/libc/string/bcmp.388
-rw-r--r--src/lib/libc/string/bcmp.c55
-rw-r--r--src/lib/libc/string/bcopy.367
-rw-r--r--src/lib/libc/string/bcopy.c128
-rw-r--r--src/lib/libc/string/bm.3120
-rw-r--r--src/lib/libc/string/bm.c205
-rw-r--r--src/lib/libc/string/bstring.3108
-rw-r--r--src/lib/libc/string/bzero.361
-rw-r--r--src/lib/libc/string/bzero.c48
-rw-r--r--src/lib/libc/string/ffs.361
-rw-r--r--src/lib/libc/string/ffs.c44
-rw-r--r--src/lib/libc/string/index.c47
-rw-r--r--src/lib/libc/string/memccpy.375
-rw-r--r--src/lib/libc/string/memccpy.c48
-rw-r--r--src/lib/libc/string/memchr.3101
-rw-r--r--src/lib/libc/string/memchr.c48
-rw-r--r--src/lib/libc/string/memcmp.385
-rw-r--r--src/lib/libc/string/memcmp.c51
-rw-r--r--src/lib/libc/string/memcpy.385
-rw-r--r--src/lib/libc/string/memmove.376
-rw-r--r--src/lib/libc/string/memrchr.c38
-rw-r--r--src/lib/libc/string/memset.375
-rw-r--r--src/lib/libc/string/memset.c47
-rw-r--r--src/lib/libc/string/rindex.c49
-rw-r--r--src/lib/libc/string/stpcpy.3117
-rw-r--r--src/lib/libc/string/stpcpy.c44
-rw-r--r--src/lib/libc/string/stpncpy.c56
-rw-r--r--src/lib/libc/string/strcasecmp.392
-rw-r--r--src/lib/libc/string/strcasecmp.c105
-rw-r--r--src/lib/libc/string/strcasestr.c60
-rw-r--r--src/lib/libc/string/strcat.3141
-rw-r--r--src/lib/libc/string/strcat.c51
-rw-r--r--src/lib/libc/string/strchr.3114
-rw-r--r--src/lib/libc/string/strcmp.395
-rw-r--r--src/lib/libc/string/strcmp.c51
-rw-r--r--src/lib/libc/string/strcoll.373
-rw-r--r--src/lib/libc/string/strcoll.c44
-rw-r--r--src/lib/libc/string/strcpy.3162
-rw-r--r--src/lib/libc/string/strcpy.c50
-rw-r--r--src/lib/libc/string/strcspn.3108
-rw-r--r--src/lib/libc/string/strcspn.c58
-rw-r--r--src/lib/libc/string/strdup.3112
-rw-r--r--src/lib/libc/string/strdup.c49
-rw-r--r--src/lib/libc/string/strerror.3122
-rw-r--r--src/lib/libc/string/strerror.c41
-rw-r--r--src/lib/libc/string/strerror_r.c137
-rw-r--r--src/lib/libc/string/string.3136
-rw-r--r--src/lib/libc/string/strlcat.c55
-rw-r--r--src/lib/libc/string/strlcpy.3182
-rw-r--r--src/lib/libc/string/strlcpy.c51
-rw-r--r--src/lib/libc/string/strlen.3104
-rw-r--r--src/lib/libc/string/strlen.c47
-rw-r--r--src/lib/libc/string/strmode.3157
-rw-r--r--src/lib/libc/string/strmode.c140
-rw-r--r--src/lib/libc/string/strncat.c57
-rw-r--r--src/lib/libc/string/strncmp.c51
-rw-r--r--src/lib/libc/string/strncpy.c62
-rw-r--r--src/lib/libc/string/strndup.c39
-rw-r--r--src/lib/libc/string/strnlen.c36
-rw-r--r--src/lib/libc/string/strpbrk.380
-rw-r--r--src/lib/libc/string/strpbrk.c48
-rw-r--r--src/lib/libc/string/strrchr.3116
-rw-r--r--src/lib/libc/string/strsep.3110
-rw-r--r--src/lib/libc/string/strsep.c71
-rw-r--r--src/lib/libc/string/strsignal.368
-rw-r--r--src/lib/libc/string/strsignal.c41
-rw-r--r--src/lib/libc/string/strspn.392
-rw-r--r--src/lib/libc/string/strspn.c51
-rw-r--r--src/lib/libc/string/strstr.3100
-rw-r--r--src/lib/libc/string/strstr.c56
-rw-r--r--src/lib/libc/string/strtok.3166
-rw-r--r--src/lib/libc/string/strtok.c86
-rw-r--r--src/lib/libc/string/strxfrm.379
-rw-r--r--src/lib/libc/string/strxfrm.c51
-rw-r--r--src/lib/libc/string/swab.361
-rw-r--r--src/lib/libc/string/swab.c61
-rw-r--r--src/lib/libc/string/timingsafe_bcmp.c33
-rw-r--r--src/lib/libc/string/wcscasecmp.394
-rw-r--r--src/lib/libc/string/wcscasecmp.c61
-rw-r--r--src/lib/libc/string/wcscat.3115
-rw-r--r--src/lib/libc/string/wcscat.c55
-rw-r--r--src/lib/libc/string/wcschr.385
-rw-r--r--src/lib/libc/string/wcschr.c50
-rw-r--r--src/lib/libc/string/wcscmp.392
-rw-r--r--src/lib/libc/string/wcscmp.c51
-rw-r--r--src/lib/libc/string/wcscpy.3123
-rw-r--r--src/lib/libc/string/wcscpy.c52
-rw-r--r--src/lib/libc/string/wcscspn.383
-rw-r--r--src/lib/libc/string/wcscspn.c53
-rw-r--r--src/lib/libc/string/wcsdup.397
-rw-r--r--src/lib/libc/string/wcsdup.c31
-rw-r--r--src/lib/libc/string/wcslcat.c56
-rw-r--r--src/lib/libc/string/wcslcpy.3147
-rw-r--r--src/lib/libc/string/wcslcpy.c52
-rw-r--r--src/lib/libc/string/wcslen.370
-rw-r--r--src/lib/libc/string/wcslen.c44
-rw-r--r--src/lib/libc/string/wcsncat.c52
-rw-r--r--src/lib/libc/string/wcsncmp.c52
-rw-r--r--src/lib/libc/string/wcsncpy.c50
-rw-r--r--src/lib/libc/string/wcspbrk.381
-rw-r--r--src/lib/libc/string/wcspbrk.c53
-rw-r--r--src/lib/libc/string/wcsrchr.385
-rw-r--r--src/lib/libc/string/wcsrchr.c50
-rw-r--r--src/lib/libc/string/wcsspn.379
-rw-r--r--src/lib/libc/string/wcsspn.c55
-rw-r--r--src/lib/libc/string/wcsstr.388
-rw-r--r--src/lib/libc/string/wcsstr.c70
-rw-r--r--src/lib/libc/string/wcstok.3151
-rw-r--r--src/lib/libc/string/wcstok.c93
-rw-r--r--src/lib/libc/string/wcswcs.c5
-rw-r--r--src/lib/libc/string/wcswidth.369
-rw-r--r--src/lib/libc/string/wcswidth.c50
-rw-r--r--src/lib/libc/string/wmemchr.381
-rw-r--r--src/lib/libc/string/wmemchr.c47
-rw-r--r--src/lib/libc/string/wmemcmp.378
-rw-r--r--src/lib/libc/string/wmemcmp.c50
-rw-r--r--src/lib/libc/string/wmemcpy.385
-rw-r--r--src/lib/libc/string/wmemcpy.c40
-rw-r--r--src/lib/libc/string/wmemmove.378
-rw-r--r--src/lib/libc/string/wmemmove.c40
-rw-r--r--src/lib/libc/string/wmemset.373
-rw-r--r--src/lib/libc/string/wmemset.c46
123 files changed, 0 insertions, 9463 deletions
diff --git a/src/lib/libc/string/Makefile.inc b/src/lib/libc/string/Makefile.inc
deleted file mode 100644
index 25e67e4f87..0000000000
--- a/src/lib/libc/string/Makefile.inc
+++ /dev/null
@@ -1,172 +0,0 @@
1# $OpenBSD: Makefile.inc,v 1.28 2012/01/17 02:48:01 guenther Exp $
2
3# string sources
4.PATH: ${LIBCSRCDIR}/arch/${MACHINE_CPU}/string ${LIBCSRCDIR}/string
5
6SRCS+= bm.c memccpy.c memrchr.c stpcpy.c stpncpy.c \
7 strcasecmp.c strcasestr.c strcoll.c strdup.c \
8 strerror.c strerror_r.c strlcat.c strmode.c strndup.c strnlen.c \
9 strsignal.c strtok.c strxfrm.c \
10 wcscat.c wcschr.c wcscmp.c wcscpy.c wcscspn.c wcslcat.c wcslcpy.c \
11 wcslen.c wcsncat.c wcsncmp.c wcsncpy.c wcspbrk.c wcsrchr.c wcsspn.c \
12 wcsstr.c wcstok.c wcswcs.c wcswidth.c wmemchr.c wmemcmp.c wmemcpy.c \
13 wmemmove.c wmemset.c wcsdup.c \
14 timingsafe_bcmp.c wcscasecmp.c
15
16# machine-dependent net sources
17# m-d Makefile.inc must include sources for:
18# bcmp() bcopy() bzero() ffs() index() memchr() memcmp() memset()
19# rindex() strcat() strcmp() strcpy() strcspn() strlen() strlcpy()
20# strncat() strncmp() strncpy() strpbrk() strsep()
21# strspn() strstr() swav()
22# m-d Makefile.inc may include sources for:
23# memcpy() memmove() strchr() strrchr()
24
25.include "${LIBCSRCDIR}/arch/${MACHINE_CPU}/string/Makefile.inc"
26
27# if no machine specific memmove(3), build one out of bcopy(3).
28.if empty(SRCS:Mmemmove.S)
29OBJS+= memmove.o
30memmove.o: bcopy.c
31 ${CC} -DMEMMOVE ${CFLAGS} ${CPPFLAGS} -c ${.ALLSRC} -o ${.TARGET}
32 @${LD} -o ${.TARGET}.tmp -x -r ${.TARGET}
33 @mv ${.TARGET}.tmp ${.TARGET}
34
35memmove.go: bcopy.c
36 ${CC} -g -DMEMMOVE ${CFLAGS} ${CPPFLAGS} -c ${.ALLSRC} -o ${.TARGET}
37 @${LD} -o ${.TARGET}.tmp -x -r ${.TARGET}
38 @mv ${.TARGET}.tmp ${.TARGET}
39
40memmove.po: bcopy.c
41 ${CC} -DMEMMOVE ${CFLAGS} ${CPPFLAGS} -c -p ${.ALLSRC} -o ${.TARGET}
42 @${LD} -o ${.TARGET}.tmp -X -r ${.TARGET}
43 @mv ${.TARGET}.tmp ${.TARGET}
44
45memmove.so: bcopy.c
46 ${CC} ${PICFLAG} -DPIC -DMEMMOVE ${CFLAGS} ${CPPFLAGS} -c ${.ALLSRC} \
47 -o ${.TARGET}
48.endif
49
50# if no machine specific memcpy(3), build one out of bcopy(3).
51# if there is a machine specific memmove(3), we'll assume it aliases
52# memcpy(3).
53.if empty(SRCS:Mmemcpy.S)
54.if empty(SRCS:Mmemmove.S)
55OBJS+= memcpy.o
56memcpy.o: bcopy.c
57 ${CC} -DMEMCOPY ${CFLAGS} ${CPPFLAGS} -c ${.ALLSRC} -o ${.TARGET}
58 @${LD} -o ${.TARGET}.tmp -x -r ${.TARGET}
59 @mv ${.TARGET}.tmp ${.TARGET}
60
61memcpy.go: bcopy.c
62 ${CC} -g -DMEMCOPY ${CFLAGS} ${CPPFLAGS} -c ${.ALLSRC} -o ${.TARGET}
63 @${LD} -o ${.TARGET}.tmp -x -r ${.TARGET}
64 @mv ${.TARGET}.tmp ${.TARGET}
65
66memcpy.po: bcopy.c
67 ${CC} -DMEMCOPY ${CFLAGS} ${CPPFLAGS} -c -p ${.ALLSRC} -o ${.TARGET}
68 @${LD} -o ${.TARGET}.tmp -X -r ${.TARGET}
69 @mv ${.TARGET}.tmp ${.TARGET}
70
71memcpy.so: bcopy.c
72 ${CC} ${PICFLAG} -DPIC -DMEMCOPY ${CFLAGS} ${CPPFLAGS} -c ${.ALLSRC} \
73 -o ${.TARGET}
74.endif
75.endif
76
77# if no machine specific strchr(3), build one out of index(3).
78.if empty(SRCS:Mstrchr.S)
79OBJS+= strchr.o
80strchr.o: index.c
81 ${CC} -DSTRCHR ${CFLAGS} ${CPPFLAGS} -c ${.ALLSRC} -o ${.TARGET}
82 @${LD} -o ${.TARGET}.tmp -x -r ${.TARGET}
83 @mv ${.TARGET}.tmp ${.TARGET}
84
85strchr.go: index.c
86 ${CC} -g -DSTRCHR ${CFLAGS} ${CPPFLAGS} -c ${.ALLSRC} -o ${.TARGET}
87 @${LD} -o ${.TARGET}.tmp -x -r ${.TARGET}
88 @mv ${.TARGET}.tmp ${.TARGET}
89
90strchr.po: index.c
91 ${CC} -DSTRCHR ${CFLAGS} ${CPPFLAGS} -c -p ${.ALLSRC} -o ${.TARGET}
92 @${LD} -o ${.TARGET}.tmp -X -r ${.TARGET}
93 @mv ${.TARGET}.tmp ${.TARGET}
94
95strchr.so: index.c
96 ${CC} ${PICFLAG} -DPIC -DSTRCHR ${CFLAGS} ${CPPFLAGS} -c ${.ALLSRC} \
97 -o ${.TARGET}
98.endif
99
100# if no machine specific strrchr(3), build one out of rindex(3).
101.if empty(SRCS:Mstrrchr.S)
102OBJS+= strrchr.o
103strrchr.o: rindex.c
104 ${CC} -DSTRRCHR ${CFLAGS} ${CPPFLAGS} -c ${.ALLSRC} -o ${.TARGET}
105 @${LD} -o ${.TARGET}.tmp -x -r ${.TARGET}
106 @mv ${.TARGET}.tmp ${.TARGET}
107
108strrchr.go: rindex.c
109 ${CC} -g -DSTRRCHR ${CFLAGS} ${CPPFLAGS} -c ${.ALLSRC} -o ${.TARGET}
110 @${LD} -o ${.TARGET}.tmp -x -r ${.TARGET}
111 @mv ${.TARGET}.tmp ${.TARGET}
112
113strrchr.po: rindex.c
114 ${CC} -DSTRRCHR ${CFLAGS} ${CPPFLAGS} -c -p ${.ALLSRC} -o ${.TARGET}
115 @${LD} -o ${.TARGET}.tmp -X -r ${.TARGET}
116 @mv ${.TARGET}.tmp ${.TARGET}
117
118strrchr.so: rindex.c
119 ${CC} ${PICFLAG} -DPIC -DSTRRCHR ${CFLAGS} ${CPPFLAGS} -c ${.ALLSRC} \
120 -o ${.TARGET}
121.endif
122
123# build .ln files for memmove, memcpy, strchr and strrchr always from
124# bcopy, index, and rindex
125LOBJS+= memmove.ln memcpy.ln strchr.ln strrchr.ln
126
127memmove.ln: bcopy.c
128 lint ${LINTFLAGS} -DMEMMOVE ${CFLAGS:M-[IDU]*} -i -o ${.TARGET} \
129 ${LIBCSRCDIR}/string/bcopy.c
130
131memcpy.ln: bcopy.c
132 lint ${LINTFLAGS} -DMEMCOPY ${CFLAGS:M-[IDU]*} -i -o ${.TARGET} \
133 ${LIBCSRCDIR}/string/bcopy.c
134
135strchr.ln: index.c
136 lint ${LINTFLAGS} -DSTRCHR ${CFLAGS:M-[IDU]*} -i -o ${.TARGET} \
137 ${LIBCSRCDIR}/string/index.c
138
139strrchr.ln: rindex.c
140 lint ${LINTFLAGS} -DSTRRCHR ${CFLAGS:M-[IDU]*} -i -o ${.TARGET} \
141 ${LIBCSRCDIR}/string/rindex.c
142
143MAN+= bm.3 bcmp.3 bcopy.3 bstring.3 bzero.3 ffs.3 memccpy.3 memchr.3 \
144 memcmp.3 memcpy.3 memmove.3 memset.3 stpcpy.3 strcasecmp.3 strcat.3 \
145 strchr.3 strcmp.3 strcoll.3 strcpy.3 strcspn.3 strerror.3 \
146 string.3 strlen.3 strmode.3 strdup.3 strpbrk.3 strrchr.3 strsep.3 \
147 strsignal.3 strspn.3 strstr.3 strtok.3 strxfrm.3 swab.3 strlcpy.3 \
148 wcscasecmp.3 wcscat.3 wcschr.3 wcscmp.3 wcscpy.3 wcscspn.3 wcsdup.3 \
149 wcslcpy.3 wcslen.3 wcspbrk.3 wcsrchr.3 wcsspn.3 wcsstr.3 wcstok.3 \
150 wcswidth.3 wmemchr.3 wmemcmp.3 wmemcpy.3 wmemmove.3 wmemset.3
151
152MLINKS+=bm.3 bm_comp.3 bm.3 bm_exec.3 bm.3 bm_free.3
153MLINKS+=memchr.3 memrchr.3
154MLINKS+=stpcpy.3 stpncpy.3
155MLINKS+=strchr.3 index.3
156MLINKS+=strrchr.3 rindex.3
157MLINKS+=strcasecmp.3 strncasecmp.3
158MLINKS+=strcat.3 strncat.3
159MLINKS+=strcmp.3 strncmp.3
160MLINKS+=strcpy.3 strncpy.3
161MLINKS+=strdup.3 strndup.3
162MLINKS+=strlcpy.3 strlcat.3
163MLINKS+=strlen.3 strnlen.3
164MLINKS+=strstr.3 strcasestr.3
165MLINKS+=strtok.3 strtok_r.3
166MLINKS+=strerror.3 strerror_r.3
167MLINKS+=wcscasecmp.3 wcsncasecmp.3
168MLINKS+=wcscat.3 wcsncat.3
169MLINKS+=wcscmp.3 wcsncmp.3
170MLINKS+=wcscpy.3 wcsncpy.3
171MLINKS+=wcslcpy.3 wcslcat.3
172MLINKS+=bcmp.3 timingsafe_bcmp.3
diff --git a/src/lib/libc/string/bcmp.3 b/src/lib/libc/string/bcmp.3
deleted file mode 100644
index 1660b4356b..0000000000
--- a/src/lib/libc/string/bcmp.3
+++ /dev/null
@@ -1,88 +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.9 2011/07/25 00:38:52 schwarze Exp $
31.\"
32.Dd $Mdocdate: July 25 2011 $
33.Dt BCMP 3
34.Os
35.Sh NAME
36.Nm bcmp ,
37.Nm timingsafe_bcmp
38.Nd compare byte string
39.Sh SYNOPSIS
40.Fd #include <string.h>
41.Ft int
42.Fn bcmp "const void *b1" "const void *b2" "size_t len"
43.Ft int
44.Fn timingsafe_bcmp "const void *b1" "const void *b2" "size_t len"
45.Sh DESCRIPTION
46The
47.Fn bcmp
48function compares byte string
49.Fa b1
50against byte string
51.Fa b2 ,
52returning zero if they are identical, non-zero otherwise.
53Both strings are assumed to be
54.Fa len
55bytes long.
56Zero-length strings are always identical.
57.Pp
58The strings may overlap.
59.Pp
60The
61.Fn timingsafe_bcmp
62function has the same semantics as
63.Fn bcmp ,
64but its running time is independent of the contents of
65.Fa b1
66and
67.Fa b2 ,
68making it safe to use for comparing secret values such as cryptographic MACs.
69In contrast,
70.Fn bcmp
71returns after finding the first differing byte,
72making it vulnerable to timing attacks.
73.Sh SEE ALSO
74.Xr memcmp 3 ,
75.Xr strcasecmp 3 ,
76.Xr strcmp 3 ,
77.Xr strcoll 3 ,
78.Xr strxfrm 3
79.Sh HISTORY
80The
81.Fn bcmp
82function first appeared in
83.Bx 4.2 .
84.Pp
85The
86.Fn timingsafe_bcmp
87function first appeared in
88.Ox 4.9 .
diff --git a/src/lib/libc/string/bcmp.c b/src/lib/libc/string/bcmp.c
deleted file mode 100644
index fd5c93121e..0000000000
--- a/src/lib/libc/string/bcmp.c
+++ /dev/null
@@ -1,55 +0,0 @@
1/* $OpenBSD: bcmp.c,v 1.9 2008/03/19 03:00:23 ray 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#if !defined(_KERNEL) && !defined(_STANDALONE)
33#include <string.h>
34#else
35#include <lib/libkern/libkern.h>
36#endif
37
38/*
39 * bcmp -- vax cmpc3 instruction
40 */
41int
42bcmp(const void *b1, const void *b2, size_t length)
43{
44 char *p1, *p2;
45
46 if (length == 0)
47 return (0);
48 p1 = (char *)b1;
49 p2 = (char *)b2;
50 do
51 if (*p1++ != *p2++)
52 return (1);
53 while (--length);
54 return (0);
55}
diff --git a/src/lib/libc/string/bcopy.3 b/src/lib/libc/string/bcopy.3
deleted file mode 100644
index 3beaf09aca..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.10 2011/07/25 00:38:52 schwarze Exp $
32.\"
33.Dd $Mdocdate: July 25 2011 $
34.Dt BCOPY 3
35.Os
36.Sh NAME
37.Nm bcopy
38.Nd copy bytes
39.Sh SYNOPSIS
40.Fd #include <string.h>
41.Ft void
42.Fn bcopy "const void *src" "void *dst" "size_t len"
43.Sh DESCRIPTION
44The
45.Fn bcopy
46function copies
47.Fa len
48bytes from buffer
49.Fa src
50to buffer
51.Fa dst .
52The two buffers may overlap.
53If
54.Fa len
55is 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
64The
65.Fn bcopy
66function 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 4308c6484a..0000000000
--- a/src/lib/libc/string/bcopy.c
+++ /dev/null
@@ -1,128 +0,0 @@
1/* $OpenBSD: bcopy.c,v 1.5 2005/08/08 08:05:37 espie 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 */
40typedef 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 * This is the routine that actually implements
48 * (the portable versions of) bcopy, memcpy, and memmove.
49 */
50#ifdef MEMCOPY
51void *
52memcpy(void *dst0, const void *src0, size_t length)
53#else
54#ifdef MEMMOVE
55void *
56memmove(void *dst0, const void *src0, size_t length)
57#else
58void
59bcopy(const void *src0, void *dst0, size_t length)
60#endif
61#endif
62{
63 char *dst = dst0;
64 const char *src = src0;
65 size_t t;
66
67 if (length == 0 || dst == src) /* nothing to do */
68 goto done;
69
70 /*
71 * Macros: loop-t-times; and loop-t-times, t>0
72 */
73#define TLOOP(s) if (t) TLOOP1(s)
74#define TLOOP1(s) do { s; } while (--t)
75
76 if ((unsigned long)dst < (unsigned long)src) {
77 /*
78 * Copy forward.
79 */
80 t = (long)src; /* only need low bits */
81 if ((t | (long)dst) & wmask) {
82 /*
83 * Try to align operands. This cannot be done
84 * unless the low bits match.
85 */
86 if ((t ^ (long)dst) & wmask || length < wsize)
87 t = length;
88 else
89 t = wsize - (t & wmask);
90 length -= t;
91 TLOOP1(*dst++ = *src++);
92 }
93 /*
94 * Copy whole words, then mop up any trailing bytes.
95 */
96 t = length / wsize;
97 TLOOP(*(word *)dst = *(word *)src; src += wsize; dst += wsize);
98 t = length & wmask;
99 TLOOP(*dst++ = *src++);
100 } else {
101 /*
102 * Copy backwards. Otherwise essentially the same.
103 * Alignment works as before, except that it takes
104 * (t&wmask) bytes to align, not wsize-(t&wmask).
105 */
106 src += length;
107 dst += length;
108 t = (long)src;
109 if ((t | (long)dst) & wmask) {
110 if ((t ^ (long)dst) & wmask || length <= wsize)
111 t = length;
112 else
113 t &= wmask;
114 length -= t;
115 TLOOP1(*--dst = *--src);
116 }
117 t = length / wsize;
118 TLOOP(src -= wsize; dst -= wsize; *(word *)dst = *(word *)src);
119 t = length & wmask;
120 TLOOP(*--dst = *--src);
121 }
122done:
123#if defined(MEMCOPY) || defined(MEMMOVE)
124 return (dst0);
125#else
126 return;
127#endif
128}
diff --git a/src/lib/libc/string/bm.3 b/src/lib/libc/string/bm.3
deleted file mode 100644
index 6c74848ecc..0000000000
--- a/src/lib/libc/string/bm.3
+++ /dev/null
@@ -1,120 +0,0 @@
1.\" Copyright (c) 1994
2.\" The Regents of the University of California. All rights reserved.
3.\"
4.\" This code is derived from software contributed to Berkeley by
5.\" Andrew Hume of AT&T Bell Laboratories.
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: bm.3,v 1.10 2011/07/25 00:38:52 schwarze Exp $
32.\"
33.Dd $Mdocdate: July 25 2011 $
34.Dt BM 3
35.Os
36.Sh NAME
37.Nm bm_comp ,
38.Nm bm_exec ,
39.Nm bm_free
40.Nd Boyer-Moore string search
41.Sh SYNOPSIS
42.Fd #include <sys/types.h>
43.Fd #include <bm.h>
44.Ft bm_pat *
45.Fn bm_comp "const unsigned char *pattern" "size_t patlen" \
46 "const unsigned char freq[256]"
47.Ft unsigned char *
48.Fn bm_exec "bm_pat *pdesc" "unsigned char *text" "size_t len"
49.Ft void
50.Fn bm_free "bm_pat *pdesc"
51.Sh DESCRIPTION
52These routines implement an efficient mechanism to find an
53occurrence of a byte string within another byte string.
54.Pp
55.Fn bm_comp
56evaluates
57.Fa patlen
58bytes starting at
59.Fa pattern
60and returns a pointer to a structure describing them.
61The bytes referenced by
62.Fa pattern
63may be of any value.
64.Pp
65The search takes advantage of the frequency distribution of the
66bytes in the text to be searched.
67If specified,
68.Ar freq
69should be an array of 256 values,
70with higher values indicating that the corresponding character occurs
71more frequently.
72(A less than optimal frequency distribution can only result in less
73than optimal performance, not incorrect results.)
74If
75.Ar freq
76is
77.Dv NULL ,
78a system default table is used.
79.Pp
80.Fn bm_exec
81returns a pointer to the leftmost occurrence of the string given to
82.Fn bm_comp
83within
84.Ar text ,
85or
86.Dv NULL
87if none occurs.
88The number of bytes in
89.Ar text
90must be specified by
91.Ar len .
92.Pp
93Space allocated for the returned description is discarded
94by calling
95.Fn bm_free
96with the returned description as an argument.
97.Pp
98The asymptotic speed of
99.Fn bm_exec
100is
101.Pf O Ns Pq len / patlen .
102.Sh SEE ALSO
103.Xr regexp 3 ,
104.Xr strstr 3
105.Rs
106.%R "Fast String Searching"
107.%A Andrew Hume
108.%A Daniel Sunday
109.%J "Software Practice and Experience"
110.%V Volume 21, 11 (November 1991)
111.%P 1221-48
112.Re
113.Sh HISTORY
114The
115.Fn bm_comp ,
116.Fn bm_exec ,
117and
118.Fn bm_free
119functions first appeared in
120.Nx 1.0 .
diff --git a/src/lib/libc/string/bm.c b/src/lib/libc/string/bm.c
deleted file mode 100644
index 2c4c6ca720..0000000000
--- a/src/lib/libc/string/bm.c
+++ /dev/null
@@ -1,205 +0,0 @@
1/* $OpenBSD: bm.c,v 1.7 2007/09/02 15:19:18 deraadt Exp $ */
2/*-
3 * Copyright (c) 1994
4 * The Regents of the University of California. All rights reserved.
5 *
6 * This code is derived from software contributed to Berkeley by
7 * Andrew Hume of AT&T Bell Laboratories.
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 <sys/types.h>
35
36#include <bm.h>
37#include <errno.h>
38#include <stdlib.h>
39#include <string.h>
40
41/*
42 * XXX
43 * The default frequency table starts at 99 and counts down. The default
44 * table should probably be oriented toward text, and will necessarily be
45 * locale specific. This one is for English. It was derived from the
46 * OSF/1 and 4.4BSD formatted and unformatted manual pages, and about 100Mb
47 * of email and random text. Change it if you can find something better.
48 */
49static u_char const freq_def[256] = {
50 0, 0, 0, 0, 0, 0, 0, 0,
51 0, 77, 90, 0, 0, 0, 0, 0,
52 0, 0, 0, 0, 0, 0, 0, 0,
53 0, 0, 0, 0, 0, 0, 0, 0,
54 99, 28, 42, 27, 16, 14, 20, 51,
55 66, 65, 59, 24, 75, 76, 84, 56,
56 72, 74, 64, 55, 54, 47, 41, 37,
57 44, 61, 70, 43, 23, 53, 49, 22,
58 33, 58, 40, 46, 45, 57, 60, 26,
59 30, 63, 21, 12, 32, 50, 38, 39,
60 34, 11, 48, 67, 62, 35, 15, 29,
61 71, 18, 9, 17, 25, 13, 10, 52,
62 36, 95, 78, 86, 87, 98, 82, 80,
63 88, 94, 19, 68, 89, 83, 93, 96,
64 81, 7, 91, 92, 97, 85, 69, 73,
65 31, 79, 8, 5, 4, 6, 3, 0,
66 0, 0, 0, 0, 0, 0, 0, 0,
67 0, 0, 0, 0, 0, 0, 0, 0,
68 0, 0, 0, 0, 0, 0, 0, 0,
69 0, 0, 0, 0, 0, 0, 0, 0,
70 0, 0, 0, 0, 0, 0, 0, 0,
71 0, 0, 0, 0, 0, 0, 0, 0,
72 0, 0, 0, 0, 0, 0, 0, 0,
73 0, 0, 0, 0, 0, 0, 0, 0,
74 0, 0, 0, 0, 0, 0, 0, 0,
75 0, 0, 0, 0, 0, 0, 0, 0,
76 0, 0, 0, 0, 0, 0, 0, 0,
77 0, 0, 0, 0, 0, 0, 0, 0,
78 0, 0, 0, 0, 0, 0, 0, 0,
79 0, 0, 0, 0, 0, 0, 0, 0,
80 0, 0, 0, 0, 0, 0, 0, 0,
81 0, 0, 0, 0, 0, 0, 0, 0,
82};
83
84bm_pat *
85bm_comp(u_char const *pb, size_t len, u_char const *freq)
86{
87 u_char const *pe, *p;
88 size_t *d, r;
89 int j;
90 int sv_errno;
91 bm_pat *pat;
92
93 if (len == 0) {
94 errno = EINVAL;
95 return (NULL);
96 }
97 if ((pat = malloc(sizeof(*pat))) == NULL)
98 return (NULL);
99 pat->pat = NULL;
100 pat->delta = NULL;
101
102 pat->patlen = len; /* copy pattern */
103 if ((pat->pat = malloc(pat->patlen)) == NULL)
104 goto mem;
105 memcpy(pat->pat, pb, pat->patlen);
106 /* get skip delta */
107 if ((pat->delta = calloc(256, sizeof(*d))) == NULL)
108 goto mem;
109 for (j = 0, d = pat->delta; j < 256; j++)
110 d[j] = pat->patlen;
111 for (pe = pb + pat->patlen - 1; pb <= pe; pb++)
112 d[*pb] = pe - pb;
113
114 if (freq == NULL) /* default freq table */
115 freq = freq_def;
116 r = 0; /* get guard */
117 for (pb = pat->pat, pe = pb + pat->patlen - 1; pb < pe; pb++)
118 if (freq[*pb] < freq[pat->pat[r]])
119 r = pb - pat->pat;
120 pat->rarec = pat->pat[r];
121 pat->rareoff = r - (pat->patlen - 1);
122
123 /* get md2 shift */
124 for (pe = pat->pat + pat->patlen - 1, p = pe - 1; p >= pat->pat; p--)
125 if (*p == *pe)
126 break;
127
128 /* *p is first leftward reoccurrence of *pe */
129 pat->md2 = pe - p;
130 return (pat);
131
132mem: sv_errno = errno;
133 bm_free(pat);
134 errno = sv_errno;
135 return (NULL);
136}
137
138void
139bm_free(bm_pat *pat)
140{
141 if (pat->pat != NULL)
142 free(pat->pat);
143 if (pat->delta != NULL)
144 free(pat->delta);
145 free(pat);
146}
147
148u_char *
149bm_exec(bm_pat *pat, u_char *base, size_t n)
150{
151 u_char *e, *ep, *p, *q, *s;
152 size_t *d0, k, md2, n1, ro;
153 int rc;
154
155 if (n == 0)
156 return (NULL);
157
158 d0 = pat->delta;
159 n1 = pat->patlen - 1;
160 md2 = pat->md2;
161 ro = pat->rareoff;
162 rc = pat->rarec;
163 ep = pat->pat + pat->patlen - 1;
164 s = base + (pat->patlen - 1);
165
166 /* fast loop up to n - 3 * patlen */
167 e = base + n - 3 * pat->patlen;
168 while (s < e) {
169 k = d0[*s]; /* ufast skip loop */
170 while (k) {
171 k = d0[*(s += k)];
172 k = d0[*(s += k)];
173 }
174 if (s >= e)
175 break;
176 if (s[ro] != rc) /* guard test */
177 goto mismatch1;
178 /* fwd match */
179 for (p = pat->pat, q = s - n1; p < ep;)
180 if (*q++ != *p++)
181 goto mismatch1;
182 return (s - n1);
183
184mismatch1: s += md2; /* md2 shift */
185 }
186
187 /* slow loop up to end */
188 e = base + n;
189 while (s < e) {
190 s += d0[*s]; /* step */
191 if (s >= e)
192 break;
193 if (s[ro] != rc) /* guard test */
194 goto mismatch2;
195 /* fwd match */
196 for (p = pat->pat, q = s - n1; p <= ep;)
197 if (*q++ != *p++)
198 goto mismatch2;
199 return (s - n1);
200
201mismatch2: s += md2; /* md2 shift */
202 }
203
204 return (NULL);
205}
diff --git a/src/lib/libc/string/bstring.3 b/src/lib/libc/string/bstring.3
deleted file mode 100644
index c44c5386c6..0000000000
--- a/src/lib/libc/string/bstring.3
+++ /dev/null
@@ -1,108 +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: bstring.3,v 1.9 2011/07/25 00:38:52 schwarze Exp $
31.\"
32.Dd $Mdocdate: July 25 2011 $
33.Dt BSTRING 3
34.Os
35.Sh NAME
36.Nm bstring
37.Nd byte string operations
38.Sh SYNOPSIS
39.Fd #include <string.h>
40.Ft int
41.Fn bcmp "const void *b1" "const void *b2" "size_t len"
42.Ft void
43.Fn bcopy "const void *src" "void *dst" "size_t len"
44.Ft void
45.Fn bzero "void *b" "size_t len"
46.Ft void *
47.Fn memchr "const void *b" "int c" "size_t len"
48.Ft int
49.Fn memcmp "const void *b1" "const void *b2" "size_t len"
50.Ft void *
51.Fn memccpy "void *dst" "const void *src" "int c" "size_t len"
52.Ft void *
53.Fn memcpy "void *dst" "const void *src" "size_t len"
54.Ft void *
55.Fn memmove "void *dst" "const void *src" "size_t len"
56.Ft void *
57.Fn memset "void *b" "int c" "size_t len"
58.Sh DESCRIPTION
59These functions operate on variable length strings of bytes.
60They do not check for terminating NUL bytes as the routines
61listed in
62.Xr string 3
63do.
64.Pp
65See the specific manual pages for more information.
66.Sh SEE ALSO
67.Xr bcmp 3 ,
68.Xr bcopy 3 ,
69.Xr bzero 3 ,
70.Xr memccpy 3 ,
71.Xr memchr 3 ,
72.Xr memcmp 3 ,
73.Xr memcpy 3 ,
74.Xr memmove 3 ,
75.Xr memset 3
76.Sh STANDARDS
77The functions
78.Fn memchr ,
79.Fn memcmp ,
80.Fn memcpy ,
81.Fn memmove ,
82and
83.Fn memset
84conform to
85.St -ansiC .
86.Sh HISTORY
87The
88.Fn bcmp ,
89.Fn bcopy ,
90and
91.Fn bzero
92functions first appeared in
93.Bx 4.2 .
94The
95.Fn memchr ,
96.Fn memcmp ,
97.Fn memccpy ,
98.Fn memcpy ,
99and
100.Fn memset
101functions first appeared in
102.At V
103and were reimplemented for
104.Bx 4.3 Tahoe .
105The
106.Fn memmove
107function first appeared in
108.Bx 4.3 Reno .
diff --git a/src/lib/libc/string/bzero.3 b/src/lib/libc/string/bzero.3
deleted file mode 100644
index c79470377f..0000000000
--- a/src/lib/libc/string/bzero.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: bzero.3,v 1.8 2011/07/25 00:38:52 schwarze Exp $
31.\"
32.Dd $Mdocdate: July 25 2011 $
33.Dt BZERO 3
34.Os
35.Sh NAME
36.Nm bzero
37.Nd write zeroes to a byte string
38.Sh SYNOPSIS
39.Fd #include <string.h>
40.Ft void
41.Fn bzero "void *b" "size_t len"
42.Sh DESCRIPTION
43The
44.Fn bzero
45function writes
46.Fa len
47zero bytes to the string
48.Fa b .
49If
50.Fa len
51is zero,
52.Fn bzero
53does nothing.
54.Sh SEE ALSO
55.Xr memset 3 ,
56.Xr swab 3
57.Sh HISTORY
58The
59.Fn bzero
60function first appeared in
61.Bx 4.2 .
diff --git a/src/lib/libc/string/bzero.c b/src/lib/libc/string/bzero.c
deleted file mode 100644
index 4d267d4f40..0000000000
--- a/src/lib/libc/string/bzero.c
+++ /dev/null
@@ -1,48 +0,0 @@
1/* $OpenBSD: bzero.c,v 1.7 2005/08/08 08:05:37 espie 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#if !defined(_KERNEL) && !defined(_STANDALONE)
33#include <string.h>
34#else
35#include <lib/libkern/libkern.h>
36#endif
37
38/*
39 * bzero -- vax movc5 instruction
40 */
41void
42bzero(void *b, size_t length)
43{
44 char *p;
45
46 for (p = b; length--;)
47 *p++ = '\0';
48}
diff --git a/src/lib/libc/string/ffs.3 b/src/lib/libc/string/ffs.3
deleted file mode 100644
index eea0994cb1..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.8 2012/01/14 13:31:32 jmc Exp $
31.\"
32.Dd $Mdocdate: January 14 2012 $
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.Fd #include <string.h>
40.Ft int
41.Fn ffs "int value"
42.Sh DESCRIPTION
43The
44.Fn ffs
45function finds the first bit set in
46.Fa value
47and returns the index of that bit.
48Bits are numbered starting from 1, starting at the rightmost bit.
49A return value of 0 means that the argument was zero.
50.Sh SEE ALSO
51.Xr bitstring 3
52.Sh STANDARDS
53The
54.Fn ffs
55function conforms to
56.St -p1003.1-2008 .
57.Sh HISTORY
58The
59.Fn ffs
60function 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 7dec1613a8..0000000000
--- a/src/lib/libc/string/ffs.c
+++ /dev/null
@@ -1,44 +0,0 @@
1/* $OpenBSD: ffs.c,v 1.7 2005/08/08 08:05:37 espie Exp $ */
2
3/*
4 * Public domain.
5 * Written by Dale Rahn.
6 */
7
8#if !defined(_KERNEL) && !defined(_STANDALONE)
9#include <string.h>
10#else
11#include <lib/libkern/libkern.h>
12#endif
13
14/*
15 * ffs -- vax ffs instruction
16 */
17int
18ffs(int mask)
19{
20 int bit;
21 unsigned int r = mask;
22 static const signed char t[16] = {
23 -28, 1, 2, 1,
24 3, 1, 2, 1,
25 4, 1, 2, 1,
26 3, 1, 2, 1
27 };
28
29 bit = 0;
30 if (!(r & 0xffff)) {
31 bit += 16;
32 r >>= 16;
33 }
34 if (!(r & 0xff)) {
35 bit += 8;
36 r >>= 8;
37 }
38 if (!(r & 0xf)) {
39 bit += 4;
40 r >>= 4;
41 }
42
43 return (bit + t[ r & 0xf ]);
44}
diff --git a/src/lib/libc/string/index.c b/src/lib/libc/string/index.c
deleted file mode 100644
index 50e9ca35ab..0000000000
--- a/src/lib/libc/string/index.c
+++ /dev/null
@@ -1,47 +0,0 @@
1/* $OpenBSD: index.c,v 1.5 2005/08/08 08:05:37 espie 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
33char *
34#ifdef STRCHR
35strchr(const char *p, int ch)
36#else
37index(const char *p, int ch)
38#endif
39{
40 for (;; ++p) {
41 if (*p == ch)
42 return((char *)p);
43 if (!*p)
44 return((char *)NULL);
45 }
46 /* NOTREACHED */
47}
diff --git a/src/lib/libc/string/memccpy.3 b/src/lib/libc/string/memccpy.3
deleted file mode 100644
index f8f880e3b1..0000000000
--- a/src/lib/libc/string/memccpy.3
+++ /dev/null
@@ -1,75 +0,0 @@
1.\" $OpenBSD: memccpy.3,v 1.10 2011/07/25 00:38:52 schwarze 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: July 25 2011 $
33.Dt MEMCCPY 3
34.Os
35.Sh NAME
36.Nm memccpy
37.Nd copy string until character found
38.Sh SYNOPSIS
39.Fd #include <string.h>
40.Ft void *
41.Fn memccpy "void *dst" "const void *src" "int c" "size_t len"
42.Sh DESCRIPTION
43The
44.Fn memccpy
45function copies bytes from string
46.Fa src
47to string
48.Fa dst .
49If the character
50.Fa c
51(as converted to an
52.Li unsigned char )
53occurs in the string
54.Fa src ,
55the copy stops and a pointer to the byte after the copy of
56.Fa c
57in the string
58.Fa dst
59is returned.
60Otherwise,
61.Fa len
62bytes are copied, and a null pointer is returned.
63.Sh SEE ALSO
64.Xr bcopy 3 ,
65.Xr memcpy 3 ,
66.Xr memmove 3 ,
67.Xr strcpy 3 ,
68.Xr strlcpy 3
69.Sh HISTORY
70The
71.Fn memccpy
72function first appeared in
73.At V
74and was reimplemented for
75.Bx 4.3 Tahoe .
diff --git a/src/lib/libc/string/memccpy.c b/src/lib/libc/string/memccpy.c
deleted file mode 100644
index 485c55fcab..0000000000
--- a/src/lib/libc/string/memccpy.c
+++ /dev/null
@@ -1,48 +0,0 @@
1/* $OpenBSD: memccpy.c,v 1.6 2005/08/08 08:05:37 espie 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
34void *
35memccpy(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}
diff --git a/src/lib/libc/string/memchr.3 b/src/lib/libc/string/memchr.3
deleted file mode 100644
index 56a4e4780e..0000000000
--- a/src/lib/libc/string/memchr.3
+++ /dev/null
@@ -1,101 +0,0 @@
1.\" $OpenBSD: memchr.3,v 1.10 2011/07/25 00:38:52 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: July 25 2011 $
35.Dt MEMCHR 3
36.Os
37.Sh NAME
38.Nm memchr
39.Nd locate byte in byte string
40.Sh SYNOPSIS
41.Fd #include <string.h>
42.Ft void *
43.Fn memchr "const void *b" "int c" "size_t len"
44.Ft void *
45.Fn memrchr "const void *b" "int c" "size_t len"
46.Sh DESCRIPTION
47The
48.Fn memchr
49function locates the first occurrence of
50.Fa c
51(converted to an
52.Li unsigned char )
53in string
54.Fa b .
55.Pp
56The
57.Fn memrchr
58function behaves like
59.Fn memchr ,
60except that it locates the last occurrence of
61.Fa c
62in string
63.Fa b .
64.Sh RETURN VALUES
65The
66.Fn memchr
67and
68.Fn memrchr
69functions return a pointer to the byte located, or
70.Dv NULL
71if no such byte exists within
72.Fa len
73bytes.
74.Sh SEE ALSO
75.Xr strchr 3 ,
76.Xr strcspn 3 ,
77.Xr strpbrk 3 ,
78.Xr strrchr 3 ,
79.Xr strsep 3 ,
80.Xr strspn 3 ,
81.Xr strstr 3 ,
82.Xr strtok 3 ,
83.Xr wmemchr 3
84.Sh STANDARDS
85The
86.Fn memchr
87function conforms to
88.St -ansiC .
89.Pp
90The
91.Fn memrchr
92function is an
93.Ox
94extension.
95.Sh HISTORY
96The
97.Fn memchr
98function first appeared in
99.At V
100and was reimplemented for
101.Bx 4.3 Tahoe .
diff --git a/src/lib/libc/string/memchr.c b/src/lib/libc/string/memchr.c
deleted file mode 100644
index 4573e3ceb1..0000000000
--- a/src/lib/libc/string/memchr.c
+++ /dev/null
@@ -1,48 +0,0 @@
1/* $OpenBSD: memchr.c,v 1.7 2005/08/08 08:05:37 espie 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
36void *
37memchr(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}
diff --git a/src/lib/libc/string/memcmp.3 b/src/lib/libc/string/memcmp.3
deleted file mode 100644
index 951a04ed8a..0000000000
--- a/src/lib/libc/string/memcmp.3
+++ /dev/null
@@ -1,85 +0,0 @@
1.\" $OpenBSD: memcmp.3,v 1.7 2011/07/25 00:38:52 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: July 25 2011 $
35.Dt MEMCMP 3
36.Os
37.Sh NAME
38.Nm memcmp
39.Nd compare byte string
40.Sh SYNOPSIS
41.Fd #include <string.h>
42.Ft int
43.Fn memcmp "const void *b1" "const void *b2" "size_t len"
44.Sh DESCRIPTION
45The
46.Fn memcmp
47function compares byte string
48.Fa b1
49against byte string
50.Fa b2 .
51Both strings are assumed to be
52.Fa len
53bytes long.
54.Sh RETURN VALUES
55The
56.Fn memcmp
57function returns zero if the two strings are identical,
58otherwise returns the difference between the first two differing bytes
59(treated as
60.Li unsigned char
61values, so that
62.Sq Li \e200
63is greater than
64.Sq Li \&\e0 ,
65for example).
66Zero-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 wmemcmp 3
74.Sh STANDARDS
75The
76.Fn memcmp
77function conforms to
78.St -ansiC .
79.Sh HISTORY
80The
81.Fn memcmp
82function first appeared in
83.At V
84and was reimplemented for
85.Bx 4.3 Tahoe .
diff --git a/src/lib/libc/string/memcmp.c b/src/lib/libc/string/memcmp.c
deleted file mode 100644
index 49384a6fb9..0000000000
--- a/src/lib/libc/string/memcmp.c
+++ /dev/null
@@ -1,51 +0,0 @@
1/* $OpenBSD: memcmp.c,v 1.5 2005/08/08 08:05:37 espie 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 */
39int
40memcmp(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}
diff --git a/src/lib/libc/string/memcpy.3 b/src/lib/libc/string/memcpy.3
deleted file mode 100644
index e95d670ad9..0000000000
--- a/src/lib/libc/string/memcpy.3
+++ /dev/null
@@ -1,85 +0,0 @@
1.\" $OpenBSD: memcpy.3,v 1.8 2011/07/25 00:38:52 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: July 25 2011 $
35.Dt MEMCPY 3
36.Os
37.Sh NAME
38.Nm memcpy
39.Nd copy bytes
40.Sh SYNOPSIS
41.Fd #include <string.h>
42.Ft void *
43.Fn memcpy "void *dst" "const void *src" "size_t len"
44.Sh DESCRIPTION
45The
46.Fn memcpy
47function copies
48.Fa len
49bytes from buffer
50.Fa src
51to buffer
52.Fa dst .
53.Sh RETURN VALUES
54The
55.Fn memcpy
56function returns the original value of
57.Fa dst .
58.Sh SEE ALSO
59.Xr bcopy 3 ,
60.Xr memccpy 3 ,
61.Xr memmove 3 ,
62.Xr strcpy 3 ,
63.Xr strlcpy 3 ,
64.Xr wmemcpy 3
65.Sh STANDARDS
66The
67.Fn memcpy
68function conforms to
69.St -ansiC .
70.Sh HISTORY
71The
72.Fn memcpy
73function first appeared in
74.At V
75and was reimplemented for
76.Bx 4.3 Tahoe .
77.Sh CAVEATS
78In this implementation
79.Fn memcpy
80is implemented using
81.Xr bcopy 3 ,
82and therefore the buffers may overlap.
83On other systems, copying overlapping buffers may produce surprises.
84A portable, safe solution is to use
85.Xr memmove 3 .
diff --git a/src/lib/libc/string/memmove.3 b/src/lib/libc/string/memmove.3
deleted file mode 100644
index ae8569a1c7..0000000000
--- a/src/lib/libc/string/memmove.3
+++ /dev/null
@@ -1,76 +0,0 @@
1.\" $OpenBSD: memmove.3,v 1.8 2011/07/25 00:38:52 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: July 25 2011 $
35.Dt MEMMOVE 3
36.Os
37.Sh NAME
38.Nm memmove
39.Nd copy bytes
40.Sh SYNOPSIS
41.Fd #include <string.h>
42.Ft void *
43.Fn memmove "void *dst" "const void *src" "size_t len"
44.Sh DESCRIPTION
45The
46.Fn memmove
47function copies
48.Fa len
49bytes from buffer
50.Fa src
51to buffer
52.Fa dst .
53The two buffers may overlap;
54the copy is always done in a non-destructive manner.
55.Sh RETURN VALUES
56The
57.Fn memmove
58function 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
68The
69.Fn memmove
70function conforms to
71.St -ansiC .
72.Sh HISTORY
73The
74.Fn memmove
75function first appeared in
76.Bx 4.3 Reno .
diff --git a/src/lib/libc/string/memrchr.c b/src/lib/libc/string/memrchr.c
deleted file mode 100644
index bd27ebc620..0000000000
--- a/src/lib/libc/string/memrchr.c
+++ /dev/null
@@ -1,38 +0,0 @@
1/* $OpenBSD: memrchr.c,v 1.2 2007/11/27 16:22:12 martynas Exp $ */
2
3/*
4 * Copyright (c) 2007 Todd C. Miller <Todd.Miller@courtesan.com>
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 */
25void *
26memrchr(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}
diff --git a/src/lib/libc/string/memset.3 b/src/lib/libc/string/memset.3
deleted file mode 100644
index db94cb9ba6..0000000000
--- a/src/lib/libc/string/memset.3
+++ /dev/null
@@ -1,75 +0,0 @@
1.\" $OpenBSD: memset.3,v 1.7 2011/07/25 00:38:52 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: July 25 2011 $
35.Dt MEMSET 3
36.Os
37.Sh NAME
38.Nm memset
39.Nd write a byte to byte string
40.Sh SYNOPSIS
41.Fd #include <string.h>
42.Ft void *
43.Fn memset "void *b" "int c" "size_t len"
44.Sh DESCRIPTION
45The
46.Fn memset
47function writes
48.Fa len
49bytes of value
50.Fa c
51(converted to an
52.Li unsigned char )
53to the string
54.Fa b .
55.Sh RETURN VALUES
56The
57.Fn memset
58function 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
65The
66.Fn memset
67function conforms to
68.St -ansiC .
69.Sh HISTORY
70The
71.Fn memset
72function first appeared in
73.At V
74and was reimplemented for
75.Bx 4.3 Tahoe .
diff --git a/src/lib/libc/string/memset.c b/src/lib/libc/string/memset.c
deleted file mode 100644
index 61709c139d..0000000000
--- a/src/lib/libc/string/memset.c
+++ /dev/null
@@ -1,47 +0,0 @@
1/* $OpenBSD: memset.c,v 1.6 2008/03/15 21:40:39 ray 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
36void *
37memset(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}
diff --git a/src/lib/libc/string/rindex.c b/src/lib/libc/string/rindex.c
deleted file mode 100644
index bf9d6f7cf1..0000000000
--- a/src/lib/libc/string/rindex.c
+++ /dev/null
@@ -1,49 +0,0 @@
1/* $OpenBSD: rindex.c,v 1.6 2005/08/08 08:05:37 espie 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
33char *
34#ifdef STRRCHR
35strrchr(const char *p, int ch)
36#else
37rindex(const char *p, int ch)
38#endif
39{
40 char *save;
41
42 for (save = NULL;; ++p) {
43 if (*p == ch)
44 save = (char *)p;
45 if (!*p)
46 return(save);
47 }
48 /* NOTREACHED */
49}
diff --git a/src/lib/libc/string/stpcpy.3 b/src/lib/libc/string/stpcpy.3
deleted file mode 100644
index 447bfc20a9..0000000000
--- a/src/lib/libc/string/stpcpy.3
+++ /dev/null
@@ -1,117 +0,0 @@
1.\" $OpenBSD: stpcpy.3,v 1.2 2012/01/17 08:12:12 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: January 17 2012 $
35.Dt STPCPY 3
36.Os
37.Sh NAME
38.Nm stpcpy ,
39.Nm stpncpy
40.Nd copy strings
41.Sh SYNOPSIS
42.Fd #include <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
48The
49.Fn stpcpy
50and
51.Fn stpncpy
52functions copy the string
53.Fa src
54to
55.Fa dst
56(including the terminating
57.Ql \e0
58character).
59.Pp
60The
61.Fn stpncpy
62function copies not more than
63.Fa len
64characters into
65.Fa dst ,
66appending
67.Ql \e0
68characters if
69.Fa src
70is less than
71.Fa len
72characters long, and
73.Em not
74terminating
75.Fa dst
76if the length of
77.Fa src
78is greater than or equal to
79.Fa len .
80.Sh RETURN VALUES
81The
82.Fn stpcpy
83function returns a pointer to the terminating
84.Ql \e0
85character written into
86.Fa dst .
87.Pp
88The
89.Fn stpncpy
90function returns a pointer to the first
91.Ql \e0
92character written into
93.Fa dst ,
94or to
95.Fa &dst[len]
96if the length of
97.Fa src
98is greater than or equal to
99.Fa len .
100.Sh SEE ALSO
101.Xr strcpy 3 ,
102.Xr strlcpy 3 ,
103.Xr strncpy 3
104.Sh STANDARDS
105The
106.Fn stpcpy
107and
108.Fn stpncpy
109functions conform to
110.St -p1003.1-2008 .
111.Sh HISTORY
112The
113.Fn stpcpy
114and
115.Fn stpncpy
116functions first appeared in
117.Ox 5.1 .
diff --git a/src/lib/libc/string/stpcpy.c b/src/lib/libc/string/stpcpy.c
deleted file mode 100644
index d3d61e0f14..0000000000
--- a/src/lib/libc/string/stpcpy.c
+++ /dev/null
@@ -1,44 +0,0 @@
1/* $OpenBSD: stpcpy.c,v 1.1 2012/01/17 02:48:01 guenther 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 "warning: stpcpy() is dangerous GNU crap; don't use it");
37#endif
38
39char *
40stpcpy(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 c7c2a57c4c..0000000000
--- a/src/lib/libc/string/stpncpy.c
+++ /dev/null
@@ -1,56 +0,0 @@
1/* $OpenBSD: stpncpy.c,v 1.2 2012/07/11 10:44:59 naddy 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
37char *
38stpncpy(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}
diff --git a/src/lib/libc/string/strcasecmp.3 b/src/lib/libc/string/strcasecmp.3
deleted file mode 100644
index 0900c8a97a..0000000000
--- a/src/lib/libc/string/strcasecmp.3
+++ /dev/null
@@ -1,92 +0,0 @@
1.\" $OpenBSD: strcasecmp.3,v 1.11 2011/07/25 00:38:52 schwarze 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.\" 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.\" @(#)strcasecmp.3 8.1 (Berkeley) 6/9/93
33.\"
34.Dd $Mdocdate: July 25 2011 $
35.Dt STRCASECMP 3
36.Os
37.Sh NAME
38.Nm strcasecmp ,
39.Nm strncasecmp
40.Nd compare strings, ignoring case
41.Sh SYNOPSIS
42.Fd #include <string.h>
43.Ft int
44.Fn strcasecmp "const char *s1" "const char *s2"
45.Ft int
46.Fn strncasecmp "const char *s1" "const char *s2" "size_t len"
47.Sh DESCRIPTION
48The
49.Fn strcasecmp
50and
51.Fn strncasecmp
52functions compare the NUL-terminated strings
53.Fa s1
54and
55.Fa s2
56and return an integer greater than, equal to, or less than 0,
57according to whether
58.Fa s1
59is lexicographically greater than, equal to, or less than
60.Fa s2
61after translation of each corresponding character to lower-case.
62The strings themselves are not modified.
63The comparison is done using unsigned characters, so that
64.Sq Li \e200
65is greater than
66.Ql \e0 .
67.Pp
68.Fn strncasecmp
69compares at most
70.Fa len
71characters.
72.Sh SEE ALSO
73.Xr bcmp 3 ,
74.Xr memcmp 3 ,
75.Xr strcmp 3 ,
76.Xr strcoll 3 ,
77.Xr strxfrm 3 ,
78.Xr wcscasecmp 3
79.Sh STANDARDS
80The
81.Fn strcasecmp
82and
83.Fn strncasecmp
84functions conform to
85.St -p1003.1-2008 .
86.Sh HISTORY
87The
88.Fn strcasecmp
89and
90.Fn strncasecmp
91functions first appeared in
92.Bx 4.3 Tahoe .
diff --git a/src/lib/libc/string/strcasecmp.c b/src/lib/libc/string/strcasecmp.c
deleted file mode 100644
index 2be09136c0..0000000000
--- a/src/lib/libc/string/strcasecmp.c
+++ /dev/null
@@ -1,105 +0,0 @@
1/* $OpenBSD: strcasecmp.c,v 1.6 2005/08/08 08:05:37 espie 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
34typedef 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 */
41static 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
76int
77strcasecmp(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
89int
90strncasecmp(const char *s1, const char *s2, size_t n)
91{
92 if (n != 0) {
93 const u_char *cm = charmap;
94 const u_char *us1 = (const u_char *)s1;
95 const u_char *us2 = (const u_char *)s2;
96
97 do {
98 if (cm[*us1] != cm[*us2++])
99 return (cm[*us1] - cm[*--us2]);
100 if (*us1++ == '\0')
101 break;
102 } while (--n != 0);
103 }
104 return (0);
105}
diff --git a/src/lib/libc/string/strcasestr.c b/src/lib/libc/string/strcasestr.c
deleted file mode 100644
index aa74c0176d..0000000000
--- a/src/lib/libc/string/strcasestr.c
+++ /dev/null
@@ -1,60 +0,0 @@
1/* $OpenBSD: strcasestr.c,v 1.3 2006/03/31 05:34:55 deraadt 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 */
42char *
43strcasestr(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}
diff --git a/src/lib/libc/string/strcat.3 b/src/lib/libc/string/strcat.3
deleted file mode 100644
index 81aae19a63..0000000000
--- a/src/lib/libc/string/strcat.3
+++ /dev/null
@@ -1,141 +0,0 @@
1.\" $OpenBSD: strcat.3,v 1.13 2011/07/25 00:38:52 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: July 25 2011 $
35.Dt STRCAT 3
36.Os
37.Sh NAME
38.Nm strcat ,
39.Nm strncat
40.Nd concatenate strings
41.Sh SYNOPSIS
42.Fd #include <string.h>
43.Ft char *
44.Fn strcat "char *s" "const char *append"
45.Ft char *
46.Fn strncat "char *s" "const char *append" "size_t count"
47.Sh DESCRIPTION
48The
49.Fn strcat
50and
51.Fn strncat
52functions append a copy of the NUL-terminated string
53.Fa append
54to the end of the NUL-terminated string
55.Fa s ,
56then add a terminating
57.Ql \e0 .
58The string
59.Fa s
60must have sufficient space to hold the result.
61.Pp
62The
63.Fn strncat
64function appends not more than
65.Fa count
66characters where space for the terminating
67.Ql \e0
68should not be included in
69.Fa count .
70.Sh RETURN VALUES
71The
72.Fn strcat
73and
74.Fn strncat
75functions return the pointer
76.Fa s .
77.Sh EXAMPLES
78The following appends
79.Dq Li abc
80to
81.Va chararray :
82.Bd -literal -offset indent
83char *letters = "abcdefghi";
84
85(void)strncat(chararray, letters, 3);
86.Ed
87.Pp
88The following example shows how to use
89.Fn strncat
90safely in conjunction with
91.Xr strncpy 3 .
92.Bd -literal -offset indent
93char buf[BUFSIZ];
94char *input, *suffix;
95
96(void)strncpy(buf, input, sizeof(buf) - 1);
97buf[sizeof(buf) - 1] = '\e0';
98(void)strncat(buf, suffix, sizeof(buf) - 1 - strlen(buf));
99.Ed
100.Pp
101The above will copy as many characters from
102.Va input
103to
104.Va buf
105as will fit.
106It then appends as many characters from
107.Va suffix
108as will fit (or none
109if there is no space).
110For operations like this, the
111.Xr strlcpy 3
112and
113.Xr strlcat 3
114functions are a better choice, as shown below.
115.Bd -literal -offset indent
116(void)strlcpy(buf, input, sizeof(buf));
117(void)strlcat(buf, suffix, sizeof(buf));
118.Ed
119.Sh SEE ALSO
120.Xr bcopy 3 ,
121.Xr memccpy 3 ,
122.Xr memcpy 3 ,
123.Xr memmove 3 ,
124.Xr strcpy 3 ,
125.Xr strlcpy 3 ,
126.Xr wcscat 3 ,
127.Xr wcslcpy 3
128.Sh STANDARDS
129The
130.Fn strcat
131and
132.Fn strncat
133functions conform to
134.St -ansiC .
135.Sh HISTORY
136The
137.Fn strcat
138and
139.Fn strncat
140functions first appeared in
141.At v7 .
diff --git a/src/lib/libc/string/strcat.c b/src/lib/libc/string/strcat.c
deleted file mode 100644
index 7cea5229fb..0000000000
--- a/src/lib/libc/string/strcat.c
+++ /dev/null
@@ -1,51 +0,0 @@
1/* $OpenBSD: strcat.c,v 1.8 2005/08/08 08:05:37 espie 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#if !defined(_KERNEL) && !defined(_STANDALONE)
33#include <string.h>
34#else
35#include <lib/libkern/libkern.h>
36#endif
37
38#if defined(APIWARN)
39__warn_references(strcat,
40 "warning: strcat() is almost always misused, please use strlcat()");
41#endif
42
43char *
44strcat(char *s, const char *append)
45{
46 char *save = s;
47
48 for (; *s; ++s);
49 while ((*s++ = *append++) != '\0');
50 return(save);
51}
diff --git a/src/lib/libc/string/strchr.3 b/src/lib/libc/string/strchr.3
deleted file mode 100644
index d3194dffab..0000000000
--- a/src/lib/libc/string/strchr.3
+++ /dev/null
@@ -1,114 +0,0 @@
1.\" $OpenBSD: strchr.3,v 1.10 2011/07/25 00:38:53 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: July 25 2011 $
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.Fd #include <string.h>
43.Ft char *
44.Fn strchr "const char *s" "int c"
45.Ft char *
46.Fn index "const char *s" "int c"
47.Sh DESCRIPTION
48The
49.Fn strchr
50function locates the first occurrence of the character
51.Fa c
52in the string
53.Fa s .
54The terminating NUL character is considered part of the string.
55If
56.Fa c
57is
58.Ql \e0 ,
59.Fn strchr
60locates the terminating
61.Ql \e0 .
62.Pp
63The
64.Fn index
65function is an old synonym for
66.Fn strchr .
67.Sh RETURN VALUES
68The
69.Fn strchr
70function returns a pointer to the located character or
71.Dv NULL
72if the character does not appear in the string.
73.Sh EXAMPLES
74After the following call to
75.Fn strchr ,
76.Va p
77will point to the string
78.Qq oobar :
79.Bd -literal -offset indent
80char *p;
81char *s = "foobar";
82
83p = strchr(s, 'o');
84.Ed
85.Sh SEE ALSO
86.Xr memchr 3 ,
87.Xr strcspn 3 ,
88.Xr strpbrk 3 ,
89.Xr strrchr 3 ,
90.Xr strsep 3 ,
91.Xr strspn 3 ,
92.Xr strstr 3 ,
93.Xr strtok 3 ,
94.Xr wcschr 3
95.Sh STANDARDS
96The
97.Fn strchr
98function conforms to
99.St -ansiC .
100.Pp
101The
102.Fn index
103function is deprecated and shouldn't be used in new code.
104.Sh HISTORY
105The
106.Fn index
107function first appeared in
108.At v7 .
109The
110.Fn strchr
111function first appeared in
112.At III
113and was reimplemented for
114.Bx 4.3 Tahoe .
diff --git a/src/lib/libc/string/strcmp.3 b/src/lib/libc/string/strcmp.3
deleted file mode 100644
index 5b0794208a..0000000000
--- a/src/lib/libc/string/strcmp.3
+++ /dev/null
@@ -1,95 +0,0 @@
1.\" $OpenBSD: strcmp.3,v 1.12 2011/07/25 07:51:30 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: July 25 2011 $
35.Dt STRCMP 3
36.Os
37.Sh NAME
38.Nm strcmp ,
39.Nm strncmp
40.Nd compare strings
41.Sh SYNOPSIS
42.Fd #include <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
48The
49.Fn strcmp
50and
51.Fn strncmp
52functions lexicographically compare the NUL-terminated strings
53.Fa s1
54and
55.Fa s2 .
56The
57.Fn strncmp
58function compares at most
59.Fa len
60characters.
61.Sh RETURN VALUES
62The
63.Fn strcmp
64and
65.Fn strncmp
66functions return an integer greater than, equal to, or less than 0, according
67to whether the string
68.Fa s1
69is greater than, equal to, or less than the string
70.Fa s2 .
71The comparison is done using unsigned characters, so that
72.Ql \e200
73is 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
83The
84.Fn strcmp
85and
86.Fn strncmp
87functions conform to
88.St -ansiC .
89.Sh HISTORY
90The
91.Fn strcmp
92and
93.Fn strncmp
94functions 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 816fd111ac..0000000000
--- a/src/lib/libc/string/strcmp.c
+++ /dev/null
@@ -1,51 +0,0 @@
1/* $OpenBSD: strcmp.c,v 1.7 2005/08/08 08:05:37 espie 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#if !defined(_KERNEL) && !defined(_STANDALONE)
36#include <string.h>
37#else
38#include <lib/libkern/libkern.h>
39#endif
40
41/*
42 * Compare strings.
43 */
44int
45strcmp(const char *s1, const char *s2)
46{
47 while (*s1 == *s2++)
48 if (*s1++ == 0)
49 return (0);
50 return (*(unsigned char *)s1 - *(unsigned char *)--s2);
51}
diff --git a/src/lib/libc/string/strcoll.3 b/src/lib/libc/string/strcoll.3
deleted file mode 100644
index 72e398c44c..0000000000
--- a/src/lib/libc/string/strcoll.3
+++ /dev/null
@@ -1,73 +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 and the American National Standards Committee X3,
6.\" on Information 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: strcoll.3,v 1.8 2011/07/25 00:38:53 schwarze Exp $
33.\"
34.Dd $Mdocdate: July 25 2011 $
35.Dt STRCOLL 3
36.Os
37.Sh NAME
38.Nm strcoll
39.Nd compare strings according to current collation
40.Sh SYNOPSIS
41.Fd #include <string.h>
42.Ft int
43.Fn strcoll "const char *s1" "const char *s2"
44.Sh DESCRIPTION
45The
46.Fn strcoll
47function lexicographically compares the NUL-terminated strings
48.Fa s1
49and
50.Fa s2
51according to the current locale collation
52and returns an integer greater than, equal to, or less than 0,
53according to whether
54.Fa s1
55is greater than, equal to, or less than
56.Fa s2 .
57.Sh SEE ALSO
58.Xr bcmp 3 ,
59.Xr memcmp 3 ,
60.Xr setlocale 3 ,
61.Xr strcasecmp 3 ,
62.Xr strcmp 3 ,
63.Xr strxfrm 3
64.Sh STANDARDS
65The
66.Fn strcoll
67function conforms to
68.St -ansiC .
69.Sh HISTORY
70The
71.Fn strcoll
72function first appeared in
73.Bx 4.3 Reno .
diff --git a/src/lib/libc/string/strcoll.c b/src/lib/libc/string/strcoll.c
deleted file mode 100644
index 2df983bd65..0000000000
--- a/src/lib/libc/string/strcoll.c
+++ /dev/null
@@ -1,44 +0,0 @@
1/* $OpenBSD: strcoll.c,v 1.5 2005/08/08 08:05:37 espie 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 */
39int
40strcoll(const char *s1, const char *s2)
41{
42 /* LC_COLLATE is unimplemented, hence always "C" */
43 return (strcmp(s1, s2));
44}
diff --git a/src/lib/libc/string/strcpy.3 b/src/lib/libc/string/strcpy.3
deleted file mode 100644
index 400eeee622..0000000000
--- a/src/lib/libc/string/strcpy.3
+++ /dev/null
@@ -1,162 +0,0 @@
1.\" $OpenBSD: strcpy.3,v 1.16 2011/07/25 00:38:53 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: July 25 2011 $
35.Dt STRCPY 3
36.Os
37.Sh NAME
38.Nm strcpy ,
39.Nm strncpy
40.Nd copy strings
41.Sh SYNOPSIS
42.Fd #include <string.h>
43.Ft char *
44.Fn strcpy "char *dst" "const char *src"
45.Ft char *
46.Fn strncpy "char *dst" "const char *src" "size_t len"
47.Sh DESCRIPTION
48The
49.Fn strcpy
50and
51.Fn strncpy
52functions copy the string
53.Fa src
54to
55.Fa dst
56(including the terminating
57.Ql \e0
58character).
59.Pp
60The
61.Fn strncpy
62function copies not more than
63.Fa len
64characters into
65.Fa dst ,
66appending
67.Ql \e0
68characters if
69.Fa src
70is less than
71.Fa len
72characters long, and
73.Em not
74terminating
75.Fa dst
76if the length of
77.Fa src
78is greater than or equal to
79.Fa len .
80.Sh RETURN VALUES
81The
82.Fn strcpy
83and
84.Fn strncpy
85functions return
86.Fa dst .
87.Sh EXAMPLES
88The following sets
89.Va chararray
90to
91.Dq abc\e0\e0\e0 :
92.Bd -literal -offset indent
93(void)strncpy(chararray, "abc", 6);
94.Ed
95.Pp
96The following sets
97.Va chararray
98to
99.Dq abcdef
100and does
101.Em not
102NUL terminate
103.Va chararray
104because the length of the source string is greater than or equal to the
105length parameter.
106.Fn strncpy
107.Em only
108NUL terminates the destination string when the length of the source
109string is less than the length parameter.
110.Bd -literal -offset indent
111(void)strncpy(chararray, "abcdefgh", 6);
112.Ed
113.Pp
114The following copies as many characters from
115.Va input
116to
117.Va buf
118as will fit and NUL terminates the result.
119Because
120.Fn strncpy
121does
122.Em not
123guarantee to NUL terminate the string itself, it must be done by hand.
124.Bd -literal -offset indent
125char buf[BUFSIZ];
126
127(void)strncpy(buf, input, sizeof(buf) - 1);
128buf[sizeof(buf) - 1] = '\e0';
129.Ed
130.Pp
131Note that
132.Xr strlcpy 3
133is a better choice for this kind of operation.
134The equivalent using
135.Xr strlcpy 3
136is simply:
137.Bd -literal -offset indent
138(void)strlcpy(buf, input, sizeof(buf));
139.Ed
140.Sh SEE ALSO
141.Xr bcopy 3 ,
142.Xr memccpy 3 ,
143.Xr memcpy 3 ,
144.Xr memmove 3 ,
145.Xr strcat 3 ,
146.Xr strlcpy 3 ,
147.Xr wcscpy 3 ,
148.Xr wcslcpy 3
149.Sh STANDARDS
150The
151.Fn strcpy
152and
153.Fn strncpy
154functions conform to
155.St -ansiC .
156.Sh HISTORY
157The
158.Fn strcpy
159and
160.Fn strncpy
161functions first appeared in
162.At v7 .
diff --git a/src/lib/libc/string/strcpy.c b/src/lib/libc/string/strcpy.c
deleted file mode 100644
index 71d90d4100..0000000000
--- a/src/lib/libc/string/strcpy.c
+++ /dev/null
@@ -1,50 +0,0 @@
1/* $OpenBSD: strcpy.c,v 1.8 2005/08/08 08:05:37 espie 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#if !defined(_KERNEL) && !defined(_STANDALONE)
33#include <string.h>
34#else
35#include <lib/libkern/libkern.h>
36#endif
37
38#if defined(APIWARN)
39__warn_references(strcpy,
40 "warning: strcpy() is almost always misused, please use strlcpy()");
41#endif
42
43char *
44strcpy(char *to, const char *from)
45{
46 char *save = to;
47
48 for (; (*to = *from) != '\0'; ++from, ++to);
49 return(save);
50}
diff --git a/src/lib/libc/string/strcspn.3 b/src/lib/libc/string/strcspn.3
deleted file mode 100644
index 70c8ef7612..0000000000
--- a/src/lib/libc/string/strcspn.3
+++ /dev/null
@@ -1,108 +0,0 @@
1.\" $OpenBSD: strcspn.3,v 1.10 2011/07/25 00:38:53 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: July 25 2011 $
35.Dt STRCSPN 3
36.Os
37.Sh NAME
38.Nm strcspn
39.Nd span the complement of a string
40.Sh SYNOPSIS
41.Fd #include <string.h>
42.Ft size_t
43.Fn strcspn "const char *s" "const char *charset"
44.Sh DESCRIPTION
45The
46.Fn strcspn
47function spans the initial part of the NUL-terminated string
48.Fa s
49as long as the characters from
50.Fa s
51do not occur in string
52.Fa charset
53(it spans the
54.Em complement
55of
56.Fa charset ) .
57.Sh RETURN VALUES
58The
59.Fn strcspn
60function returns the number of characters spanned.
61.Sh EXAMPLES
62The following call to
63.Fn strcspn
64will return 3, since the first three characters of string
65.Fa s
66do not occur in string
67.Fa charset :
68.Bd -literal -offset indent
69char *s = "foobar";
70char *charset = "bar";
71size_t span;
72
73span = strcspn(s, charset);
74.Ed
75.Pp
76The following removes the first (if any) newline character from string
77.Fa line .
78This is useful for trimming the newline after a
79.Xr fgets 3
80call.
81.Bd -literal -offset indent
82char line[BUFSIZ];
83
84if (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
98The
99.Fn strcspn
100function conforms to
101.St -ansiC .
102.Sh HISTORY
103The
104.Fn strcspn
105function first appeared in
106.At III
107and was reimplemented for
108.Bx 4.3 Tahoe .
diff --git a/src/lib/libc/string/strcspn.c b/src/lib/libc/string/strcspn.c
deleted file mode 100644
index 1eb233614d..0000000000
--- a/src/lib/libc/string/strcspn.c
+++ /dev/null
@@ -1,58 +0,0 @@
1/* $OpenBSD: strcspn.c,v 1.5 2005/08/08 08:05:37 espie 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 */
39size_t
40strcspn(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}
diff --git a/src/lib/libc/string/strdup.3 b/src/lib/libc/string/strdup.3
deleted file mode 100644
index 45a7bd1826..0000000000
--- a/src/lib/libc/string/strdup.3
+++ /dev/null
@@ -1,112 +0,0 @@
1.\" $OpenBSD: strdup.3,v 1.19 2011/12/08 08:06:19 lum 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 8 2011 $
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.Fd #include <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
46The
47.Fn strdup
48function allocates sufficient memory for a copy of the string
49.Fa s ,
50does the copy, and returns a pointer to it.
51The pointer may subsequently be used as an argument to the function
52.Xr free 3 .
53.Pp
54The
55.Fn strndup
56function behaves similarly to
57.Nm strdup
58but only copies up to
59.Fa maxlen
60characters from
61.Fa s .
62The resulting string is always NUL-terminated.
63.Pp
64If insufficient memory is available,
65.Dv NULL
66is returned.
67.Sh EXAMPLES
68The following will point
69.Va p
70to an allocated area of memory containing the NUL-terminated string
71.Qq foobar :
72.Bd -literal -offset indent
73char *p;
74
75p = strdup("foobar");
76if (p == NULL)
77 err(1, NULL);
78.Ed
79.Sh ERRORS
80The
81.Fn strdup
82and
83.Fn strndup
84functions may fail and set the external variable
85.Va errno
86for 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
96The
97.Fn strdup
98and
99.Fn strndup
100functions conform to
101.St -p1003.1-2008 .
102.Sh HISTORY
103The
104.Fn strdup
105function first appeared in
106.Bx 4.3 Reno .
107The
108.Fn strndup
109function appeared in glibc 2.0, was reimplemented for
110.Nx 4.0 ,
111and ported to
112.Ox 4.8 .
diff --git a/src/lib/libc/string/strdup.c b/src/lib/libc/string/strdup.c
deleted file mode 100644
index a6aa1e03b0..0000000000
--- a/src/lib/libc/string/strdup.c
+++ /dev/null
@@ -1,49 +0,0 @@
1/* $OpenBSD: strdup.c,v 1.6 2005/08/08 08:05:37 espie 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
38char *
39strdup(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}
diff --git a/src/lib/libc/string/strerror.3 b/src/lib/libc/string/strerror.3
deleted file mode 100644
index bab48af308..0000000000
--- a/src/lib/libc/string/strerror.3
+++ /dev/null
@@ -1,122 +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: strerror.3,v 1.11 2012/03/26 05:07:38 guenther Exp $
33.\"
34.Dd $Mdocdate: March 26 2012 $
35.Dt STRERROR 3
36.Os
37.Sh NAME
38.Nm strerror
39.Nd get error message string
40.Sh SYNOPSIS
41.Fd #include <string.h>
42.Ft char *
43.Fn strerror "int errnum"
44.Ft int
45.Fn strerror_r "int errnum" "char *strerrbuf" "size_t buflen"
46.Sh DESCRIPTION
47The
48.Fn strerror
49and
50.Fn strerror_r
51functions map the error number
52.Fa errnum
53to a language-dependent error message string.
54.Pp
55.Fn strerror
56returns a string containing a maximum of
57.Dv NL_TEXTMAX
58characters, including the trailing NUL.
59This string is not to be modified by the calling program,
60but may be overwritten by subsequent calls to
61.Fn strerror .
62.Pp
63.Fn strerror_r
64is a thread safe version of
65.Fn strerror
66that places the error message in the specified buffer
67.Fa strerrbuf .
68.Sh RETURN VALUES
69.Fn strerror
70returns a pointer to the error message string.
71If an error occurs, the error code is stored in
72.Va errno .
73.Pp
74.Fn strerror_r
75returns zero upon successful completion.
76If an error occurs, the error code is stored in
77.Va errno
78and the error code is returned.
79.Sh ERRORS
80.Fn strerror
81and
82.Fn strerror_r
83may fail if:
84.Bl -tag -width Er
85.It Bq Er EINVAL
86.Fa errnum
87is not a valid error number.
88The returned error string will consist of an error message that includes
89.Fa errnum .
90.El
91.Pp
92.Fn strerror_r
93may fail if:
94.Bl -tag -width Er
95.It Bq Er ERANGE
96The error message is larger than
97.Fa buflen
98characters.
99The message will be truncated to fit.
100.El
101.Sh SEE ALSO
102.Xr intro 2 ,
103.Xr perror 3 ,
104.Xr setlocale 3
105.Sh STANDARDS
106The
107.Fn strerror
108function conforms to
109.St -ansiC-99 .
110The
111.Fn strerror_r
112function conforms to
113.St -p1003.1-2008 .
114.Sh HISTORY
115The
116.Fn strerror
117function first appeared in
118.Bx 4.3 Reno .
119The
120.Fn strerror_r
121function first appeared in
122.Ox 3.3 .
diff --git a/src/lib/libc/string/strerror.c b/src/lib/libc/string/strerror.c
deleted file mode 100644
index 13996f08e9..0000000000
--- a/src/lib/libc/string/strerror.c
+++ /dev/null
@@ -1,41 +0,0 @@
1/* $OpenBSD: strerror.c,v 1.7 2005/08/08 08:05:37 espie 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
34char *
35strerror(int num)
36{
37 static char buf[NL_TEXTMAX];
38
39 (void)strerror_r(num, buf, sizeof(buf));
40 return (buf);
41}
diff --git a/src/lib/libc/string/strerror_r.c b/src/lib/libc/string/strerror_r.c
deleted file mode 100644
index aa63408ab8..0000000000
--- a/src/lib/libc/string/strerror_r.c
+++ /dev/null
@@ -1,137 +0,0 @@
1/* $OpenBSD: strerror_r.c,v 1.7 2007/03/01 16:29:09 bluhm Exp $ */
2/* Public Domain <marc@snafu.org> */
3
4#ifdef NLS
5#define catclose _catclose
6#define catgets _catgets
7#define catopen _catopen
8#include <nl_types.h>
9#endif
10
11#define sys_errlist _sys_errlist
12#define sys_nerr _sys_nerr
13#define sys_siglist _sys_siglist
14
15#include <errno.h>
16#include <limits.h>
17#include <signal.h>
18#include <string.h>
19
20static size_t
21__digits10(unsigned int num)
22{
23 size_t i = 0;
24
25 do {
26 num /= 10;
27 i++;
28 } while (num != 0);
29
30 return i;
31}
32
33static int
34__itoa(int num, int sign, char *buffer, size_t start, size_t end)
35{
36 size_t pos;
37 unsigned int a;
38 int neg;
39
40 if (sign && num < 0) {
41 a = -num;
42 neg = 1;
43 }
44 else {
45 a = num;
46 neg = 0;
47 }
48
49 pos = start + __digits10(a);
50 if (neg)
51 pos++;
52
53 if (pos < end)
54 buffer[pos] = '\0';
55 else
56 return ERANGE;
57 pos--;
58 do {
59 buffer[pos] = (a % 10) + '0';
60 pos--;
61 a /= 10;
62 } while (a != 0);
63 if (neg)
64 buffer[pos] = '-';
65 return 0;
66}
67
68
69static int
70__num2string(int num, int sign, int setid, char *buf, size_t buflen,
71 char * list[], size_t max, const char *def)
72{
73 int ret = 0;
74 size_t len;
75
76#ifdef NLS
77 nl_catd catd;
78 catd = catopen("libc", 0);
79#endif
80
81 if (0 <= num && num < max) {
82#ifdef NLS
83 len = strlcpy(buf, catgets(catd, setid, num, list[num]),
84 buflen);
85#else
86 len = strlcpy(buf, list[num], buflen);
87#endif
88 if (len >= buflen)
89 ret = ERANGE;
90 } else {
91#ifdef NLS
92 len = strlcpy(buf, catgets(catd, setid, 0xffff, def), buflen);
93#else
94 len = strlcpy(buf, def, buflen);
95#endif
96 if (len >= buflen)
97 ret = ERANGE;
98 else {
99 ret = __itoa(num, sign, buf, len, buflen);
100 if (ret == 0)
101 ret = EINVAL;
102 }
103 }
104
105#ifdef NLS
106 catclose(catd);
107#endif
108
109 return ret;
110}
111
112#define UPREFIX "Unknown error: "
113
114int
115strerror_r(int errnum, char *strerrbuf, size_t buflen)
116{
117 int save_errno;
118 int ret_errno;
119
120 save_errno = errno;
121
122 ret_errno = __num2string(errnum, 1, 1, strerrbuf, buflen,
123 sys_errlist, sys_nerr, UPREFIX);
124
125 errno = ret_errno ? ret_errno : save_errno;
126 return (ret_errno);
127}
128
129#define USIGPREFIX "Unknown signal: "
130
131char *
132__strsignal(int num, char *buf)
133{
134 __num2string(num, 0, 2, buf, NL_TEXTMAX, (char **)sys_siglist, NSIG,
135 USIGPREFIX);
136 return buf;
137}
diff --git a/src/lib/libc/string/string.3 b/src/lib/libc/string/string.3
deleted file mode 100644
index 4d47ad444d..0000000000
--- a/src/lib/libc/string/string.3
+++ /dev/null
@@ -1,136 +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: string.3,v 1.12 2007/05/31 19:19:32 jmc Exp $
31.\"
32.Dd $Mdocdate: May 31 2007 $
33.Dt STRING 3
34.Os
35.Sh NAME
36.Nm string
37.Nd string specific functions
38.Sh SYNOPSIS
39.Fd #include <string.h>
40.Ft char *
41.Fn strcat "char *s" "const char *append"
42.Ft char *
43.Fn strlcat "char *s" "const char *append" "size_t size"
44.Ft char *
45.Fn strncat "char *s" "const char *append" "size_t count"
46.Ft char *
47.Fn strchr "const char *s" "int c"
48.Ft char *
49.Fn strrchr "const char *s" "int c"
50.Ft int
51.Fn strcmp "const char *s1" "const char *s2"
52.Ft int
53.Fn strncmp "const char *s1" "const char *s2" "size_t count"
54.Ft int
55.Fn strcasecmp "const char *s1" "const char *s2"
56.Ft int
57.Fn strncasecmp "const char *s1" "const char *s2" "size_t count"
58.Ft char *
59.Fn strcpy "char *dst" "const char *src"
60.Ft char *
61.Fn strlcpy "char *dst" "const char *src" "size_t size"
62.Ft char *
63.Fn strncpy "char *dst" "const char *src" "size_t count"
64.Ft char *
65.Fn strerror "int errno"
66.Ft size_t
67.Fn strlen "const char *s"
68.Ft char *
69.Fn strpbrk "const char *s" "const char *charset"
70.Ft char *
71.Fn strsep "char **stringp" "const char *delim"
72.Ft size_t
73.Fn strspn "const char *s" "const char *charset"
74.Ft size_t
75.Fn strcspn "const char *s" "const char *charset"
76.Ft char *
77.Fn strstr "const char *big" "const char *little"
78.Ft char *
79.Fn strtok "char *s" "const char *delim"
80.Ft char *
81.Fn index "const char *s" "int c"
82.Ft char *
83.Fn rindex "const char *s" "int c"
84.Sh DESCRIPTION
85The string functions
86manipulate strings terminated by a
87NUL byte.
88.Pp
89See the specific manual pages for more information.
90For manipulating variable length generic objects as byte
91strings (without the NUL-byte check), see
92.Xr bstring 3 .
93.Pp
94Except as noted in their specific manual pages,
95the string functions do not test the destination
96for size limitations.
97.Sh SEE ALSO
98.Xr bstring 3 ,
99.Xr index 3 ,
100.Xr rindex 3 ,
101.Xr strcasecmp 3 ,
102.Xr strcat 3 ,
103.Xr strchr 3 ,
104.Xr strcmp 3 ,
105.Xr strcpy 3 ,
106.Xr strcspn 3 ,
107.Xr strerror 3 ,
108.Xr strlcat 3 ,
109.Xr strlcpy 3 ,
110.Xr strlen 3 ,
111.Xr strpbrk 3 ,
112.Xr strrchr 3 ,
113.Xr strsep 3 ,
114.Xr strspn 3 ,
115.Xr strstr 3 ,
116.Xr strtok 3
117.Sh STANDARDS
118The
119.Fn strcat ,
120.Fn strncat ,
121.Fn strchr ,
122.Fn strrchr ,
123.Fn strcmp ,
124.Fn strncmp ,
125.Fn strcpy ,
126.Fn strncpy ,
127.Fn strerror ,
128.Fn strlen ,
129.Fn strpbrk ,
130.Fn strspn ,
131.Fn strcspn ,
132.Fn strstr ,
133and
134.Fn strtok
135functions conform to
136.St -ansiC .
diff --git a/src/lib/libc/string/strlcat.c b/src/lib/libc/string/strlcat.c
deleted file mode 100644
index ceab094411..0000000000
--- a/src/lib/libc/string/strlcat.c
+++ /dev/null
@@ -1,55 +0,0 @@
1/* $OpenBSD: strlcat.c,v 1.13 2005/08/08 08:05:37 espie Exp $ */
2
3/*
4 * Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com>
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 siz (unlike strncat, siz is the
24 * full size of dst, not space left). At most siz-1 characters
25 * will be copied. Always NUL terminates (unless siz <= strlen(dst)).
26 * Returns strlen(src) + MIN(siz, strlen(initial dst)).
27 * If retval >= siz, truncation occurred.
28 */
29size_t
30strlcat(char *dst, const char *src, size_t siz)
31{
32 char *d = dst;
33 const char *s = src;
34 size_t n = siz;
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 && *d != '\0')
39 d++;
40 dlen = d - dst;
41 n = siz - dlen;
42
43 if (n == 0)
44 return(dlen + strlen(s));
45 while (*s != '\0') {
46 if (n != 1) {
47 *d++ = *s;
48 n--;
49 }
50 s++;
51 }
52 *d = '\0';
53
54 return(dlen + (s - src)); /* count does not include NUL */
55}
diff --git a/src/lib/libc/string/strlcpy.3 b/src/lib/libc/string/strlcpy.3
deleted file mode 100644
index acce0f7d43..0000000000
--- a/src/lib/libc/string/strlcpy.3
+++ /dev/null
@@ -1,182 +0,0 @@
1.\" $OpenBSD: strlcpy.3,v 1.22 2012/04/03 14:01:55 jmc Exp $
2.\"
3.\" Copyright (c) 1998, 2000 Todd C. Miller <Todd.Miller@courtesan.com>
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: April 3 2012 $
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.Fd #include <string.h>
26.Ft size_t
27.Fn strlcpy "char *dst" "const char *src" "size_t dstsize"
28.Ft size_t
29.Fn strlcat "char *dst" "const char *src" "size_t dstsize"
30.Sh DESCRIPTION
31The
32.Fn strlcpy
33and
34.Fn strlcat
35functions copy and concatenate strings with the
36same input parameters and output result as
37.Xr snprintf 3 .
38They are designed to be safer, more consistent, and less error
39prone replacements for the easily misused functions
40.Xr strncpy 3
41and
42.Xr strncat 3 .
43.Pp
44.Fn strlcpy
45and
46.Fn strlcat
47take the full size of the destination buffer and guarantee
48NUL-termination if there is room.
49Note that room for the NUL should be included in
50.Fa dstsize .
51.Pp
52.Fn strlcpy
53copies up to
54.Fa dstsize
55\- 1 characters from the string
56.Fa src
57to
58.Fa dst ,
59NUL-terminating the result if
60.Fa dstsize
61is not 0.
62.Pp
63.Fn strlcat
64appends string
65.Fa src
66to the end of
67.Fa dst .
68It will append at most
69.Fa dstsize
70\- strlen(dst) \- 1 characters.
71It will then NUL-terminate, unless
72.Fa dstsize
73is 0 or the original
74.Fa dst
75string was longer than
76.Fa dstsize
77(in practice this should not happen
78as it means that either
79.Fa dstsize
80is incorrect or that
81.Fa dst
82is not a proper string).
83.Sh RETURN VALUES
84Besides quibbles over the return type
85.Pf ( Va size_t
86versus
87.Va int )
88and signal handler safety
89.Pf ( Xr snprintf 3
90is not entirely safe on some systems), the
91following two are equivalent:
92.Bd -literal -offset indent
93n = strlcpy(dst, src, len);
94n = snprintf(dst, len, "%s", src);
95.Ed
96.Pp
97Like
98.Xr snprintf 3 ,
99the
100.Fn strlcpy
101and
102.Fn strlcat
103functions return the total length of the string they tried to create.
104For
105.Fn strlcpy
106that means the length of
107.Fa src .
108For
109.Fn strlcat
110that means the initial length of
111.Fa dst
112plus
113the length of
114.Fa src .
115.Pp
116If the return value is
117.Cm >=
118.Va dstsize ,
119the output string has been truncated.
120It is the caller's responsibility to handle this.
121.Sh EXAMPLES
122The following code fragment illustrates the simple case:
123.Bd -literal -offset indent
124char *s, *p, buf[BUFSIZ];
125
126\&...
127
128(void)strlcpy(buf, s, sizeof(buf));
129(void)strlcat(buf, p, sizeof(buf));
130.Ed
131.Pp
132To detect truncation, perhaps while building a pathname, something
133like the following might be used:
134.Bd -literal -offset indent
135char *dir, *file, pname[MAXPATHLEN];
136
137\&...
138
139if (strlcpy(pname, dir, sizeof(pname)) >= sizeof(pname))
140 goto toolong;
141if (strlcat(pname, file, sizeof(pname)) >= sizeof(pname))
142 goto toolong;
143.Ed
144.Pp
145Since it is known how many characters were copied the first time, things
146can be sped up a bit by using a copy instead of an append:
147.Bd -literal -offset indent
148char *dir, *file, pname[MAXPATHLEN];
149size_t n;
150
151\&...
152
153n = strlcpy(pname, dir, sizeof(pname));
154if (n >= sizeof(pname))
155 goto toolong;
156if (strlcpy(pname + n, file, sizeof(pname) - n) >= sizeof(pname) - n)
157 goto toolong;
158.Ed
159.Pp
160However, one may question the validity of such optimizations, as they
161defeat the whole purpose of
162.Fn strlcpy
163and
164.Fn strlcat .
165As a matter of fact, the first version of this manual page got it wrong.
166.Sh SEE ALSO
167.Xr snprintf 3 ,
168.Xr strncat 3 ,
169.Xr strncpy 3 ,
170.Xr wcslcpy 3
171.Sh HISTORY
172.Fn strlcpy
173and
174.Fn strlcat
175first appeared in
176.Ox 2.4 .
177.Sh AUTHORS
178.Fn strlcpy
179and
180.Fn strlcat
181were created by
182.An Todd C. Miller Aq Todd.Miller@courtesan.com .
diff --git a/src/lib/libc/string/strlcpy.c b/src/lib/libc/string/strlcpy.c
deleted file mode 100644
index d32b6590f1..0000000000
--- a/src/lib/libc/string/strlcpy.c
+++ /dev/null
@@ -1,51 +0,0 @@
1/* $OpenBSD: strlcpy.c,v 1.11 2006/05/05 15:27:38 millert Exp $ */
2
3/*
4 * Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com>
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 src to string dst of size siz. At most siz-1 characters
24 * will be copied. Always NUL terminates (unless siz == 0).
25 * Returns strlen(src); if retval >= siz, truncation occurred.
26 */
27size_t
28strlcpy(char *dst, const char *src, size_t siz)
29{
30 char *d = dst;
31 const char *s = src;
32 size_t n = siz;
33
34 /* Copy as many bytes as will fit */
35 if (n != 0) {
36 while (--n != 0) {
37 if ((*d++ = *s++) == '\0')
38 break;
39 }
40 }
41
42 /* Not enough room in dst, add NUL and traverse rest of src */
43 if (n == 0) {
44 if (siz != 0)
45 *d = '\0'; /* NUL-terminate dst */
46 while (*s++)
47 ;
48 }
49
50 return(s - src - 1); /* count does not include NUL */
51}
diff --git a/src/lib/libc/string/strlen.3 b/src/lib/libc/string/strlen.3
deleted file mode 100644
index 9187496a00..0000000000
--- a/src/lib/libc/string/strlen.3
+++ /dev/null
@@ -1,104 +0,0 @@
1.\" $OpenBSD: strlen.3,v 1.10 2011/07/25 00:38:53 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: July 25 2011 $
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.Fd #include <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
48The
49.Fn strlen
50function computes the length of the string
51.Fa s .
52.Pp
53The
54.Fn strnlen
55function computes the length of the string
56.Fa s ,
57up to
58.Fa maxlen
59characters.
60The
61.Fn strnlen
62function will never attempt to address more than
63.Fa maxlen
64characters, making it suitable for use with character arrays that are
65not guaranteed to be NUL-terminated.
66.Sh RETURN VALUES
67The
68.Fn strlen
69function returns the number of characters that precede the terminating
70.Tn NUL
71character.
72.Pp
73The
74.Fn strnlen
75function returns the number of characters that precede the terminating
76.Tn NUL
77or
78.Fa maxlen ,
79whichever is smaller.
80.Sh SEE ALSO
81.Xr string 3 ,
82.Xr wcslen 3
83.Sh STANDARDS
84The
85.Fn strlen
86function conforms to
87.St -ansiC .
88.Pp
89The
90.Fn strlen
91and
92.Fn strnlen
93functions conform to
94.St -p1003.1-2008 .
95.Sh HISTORY
96The
97.Fn strlen
98function first appeared in
99.At v7 .
100The
101.Fn strnlen
102function appeared in glibc 2.0
103and was reimplemented for
104.Ox 4.8 .
diff --git a/src/lib/libc/string/strlen.c b/src/lib/libc/string/strlen.c
deleted file mode 100644
index 12d9ec4dad..0000000000
--- a/src/lib/libc/string/strlen.c
+++ /dev/null
@@ -1,47 +0,0 @@
1/* $OpenBSD: strlen.c,v 1.7 2005/08/08 08:05:37 espie 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#if !defined(_KERNEL) && !defined(_STANDALONE)
33#include <string.h>
34#else
35#include <lib/libkern/libkern.h>
36#endif
37
38size_t
39strlen(const char *str)
40{
41 const char *s;
42
43 for (s = str; *s; ++s)
44 ;
45 return (s - str);
46}
47
diff --git a/src/lib/libc/string/strmode.3 b/src/lib/libc/string/strmode.3
deleted file mode 100644
index 5d371b38c8..0000000000
--- a/src/lib/libc/string/strmode.3
+++ /dev/null
@@ -1,157 +0,0 @@
1.\" $OpenBSD: strmode.3,v 1.15 2011/07/25 00:38:53 schwarze 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 25 2011 $
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.Fd #include <string.h>
40.Ft void
41.Fn strmode "mode_t mode" "char *bp"
42.Sh DESCRIPTION
43The
44.Fn strmode
45function converts a file
46.Fa mode
47(the type and permission information associated with an inode, see
48.Xr stat 2 )
49into a symbolic string which is stored in the location referenced by
50.Fa bp .
51This stored string is eleven characters in length plus a trailing NUL byte.
52.Pp
53The 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 \-
57regular file
58.It b
59block special
60.It c
61character special
62.It d
63directory
64.It l
65symbolic link
66.It p
67FIFO
68.It s
69socket
70.It \&?
71unknown inode type
72.El
73.Pp
74The next nine characters encode three sets of permissions, in three
75characters each.
76The first three characters are the permissions for the owner of the
77file, the second three for the group the file belongs to, and the
78third for the
79.Dq other ,
80or default, set of users.
81.Pp
82Permission checking is done as specifically as possible.
83If read permission is denied to the owner of a file in the first set
84of permissions, the owner of the file will not be able to read the file.
85This is true even if the owner is in the file's group and the group
86permissions allow reading or the
87.Dq other
88permissions allow reading.
89.Pp
90If the first character of the three character set is an
91.Sq r ,
92the file is readable for that set of users; if a dash
93.Pq Ql - ,
94it is not readable.
95.Pp
96If the second character of the three character set is a
97.Sq w ,
98the file is writable for that set of users; if a dash
99.Pq Ql - ,
100it is not writable.
101.Pp
102The third character is the first of the following characters that apply:
103.Bl -tag -width xxxx
104.It S
105If the character is part of the owner permissions and the file is not
106executable or the directory is not searchable by the owner, and the
107set-user-ID bit is set.
108.It S
109If the character is part of the group permissions and the file is not
110executable or the directory is not searchable by the group, and the
111set-group-ID bit is set.
112.It T
113If the character is part of the other permissions and the file is not
114executable or the directory is not searchable by others, and the
115.Dq sticky
116.Pq Dv S_ISVTX
117bit is set.
118.It s
119If the character is part of the owner permissions and the file is
120executable or the directory searchable by the owner, and the set-user-ID
121bit is set.
122.It s
123If the character is part of the group permissions and the file is
124executable or the directory searchable by the group, and the set-group-ID
125bit is set.
126.It t
127If the character is part of the other permissions and the file is
128executable or the directory searchable by others, and the
129.Dq sticky
130.Pq Dv S_ISVTX
131bit is set.
132.It x
133The file is executable or the directory is searchable.
134.It \-
135None of the above apply.
136.El
137.Pp
138The last character is a plus sign
139.Pq Ql +
140if there are any alternate
141or additional access control methods associated with the inode, otherwise
142it will be a space.
143.Sh RETURN VALUES
144The
145.Fn strmode
146function always returns 0.
147.Sh SEE ALSO
148.Xr chmod 1 ,
149.Xr find 1 ,
150.Xr stat 2 ,
151.Xr getmode 3 ,
152.Xr setmode 3
153.Sh HISTORY
154The
155.Fn strmode
156function first appeared in
157.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 6f0fa34ed8..0000000000
--- a/src/lib/libc/string/strmode.c
+++ /dev/null
@@ -1,140 +0,0 @@
1/* $OpenBSD: strmode.c,v 1.7 2005/08/08 08:05:37 espie 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/* XXX mode should be mode_t */
36
37void
38strmode(int mode, char *p)
39{
40 /* print type */
41 switch (mode & S_IFMT) {
42 case S_IFDIR: /* directory */
43 *p++ = 'd';
44 break;
45 case S_IFCHR: /* character special */
46 *p++ = 'c';
47 break;
48 case S_IFBLK: /* block special */
49 *p++ = 'b';
50 break;
51 case S_IFREG: /* regular */
52 *p++ = '-';
53 break;
54 case S_IFLNK: /* symbolic link */
55 *p++ = 'l';
56 break;
57 case S_IFSOCK: /* socket */
58 *p++ = 's';
59 break;
60#ifdef S_IFIFO
61 case S_IFIFO: /* fifo */
62 *p++ = 'p';
63 break;
64#endif
65 default: /* unknown */
66 *p++ = '?';
67 break;
68 }
69 /* usr */
70 if (mode & S_IRUSR)
71 *p++ = 'r';
72 else
73 *p++ = '-';
74 if (mode & S_IWUSR)
75 *p++ = 'w';
76 else
77 *p++ = '-';
78 switch (mode & (S_IXUSR | S_ISUID)) {
79 case 0:
80 *p++ = '-';
81 break;
82 case S_IXUSR:
83 *p++ = 'x';
84 break;
85 case S_ISUID:
86 *p++ = 'S';
87 break;
88 case S_IXUSR | S_ISUID:
89 *p++ = 's';
90 break;
91 }
92 /* group */
93 if (mode & S_IRGRP)
94 *p++ = 'r';
95 else
96 *p++ = '-';
97 if (mode & S_IWGRP)
98 *p++ = 'w';
99 else
100 *p++ = '-';
101 switch (mode & (S_IXGRP | S_ISGID)) {
102 case 0:
103 *p++ = '-';
104 break;
105 case S_IXGRP:
106 *p++ = 'x';
107 break;
108 case S_ISGID:
109 *p++ = 'S';
110 break;
111 case S_IXGRP | S_ISGID:
112 *p++ = 's';
113 break;
114 }
115 /* other */
116 if (mode & S_IROTH)
117 *p++ = 'r';
118 else
119 *p++ = '-';
120 if (mode & S_IWOTH)
121 *p++ = 'w';
122 else
123 *p++ = '-';
124 switch (mode & (S_IXOTH | S_ISVTX)) {
125 case 0:
126 *p++ = '-';
127 break;
128 case S_IXOTH:
129 *p++ = 'x';
130 break;
131 case S_ISVTX:
132 *p++ = 'T';
133 break;
134 case S_IXOTH | S_ISVTX:
135 *p++ = 't';
136 break;
137 }
138 *p++ = ' '; /* will be a '+' if ACL's implemented */
139 *p = '\0';
140}
diff --git a/src/lib/libc/string/strncat.c b/src/lib/libc/string/strncat.c
deleted file mode 100644
index c4df4f2fad..0000000000
--- a/src/lib/libc/string/strncat.c
+++ /dev/null
@@ -1,57 +0,0 @@
1/* $OpenBSD: strncat.c,v 1.5 2005/08/08 08:05:37 espie 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 */
40char *
41strncat(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}
diff --git a/src/lib/libc/string/strncmp.c b/src/lib/libc/string/strncmp.c
deleted file mode 100644
index 0aea80d7d9..0000000000
--- a/src/lib/libc/string/strncmp.c
+++ /dev/null
@@ -1,51 +0,0 @@
1/* $OpenBSD: strncmp.c,v 1.7 2005/08/08 08:05:37 espie 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#if !defined(_KERNEL) && !defined(_STANDALONE)
33#include <string.h>
34#else
35#include <lib/libkern/libkern.h>
36#endif
37
38int
39strncmp(const char *s1, const char *s2, size_t n)
40{
41
42 if (n == 0)
43 return (0);
44 do {
45 if (*s1 != *s2++)
46 return (*(unsigned char *)s1 - *(unsigned char *)--s2);
47 if (*s1++ == 0)
48 break;
49 } while (--n != 0);
50 return (0);
51}
diff --git a/src/lib/libc/string/strncpy.c b/src/lib/libc/string/strncpy.c
deleted file mode 100644
index 4426cbe2e3..0000000000
--- a/src/lib/libc/string/strncpy.c
+++ /dev/null
@@ -1,62 +0,0 @@
1/* $OpenBSD: strncpy.c,v 1.6 2005/08/08 08:05:37 espie 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#if !defined(_KERNEL) && !defined(_STANDALONE)
36#include <string.h>
37#else
38#include <lib/libkern/libkern.h>
39#endif
40
41/*
42 * Copy src to dst, truncating or null-padding to always copy n bytes.
43 * Return dst.
44 */
45char *
46strncpy(char *dst, const char *src, size_t n)
47{
48 if (n != 0) {
49 char *d = dst;
50 const char *s = src;
51
52 do {
53 if ((*d++ = *s++) == 0) {
54 /* NUL pad the remaining n-1 bytes */
55 while (--n != 0)
56 *d++ = 0;
57 break;
58 }
59 } while (--n != 0);
60 }
61 return (dst);
62}
diff --git a/src/lib/libc/string/strndup.c b/src/lib/libc/string/strndup.c
deleted file mode 100644
index 27701ac555..0000000000
--- a/src/lib/libc/string/strndup.c
+++ /dev/null
@@ -1,39 +0,0 @@
1/* $OpenBSD: strndup.c,v 1.1 2010/05/18 22:24:55 tedu Exp $ */
2
3/*
4 * Copyright (c) 2010 Todd C. Miller <Todd.Miller@courtesan.com>
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
25char *
26strndup(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}
diff --git a/src/lib/libc/string/strnlen.c b/src/lib/libc/string/strnlen.c
deleted file mode 100644
index a5e13ae04e..0000000000
--- a/src/lib/libc/string/strnlen.c
+++ /dev/null
@@ -1,36 +0,0 @@
1/* $OpenBSD: strnlen.c,v 1.4 2012/04/26 01:22:31 matthew Exp $ */
2
3/*
4 * Copyright (c) 2010 Todd C. Miller <Todd.Miller@courtesan.com>
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#if !defined(_KERNEL) && !defined(_STANDALONE)
22#include <string.h>
23#else
24#include <lib/libkern/libkern.h>
25#endif
26
27size_t
28strnlen(const char *str, size_t maxlen)
29{
30 const char *cp;
31
32 for (cp = str; maxlen != 0 && *cp != '\0'; cp++, maxlen--)
33 ;
34
35 return (size_t)(cp - str);
36}
diff --git a/src/lib/libc/string/strpbrk.3 b/src/lib/libc/string/strpbrk.3
deleted file mode 100644
index 9e13c42ad0..0000000000
--- a/src/lib/libc/string/strpbrk.3
+++ /dev/null
@@ -1,80 +0,0 @@
1.\" $OpenBSD: strpbrk.3,v 1.9 2011/07/25 00:38:53 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: July 25 2011 $
35.Dt STRPBRK 3
36.Os
37.Sh NAME
38.Nm strpbrk
39.Nd locate multiple characters in string
40.Sh SYNOPSIS
41.Fd #include <string.h>
42.Ft char *
43.Fn strpbrk "const char *s" "const char *charset"
44.Sh DESCRIPTION
45The
46.Fn strpbrk
47function locates in the NUL-terminated string
48.Fa s
49the first occurrence of any character in the string
50.Fa charset
51and returns a pointer to this character.
52If no characters from
53.Fa charset
54occur anywhere in
55.Fa s ,
56.Fn strpbrk
57returns
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
70The
71.Fn strpbrk
72function conforms to
73.St -ansiC .
74.Sh HISTORY
75The
76.Fn strpbrk
77function first appeared in
78.At III
79and was reimplemented for
80.Bx 4.3 Tahoe .
diff --git a/src/lib/libc/string/strpbrk.c b/src/lib/libc/string/strpbrk.c
deleted file mode 100644
index cd3b71c0d3..0000000000
--- a/src/lib/libc/string/strpbrk.c
+++ /dev/null
@@ -1,48 +0,0 @@
1/* $OpenBSD: strpbrk.c,v 1.5 2005/08/08 08:05:37 espie 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 */
36char *
37strpbrk(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}
diff --git a/src/lib/libc/string/strrchr.3 b/src/lib/libc/string/strrchr.3
deleted file mode 100644
index 9eea08b0a9..0000000000
--- a/src/lib/libc/string/strrchr.3
+++ /dev/null
@@ -1,116 +0,0 @@
1.\" $OpenBSD: strrchr.3,v 1.9 2011/07/25 00:38:53 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: July 25 2011 $
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.Fd #include <string.h>
43.Ft char *
44.Fn strrchr "const char *s" "int c"
45.Ft char *
46.Fn rindex "const char *s" "int c"
47.Sh DESCRIPTION
48The
49.Fn strrchr
50function locates the last occurrence of the character
51.Fa c
52in the string
53.Fa s .
54The terminating
55.Tn NUL
56character is considered part of the string.
57If
58.Fa c
59is
60.Ql \e0 ,
61.Fn strrchr
62locates the terminating
63.Ql \e0 .
64.Pp
65The
66.Fn rindex
67function is an old synonym for
68.Fn strrchr .
69.Sh RETURN VALUES
70The
71.Fn strrchr
72function returns a pointer to the located character or
73.Dv NULL
74if the character does not appear in the string.
75.Sh EXAMPLES
76After the following call to
77.Fn strrchr ,
78.Va p
79will point to the string
80.Qq obar :
81.Bd -literal -offset indent
82char *p;
83char *s = "foobar";
84
85p = strrchr(s, 'o');
86.Ed
87.Sh SEE ALSO
88.Xr memchr 3 ,
89.Xr strchr 3 ,
90.Xr strcspn 3 ,
91.Xr strpbrk 3 ,
92.Xr strsep 3 ,
93.Xr strspn 3 ,
94.Xr strstr 3 ,
95.Xr strtok 3 ,
96.Xr wcsrchr 3
97.Sh STANDARDS
98The
99.Fn strrchr
100function conforms to
101.St -ansiC .
102.Pp
103The
104.Fn rindex
105function is deprecated and shouldn't be used in new code.
106.Sh HISTORY
107The
108.Fn rindex
109function first appeared in
110.At v7 .
111The
112.Fn strrchr
113function first appeared in
114.At III
115and was reimplemented for
116.Bx 4.3 Tahoe .
diff --git a/src/lib/libc/string/strsep.3 b/src/lib/libc/string/strsep.3
deleted file mode 100644
index 63cdf2333a..0000000000
--- a/src/lib/libc/string/strsep.3
+++ /dev/null
@@ -1,110 +0,0 @@
1.\" $OpenBSD: strsep.3,v 1.13 2011/07/25 00:38:53 schwarze 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: July 25 2011 $
36.Dt STRSEP 3
37.Os
38.Sh NAME
39.Nm strsep
40.Nd separate strings
41.Sh SYNOPSIS
42.Fd #include <string.h>
43.Ft char *
44.Fn strsep "char **stringp" "const char *delim"
45.Sh DESCRIPTION
46The
47.Fn strsep
48function locates, in the string referenced by
49.Fa *stringp ,
50the first occurrence of any character in the string
51.Fa delim
52(or the terminating
53.Ql \e0
54character) and replaces it with a
55.Ql \e0 .
56The location of the next character after the delimiter character
57(or
58.Dv NULL ,
59if the end of the string was reached) is stored in
60.Fa *stringp .
61The original value of
62.Fa *stringp
63is returned.
64.Pp
65An
66.Dq empty
67field, i.e., one caused by two adjacent delimiter characters,
68can be detected by comparing the location referenced by the pointer returned
69by
70.Fn strsep
71to
72.Ql \e0 .
73.Pp
74If
75.Fa *stringp
76is initially
77.Dv NULL ,
78.Fn strsep
79returns
80.Dv NULL .
81.Sh EXAMPLES
82The following uses
83.Fn strsep
84to parse a string, containing tokens delimited by whitespace, into an
85argument vector:
86.Bd -literal -offset indent
87char **ap, *argv[10], *inputstring;
88
89for (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
97The
98.Fn strsep
99function first appeared in
100.Bx 4.3 Reno .
101It is intended as a replacement for the
102.Xr strtok 3
103function.
104While the
105.Xr strtok 3
106function should be preferred for portability reasons (it conforms to
107.St -ansiC )
108it is unable to handle empty fields, i.e., detect fields delimited by
109two adjacent delimiter characters, or to be used for more than a single
110string at a time.
diff --git a/src/lib/libc/string/strsep.c b/src/lib/libc/string/strsep.c
deleted file mode 100644
index bcca681e03..0000000000
--- a/src/lib/libc/string/strsep.c
+++ /dev/null
@@ -1,71 +0,0 @@
1/* $OpenBSD: strsep.c,v 1.6 2005/08/08 08:05:37 espie 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#include <stdio.h>
34
35/*
36 * Get next token from string *stringp, where tokens are possibly-empty
37 * strings separated by characters from delim.
38 *
39 * Writes NULs into the string at *stringp to end tokens.
40 * delim need not remain constant from call to call.
41 * On return, *stringp points past the last NUL written (if there might
42 * be further tokens), or is NULL (if there are definitely no more tokens).
43 *
44 * If *stringp is NULL, strsep returns NULL.
45 */
46char *
47strsep(char **stringp, const char *delim)
48{
49 char *s;
50 const char *spanp;
51 int c, sc;
52 char *tok;
53
54 if ((s = *stringp) == NULL)
55 return (NULL);
56 for (tok = s;;) {
57 c = *s++;
58 spanp = delim;
59 do {
60 if ((sc = *spanp++) == c) {
61 if (c == 0)
62 s = NULL;
63 else
64 s[-1] = 0;
65 *stringp = s;
66 return (tok);
67 }
68 } while (sc != 0);
69 }
70 /* NOTREACHED */
71}
diff --git a/src/lib/libc/string/strsignal.3 b/src/lib/libc/string/strsignal.3
deleted file mode 100644
index 7128d811fd..0000000000
--- a/src/lib/libc/string/strsignal.3
+++ /dev/null
@@ -1,68 +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.7 2012/03/26 05:06:35 guenther Exp $
33.\"
34.Dd $Mdocdate: March 26 2012 $
35.Dt STRSIGNAL 3
36.Os
37.Sh NAME
38.Nm strsignal
39.Nd get signal description string
40.Sh SYNOPSIS
41.Fd #include <string.h>
42.Ft char *
43.Fn strsignal "int sig"
44.Sh DESCRIPTION
45The
46.Fn strsignal
47function returns a pointer to the language-dependent string describing
48a signal.
49.Pp
50The array pointed to is not to be modified by the program, but may be
51overwritten 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
58The
59.Fn strsignal
60function conforms to
61.St -p1003.1-2008 .
62.Sh HISTORY
63The
64.Fn strsignal
65function first appeared in
66.At V.4
67and was reimplemented for
68.Nx 1.0 .
diff --git a/src/lib/libc/string/strsignal.c b/src/lib/libc/string/strsignal.c
deleted file mode 100644
index aa541cefed..0000000000
--- a/src/lib/libc/string/strsignal.c
+++ /dev/null
@@ -1,41 +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
33extern char *__strsignal(int, char *);
34
35char *
36strsignal(int sig)
37{
38 static char buf[NL_TEXTMAX];
39
40 return __strsignal(sig, buf);
41}
diff --git a/src/lib/libc/string/strspn.3 b/src/lib/libc/string/strspn.3
deleted file mode 100644
index b1a2ae3014..0000000000
--- a/src/lib/libc/string/strspn.3
+++ /dev/null
@@ -1,92 +0,0 @@
1.\" $OpenBSD: strspn.3,v 1.10 2011/07/25 00:38:53 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: July 25 2011 $
35.Dt STRSPN 3
36.Os
37.Sh NAME
38.Nm strspn
39.Nd span a string
40.Sh SYNOPSIS
41.Fd #include <string.h>
42.Ft size_t
43.Fn strspn "const char *s" "const char *charset"
44.Sh DESCRIPTION
45The
46.Fn strspn
47function spans the initial part of the NUL-terminated string
48.Fa s
49as long as the characters from
50.Fa s
51occur in string
52.Fa charset .
53.Sh RETURN VALUES
54The
55.Fn strspn
56function returns the number of characters spanned.
57.Sh EXAMPLES
58The following call to
59.Fn strspn
60will return 3, since the first three characters of string
61.Fa s
62are part of string
63.Fa charset :
64.Bd -literal -offset indent
65char *s = "foobar";
66char *charset = "of";
67size_t span;
68
69span = 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
82The
83.Fn strspn
84function conforms to
85.St -ansiC .
86.Sh HISTORY
87The
88.Fn strspn
89function first appeared in
90.At III
91and was reimplemented for
92.Bx 4.3 Tahoe .
diff --git a/src/lib/libc/string/strspn.c b/src/lib/libc/string/strspn.c
deleted file mode 100644
index 385649c041..0000000000
--- a/src/lib/libc/string/strspn.c
+++ /dev/null
@@ -1,51 +0,0 @@
1/* $OpenBSD: strspn.c,v 1.5 2005/08/08 08:05:37 espie 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 */
36size_t
37strspn(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 */
45cont:
46 c = *p++;
47 for (spanp = s2; (sc = *spanp++) != 0;)
48 if (sc == c)
49 goto cont;
50 return (p - 1 - s1);
51}
diff --git a/src/lib/libc/string/strstr.3 b/src/lib/libc/string/strstr.3
deleted file mode 100644
index 4069d55ed2..0000000000
--- a/src/lib/libc/string/strstr.3
+++ /dev/null
@@ -1,100 +0,0 @@
1.\" $OpenBSD: strstr.3,v 1.11 2011/07/25 00:38:53 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: July 25 2011 $
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.Fd #include <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
47The
48.Fn strstr
49function locates the first occurrence of the NUL-terminated string
50.Fa little
51in the NUL-terminated string
52.Fa big .
53.Pp
54The
55.Fn strcasestr
56function is similar to
57.Fn strstr
58but ignores the case of both strings.
59.Pp
60If
61.Fa little
62is an empty string,
63.Fa big
64is returned;
65if
66.Fa little
67occurs nowhere in
68.Fa big ,
69.Dv NULL
70is returned;
71otherwise a pointer to the first character of the first occurrence of
72.Fa little
73is returned.
74.Sh SEE ALSO
75.Xr memchr 3 ,
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 strtok 3 ,
83.Xr wcsstr 3
84.Sh STANDARDS
85The
86.Fn strstr
87function conforms to
88.St -ansiC .
89.Sh HISTORY
90The
91.Fn strstr
92function first appeared in
93.Bx 4.3 Reno .
94The
95.Fn strcasestr
96function appeared in glibc 2.1,
97was reimplemented for
98.Fx 4.5
99and ported to
100.Ox 3.8 .
diff --git a/src/lib/libc/string/strstr.c b/src/lib/libc/string/strstr.c
deleted file mode 100644
index 95a865bf79..0000000000
--- a/src/lib/libc/string/strstr.c
+++ /dev/null
@@ -1,56 +0,0 @@
1/* $OpenBSD: strstr.c,v 1.5 2005/08/08 08:05:37 espie 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 * Find the first occurrence of find in s.
38 */
39char *
40strstr(const char *s, const char *find)
41{
42 char c, sc;
43 size_t len;
44
45 if ((c = *find++) != 0) {
46 len = strlen(find);
47 do {
48 do {
49 if ((sc = *s++) == 0)
50 return (NULL);
51 } while (sc != c);
52 } while (strncmp(s, find, len) != 0);
53 s--;
54 }
55 return ((char *)s);
56}
diff --git a/src/lib/libc/string/strtok.3 b/src/lib/libc/string/strtok.3
deleted file mode 100644
index fbf0abfc26..0000000000
--- a/src/lib/libc/string/strtok.3
+++ /dev/null
@@ -1,166 +0,0 @@
1.\" $OpenBSD: strtok.3,v 1.20 2011/07/25 00:38:53 schwarze 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: July 25 2011 $
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.Fd #include <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
49This interface is obsoleted by
50.Xr strsep 3 .
51.Ef
52.Pp
53The
54.Fn strtok
55function is used to isolate sequential tokens in a NUL-terminated string,
56.Fa str .
57These tokens are separated in the string by at least one of the
58characters in
59.Fa sep .
60The first time that
61.Fn strtok
62is called,
63.Fa str
64should be specified; subsequent calls, wishing to obtain further tokens
65from the same string, should pass a null pointer instead.
66The separator string,
67.Fa sep ,
68must be supplied each time, and may change between calls.
69.Pp
70The
71.Fn strtok_r
72function is a version of
73.Fn strtok
74that takes an explicit context argument and is reentrant.
75.Pp
76Since
77.Fn strtok
78and
79.Fn strtok_r
80modify the string,
81.Fa str
82should not point to an area in the initialized data segment.
83.Sh RETURN VALUES
84The
85.Fn strtok
86and
87.Fn strtok_r
88functions return a pointer to the beginning of each subsequent token
89in the string, after replacing the separator character itself with an
90.Tn ASCII NUL
91character.
92When no more tokens remain, a null pointer is returned.
93.Sh EXAMPLES
94The following will construct an array of pointers to each individual word in
95the string
96.Va s :
97.Bd -literal -offset indent
98#define MAXTOKENS 128
99
100char s[512], *p, *tokens[MAXTOKENS];
101char *last;
102int i = 0;
103
104snprintf(s, sizeof(s), "cat dog horse cow");
105
106for ((p = strtok_r(s, " ", &last)); p;
107 (p = strtok_r(NULL, " ", &last))) {
108 if (i < MAXTOKENS - 1)
109 tokens[i++] = p;
110}
111tokens[i] = NULL;
112.Ed
113.Pp
114That is,
115.Li tokens[0]
116will point to
117.Qq cat ,
118.Li tokens[1]
119will point to
120.Qq dog ,
121.Li tokens[2]
122will point to
123.Qq horse ,
124and
125.Li tokens[3]
126will point to
127.Qq cow .
128.Sh SEE ALSO
129.Xr memchr 3 ,
130.Xr strchr 3 ,
131.Xr strcspn 3 ,
132.Xr strpbrk 3 ,
133.Xr strrchr 3 ,
134.Xr strsep 3 ,
135.Xr strspn 3 ,
136.Xr strstr 3 ,
137.Xr wcstok 3
138.Sh STANDARDS
139The
140.Fn strtok
141function conforms to
142.St -ansiC .
143.Sh HISTORY
144The
145.Fn strtok
146function first appeared in
147.At III
148and was reimplemented for
149.Bx 4.3 Tahoe .
150The
151.Fn strtok_r
152function first appeared in
153.Nx 1.3
154and was reimplemented for
155.Ox 2.7 .
156.Sh BUGS
157The System V
158.Fn strtok ,
159if handed a string containing only delimiter characters,
160will not alter the next starting point, so that a call to
161.Fn strtok
162with a different (or empty) delimiter string
163may return a non-null value.
164Since this implementation always alters the next starting point,
165such a sequence of calls would always return
166.Dv NULL .
diff --git a/src/lib/libc/string/strtok.c b/src/lib/libc/string/strtok.c
deleted file mode 100644
index 4e963a019e..0000000000
--- a/src/lib/libc/string/strtok.c
+++ /dev/null
@@ -1,86 +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
32char *
33strtok(char *s, const char *delim)
34{
35 static char *last;
36
37 return strtok_r(s, delim, &last);
38}
39
40char *
41strtok_r(char *s, const char *delim, char **last)
42{
43 char *spanp;
44 int c, sc;
45 char *tok;
46
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 */
54cont:
55 c = *s++;
56 for (spanp = (char *)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 = (char *)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}
diff --git a/src/lib/libc/string/strxfrm.3 b/src/lib/libc/string/strxfrm.3
deleted file mode 100644
index e4472946be..0000000000
--- a/src/lib/libc/string/strxfrm.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.\" This code is derived from software contributed to Berkeley by
5.\" Chris Torek and the American National Standards Committee X3,
6.\" on Information 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: strxfrm.3,v 1.9 2011/07/25 00:38:53 schwarze Exp $
33.\"
34.Dd $Mdocdate: July 25 2011 $
35.Dt STRXFRM 3
36.Os
37.Sh NAME
38.Nm strxfrm
39.Nd transform a string under locale
40.Sh SYNOPSIS
41.Fd #include <string.h>
42.Ft size_t
43.Fn strxfrm "char *dst" "const char *src" "size_t n"
44.Sh DESCRIPTION
45The idea of
46.Fn strxfrm
47is to
48.Dq un-localize
49a string: the function transforms
50.Ar src ,
51storing the result in
52.Ar dst ,
53such that
54.Xr strcmp 3
55on transformed strings returns what
56.Xr strcoll 3
57on the original untransformed strings would return.
58.Sh SEE ALSO
59.Xr bcmp 3 ,
60.Xr memcmp 3 ,
61.Xr setlocale 3 ,
62.Xr strcasecmp 3 ,
63.Xr strcmp 3 ,
64.Xr strcoll 3
65.Sh STANDARDS
66The
67.Fn strxfrm
68function conforms to
69.St -ansiC .
70.Sh HISTORY
71The
72.Fn strxfrm
73function first appeared in
74.Bx 4.3 Reno .
75.Sh BUGS
76Since locales are not fully implemented on
77.Ox ,
78.Fn strxfrm
79just returns a copy of the original string.
diff --git a/src/lib/libc/string/strxfrm.c b/src/lib/libc/string/strxfrm.c
deleted file mode 100644
index 6f289c901e..0000000000
--- a/src/lib/libc/string/strxfrm.c
+++ /dev/null
@@ -1,51 +0,0 @@
1/* $OpenBSD: strxfrm.c,v 1.6 2005/08/08 08:05:37 espie 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 */
41size_t
42strxfrm(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}
diff --git a/src/lib/libc/string/swab.3 b/src/lib/libc/string/swab.3
deleted file mode 100644
index 5ebaa485e9..0000000000
--- a/src/lib/libc/string/swab.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.\" 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.7 2011/07/25 00:38:53 schwarze Exp $
29.\"
30.Dd $Mdocdate: July 25 2011 $
31.Dt SWAB 3
32.Os
33.Sh NAME
34.Nm swab
35.Nd swap adjacent bytes
36.Sh SYNOPSIS
37.Fd #include <unistd.h>
38.Ft void
39.Fn swab "const void *src" "void *dst" "size_t len"
40.Sh DESCRIPTION
41The function
42.Fn swab
43copies
44.Fa len
45bytes from the location referenced by
46.Fa src
47to the location referenced by
48.Fa dst ,
49swapping adjacent bytes.
50.Pp
51The argument
52.Fa len
53must be an even number.
54.Sh SEE ALSO
55.Xr bzero 3 ,
56.Xr memset 3
57.Sh HISTORY
58The
59.Fn swab
60function first appeared in
61.At v7 .
diff --git a/src/lib/libc/string/swab.c b/src/lib/libc/string/swab.c
deleted file mode 100644
index b74db7e62a..0000000000
--- a/src/lib/libc/string/swab.c
+++ /dev/null
@@ -1,61 +0,0 @@
1/* $OpenBSD: swab.c,v 1.8 2008/03/15 21:54:09 ray Exp $ */
2/*
3 * Copyright (c) 1988 Regents of the University of California.
4 * All rights reserved.
5 *
6 * This code is derived from software contributed to Berkeley by
7 * Jeffrey Mogul.
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 <unistd.h>
35
36void
37swab(const void *from, void *to, size_t len)
38{
39 size_t n;
40 char *fp, *tp;
41 char temp;
42
43 n = (len / 2) + 1;
44 fp = (char *)from;
45 tp = (char *)to;
46#define STEP do { \
47 temp = *fp++; \
48 *tp++ = *fp++; \
49 *tp++ = temp; \
50} while (0)
51 /* round to multiple of 8 */
52 while ((--n) & 07)
53 STEP;
54 n >>= 3;
55 if (n == 0)
56 return;
57 while (n-- != 0) {
58 STEP; STEP; STEP; STEP;
59 STEP; STEP; STEP; STEP;
60 }
61}
diff --git a/src/lib/libc/string/timingsafe_bcmp.c b/src/lib/libc/string/timingsafe_bcmp.c
deleted file mode 100644
index 9c4287cf63..0000000000
--- a/src/lib/libc/string/timingsafe_bcmp.c
+++ /dev/null
@@ -1,33 +0,0 @@
1/* $OpenBSD: timingsafe_bcmp.c,v 1.1 2010/09/24 13:33:00 matthew 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#if !defined(_KERNEL) && !defined(_STANDALONE)
19#include <string.h>
20#else
21#include <lib/libkern/libkern.h>
22#endif
23
24int
25timingsafe_bcmp(const void *b1, const void *b2, size_t n)
26{
27 const unsigned char *p1 = b1, *p2 = b2;
28 int ret = 0;
29
30 for (; n > 0; n--)
31 ret |= *p1++ ^ *p2++;
32 return (ret != 0);
33}
diff --git a/src/lib/libc/string/wcscasecmp.3 b/src/lib/libc/string/wcscasecmp.3
deleted file mode 100644
index 94cd6e0c38..0000000000
--- a/src/lib/libc/string/wcscasecmp.3
+++ /dev/null
@@ -1,94 +0,0 @@
1.\" $OpenBSD: wcscasecmp.3,v 1.2 2011/07/25 00:38:53 schwarze 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.\" 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.\" @(#)strcasecmp.3 8.1 (Berkeley) 6/9/93
33.\"
34.Dd $Mdocdate: July 25 2011 $
35.Dt WCSCASECMP 3
36.Os
37.Sh NAME
38.Nm wcscasecmp ,
39.Nm wcsncasecmp
40.Nd compare wide strings, ignoring case
41.Sh SYNOPSIS
42.Fd #include <wchar.h>
43.Ft int
44.Fn wcscasecmp "const wchar_t *s1" "const wchar_t *s2"
45.Ft int
46.Fn wcsncasecmp "const wchar_t *s1" "const wchar_t *s2" "size_t len"
47.Sh DESCRIPTION
48The
49.Fn wcscasecmp
50and
51.Fn wcsncasecmp
52functions compare the wide strings
53.Fa s1
54and
55.Fa s2
56and return an integer greater than, equal to, or less than 0,
57according to whether
58.Fa s1
59is lexicographically greater than, equal to, or less than
60.Fa s2
61after translation of each corresponding wide character to lower case.
62The wide strings themselves are not modified.
63.Pp
64.Fn wcsncasecmp
65compares at most
66.Fa len
67wide characters.
68.Sh SEE ALSO
69.Xr strcasecmp 3 ,
70.Xr wcscmp 3 ,
71.Xr wmemcmp 3
72.Sh STANDARDS
73The
74.Fn wcscasecmp
75and
76.Fn wcsncasecmp
77functions conform to
78.St -p1003.1-2008 .
79.Sh HISTORY
80The
81.Fn wcscasecmp
82and
83.Fn wcsncasecmp
84functions first appeared in
85.Ox 5.0 .
86.Sh AUTHORS
87The
88.Ox
89versions of
90.Fn wcscasecmp
91and
92.Fn wcsncasecmp
93were implemented by
94.An Marc Espie Aq espie@openbsd.org .
diff --git a/src/lib/libc/string/wcscasecmp.c b/src/lib/libc/string/wcscasecmp.c
deleted file mode 100644
index b14997ee75..0000000000
--- a/src/lib/libc/string/wcscasecmp.c
+++ /dev/null
@@ -1,61 +0,0 @@
1/* $OpenBSD: wcscasecmp.c,v 1.2 2011/06/01 19:29:48 naddy 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
32int
33wcscasecmp(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
45int
46wcsncasecmp(const wchar_t *s1, const wchar_t *s2, size_t n)
47{
48 wchar_t l1, l2;
49
50 if (n == 0)
51 return (0);
52 do {
53 if (((l1 = towlower(*s1++))) != (l2 = towlower(*s2++))) {
54 /* XXX assumes wchar_t = int */
55 return ((rune_t)l1 - (rune_t)l2);
56 }
57 if (l1 == 0)
58 break;
59 } while (--n != 0);
60 return (0);
61}
diff --git a/src/lib/libc/string/wcscat.3 b/src/lib/libc/string/wcscat.3
deleted file mode 100644
index d0281b8bd1..0000000000
--- a/src/lib/libc/string/wcscat.3
+++ /dev/null
@@ -1,115 +0,0 @@
1.\" $OpenBSD: wcscat.3,v 1.2 2011/07/25 00:38:53 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: July 25 2011 $
35.Dt WCSCAT 3
36.Os
37.Sh NAME
38.Nm wcscat ,
39.Nm wcsncat
40.Nd concatenate wide strings
41.Sh SYNOPSIS
42.Fd #include <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
52The
53.Fn wcscat
54and
55.Fn wcsncat
56functions append a copy of the wide string
57.Fa append
58to the end of the wide string
59.Fa s ,
60then add a terminating null wide character (L'\e0').
61The wide string
62.Fa s
63must have sufficient space to hold the result.
64.Pp
65The
66.Fn wcsncat
67function appends not more than
68.Fa count
69wide characters where space for the terminating null wide character
70should not be included in
71.Fa count .
72.Sh RETURN VALUES
73The
74.Fn wcscat
75and
76.Fn wcsncat
77functions 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
87The
88.Fn wcscat
89and
90.Fn wcsncat
91functions conform to
92.St -isoC-99
93and were first introduced in
94.St -isoC-amd1 .
95.Sh HISTORY
96The
97.Fn wcscat
98and
99.Fn wcsncat
100functions were ported from
101.Nx
102and first appeared in
103.Ox 3.8 .
104.Sh CAVEATS
105Using the functions
106.Fn wcscat
107and
108.Fn wcsncat
109is very error-prone with respect to buffer overflows;
110see the EXAMPLES section in
111.Xr strcat 3
112for correct usage.
113Using
114.Xr wcslcat 3
115is 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 a4841a975a..0000000000
--- a/src/lib/libc/string/wcscat.c
+++ /dev/null
@@ -1,55 +0,0 @@
1/* $OpenBSD: wcscat.c,v 1.3 2005/08/08 08:05:37 espie 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 "warning: wcscat() is almost always misused, please use wcslcat()");
37#endif
38
39wchar_t *
40wcscat(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}
diff --git a/src/lib/libc/string/wcschr.3 b/src/lib/libc/string/wcschr.3
deleted file mode 100644
index ca2c0ed743..0000000000
--- a/src/lib/libc/string/wcschr.3
+++ /dev/null
@@ -1,85 +0,0 @@
1.\" $OpenBSD: wcschr.3,v 1.3 2011/07/25 07:51:30 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: July 25 2011 $
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.Fd #include <wchar.h>
42.Ft wchar_t *
43.Fn wcschr "const wchar_t *s" "wchar_t c"
44.Sh DESCRIPTION
45The
46.Fn wcschr
47function locates the first occurrence of the wide character
48.Fa c
49in the wide string
50.Fa s .
51The terminating null wide character is considered part of the wide string.
52If
53.Fa c
54is the null wide character (L'\e0'),
55.Fn wcschr
56locates the terminating null wide character.
57.Sh RETURN VALUES
58The
59.Fn wcschr
60function returns a pointer to the located wide character or
61.Dv NULL
62if 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
73The
74.Fn wcschr
75function conforms to
76.St -isoC-99
77and was first introduced in
78.St -isoC-amd1 .
79.Sh HISTORY
80The
81.Fn wcschr
82function was ported from
83.Nx
84and 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 b84a2d32e3..0000000000
--- a/src/lib/libc/string/wcschr.c
+++ /dev/null
@@ -1,50 +0,0 @@
1/* $OpenBSD: wcschr.c,v 1.4 2008/08/23 05:34:36 djm 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
34wchar_t *
35wcschr(const wchar_t *s, wchar_t c)
36{
37 const wchar_t *p;
38
39 p = s;
40 for (;;) {
41 if (*p == c) {
42 /* LINTED interface specification */
43 return (wchar_t *)p;
44 }
45 if (!*p)
46 return NULL;
47 p++;
48 }
49 /* NOTREACHED */
50}
diff --git a/src/lib/libc/string/wcscmp.3 b/src/lib/libc/string/wcscmp.3
deleted file mode 100644
index b34e5c2168..0000000000
--- a/src/lib/libc/string/wcscmp.3
+++ /dev/null
@@ -1,92 +0,0 @@
1.\" $OpenBSD: wcscmp.3,v 1.2 2011/07/25 00:38:53 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: July 25 2011 $
35.Dt WCSCMP 3
36.Os
37.Sh NAME
38.Nm wcscmp ,
39.Nm wcsncmp
40.Nd compare wide strings
41.Sh SYNOPSIS
42.Fd #include <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
48The
49.Fn wcscmp
50and
51.Fn wcsncmp
52functions lexicographically compare the wide strings
53.Fa s1
54and
55.Fa s2 .
56The
57.Fn wcsncmp
58function compares at most
59.Fa len
60wide characters.
61.Sh RETURN VALUES
62The
63.Fn wcscmp
64and
65.Fn wcsncmp
66functions return an integer greater than, equal to, or less than 0, according
67to whether the wide string
68.Fa s1
69is 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
76The
77.Fn wcscmp
78and
79.Fn wcsncmp
80functions conform to
81.St -isoC-99
82and were first introduced in
83.St -isoC-amd1 .
84.Sh HISTORY
85The
86.Fn wcscmp
87and
88.Fn wcsncmp
89functions were ported from
90.Nx
91and 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 4a8f6ba3fb..0000000000
--- a/src/lib/libc/string/wcscmp.c
+++ /dev/null
@@ -1,51 +0,0 @@
1/* $OpenBSD: wcscmp.c,v 1.4 2005/08/08 08:05:37 espie 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 */
42int
43wcscmp(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}
diff --git a/src/lib/libc/string/wcscpy.3 b/src/lib/libc/string/wcscpy.3
deleted file mode 100644
index dcc375acbf..0000000000
--- a/src/lib/libc/string/wcscpy.3
+++ /dev/null
@@ -1,123 +0,0 @@
1.\" $OpenBSD: wcscpy.3,v 1.2 2011/07/25 00:38:53 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: July 25 2011 $
35.Dt WCSCPY 3
36.Os
37.Sh NAME
38.Nm wcscpy ,
39.Nm wcsncpy
40.Nd copy wide strings
41.Sh SYNOPSIS
42.Fd #include <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
52The
53.Fn wcscpy
54and
55.Fn wcsncpy
56functions copy the wide string
57.Fa src
58to
59.Fa dst
60(including the terminating null wide character).
61.Pp
62The
63.Fn wcsncpy
64function copies not more than
65.Fa len
66wide characters to
67.Fa dst ,
68appending null wide characters if the length of
69.Fa src
70is less than
71.Fa len ,
72and
73.Em not
74terminating
75.Fa dst
76if the length of
77.Fa src
78is greater than or equal to
79.Fa len .
80.Sh RETURN VALUES
81The
82.Fn wcscpy
83and
84.Fn wcsncpy
85functions return
86.Fa dst .
87.Sh SEE ALSO
88.Xr strcpy 3 ,
89.Xr strlcpy 3 ,
90.Xr wcscat 3 ,
91.Xr wcslcpy 3 ,
92.Xr wmemcpy 3 ,
93.Xr wmemmove 3
94.Sh STANDARDS
95The
96.Fn wcscpy
97and
98.Fn wcsncpy
99functions conform to
100.St -isoC-99
101and were first introduced in
102.St -isoC-amd1 .
103.Sh HISTORY
104The
105.Fn wcscpy
106and
107.Fn wcsncpy
108functions were ported from
109.Nx
110and first appeared in
111.Ox 3.8 .
112.Sh CAVEATS
113Using the functions
114.Fn wcscpy
115and
116.Fn wcsncpy
117is very error-prone with respect to buffer overflows;
118see the EXAMPLES section in
119.Xr strcpy 3
120for correct usage.
121Using
122.Xr wcslcpy 3
123is 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 75fdb75fe4..0000000000
--- a/src/lib/libc/string/wcscpy.c
+++ /dev/null
@@ -1,52 +0,0 @@
1/* $OpenBSD: wcscpy.c,v 1.4 2005/08/08 08:05:37 espie 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 "warning: wcscpy() is almost always misused, please use wcslcpy()");
37#endif
38
39wchar_t *
40wcscpy(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 c17992501f..0000000000
--- a/src/lib/libc/string/wcscspn.3
+++ /dev/null
@@ -1,83 +0,0 @@
1.\" $OpenBSD: wcscspn.3,v 1.2 2011/07/25 00:38:53 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: July 25 2011 $
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.Fd #include <wchar.h>
42.Ft size_t
43.Fn wcscspn "const wchar_t *s" "const wchar_t *charset"
44.Sh DESCRIPTION
45The
46.Fn wcscspn
47function spans the initial part of the wide string
48.Fa s
49as long as the wide characters from
50.Fa s
51do not occur in string
52.Fa charset
53(it spans the
54.Em complement
55of
56.Fa charset ) .
57.Sh RETURN VALUES
58The
59.Fn wcscspn
60function 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
71The
72.Fn wcscspn
73function conforms to
74.St -isoC-99
75and was first introduced in
76.St -isoC-amd1 .
77.Sh HISTORY
78The
79.Fn wcscspn
80function was ported from
81.Nx
82and 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 cf40092465..0000000000
--- a/src/lib/libc/string/wcscspn.c
+++ /dev/null
@@ -1,53 +0,0 @@
1/* $OpenBSD: wcscspn.c,v 1.3 2005/08/08 08:05:37 espie 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
34size_t
35wcscspn(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
51done:
52 return (p - s);
53}
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
44The
45.Fn wcsdup
46function
47allocates sufficient memory for a copy
48of the wide-character string
49.Fa str ,
50does the copy, and returns a pointer to it.
51The pointer may subsequently be used as an
52argument to the function
53.Xr free 3 .
54.Pp
55If insufficient memory is available,
56.Dv NULL
57is returned.
58.Sh EXAMPLES
59The following will point
60.Va p
61to an allocated area of memory containing the nul-terminated string
62.Qq foobar :
63.Bd -literal -offset indent
64const char *o = "foobar";
65wchar_t *p, b[32];
66size_t blen;
67
68blen = sizeof(b) / sizeof(b[0]);
69if (mbstowcs(b, o, blen) == (size_t)-1)
70 err(1, NULL);
71b[blen - 1] = 0;
72if ((p = wcsdup(b)) == NULL)
73 err(1, NULL);
74.Ed
75.Sh ERRORS
76The
77.Fn wcsdup
78function may fail and set the external variable
79.Va errno
80for 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
87The
88.Fn wcsdup
89function conforms to
90.St -p1003.1-2008 .
91.Sh HISTORY
92The
93.Fn wcsdup
94function was ported from
95.Nx
96and 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 57a328a8c2..0000000000
--- a/src/lib/libc/string/wcsdup.c
+++ /dev/null
@@ -1,31 +0,0 @@
1/* $OpenBSD: wcsdup.c,v 1.1 2011/07/04 04:37:34 nicm 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
18wchar_t *
19wcsdup(const wchar_t *str)
20{
21 wchar_t *copy;
22 size_t len;
23
24 len = wcslen(str) + 1;
25 copy = malloc(len * sizeof (wchar_t));
26
27 if (!copy)
28 return (NULL);
29
30 return (wmemcpy(copy, str, len));
31}
diff --git a/src/lib/libc/string/wcslcat.c b/src/lib/libc/string/wcslcat.c
deleted file mode 100644
index ee8ff3c343..0000000000
--- a/src/lib/libc/string/wcslcat.c
+++ /dev/null
@@ -1,56 +0,0 @@
1/* $OpenBSD: wcslcat.c,v 1.4 2011/07/24 15:21:28 millert Exp $ */
2/* $NetBSD: wcslcat.c,v 1.2 2001/01/03 14:33:02 lukem Exp $ */
3
4/*
5 * Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com>
6 *
7 * Permission to use, copy, modify, and distribute this software for any
8 * purpose with or without fee is hereby granted, provided that the above
9 * copyright notice and this permission notice appear in all copies.
10 *
11 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18 */
19
20#include <sys/types.h>
21#include <wchar.h>
22
23/*
24 * Appends src to string dst of size siz (unlike wcsncat, siz is the
25 * full size of dst, not space left). At most siz-1 characters
26 * will be copied. Always NUL terminates (unless siz <= wcslen(dst)).
27 * Returns wcslen(src) + MIN(siz, wcslen(initial dst)).
28 * If retval >= siz, truncation occurred.
29 */
30size_t
31wcslcat(wchar_t *dst, const wchar_t *src, size_t siz)
32{
33 wchar_t *d = dst;
34 const wchar_t *s = src;
35 size_t n = siz;
36 size_t dlen;
37
38 /* Find the end of dst and adjust bytes left but don't go past end */
39 while (n-- != 0 && *d != '\0')
40 d++;
41 dlen = d - dst;
42 n = siz - dlen;
43
44 if (n == 0)
45 return(dlen + wcslen(s));
46 while (*s != '\0') {
47 if (n != 1) {
48 *d++ = *s;
49 n--;
50 }
51 s++;
52 }
53 *d = '\0';
54
55 return(dlen + (s - src)); /* count does not include NUL */
56}
diff --git a/src/lib/libc/string/wcslcpy.3 b/src/lib/libc/string/wcslcpy.3
deleted file mode 100644
index 98ecf0aabc..0000000000
--- a/src/lib/libc/string/wcslcpy.3
+++ /dev/null
@@ -1,147 +0,0 @@
1.\" $OpenBSD: wcslcpy.3,v 1.3 2011/07/25 07:51:30 jmc Exp $
2.\"
3.\" Copyright (c) 1998, 2000 Todd C. Miller <Todd.Miller@courtesan.com>
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: July 25 2011 $
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.Fd #include <wchar.h>
26.Ft size_t
27.Fn wcslcpy "wchar_t *dst" "const wchar_t *src" "size_t size"
28.Ft size_t
29.Fn wcslcat "wchar_t *dst" "const wchar_t *src" "size_t size"
30.Sh DESCRIPTION
31The
32.Fn wcslcpy
33and
34.Fn wcslcat
35functions copy and concatenate wide strings respectively.
36They are designed to be safer, more consistent, and less error prone
37replacements for
38.Xr wcsncpy 3
39and
40.Xr wcsncat 3 .
41Unlike those functions,
42.Fn wcslcpy
43and
44.Fn wcslcat
45take the full size of the buffer (not just the length) and guarantee to
46terminate the result with a null wide character (as long as
47.Fa size
48is larger than 0 or, in the case of
49.Fn wcslcat ,
50as long as there is at least one wide character free in
51.Fa dst ) .
52Note that a wide character for the null wide character should be included in
53.Fa size .
54Also note that
55.Fn wcslcpy
56and
57.Fn wcslcat
58only operate on wide strings that are terminated with a null wide character
59(L'\e0').
60This means that for
61.Fn wcslcpy
62.Fa src
63must be terminated with a null wide character and for
64.Fn wcslcat
65both
66.Fa src
67and
68.Fa dst
69must be terminated with a null wide character.
70.Pp
71The
72.Fn wcslcpy
73function copies up to
74.Fa size
75\(mi 1 wide characters from the wide string
76.Fa src
77to
78.Fa dst ,
79terminating the result with a null wide character.
80.Pp
81The
82.Fn wcslcat
83function appends the wide string
84.Fa src
85to the end of
86.Fa dst .
87It will append at most
88.Fa size
89\(mi wcslen(dst) \(mi 1 wide characters, terminating the result with a null
90wide character.
91.Sh RETURN VALUES
92The
93.Fn wcslcpy
94and
95.Fn wcslcat
96functions return the total length of the wide string they tried to create.
97For
98.Fn wcslcpy
99that means the length of
100.Fa src .
101For
102.Fn wcslcat
103that means the initial length of
104.Fa dst
105plus
106the length of
107.Fa src .
108While this may seem somewhat confusing, it was done to make
109truncation detection simple.
110.Pp
111Note, however, that if
112.Fn wcslcat
113traverses
114.Fa size
115wide characters without finding a null wide character, the length of the
116string is considered to be
117.Fa size
118and the destination wide string will not be terminated with a null wide
119character (since there was no space for it).
120This keeps
121.Fn wcslcat
122from running off the end of a wide string.
123In practice this should not happen (as it means that either
124.Fa size
125is incorrect or that
126.Fa dst
127is not terminated with a null wide character).
128The check exists to prevent potential security problems in incorrect code.
129.Sh SEE ALSO
130.Xr strlcpy 3 ,
131.Xr swprintf 3 ,
132.Xr wcsncat 3 ,
133.Xr wcsncpy 3
134.Sh HISTORY
135The
136.Fn wcslcpy
137and
138.Fn wcslcat
139functions first appeared in
140.Ox 3.8 .
141.Sh AUTHORS
142The
143.Fn wcslcpy
144and
145.Fn wcslcat
146functions are based on code by
147.An Todd C. Miller Aq Todd.Miller@courtesan.com .
diff --git a/src/lib/libc/string/wcslcpy.c b/src/lib/libc/string/wcslcpy.c
deleted file mode 100644
index f49936a885..0000000000
--- a/src/lib/libc/string/wcslcpy.c
+++ /dev/null
@@ -1,52 +0,0 @@
1/* $OpenBSD: wcslcpy.c,v 1.5 2011/07/24 15:21:28 millert Exp $ */
2/* $NetBSD: wcslcpy.c,v 1.2 2001/01/03 14:33:02 lukem Exp $ */
3
4/*
5 * Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com>
6 *
7 * Permission to use, copy, modify, and distribute this software for any
8 * purpose with or without fee is hereby granted, provided that the above
9 * copyright notice and this permission notice appear in all copies.
10 *
11 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18 */
19
20#include <sys/types.h>
21#include <wchar.h>
22
23/*
24 * Copy src to string dst of size siz. At most siz-1 characters
25 * will be copied. Always NUL terminates (unless siz == 0).
26 * Returns wcslen(src); if retval >= siz, truncation occurred.
27 */
28size_t
29wcslcpy(wchar_t *dst, const wchar_t *src, size_t siz)
30{
31 wchar_t *d = dst;
32 const wchar_t *s = src;
33 size_t n = siz;
34
35 /* Copy as many bytes as will fit */
36 if (n != 0) {
37 while (--n != 0) {
38 if ((*d++ = *s++) == '\0')
39 break;
40 }
41 }
42
43 /* Not enough room in dst, add NUL and traverse rest of src */
44 if (n == 0) {
45 if (siz != 0)
46 *d = '\0'; /* NUL-terminate dst */
47 while (*s++)
48 ;
49 }
50
51 return(s - src - 1); /* count does not include NUL */
52}
diff --git a/src/lib/libc/string/wcslen.3 b/src/lib/libc/string/wcslen.3
deleted file mode 100644
index 1b2eceab93..0000000000
--- a/src/lib/libc/string/wcslen.3
+++ /dev/null
@@ -1,70 +0,0 @@
1.\" $OpenBSD: wcslen.3,v 1.2 2011/07/25 00:38:53 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: July 25 2011 $
35.Dt WCSLEN 3
36.Os
37.Sh NAME
38.Nm wcslen
39.Nd find length of a wide string
40.Sh SYNOPSIS
41.Fd #include <wchar.h>
42.Ft size_t
43.Fn wcslen "const wchar_t *s"
44.Sh DESCRIPTION
45The
46.Fn wcslen
47function computes the length of the wide string
48.Fa s .
49.Sh RETURN VALUES
50The
51.Fn wcslen
52function returns the number of wide characters that precede the terminating
53null wide character.
54.Sh SEE ALSO
55.Xr strlen 3 ,
56.Xr wcswidth 3
57.Sh STANDARDS
58The
59.Fn wcslen
60function conforms to
61.St -isoC-99
62and was first introduced in
63.St -isoC-amd1 .
64.Sh HISTORY
65The
66.Fn wcslen
67function was ported from
68.Nx
69and first appeared in
70.Ox 3.8 .
diff --git a/src/lib/libc/string/wcslen.c b/src/lib/libc/string/wcslen.c
deleted file mode 100644
index c1de4a271e..0000000000
--- a/src/lib/libc/string/wcslen.c
+++ /dev/null
@@ -1,44 +0,0 @@
1/* $OpenBSD: wcslen.c,v 1.3 2005/08/08 08:05:37 espie 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
34size_t
35wcslen(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}
diff --git a/src/lib/libc/string/wcsncat.c b/src/lib/libc/string/wcsncat.c
deleted file mode 100644
index eb9a701514..0000000000
--- a/src/lib/libc/string/wcsncat.c
+++ /dev/null
@@ -1,52 +0,0 @@
1/* $OpenBSD: wcsncat.c,v 1.3 2005/08/08 08:05:37 espie 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
34wchar_t *
35wcsncat(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}
diff --git a/src/lib/libc/string/wcsncmp.c b/src/lib/libc/string/wcsncmp.c
deleted file mode 100644
index fb3c7057cf..0000000000
--- a/src/lib/libc/string/wcsncmp.c
+++ /dev/null
@@ -1,52 +0,0 @@
1/* $OpenBSD: wcsncmp.c,v 1.4 2005/08/08 08:05:37 espie 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
36int
37wcsncmp(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}
diff --git a/src/lib/libc/string/wcsncpy.c b/src/lib/libc/string/wcsncpy.c
deleted file mode 100644
index 107696f1de..0000000000
--- a/src/lib/libc/string/wcsncpy.c
+++ /dev/null
@@ -1,50 +0,0 @@
1/* $OpenBSD: wcsncpy.c,v 1.4 2006/04/17 18:05:35 espie 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
34wchar_t *
35wcsncpy(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}
diff --git a/src/lib/libc/string/wcspbrk.3 b/src/lib/libc/string/wcspbrk.3
deleted file mode 100644
index 6589e83c83..0000000000
--- a/src/lib/libc/string/wcspbrk.3
+++ /dev/null
@@ -1,81 +0,0 @@
1.\" $OpenBSD: wcspbrk.3,v 1.2 2011/07/25 00:38:53 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: July 25 2011 $
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.Fd #include <wchar.h>
42.Ft wchar_t *
43.Fn wcspbrk "const wchar_t *s" "const wchar_t *charset"
44.Sh DESCRIPTION
45The
46.Fn wcspbrk
47function locates in the wide string
48.Fa s
49the first occurrence of any wide character in the wide string
50.Fa charset
51and returns a pointer to this wide character.
52If no wide characters from
53.Fa charset
54occur anywhere in
55.Fa s ,
56.Fn wcspbrk
57returns
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
69The
70.Fn wcspbrk
71function conforms to
72.St -isoC-99
73and was first introduced in
74.St -isoC-amd1 .
75.Sh HISTORY
76The
77.Fn wcspbrk
78function was ported from
79.Nx
80and 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 1923abfc89..0000000000
--- a/src/lib/libc/string/wcspbrk.c
+++ /dev/null
@@ -1,53 +0,0 @@
1/* $OpenBSD: wcspbrk.c,v 1.3 2005/08/08 08:05:37 espie 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
34wchar_t *
35wcspbrk(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 /* LINTED interface specification */
46 return (wchar_t *)p;
47 }
48 q++;
49 }
50 p++;
51 }
52 return NULL;
53}
diff --git a/src/lib/libc/string/wcsrchr.3 b/src/lib/libc/string/wcsrchr.3
deleted file mode 100644
index d65caa4292..0000000000
--- a/src/lib/libc/string/wcsrchr.3
+++ /dev/null
@@ -1,85 +0,0 @@
1.\" $OpenBSD: wcsrchr.3,v 1.2 2011/07/25 00:38:53 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: July 25 2011 $
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.Fd #include <wchar.h>
42.Ft wchar_t *
43.Fn wcsrchr "const wchar_t *s" "wchar_t c"
44.Sh DESCRIPTION
45The
46.Fn wcsrchr
47function locates the last occurrence of the wide character
48.Fa c
49in the wide string
50.Fa s .
51The terminating null wide character is considered part of the wide string.
52If
53.Fa c
54is the null wide character (L'\e0'),
55.Fn wcsrchr
56locates the terminating null wide character.
57.Sh RETURN VALUES
58The
59.Fn wcsrchr
60function returns a pointer to the located wide character or
61.Dv NULL
62if 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
73The
74.Fn wcsrchr
75function conforms to
76.St -isoC-99
77and was first introduced in
78.St -isoC-amd1 .
79.Sh HISTORY
80The
81.Fn wcsrchr
82function was ported from
83.Nx
84and 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 3433310c56..0000000000
--- a/src/lib/libc/string/wcsrchr.c
+++ /dev/null
@@ -1,50 +0,0 @@
1/* $OpenBSD: wcsrchr.c,v 1.3 2005/08/08 08:05:37 espie 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
34wchar_t *
35wcsrchr(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 /* LINTED interface specification */
45 return (wchar_t *)p;
46 }
47 p--;
48 }
49 return NULL;
50}
diff --git a/src/lib/libc/string/wcsspn.3 b/src/lib/libc/string/wcsspn.3
deleted file mode 100644
index 66505c59d1..0000000000
--- a/src/lib/libc/string/wcsspn.3
+++ /dev/null
@@ -1,79 +0,0 @@
1.\" $OpenBSD: wcsspn.3,v 1.2 2011/07/25 00:38:53 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: July 25 2011 $
35.Dt WCSSPN 3
36.Os
37.Sh NAME
38.Nm wcsspn
39.Nd span a wide string
40.Sh SYNOPSIS
41.Fd #include <wchar.h>
42.Ft size_t
43.Fn wcsspn "const wchar_t *s" "const wchar_t *charset"
44.Sh DESCRIPTION
45The
46.Fn wcsspn
47function spans the initial part of the wide string
48.Fa s
49as long as the wide characters from
50.Fa s
51occur in the wide string
52.Fa charset .
53.Sh RETURN VALUES
54The
55.Fn wcsspn
56function 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
67The
68.Fn wcsspn
69function conforms to
70.St -isoC-99
71and was first introduced in
72.St -isoC-amd1 .
73.Sh HISTORY
74The
75.Fn wcsspn
76function was ported from
77.Nx
78and 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 5162fa0763..0000000000
--- a/src/lib/libc/string/wcsspn.c
+++ /dev/null
@@ -1,55 +0,0 @@
1/* $OpenBSD: wcsspn.c,v 1.3 2005/08/08 08:05:37 espie 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
34size_t
35wcsspn(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
53done:
54 return (p - s);
55}
diff --git a/src/lib/libc/string/wcsstr.3 b/src/lib/libc/string/wcsstr.3
deleted file mode 100644
index 73f85c3504..0000000000
--- a/src/lib/libc/string/wcsstr.3
+++ /dev/null
@@ -1,88 +0,0 @@
1.\" $OpenBSD: wcsstr.3,v 1.2 2011/07/25 00:38:53 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: July 25 2011 $
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.Fd #include <wchar.h>
42.Ft wchar_t *
43.Fn wcsstr "const wchar_t *big" "const wchar_t *little"
44.Sh DESCRIPTION
45The
46.Fn wcsstr
47function locates the first occurrence of the wide string
48.Fa little
49in the wide string
50.Fa big .
51.Pp
52If
53.Fa little
54is an empty wide string,
55.Fa big
56is returned;
57if
58.Fa little
59occurs nowhere in
60.Fa big ,
61.Dv NULL
62is returned;
63otherwise a pointer to the first wide character of the first occurrence of
64.Fa little
65is 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
76The
77.Fn wcsstr
78function conforms to
79.St -isoC-99
80and was first introduced in
81.St -isoC-amd1 .
82.Sh HISTORY
83The
84.Fn wcsstr
85function was ported from
86.Nx
87and 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 669e340280..0000000000
--- a/src/lib/libc/string/wcsstr.c
+++ /dev/null
@@ -1,70 +0,0 @@
1/* $OpenBSD: wcsstr.c,v 1.3 2005/08/08 08:05:37 espie 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
34wchar_t *
35#ifdef WCSWCS
36wcswcs(const wchar_t *big, const wchar_t *little)
37#else
38wcsstr(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 /* LINTED interface specification */
47 return (wchar_t *)big;
48 }
49 if (wcslen(big) < wcslen(little))
50 return NULL;
51
52 p = big;
53 q = little;
54 while (*p) {
55 q = little;
56 r = p;
57 while (*q) {
58 if (*r != *q)
59 break;
60 q++;
61 r++;
62 }
63 if (!*q) {
64 /* LINTED interface specification */
65 return (wchar_t *)p;
66 }
67 p++;
68 }
69 return NULL;
70}
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
68The
69.Fn wcstok
70function
71is used to isolate sequential tokens in a NUL-terminated wide-character
72string,
73.Fa str .
74These tokens are separated in the string by at least one of the
75characters in
76.Fa sep .
77The first time that
78.Fn wcstok
79is called,
80.Fa str
81should be specified; subsequent calls, wishing to obtain further tokens
82from the same string, should pass a null pointer instead.
83The separator string,
84.Fa sep ,
85must be supplied each time, and may change between calls.
86The context pointer
87.Fa last
88must be provided on each call.
89.Pp
90The
91.Fn wcstok
92function is the wide-character counterpart of the
93.Xr strtok_r 3
94function.
95.Pp
96Since
97.Fn wcstok
98modifies the string,
99.Fa str
100should not point to an area in the initialized data segment.
101.Sh RETURN VALUES
102The
103.Fn wcstok
104function
105returns a pointer to the beginning of each subsequent token in the string,
106after replacing the token itself with a NUL wide character (L'\e0').
107When no more tokens remain, a null pointer is returned.
108.Sh EXAMPLES
109The following code fragment splits a wide-character string on
110.Tn ASCII
111space, tab, and newline characters and writes the tokens to
112standard output:
113.Bd -literal -offset indent
114const wchar_t *seps = L" \et\en";
115wchar_t *last, *tok, text[] = L" \enone\ettwo\et\etthree \en";
116
117for (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
131The
132.Fn wcstok
133function
134conforms to
135.St -isoC-99 .
136.Sh HISTORY
137The
138.Fn wcstok
139function was ported from
140.Nx
141and first appeared in
142.Ox 3.8 .
143.Pp
144Some early implementations of
145.Fn wcstok
146omit the
147context pointer argument,
148.Fa last ,
149and maintain state across calls in a static variable like
150.Xr strtok 3
151does.
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
47wchar_t *
48wcstok(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 */
61cont:
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
38The
39.Fn wcswidth
40function determines the number of column positions required for the first
41.Fa n
42characters of
43.Fa pwcs ,
44or until a null wide character (L'\e0') is encountered.
45.Sh RETURN VALUES
46The
47.Fn wcswidth
48function returns 0 if
49.Fa pwcs
50is an empty string (L""),
51\-1 if a non-printing wide character is encountered,
52otherwise 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
59The
60.Fn wcswidth
61function conforms to
62.St -p1003.1-2001 .
63.Sh HISTORY
64The
65.Fn wcswidth
66function was ported from
67.Nx
68and 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 8ea1bdf6e6..0000000000
--- a/src/lib/libc/string/wcswidth.c
+++ /dev/null
@@ -1,50 +0,0 @@
1/* $OpenBSD: wcswidth.c,v 1.4 2011/04/04 18:16:24 stsp 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
34int
35wcswidth(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}
diff --git a/src/lib/libc/string/wmemchr.3 b/src/lib/libc/string/wmemchr.3
deleted file mode 100644
index 21df1aaa88..0000000000
--- a/src/lib/libc/string/wmemchr.3
+++ /dev/null
@@ -1,81 +0,0 @@
1.\" $OpenBSD: wmemchr.3,v 1.9 2011/07/25 00:38:53 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: July 25 2011 $
35.Dt WMEMCHR 3
36.Os
37.Sh NAME
38.Nm wmemchr
39.Nd locate wide character in wide string
40.Sh SYNOPSIS
41.Fd #include <wchar.h>
42.Ft wchar_t *
43.Fn wmemchr "const wchar_t *b" "wchar_t c" "size_t len"
44.Sh DESCRIPTION
45The
46.Fn wmemchr
47function locates the first occurrence of
48.Fa c
49in wide string
50.Fa b .
51.Sh RETURN VALUES
52The
53.Fn wmemchr
54function returns a pointer to the wide character located, or
55.Dv NULL
56if no such wide character exists within
57.Fa len
58wide 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
69The
70.Fn wmemchr
71function conforms to
72.St -isoC-99
73and was first introduced in
74.St -isoC-amd1 .
75.Sh HISTORY
76The
77.Fn wmemchr
78function was ported from
79.Nx
80and 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 8c9517861b..0000000000
--- a/src/lib/libc/string/wmemchr.c
+++ /dev/null
@@ -1,47 +0,0 @@
1/* $OpenBSD: wmemchr.c,v 1.3 2005/08/08 08:05:37 espie 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
34wchar_t *
35wmemchr(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 /* LINTED const castaway */
42 return (wchar_t *)s;
43 }
44 s++;
45 }
46 return NULL;
47}
diff --git a/src/lib/libc/string/wmemcmp.3 b/src/lib/libc/string/wmemcmp.3
deleted file mode 100644
index 6006b4e5c1..0000000000
--- a/src/lib/libc/string/wmemcmp.3
+++ /dev/null
@@ -1,78 +0,0 @@
1.\" $OpenBSD: wmemcmp.3,v 1.2 2011/07/25 00:38:53 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: July 25 2011 $
35.Dt WMEMCMP 3
36.Os
37.Sh NAME
38.Nm wmemcmp
39.Nd compare wide strings
40.Sh SYNOPSIS
41.Fd #include <wchar.h>
42.Ft int
43.Fn wmemcmp "const wchar_t *s1" "const wchar_t *s2" "size_t len"
44.Sh DESCRIPTION
45The
46.Fn wmemcmp
47function compares the wide string
48.Fa s1
49against the wide string
50.Fa s2 .
51Both wide strings are assumed to be
52.Fa len
53wide characters long.
54.Sh RETURN VALUES
55The
56.Fn wmemcmp
57function returns zero if the two wide strings are identical,
58otherwise the difference between the first two differing wide characters is
59returned.
60Zero-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
66The
67.Fn wmemcmp
68function conforms to
69.St -isoC-99
70and was first introduced in
71.St -isoC-amd1 .
72.Sh HISTORY
73The
74.Fn wmemcmp
75function was ported from
76.Nx
77and 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 39419aeddc..0000000000
--- a/src/lib/libc/string/wmemcmp.c
+++ /dev/null
@@ -1,50 +0,0 @@
1/* $OpenBSD: wmemcmp.c,v 1.4 2005/08/08 08:05:37 espie 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
35int
36wmemcmp(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}
diff --git a/src/lib/libc/string/wmemcpy.3 b/src/lib/libc/string/wmemcpy.3
deleted file mode 100644
index 1102640ad4..0000000000
--- a/src/lib/libc/string/wmemcpy.3
+++ /dev/null
@@ -1,85 +0,0 @@
1.\" $OpenBSD: wmemcpy.3,v 1.3 2011/07/25 00:38:53 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: July 25 2011 $
35.Dt WMEMCPY 3
36.Os
37.Sh NAME
38.Nm wmemcpy
39.Nd copy wide characters
40.Sh SYNOPSIS
41.Fd #include <wchar.h>
42.Ft wchar_t *
43.Fn wmemcpy "wchar_t * restrict dst" "const wchar_t * restrict src" "size_t len"
44.Sh DESCRIPTION
45The
46.Fn wmemcpy
47function copies
48.Fa len
49wide characters from buffer
50.Fa src
51to buffer
52.Fa dst .
53.Sh RETURN VALUES
54The
55.Fn wmemcpy
56function returns the original value of
57.Fa dst .
58.Sh SEE ALSO
59.Xr memcpy 3 ,
60.Xr wcscpy 3 ,
61.Xr wcslcpy 3 ,
62.Xr wmemmove 3
63.Sh STANDARDS
64The
65.Fn wmemcpy
66function conforms to
67.St -isoC-99
68and was first introduced in
69.St -isoC-amd1 .
70.Sh HISTORY
71The
72.Fn wmemcpy
73function was ported from
74.Nx
75and first appeared in
76.Ox 3.8 .
77.Sh CAVEATS
78In this implementation
79.Fn wmemcpy
80is implemented using
81.Xr bcopy 3 ,
82and therefore the buffers may overlap.
83On other systems, copying overlapping buffers may produce surprises.
84A portable, safe solution is to use
85.Xr wmemmove 3 .
diff --git a/src/lib/libc/string/wmemcpy.c b/src/lib/libc/string/wmemcpy.c
deleted file mode 100644
index 9bbd83648e..0000000000
--- a/src/lib/libc/string/wmemcpy.c
+++ /dev/null
@@ -1,40 +0,0 @@
1/* $OpenBSD: wmemcpy.c,v 1.3 2005/08/08 08:05:37 espie 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
35wchar_t *
36wmemcpy(wchar_t *d, const wchar_t *s, size_t n)
37{
38
39 return (wchar_t *)memcpy(d, s, n * sizeof(wchar_t));
40}
diff --git a/src/lib/libc/string/wmemmove.3 b/src/lib/libc/string/wmemmove.3
deleted file mode 100644
index 45daa854ba..0000000000
--- a/src/lib/libc/string/wmemmove.3
+++ /dev/null
@@ -1,78 +0,0 @@
1.\" $OpenBSD: wmemmove.3,v 1.2 2011/07/25 00:38:53 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: July 25 2011 $
35.Dt WMEMMOVE 3
36.Os
37.Sh NAME
38.Nm wmemmove
39.Nd copy wide characters
40.Sh SYNOPSIS
41.Fd #include <wchar.h>
42.Ft wchar_t *
43.Fn wmemmove "wchar_t *dst" "const wchar_t *src" "size_t len"
44.Sh DESCRIPTION
45The
46.Fn wmemmove
47function copies
48.Fa len
49wide characters from buffer
50.Fa src
51to buffer
52.Fa dst .
53The two buffers may overlap;
54the copy is always done in a non-destructive manner.
55.Sh RETURN VALUES
56The
57.Fn wmemmove
58function 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
66The
67.Fn wmemmove
68function conforms to
69.St -isoC-99
70and was first introduced in
71.St -isoC-amd1 .
72.Sh HISTORY
73The
74.Fn wmemmove
75function was ported from
76.Nx
77and 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 21bbabcd0c..0000000000
--- a/src/lib/libc/string/wmemmove.c
+++ /dev/null
@@ -1,40 +0,0 @@
1/* $OpenBSD: wmemmove.c,v 1.3 2005/08/08 08:05:37 espie 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
35wchar_t *
36wmemmove(wchar_t *d, const wchar_t *s, size_t n)
37{
38
39 return (wchar_t *)memmove(d, s, n * sizeof(wchar_t));
40}
diff --git a/src/lib/libc/string/wmemset.3 b/src/lib/libc/string/wmemset.3
deleted file mode 100644
index 1b840762ec..0000000000
--- a/src/lib/libc/string/wmemset.3
+++ /dev/null
@@ -1,73 +0,0 @@
1.\" $OpenBSD: wmemset.3,v 1.3 2011/07/25 00:38:53 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: July 25 2011 $
35.Dt WMEMSET 3
36.Os
37.Sh NAME
38.Nm wmemset
39.Nd write a wide string
40.Sh SYNOPSIS
41.Fd #include <wchar.h>
42.Ft wchar_t *
43.Fn wmemset "wchar_t *s" "wchar_t c" "size_t len"
44.Sh DESCRIPTION
45The
46.Fn wmemset
47function writes
48.Fa len
49wide characters of value
50.Fa c
51to the wide string
52.Fa s .
53.Sh RETURN VALUES
54The
55.Fn wmemset
56function returns the original value of
57.Fa s .
58.Sh SEE ALSO
59.Xr memset 3
60.Sh STANDARDS
61The
62.Fn wmemset
63function conforms to
64.St -isoC-99
65and was first introduced in
66.St -isoC-amd1 .
67.Sh HISTORY
68The
69.Fn wmemset
70function was ported from
71.Nx
72and 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 ac476dba6a..0000000000
--- a/src/lib/libc/string/wmemset.c
+++ /dev/null
@@ -1,46 +0,0 @@
1/* $OpenBSD: wmemset.c,v 1.3 2005/08/08 08:05:37 espie 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
34wchar_t *
35wmemset(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}