From eb8dd9dca1228af0cd132f515509051ecfabf6f6 Mon Sep 17 00:00:00 2001 From: cvs2svn Date: Mon, 14 Apr 2025 17:32:06 +0000 Subject: This commit was manufactured by cvs2git to create tag 'tb_20250414'. --- src/lib/libc/string/Makefile.inc | 35 ------ src/lib/libc/string/bcmp.3 | 67 ----------- src/lib/libc/string/bcmp.c | 52 --------- src/lib/libc/string/bcopy.3 | 67 ----------- src/lib/libc/string/bcopy.c | 113 ------------------ src/lib/libc/string/bzero.3 | 92 --------------- src/lib/libc/string/bzero.c | 45 -------- src/lib/libc/string/explicit_bzero.c | 20 ---- src/lib/libc/string/ffs.3 | 61 ---------- src/lib/libc/string/ffs.c | 40 ------- src/lib/libc/string/memccpy.3 | 81 ------------- src/lib/libc/string/memccpy.c | 49 -------- src/lib/libc/string/memchr.3 | 102 ----------------- src/lib/libc/string/memchr.c | 49 -------- src/lib/libc/string/memcmp.3 | 86 -------------- src/lib/libc/string/memcmp.c | 52 --------- src/lib/libc/string/memcpy.3 | 79 ------------- src/lib/libc/string/memcpy.c | 109 ------------------ src/lib/libc/string/memmem.3 | 77 ------------- src/lib/libc/string/memmem.c | 184 ------------------------------ src/lib/libc/string/memmove.3 | 76 ------------- src/lib/libc/string/memmove.c | 113 ------------------ src/lib/libc/string/memrchr.c | 39 ------- src/lib/libc/string/memset.3 | 75 ------------ src/lib/libc/string/memset.c | 48 -------- src/lib/libc/string/stpcpy.3 | 184 ------------------------------ src/lib/libc/string/stpcpy.c | 44 ------- src/lib/libc/string/stpncpy.c | 57 ---------- src/lib/libc/string/strcasecmp.3 | 128 --------------------- src/lib/libc/string/strcasecmp.c | 107 ------------------ src/lib/libc/string/strcasecmp_l.c | 21 ---- src/lib/libc/string/strcasestr.c | 61 ---------- src/lib/libc/string/strcat.3 | 76 ------------- src/lib/libc/string/strcat.c | 47 -------- src/lib/libc/string/strchr.3 | 116 ------------------- src/lib/libc/string/strchr.c | 46 -------- src/lib/libc/string/strcmp.3 | 95 ---------------- src/lib/libc/string/strcmp.c | 48 -------- src/lib/libc/string/strcoll.3 | 103 ----------------- src/lib/libc/string/strcoll.c | 45 -------- src/lib/libc/string/strcoll_l.c | 14 --- src/lib/libc/string/strcpy.3 | 82 -------------- src/lib/libc/string/strcpy.c | 46 -------- src/lib/libc/string/strcspn.3 | 108 ------------------ src/lib/libc/string/strcspn.c | 59 ---------- src/lib/libc/string/strdup.3 | 119 ------------------- src/lib/libc/string/strdup.c | 50 -------- src/lib/libc/string/strerror.3 | 154 ------------------------- src/lib/libc/string/strerror.c | 42 ------- src/lib/libc/string/strerror_l.c | 33 ------ src/lib/libc/string/strerror_r.c | 107 ------------------ src/lib/libc/string/strlcat.c | 56 --------- src/lib/libc/string/strlcpy.3 | 195 -------------------------------- src/lib/libc/string/strlcpy.c | 51 --------- src/lib/libc/string/strlen.3 | 103 ----------------- src/lib/libc/string/strlen.c | 44 ------- src/lib/libc/string/strmode.3 | 153 ------------------------- src/lib/libc/string/strmode.c | 139 ----------------------- src/lib/libc/string/strncat.3 | 132 --------------------- src/lib/libc/string/strncat.c | 58 ---------- src/lib/libc/string/strncmp.c | 48 -------- src/lib/libc/string/strncpy.3 | 138 ---------------------- src/lib/libc/string/strncpy.c | 59 ---------- src/lib/libc/string/strndup.c | 40 ------- src/lib/libc/string/strnlen.c | 33 ------ src/lib/libc/string/strpbrk.3 | 80 ------------- src/lib/libc/string/strpbrk.c | 49 -------- src/lib/libc/string/strrchr.3 | 118 ------------------- src/lib/libc/string/strrchr.c | 48 -------- src/lib/libc/string/strsep.3 | 110 ------------------ src/lib/libc/string/strsep.c | 71 ------------ src/lib/libc/string/strsignal.3 | 78 ------------- src/lib/libc/string/strsignal.c | 40 ------- src/lib/libc/string/strspn.3 | 92 --------------- src/lib/libc/string/strspn.c | 52 --------- src/lib/libc/string/strstr.3 | 101 ----------------- src/lib/libc/string/strstr.c | 189 ------------------------------- src/lib/libc/string/strtok.3 | 169 --------------------------- src/lib/libc/string/strtok.c | 87 -------------- src/lib/libc/string/strxfrm.3 | 105 ----------------- src/lib/libc/string/strxfrm.c | 52 --------- src/lib/libc/string/strxfrm_l.c | 14 --- src/lib/libc/string/swab.3 | 79 ------------- src/lib/libc/string/swab.c | 35 ------ src/lib/libc/string/timingsafe_bcmp.3 | 87 -------------- src/lib/libc/string/timingsafe_bcmp.c | 30 ----- src/lib/libc/string/timingsafe_memcmp.c | 47 -------- src/lib/libc/string/wcscasecmp.3 | 134 ---------------------- src/lib/libc/string/wcscasecmp.c | 63 ----------- src/lib/libc/string/wcscasecmp_l.c | 63 ----------- src/lib/libc/string/wcscat.3 | 115 ------------------- src/lib/libc/string/wcscat.c | 56 --------- src/lib/libc/string/wcschr.3 | 85 -------------- src/lib/libc/string/wcschr.c | 50 -------- src/lib/libc/string/wcscmp.3 | 92 --------------- src/lib/libc/string/wcscmp.c | 52 --------- src/lib/libc/string/wcscpy.3 | 129 --------------------- src/lib/libc/string/wcscpy.c | 52 --------- src/lib/libc/string/wcscspn.3 | 83 -------------- src/lib/libc/string/wcscspn.c | 54 --------- src/lib/libc/string/wcsdup.3 | 97 ---------------- src/lib/libc/string/wcsdup.c | 32 ------ src/lib/libc/string/wcslcat.c | 56 --------- src/lib/libc/string/wcslcpy.3 | 160 -------------------------- src/lib/libc/string/wcslcpy.c | 51 --------- src/lib/libc/string/wcslen.3 | 102 ----------------- src/lib/libc/string/wcslen.c | 45 -------- src/lib/libc/string/wcsncat.c | 53 --------- src/lib/libc/string/wcsncmp.c | 53 --------- src/lib/libc/string/wcsncpy.c | 51 --------- src/lib/libc/string/wcsnlen.c | 45 -------- src/lib/libc/string/wcspbrk.3 | 81 ------------- src/lib/libc/string/wcspbrk.c | 53 --------- src/lib/libc/string/wcsrchr.3 | 85 -------------- src/lib/libc/string/wcsrchr.c | 50 -------- src/lib/libc/string/wcsspn.3 | 79 ------------- src/lib/libc/string/wcsspn.c | 56 --------- src/lib/libc/string/wcsstr.3 | 88 -------------- src/lib/libc/string/wcsstr.c | 71 ------------ src/lib/libc/string/wcstok.3 | 151 ------------------------- src/lib/libc/string/wcstok.c | 93 --------------- src/lib/libc/string/wcswcs.c | 5 - src/lib/libc/string/wcswidth.3 | 69 ----------- src/lib/libc/string/wcswidth.c | 51 --------- src/lib/libc/string/wmemchr.3 | 81 ------------- src/lib/libc/string/wmemchr.c | 47 -------- src/lib/libc/string/wmemcmp.3 | 78 ------------- src/lib/libc/string/wmemcmp.c | 51 --------- src/lib/libc/string/wmemcpy.3 | 79 ------------- src/lib/libc/string/wmemcpy.c | 41 ------- src/lib/libc/string/wmemmove.3 | 78 ------------- src/lib/libc/string/wmemmove.c | 41 ------- src/lib/libc/string/wmemset.3 | 73 ------------ src/lib/libc/string/wmemset.c | 47 -------- 134 files changed, 10106 deletions(-) delete mode 100644 src/lib/libc/string/Makefile.inc delete mode 100644 src/lib/libc/string/bcmp.3 delete mode 100644 src/lib/libc/string/bcmp.c delete mode 100644 src/lib/libc/string/bcopy.3 delete mode 100644 src/lib/libc/string/bcopy.c delete mode 100644 src/lib/libc/string/bzero.3 delete mode 100644 src/lib/libc/string/bzero.c delete mode 100644 src/lib/libc/string/explicit_bzero.c delete mode 100644 src/lib/libc/string/ffs.3 delete mode 100644 src/lib/libc/string/ffs.c delete mode 100644 src/lib/libc/string/memccpy.3 delete mode 100644 src/lib/libc/string/memccpy.c delete mode 100644 src/lib/libc/string/memchr.3 delete mode 100644 src/lib/libc/string/memchr.c delete mode 100644 src/lib/libc/string/memcmp.3 delete mode 100644 src/lib/libc/string/memcmp.c delete mode 100644 src/lib/libc/string/memcpy.3 delete mode 100644 src/lib/libc/string/memcpy.c delete mode 100644 src/lib/libc/string/memmem.3 delete mode 100644 src/lib/libc/string/memmem.c delete mode 100644 src/lib/libc/string/memmove.3 delete mode 100644 src/lib/libc/string/memmove.c delete mode 100644 src/lib/libc/string/memrchr.c delete mode 100644 src/lib/libc/string/memset.3 delete mode 100644 src/lib/libc/string/memset.c delete mode 100644 src/lib/libc/string/stpcpy.3 delete mode 100644 src/lib/libc/string/stpcpy.c delete mode 100644 src/lib/libc/string/stpncpy.c delete mode 100644 src/lib/libc/string/strcasecmp.3 delete mode 100644 src/lib/libc/string/strcasecmp.c delete mode 100644 src/lib/libc/string/strcasecmp_l.c delete mode 100644 src/lib/libc/string/strcasestr.c delete mode 100644 src/lib/libc/string/strcat.3 delete mode 100644 src/lib/libc/string/strcat.c delete mode 100644 src/lib/libc/string/strchr.3 delete mode 100644 src/lib/libc/string/strchr.c delete mode 100644 src/lib/libc/string/strcmp.3 delete mode 100644 src/lib/libc/string/strcmp.c delete mode 100644 src/lib/libc/string/strcoll.3 delete mode 100644 src/lib/libc/string/strcoll.c delete mode 100644 src/lib/libc/string/strcoll_l.c delete mode 100644 src/lib/libc/string/strcpy.3 delete mode 100644 src/lib/libc/string/strcpy.c delete mode 100644 src/lib/libc/string/strcspn.3 delete mode 100644 src/lib/libc/string/strcspn.c delete mode 100644 src/lib/libc/string/strdup.3 delete mode 100644 src/lib/libc/string/strdup.c delete mode 100644 src/lib/libc/string/strerror.3 delete mode 100644 src/lib/libc/string/strerror.c delete mode 100644 src/lib/libc/string/strerror_l.c delete mode 100644 src/lib/libc/string/strerror_r.c delete mode 100644 src/lib/libc/string/strlcat.c delete mode 100644 src/lib/libc/string/strlcpy.3 delete mode 100644 src/lib/libc/string/strlcpy.c delete mode 100644 src/lib/libc/string/strlen.3 delete mode 100644 src/lib/libc/string/strlen.c delete mode 100644 src/lib/libc/string/strmode.3 delete mode 100644 src/lib/libc/string/strmode.c delete mode 100644 src/lib/libc/string/strncat.3 delete mode 100644 src/lib/libc/string/strncat.c delete mode 100644 src/lib/libc/string/strncmp.c delete mode 100644 src/lib/libc/string/strncpy.3 delete mode 100644 src/lib/libc/string/strncpy.c delete mode 100644 src/lib/libc/string/strndup.c delete mode 100644 src/lib/libc/string/strnlen.c delete mode 100644 src/lib/libc/string/strpbrk.3 delete mode 100644 src/lib/libc/string/strpbrk.c delete mode 100644 src/lib/libc/string/strrchr.3 delete mode 100644 src/lib/libc/string/strrchr.c delete mode 100644 src/lib/libc/string/strsep.3 delete mode 100644 src/lib/libc/string/strsep.c delete mode 100644 src/lib/libc/string/strsignal.3 delete mode 100644 src/lib/libc/string/strsignal.c delete mode 100644 src/lib/libc/string/strspn.3 delete mode 100644 src/lib/libc/string/strspn.c delete mode 100644 src/lib/libc/string/strstr.3 delete mode 100644 src/lib/libc/string/strstr.c delete mode 100644 src/lib/libc/string/strtok.3 delete mode 100644 src/lib/libc/string/strtok.c delete mode 100644 src/lib/libc/string/strxfrm.3 delete mode 100644 src/lib/libc/string/strxfrm.c delete mode 100644 src/lib/libc/string/strxfrm_l.c delete mode 100644 src/lib/libc/string/swab.3 delete mode 100644 src/lib/libc/string/swab.c delete mode 100644 src/lib/libc/string/timingsafe_bcmp.3 delete mode 100644 src/lib/libc/string/timingsafe_bcmp.c delete mode 100644 src/lib/libc/string/timingsafe_memcmp.c delete mode 100644 src/lib/libc/string/wcscasecmp.3 delete mode 100644 src/lib/libc/string/wcscasecmp.c delete mode 100644 src/lib/libc/string/wcscasecmp_l.c delete mode 100644 src/lib/libc/string/wcscat.3 delete mode 100644 src/lib/libc/string/wcscat.c delete mode 100644 src/lib/libc/string/wcschr.3 delete mode 100644 src/lib/libc/string/wcschr.c delete mode 100644 src/lib/libc/string/wcscmp.3 delete mode 100644 src/lib/libc/string/wcscmp.c delete mode 100644 src/lib/libc/string/wcscpy.3 delete mode 100644 src/lib/libc/string/wcscpy.c delete mode 100644 src/lib/libc/string/wcscspn.3 delete mode 100644 src/lib/libc/string/wcscspn.c delete mode 100644 src/lib/libc/string/wcsdup.3 delete mode 100644 src/lib/libc/string/wcsdup.c delete mode 100644 src/lib/libc/string/wcslcat.c delete mode 100644 src/lib/libc/string/wcslcpy.3 delete mode 100644 src/lib/libc/string/wcslcpy.c delete mode 100644 src/lib/libc/string/wcslen.3 delete mode 100644 src/lib/libc/string/wcslen.c delete mode 100644 src/lib/libc/string/wcsncat.c delete mode 100644 src/lib/libc/string/wcsncmp.c delete mode 100644 src/lib/libc/string/wcsncpy.c delete mode 100644 src/lib/libc/string/wcsnlen.c delete mode 100644 src/lib/libc/string/wcspbrk.3 delete mode 100644 src/lib/libc/string/wcspbrk.c delete mode 100644 src/lib/libc/string/wcsrchr.3 delete mode 100644 src/lib/libc/string/wcsrchr.c delete mode 100644 src/lib/libc/string/wcsspn.3 delete mode 100644 src/lib/libc/string/wcsspn.c delete mode 100644 src/lib/libc/string/wcsstr.3 delete mode 100644 src/lib/libc/string/wcsstr.c delete mode 100644 src/lib/libc/string/wcstok.3 delete mode 100644 src/lib/libc/string/wcstok.c delete mode 100644 src/lib/libc/string/wcswcs.c delete mode 100644 src/lib/libc/string/wcswidth.3 delete mode 100644 src/lib/libc/string/wcswidth.c delete mode 100644 src/lib/libc/string/wmemchr.3 delete mode 100644 src/lib/libc/string/wmemchr.c delete mode 100644 src/lib/libc/string/wmemcmp.3 delete mode 100644 src/lib/libc/string/wmemcmp.c delete mode 100644 src/lib/libc/string/wmemcpy.3 delete mode 100644 src/lib/libc/string/wmemcpy.c delete mode 100644 src/lib/libc/string/wmemmove.3 delete mode 100644 src/lib/libc/string/wmemmove.c delete mode 100644 src/lib/libc/string/wmemset.3 delete mode 100644 src/lib/libc/string/wmemset.c (limited to 'src/lib/libc/string') diff --git a/src/lib/libc/string/Makefile.inc b/src/lib/libc/string/Makefile.inc deleted file mode 100644 index 204ca1b266..0000000000 --- a/src/lib/libc/string/Makefile.inc +++ /dev/null @@ -1,35 +0,0 @@ -# $OpenBSD: Makefile.inc,v 1.40 2024/07/14 09:51:18 jca Exp $ - -# string sources -.PATH: ${LIBCSRCDIR}/arch/${MACHINE_CPU}/string ${LIBCSRCDIR}/string - -SRCS+= explicit_bzero.c memccpy.c memmem.c memrchr.c stpcpy.c stpncpy.c \ - strcasecmp.c strcasecmp_l.c strcasestr.c strcoll.c strcoll_l.c \ - strdup.c strerror.c strerror_l.c strerror_r.c strmode.c \ - strndup.c strnlen.c strsignal.c strtok.c strxfrm.c strxfrm_l.c \ - timingsafe_bcmp.c timingsafe_memcmp.c \ - wcscat.c wcschr.c wcscmp.c wcscpy.c wcscspn.c wcslcat.c wcslcpy.c \ - wcslen.c wcsncat.c wcsncmp.c wcsncpy.c wcsnlen.c wcspbrk.c wcsrchr.c \ - wcsspn.c wcsstr.c wcstok.c wcswcs.c wcswidth.c wmemchr.c wmemcmp.c \ - wmemcpy.c wmemmove.c wmemset.c wcsdup.c wcscasecmp.c wcscasecmp_l.c - -# machine-dependent net sources -# ../arch/ARCH/Makefile.inc must include sources for: -# bcmp() bcopy() bzero() ffs() index() memchr() memcmp() memset() -# memcpy() memmove() memset() rindex() strcat() strchr() -# strcmp() strcpy() strcspn() strlen() strlcat() strlcpy() -# strncat() strncmp() strncpy() strpbrk() strrchr() strsep() -# strspn() strstr() swab() - -.include "${LIBCSRCDIR}/arch/${MACHINE_CPU}/string/Makefile.inc" - -MAN+= bcmp.3 bcopy.3 bzero.3 ffs.3 memccpy.3 memchr.3 \ - memcmp.3 memcpy.3 memmem.3 memmove.3 memset.3 stpcpy.3 strcasecmp.3 \ - strcat.3 strchr.3 strcmp.3 strcoll.3 strcpy.3 strcspn.3 strdup.3 \ - strerror.3 strlen.3 strmode.3 strncat.3 strncpy.3 strpbrk.3 \ - strrchr.3 strsep.3 strsignal.3 strspn.3 strstr.3 strtok.3 strxfrm.3 \ - swab.3 strlcpy.3 timingsafe_bcmp.3 \ - wcscasecmp.3 wcscat.3 wcschr.3 wcscmp.3 wcscpy.3 \ - wcscspn.3 wcsdup.3 wcslcpy.3 wcslen.3 wcspbrk.3 wcsrchr.3 wcsspn.3 \ - wcsstr.3 wcstok.3 wcswidth.3 wmemchr.3 wmemcmp.3 wmemcpy.3 wmemmove.3 \ - wmemset.3 diff --git a/src/lib/libc/string/bcmp.3 b/src/lib/libc/string/bcmp.3 deleted file mode 100644 index a3cb1dfb74..0000000000 --- a/src/lib/libc/string/bcmp.3 +++ /dev/null @@ -1,67 +0,0 @@ -.\" Copyright (c) 1990, 1991 The Regents of the University of California. -.\" All rights reserved. -.\" -.\" This code is derived from software contributed to Berkeley by -.\" Chris Torek. -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" $OpenBSD: bcmp.3,v 1.12 2015/11/24 09:14:35 daniel Exp $ -.\" -.Dd $Mdocdate: November 24 2015 $ -.Dt BCMP 3 -.Os -.Sh NAME -.Nm bcmp -.Nd compare byte string -.Sh SYNOPSIS -.In strings.h -.Ft int -.Fn bcmp "const void *b1" "const void *b2" "size_t len" -.Sh DESCRIPTION -The -.Fn bcmp -function compares byte string -.Fa b1 -against byte string -.Fa b2 , -returning zero if they are identical, non-zero otherwise. -Both strings are assumed to be -.Fa len -bytes long. -Zero-length strings are always identical. -.Pp -The strings may overlap. -.Sh SEE ALSO -.Xr memcmp 3 , -.Xr strcasecmp 3 , -.Xr strcmp 3 , -.Xr strcoll 3 , -.Xr strxfrm 3 , -.Xr timingsafe_bcmp 3 -.Sh HISTORY -The -.Fn bcmp -function first appeared in -.Bx 4.2 . diff --git a/src/lib/libc/string/bcmp.c b/src/lib/libc/string/bcmp.c deleted file mode 100644 index 5d446bf096..0000000000 --- a/src/lib/libc/string/bcmp.c +++ /dev/null @@ -1,52 +0,0 @@ -/* $OpenBSD: bcmp.c,v 1.11 2015/08/31 02:53:57 guenther Exp $ */ - -/* - * Copyright (c) 1987 Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include - -/* - * bcmp -- vax cmpc3 instruction - */ -int -bcmp(const void *b1, const void *b2, size_t length) -{ - char *p1, *p2; - - if (length == 0) - return (0); - p1 = (char *)b1; - p2 = (char *)b2; - do - if (*p1++ != *p2++) - return (1); - while (--length); - return (0); -} -DEF_WEAK(bcmp); diff --git a/src/lib/libc/string/bcopy.3 b/src/lib/libc/string/bcopy.3 deleted file mode 100644 index 68c63f92ec..0000000000 --- a/src/lib/libc/string/bcopy.3 +++ /dev/null @@ -1,67 +0,0 @@ -.\" Copyright (c) 1990, 1991 The Regents of the University of California. -.\" All rights reserved. -.\" -.\" This code is derived from software contributed to Berkeley by -.\" Chris Torek. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" $OpenBSD: bcopy.3,v 1.12 2015/11/24 09:14:35 daniel Exp $ -.\" -.Dd $Mdocdate: November 24 2015 $ -.Dt BCOPY 3 -.Os -.Sh NAME -.Nm bcopy -.Nd copy bytes -.Sh SYNOPSIS -.In strings.h -.Ft void -.Fn bcopy "const void *src" "void *dst" "size_t len" -.Sh DESCRIPTION -The -.Fn bcopy -function copies -.Fa len -bytes from buffer -.Fa src -to buffer -.Fa dst . -The two buffers may overlap. -If -.Fa len -is zero, no bytes are copied. -.Sh SEE ALSO -.Xr memccpy 3 , -.Xr memcpy 3 , -.Xr memmove 3 , -.Xr strcpy 3 , -.Xr strlcpy 3 , -.Xr strncpy 3 -.Sh HISTORY -The -.Fn bcopy -function first appeared in -.Bx 4.2 . diff --git a/src/lib/libc/string/bcopy.c b/src/lib/libc/string/bcopy.c deleted file mode 100644 index ef0d368053..0000000000 --- a/src/lib/libc/string/bcopy.c +++ /dev/null @@ -1,113 +0,0 @@ -/* $OpenBSD: bcopy.c,v 1.7 2015/08/31 02:53:57 guenther Exp $ */ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Chris Torek. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include - -/* - * sizeof(word) MUST BE A POWER OF TWO - * SO THAT wmask BELOW IS ALL ONES - */ -typedef long word; /* "word" used for optimal copy speed */ - -#define wsize sizeof(word) -#define wmask (wsize - 1) - -/* - * Copy a block of memory, handling overlap. - */ -void -bcopy(const void *src0, void *dst0, size_t length) -{ - char *dst = dst0; - const char *src = src0; - size_t t; - - if (length == 0 || dst == src) /* nothing to do */ - goto done; - - /* - * Macros: loop-t-times; and loop-t-times, t>0 - */ -#define TLOOP(s) if (t) TLOOP1(s) -#define TLOOP1(s) do { s; } while (--t) - - if ((unsigned long)dst < (unsigned long)src) { - /* - * Copy forward. - */ - t = (long)src; /* only need low bits */ - if ((t | (long)dst) & wmask) { - /* - * Try to align operands. This cannot be done - * unless the low bits match. - */ - if ((t ^ (long)dst) & wmask || length < wsize) - t = length; - else - t = wsize - (t & wmask); - length -= t; - TLOOP1(*dst++ = *src++); - } - /* - * Copy whole words, then mop up any trailing bytes. - */ - t = length / wsize; - TLOOP(*(word *)dst = *(word *)src; src += wsize; dst += wsize); - t = length & wmask; - TLOOP(*dst++ = *src++); - } else { - /* - * Copy backwards. Otherwise essentially the same. - * Alignment works as before, except that it takes - * (t&wmask) bytes to align, not wsize-(t&wmask). - */ - src += length; - dst += length; - t = (long)src; - if ((t | (long)dst) & wmask) { - if ((t ^ (long)dst) & wmask || length <= wsize) - t = length; - else - t &= wmask; - length -= t; - TLOOP1(*--dst = *--src); - } - t = length / wsize; - TLOOP(src -= wsize; dst -= wsize; *(word *)dst = *(word *)src); - t = length & wmask; - TLOOP(*--dst = *--src); - } -done: - return; -} -DEF_WEAK(bcopy); diff --git a/src/lib/libc/string/bzero.3 b/src/lib/libc/string/bzero.3 deleted file mode 100644 index 87a23e20bb..0000000000 --- a/src/lib/libc/string/bzero.3 +++ /dev/null @@ -1,92 +0,0 @@ -.\" Copyright (c) 1990, 1991 The Regents of the University of California. -.\" All rights reserved. -.\" -.\" This code is derived from software contributed to Berkeley by -.\" Chris Torek. -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" $OpenBSD: bzero.3,v 1.13 2017/10/12 15:22:32 schwarze Exp $ -.\" -.Dd $Mdocdate: October 12 2017 $ -.Dt BZERO 3 -.Os -.Sh NAME -.Nm bzero , -.Nm explicit_bzero -.Nd write zeroes to a byte string -.Sh SYNOPSIS -.In strings.h -.Ft void -.Fn bzero "void *b" "size_t len" -.In string.h -.Ft void -.Fn explicit_bzero "void *b" "size_t len" -.Sh DESCRIPTION -The -.Fn bzero -function writes -.Fa len -zero bytes to the string -.Fa b . -If -.Fa len -is zero, -.Fn bzero -does nothing. -.Pp -The -.Fn explicit_bzero -variant behaves the same, but will not be removed by a compiler's dead store -optimization pass, making it useful for clearing sensitive memory such as a -password. -.Sh SEE ALSO -.Xr memset 3 , -.Xr swab 3 -.Sh STANDARDS -The -.Fn bzero -function conforms to the X/Open System Interfaces option of the -.St -p1003.1-2004 -specification. -It was removed from the standard in -.St -p1003.1-2008 , -which recommends using -.Xr memset 3 -instead. -.Pp -The -.Fn explicit_bzero -function is an -.Ox -extension. -.Sh HISTORY -The -.Fn bzero -function first appeared in -.Bx 4.2 . -The -.Fn explicit_bzero -function first appeared in -.Ox 5.5 . diff --git a/src/lib/libc/string/bzero.c b/src/lib/libc/string/bzero.c deleted file mode 100644 index 5173de26dd..0000000000 --- a/src/lib/libc/string/bzero.c +++ /dev/null @@ -1,45 +0,0 @@ -/* $OpenBSD: bzero.c,v 1.9 2015/08/31 02:53:57 guenther Exp $ */ - -/* - * Copyright (c) 1987 Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include - -/* - * bzero -- vax movc5 instruction - */ -void -bzero(void *b, size_t length) -{ - char *p; - - for (p = b; length--;) - *p++ = '\0'; -} -DEF_WEAK(bzero); diff --git a/src/lib/libc/string/explicit_bzero.c b/src/lib/libc/string/explicit_bzero.c deleted file mode 100644 index 003ea7cc4c..0000000000 --- a/src/lib/libc/string/explicit_bzero.c +++ /dev/null @@ -1,20 +0,0 @@ -/* $OpenBSD: explicit_bzero.c,v 1.4 2015/08/31 02:53:57 guenther Exp $ */ -/* - * Public domain. - * Written by Matthew Dempsky. - */ - -#include - -__attribute__((weak)) void -__explicit_bzero_hook(void *buf, size_t len) -{ -} - -void -explicit_bzero(void *buf, size_t len) -{ - memset(buf, 0, len); - __explicit_bzero_hook(buf, len); -} -DEF_WEAK(explicit_bzero); diff --git a/src/lib/libc/string/ffs.3 b/src/lib/libc/string/ffs.3 deleted file mode 100644 index e78ab99e8f..0000000000 --- a/src/lib/libc/string/ffs.3 +++ /dev/null @@ -1,61 +0,0 @@ -.\" Copyright (c) 1990, 1991 The Regents of the University of California. -.\" All rights reserved. -.\" -.\" This code is derived from software contributed to Berkeley by -.\" Chris Torek. -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" $OpenBSD: ffs.3,v 1.11 2019/08/30 18:35:03 deraadt Exp $ -.\" -.Dd $Mdocdate: August 30 2019 $ -.Dt FFS 3 -.Os -.Sh NAME -.Nm ffs -.Nd find first bit set in a bit string -.Sh SYNOPSIS -.In strings.h -.Ft int -.Fn ffs "int value" -.Sh DESCRIPTION -The -.Fn ffs -function finds the first bit set in -.Fa value -and returns the index of that bit. -Bits are numbered starting from 1, starting at the rightmost bit. -A return value of 0 means that the argument was zero. -.Sh SEE ALSO -.Xr bit_ffs 3 -.Sh STANDARDS -The -.Fn ffs -function conforms to -.St -p1003.1-2008 . -.Sh HISTORY -The -.Fn ffs -function first appeared in -.Bx 4.2 . diff --git a/src/lib/libc/string/ffs.c b/src/lib/libc/string/ffs.c deleted file mode 100644 index 09d6e35eca..0000000000 --- a/src/lib/libc/string/ffs.c +++ /dev/null @@ -1,40 +0,0 @@ -/* $OpenBSD: ffs.c,v 1.10 2018/01/18 08:23:44 guenther Exp $ */ - -/* - * Public domain. - * Written by Dale Rahn. - */ - -#include - -/* - * ffs -- vax ffs instruction - */ -int -ffs(int mask) -{ - int bit; - unsigned int r = mask; - static const signed char t[16] = { - -28, 1, 2, 1, - 3, 1, 2, 1, - 4, 1, 2, 1, - 3, 1, 2, 1 - }; - - bit = 0; - if (!(r & 0xffff)) { - bit += 16; - r >>= 16; - } - if (!(r & 0xff)) { - bit += 8; - r >>= 8; - } - if (!(r & 0xf)) { - bit += 4; - r >>= 4; - } - - return (bit + t[ r & 0xf ]); -} diff --git a/src/lib/libc/string/memccpy.3 b/src/lib/libc/string/memccpy.3 deleted file mode 100644 index 49b8ab5d26..0000000000 --- a/src/lib/libc/string/memccpy.3 +++ /dev/null @@ -1,81 +0,0 @@ -.\" $OpenBSD: memccpy.3,v 1.14 2024/12/11 23:28:20 jsg Exp $ -.\" -.\" Copyright (c) 1990, 1991, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)memccpy.3 8.1 (Berkeley) 6/9/93 -.\" -.Dd $Mdocdate: December 11 2024 $ -.Dt MEMCCPY 3 -.Os -.Sh NAME -.Nm memccpy -.Nd copy string until character found -.Sh SYNOPSIS -.In string.h -.Ft void * -.Fn memccpy "void *dst" "const void *src" "int c" "size_t len" -.Sh DESCRIPTION -The -.Fn memccpy -function copies bytes from string -.Fa src -to string -.Fa dst . -If the character -.Fa c -(as converted to an -.Vt unsigned char ) -occurs in the string -.Fa src , -the copy stops and a pointer to the byte after the copy of -.Fa c -in the string -.Fa dst -is returned. -Otherwise, -.Fa len -bytes are copied, and a null pointer is returned. -.Pp -If the -.Fa src -and -.Fa dst -strings overlap, the behavior is undefined. -.Sh SEE ALSO -.Xr bcopy 3 , -.Xr memcpy 3 , -.Xr memmove 3 , -.Xr strcpy 3 , -.Xr strlcpy 3 -.Sh HISTORY -The -.Fn memccpy -function first appeared in -.At V -and was reimplemented for -.Bx 4.3 . diff --git a/src/lib/libc/string/memccpy.c b/src/lib/libc/string/memccpy.c deleted file mode 100644 index 635061b8cb..0000000000 --- a/src/lib/libc/string/memccpy.c +++ /dev/null @@ -1,49 +0,0 @@ -/* $OpenBSD: memccpy.c,v 1.7 2015/08/31 02:53:57 guenther Exp $ */ - -/*- - * Copyright (c) 1990, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include - -void * -memccpy(void *t, const void *f, int c, size_t n) -{ - - if (n) { - unsigned char *tp = t; - const unsigned char *fp = f; - unsigned char uc = c; - do { - if ((*tp++ = *fp++) == uc) - return (tp); - } while (--n != 0); - } - return (0); -} -DEF_WEAK(memccpy); diff --git a/src/lib/libc/string/memchr.3 b/src/lib/libc/string/memchr.3 deleted file mode 100644 index fa5809fa98..0000000000 --- a/src/lib/libc/string/memchr.3 +++ /dev/null @@ -1,102 +0,0 @@ -.\" $OpenBSD: memchr.3,v 1.14 2024/12/11 23:28:20 jsg Exp $ -.\" -.\" Copyright (c) 1990, 1991 The Regents of the University of California. -.\" All rights reserved. -.\" -.\" This code is derived from software contributed to Berkeley by -.\" Chris Torek and the American National Standards Committee X3, -.\" on Information Processing Systems. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.Dd $Mdocdate: December 11 2024 $ -.Dt MEMCHR 3 -.Os -.Sh NAME -.Nm memchr , -.Nm memrchr -.Nd locate byte in byte string -.Sh SYNOPSIS -.In string.h -.Ft void * -.Fn memchr "const void *b" "int c" "size_t len" -.Ft void * -.Fn memrchr "const void *b" "int c" "size_t len" -.Sh DESCRIPTION -The -.Fn memchr -function locates the first occurrence of -.Fa c -(converted to an -.Vt unsigned char ) -in string -.Fa b . -.Pp -The -.Fn memrchr -function behaves like -.Fn memchr , -except that it locates the last occurrence of -.Fa c -in string -.Fa b . -.Sh RETURN VALUES -The -.Fn memchr -and -.Fn memrchr -functions return a pointer to the byte located, or -.Dv NULL -if no such byte exists within -.Fa len -bytes. -.Sh SEE ALSO -.Xr strchr 3 , -.Xr strcspn 3 , -.Xr strpbrk 3 , -.Xr strrchr 3 , -.Xr strsep 3 , -.Xr strspn 3 , -.Xr strstr 3 , -.Xr strtok 3 , -.Xr wmemchr 3 -.Sh STANDARDS -The -.Fn memchr -function conforms to -.St -ansiC . -.Pp -The -.Fn memrchr -function is an -.Ox -extension. -.Sh HISTORY -The -.Fn memchr -function first appeared in -.At V -and was reimplemented for -.Bx 4.3 . diff --git a/src/lib/libc/string/memchr.c b/src/lib/libc/string/memchr.c deleted file mode 100644 index a6a4bd60d0..0000000000 --- a/src/lib/libc/string/memchr.c +++ /dev/null @@ -1,49 +0,0 @@ -/* $OpenBSD: memchr.c,v 1.8 2015/08/31 02:53:57 guenther Exp $ */ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Chris Torek. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include - -void * -memchr(const void *s, int c, size_t n) -{ - if (n != 0) { - const unsigned char *p = s; - - do { - if (*p++ == (unsigned char)c) - return ((void *)(p - 1)); - } while (--n != 0); - } - return (NULL); -} -DEF_STRONG(memchr); diff --git a/src/lib/libc/string/memcmp.3 b/src/lib/libc/string/memcmp.3 deleted file mode 100644 index ace8f79255..0000000000 --- a/src/lib/libc/string/memcmp.3 +++ /dev/null @@ -1,86 +0,0 @@ -.\" $OpenBSD: memcmp.3,v 1.11 2024/12/11 23:28:20 jsg Exp $ -.\" -.\" Copyright (c) 1990, 1991 The Regents of the University of California. -.\" All rights reserved. -.\" -.\" This code is derived from software contributed to Berkeley by -.\" Chris Torek and the American National Standards Committee X3, -.\" on Information Processing Systems. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.Dd $Mdocdate: December 11 2024 $ -.Dt MEMCMP 3 -.Os -.Sh NAME -.Nm memcmp -.Nd compare byte string -.Sh SYNOPSIS -.In string.h -.Ft int -.Fn memcmp "const void *b1" "const void *b2" "size_t len" -.Sh DESCRIPTION -The -.Fn memcmp -function compares byte string -.Fa b1 -against byte string -.Fa b2 . -Both strings are assumed to be -.Fa len -bytes long. -.Sh RETURN VALUES -The -.Fn memcmp -function returns zero if the two strings are identical, -otherwise returns the difference between the first two differing bytes -(treated as -.Vt unsigned char -values, so that -.Sq Li \e200 -is greater than -.Sq Li \&\e0 , -for example). -Zero-length strings are always identical. -.Sh SEE ALSO -.Xr bcmp 3 , -.Xr strcasecmp 3 , -.Xr strcmp 3 , -.Xr strcoll 3 , -.Xr strxfrm 3 , -.Xr timingsafe_memcmp 3 , -.Xr wmemcmp 3 -.Sh STANDARDS -The -.Fn memcmp -function conforms to -.St -ansiC . -.Sh HISTORY -The -.Fn memcmp -function first appeared in -.At V -and was reimplemented for -.Bx 4.3 . diff --git a/src/lib/libc/string/memcmp.c b/src/lib/libc/string/memcmp.c deleted file mode 100644 index 0df2c54d2a..0000000000 --- a/src/lib/libc/string/memcmp.c +++ /dev/null @@ -1,52 +0,0 @@ -/* $OpenBSD: memcmp.c,v 1.6 2015/08/31 02:53:57 guenther Exp $ */ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Chris Torek. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include - -/* - * Compare memory regions. - */ -int -memcmp(const void *s1, const void *s2, size_t n) -{ - if (n != 0) { - const unsigned char *p1 = s1, *p2 = s2; - - do { - if (*p1++ != *p2++) - return (*--p1 - *--p2); - } while (--n != 0); - } - return (0); -} -DEF_STRONG(memcmp); diff --git a/src/lib/libc/string/memcpy.3 b/src/lib/libc/string/memcpy.3 deleted file mode 100644 index b093afc919..0000000000 --- a/src/lib/libc/string/memcpy.3 +++ /dev/null @@ -1,79 +0,0 @@ -.\" $OpenBSD: memcpy.3,v 1.11 2024/12/11 23:28:20 jsg Exp $ -.\" -.\" Copyright (c) 1990, 1991 The Regents of the University of California. -.\" All rights reserved. -.\" -.\" This code is derived from software contributed to Berkeley by -.\" Chris Torek and the American National Standards Committee X3, -.\" on Information Processing Systems. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.Dd $Mdocdate: December 11 2024 $ -.Dt MEMCPY 3 -.Os -.Sh NAME -.Nm memcpy -.Nd copy bytes -.Sh SYNOPSIS -.In string.h -.Ft void * -.Fn memcpy "void *dst" "const void *src" "size_t len" -.Sh DESCRIPTION -The -.Fn memcpy -function copies -.Fa len -bytes from buffer -.Fa src -to buffer -.Fa dst . -If the two buffers may overlap, -.Xr memmove 3 -must be used instead. -.Sh RETURN VALUES -The -.Fn memcpy -function returns the original value of -.Fa dst . -.Sh SEE ALSO -.Xr bcopy 3 , -.Xr memccpy 3 , -.Xr memmove 3 , -.Xr strcpy 3 , -.Xr strlcpy 3 , -.Xr wmemcpy 3 -.Sh STANDARDS -The -.Fn memcpy -function conforms to -.St -ansiC . -.Sh HISTORY -The -.Fn memcpy -function first appeared in -.At V -and was reimplemented for -.Bx 4.3 . diff --git a/src/lib/libc/string/memcpy.c b/src/lib/libc/string/memcpy.c deleted file mode 100644 index 19fddc0ab5..0000000000 --- a/src/lib/libc/string/memcpy.c +++ /dev/null @@ -1,109 +0,0 @@ -/* $OpenBSD: memcpy.c,v 1.4 2017/11/29 05:13:57 guenther Exp $ */ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Chris Torek. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#include -#include - -/* - * sizeof(word) MUST BE A POWER OF TWO - * SO THAT wmask BELOW IS ALL ONES - */ -typedef long word; /* "word" used for optimal copy speed */ - -#define wsize sizeof(word) -#define wmask (wsize - 1) - -static const char backwards_msg[] = ": backwards memcpy"; - -/* - * Copy a block of memory, not handling overlap. - */ -void * -memcpy(void *dst0, const void *src0, size_t length) -{ - char *dst = dst0; - const char *src = src0; - size_t t; - - if (length == 0 || dst == src) /* nothing to do */ - goto done; - - if ((dst < src && dst + length > src) || - (src < dst && src + length > dst)) { - char buf[1024]; - - /* <10> is LOG_CRIT */ - strlcpy(buf, "<10>", sizeof buf); - - /* Make sure progname does not fill the whole buffer */ - strlcat(buf, __progname, sizeof(buf) - sizeof backwards_msg); - strlcat(buf, backwards_msg, sizeof buf); - - sendsyslog(buf, strlen(buf), LOG_CONS); - abort(); - } - - /* - * Macros: loop-t-times; and loop-t-times, t>0 - */ -#define TLOOP(s) if (t) TLOOP1(s) -#define TLOOP1(s) do { s; } while (--t) - - /* - * Copy forward. - */ - t = (long)src; /* only need low bits */ - if ((t | (long)dst) & wmask) { - /* - * Try to align operands. This cannot be done - * unless the low bits match. - */ - if ((t ^ (long)dst) & wmask || length < wsize) - t = length; - else - t = wsize - (t & wmask); - length -= t; - TLOOP1(*dst++ = *src++); - } - /* - * Copy whole words, then mop up any trailing bytes. - */ - t = length / wsize; - TLOOP(*(word *)dst = *(word *)src; src += wsize; dst += wsize); - t = length & wmask; - TLOOP(*dst++ = *src++); -done: - return (dst0); -} -DEF_BUILTIN(memcpy); diff --git a/src/lib/libc/string/memmem.3 b/src/lib/libc/string/memmem.3 deleted file mode 100644 index de62d738de..0000000000 --- a/src/lib/libc/string/memmem.3 +++ /dev/null @@ -1,77 +0,0 @@ -.\" $OpenBSD: memmem.3,v 1.4 2024/08/03 20:13:23 guenther Exp $ -.\" -.\" Copyright (c) 2005 Pascal Gloor -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. The name of the author may not be used to endorse or promote -.\" products derived from this software without specific prior written -.\" permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.Dd $Mdocdate: August 3 2024 $ -.Dt MEMMEM 3 -.Os -.Sh NAME -.Nm memmem -.Nd locate a byte substring in a byte string -.Sh SYNOPSIS -.In string.h -.Ft "void *" -.Fo memmem -.Fa "const void *big" "size_t big_len" -.Fa "const void *little" "size_t little_len" -.Fc -.Sh DESCRIPTION -The -.Fn memmem -function -locates the first occurrence of the byte string -.Fa little -in the byte string -.Fa big . -.Sh RETURN VALUES -If -.Fa little -is zero length, -.Fa big -is returned; if -.Fa little -occurs nowhere in -.Fa big , -.Dv NULL -is returned; -otherwise a pointer to the first character of the first occurrence of -.Fa little -is returned. -.Sh SEE ALSO -.Xr memchr 3 , -.Xr strchr 3 , -.Xr strstr 3 -.Sh STANDARDS -The -.Fn memmem -function conforms to -.St -p1003.1-2024 . -.Sh HISTORY -The -.Fn memmem -function first appeared in -.Ox 5.4 . diff --git a/src/lib/libc/string/memmem.c b/src/lib/libc/string/memmem.c deleted file mode 100644 index 3b180b4a62..0000000000 --- a/src/lib/libc/string/memmem.c +++ /dev/null @@ -1,184 +0,0 @@ -/* $OpenBSD: memmem.c,v 1.5 2020/04/16 12:39:28 claudio Exp $ */ - -/* - * Copyright (c) 2005-2020 Rich Felker, et al. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY - * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include -#include - -static char * -twobyte_memmem(const unsigned char *h, size_t k, const unsigned char *n) -{ - uint16_t nw = n[0]<<8 | n[1], hw = h[0]<<8 | h[1]; - for (h+=2, k-=2; k; k--, hw = hw<<8 | *h++) - if (hw == nw) return (char *)h-2; - return hw == nw ? (char *)h-2 : 0; -} - -static char * -threebyte_memmem(const unsigned char *h, size_t k, const unsigned char *n) -{ - uint32_t nw = n[0]<<24 | n[1]<<16 | n[2]<<8; - uint32_t hw = h[0]<<24 | h[1]<<16 | h[2]<<8; - for (h+=3, k-=3; k; k--, hw = (hw|*h++)<<8) - if (hw == nw) return (char *)h-3; - return hw == nw ? (char *)h-3 : 0; -} - -static char * -fourbyte_memmem(const unsigned char *h, size_t k, const unsigned char *n) -{ - uint32_t nw = n[0]<<24 | n[1]<<16 | n[2]<<8 | n[3]; - uint32_t hw = h[0]<<24 | h[1]<<16 | h[2]<<8 | h[3]; - for (h+=4, k-=4; k; k--, hw = hw<<8 | *h++) - if (hw == nw) return (char *)h-4; - return hw == nw ? (char *)h-4 : 0; -} - -#define MAX(a,b) ((a)>(b)?(a):(b)) -#define MIN(a,b) ((a)<(b)?(a):(b)) - -#define BITOP(a,b,op) \ - ((a)[(size_t)(b)/(8*sizeof *(a))] op (size_t)1<<((size_t)(b)%(8*sizeof *(a)))) - -/* - * Maxime Crochemore and Dominique Perrin, Two-way string-matching, - * Journal of the ACM, 38(3):651-675, July 1991. - */ -static char * -twoway_memmem(const unsigned char *h, const unsigned char *z, - const unsigned char *n, size_t l) -{ - size_t i, ip, jp, k, p, ms, p0, mem, mem0; - size_t byteset[32 / sizeof(size_t)] = { 0 }; - size_t shift[256]; - - /* Computing length of needle and fill shift table */ - for (i=0; i n[jp+k]) { - jp += k; - k = 1; - p = jp - ip; - } else { - ip = jp++; - k = p = 1; - } - } - ms = ip; - p0 = p; - - /* And with the opposite comparison */ - ip = -1; jp = 0; k = p = 1; - while (jp+k ms+1) ms = ip; - else p = p0; - - /* Periodic needle? */ - if (memcmp(n, n+p, ms+1)) { - mem0 = 0; - p = MAX(ms, l-ms-1) + 1; - } else mem0 = l-p; - mem = 0; - - /* Search loop */ - for (;;) { - /* If remainder of haystack is shorter than needle, done */ - if (z-h < l) return 0; - - /* Check last byte first; advance by shift on mismatch */ - if (BITOP(byteset, h[l-1], &)) { - k = l-shift[h[l-1]]; - if (k) { - if (k < mem) k = mem; - h += k; - mem = 0; - continue; - } - } else { - h += l; - mem = 0; - continue; - } - - /* Compare right half */ - for (k=MAX(ms+1,mem); kmem && n[k-1] == h[k-1]; k--); - if (k <= mem) return (char *)h; - h += p; - mem = mem0; - } -} - -void * -memmem(const void *h0, size_t k, const void *n0, size_t l) -{ - const unsigned char *h = h0, *n = n0; - - /* Return immediately on empty needle */ - if (!l) return (void *)h; - - /* Return immediately when needle is longer than haystack */ - if (k - -/* - * sizeof(word) MUST BE A POWER OF TWO - * SO THAT wmask BELOW IS ALL ONES - */ -typedef long word; /* "word" used for optimal copy speed */ - -#define wsize sizeof(word) -#define wmask (wsize - 1) - -/* - * Copy a block of memory, handling overlap. - */ -void * -memmove(void *dst0, const void *src0, size_t length) -{ - char *dst = dst0; - const char *src = src0; - size_t t; - - if (length == 0 || dst == src) /* nothing to do */ - goto done; - - /* - * Macros: loop-t-times; and loop-t-times, t>0 - */ -#define TLOOP(s) if (t) TLOOP1(s) -#define TLOOP1(s) do { s; } while (--t) - - if ((unsigned long)dst < (unsigned long)src) { - /* - * Copy forward. - */ - t = (long)src; /* only need low bits */ - if ((t | (long)dst) & wmask) { - /* - * Try to align operands. This cannot be done - * unless the low bits match. - */ - if ((t ^ (long)dst) & wmask || length < wsize) - t = length; - else - t = wsize - (t & wmask); - length -= t; - TLOOP1(*dst++ = *src++); - } - /* - * Copy whole words, then mop up any trailing bytes. - */ - t = length / wsize; - TLOOP(*(word *)dst = *(word *)src; src += wsize; dst += wsize); - t = length & wmask; - TLOOP(*dst++ = *src++); - } else { - /* - * Copy backwards. Otherwise essentially the same. - * Alignment works as before, except that it takes - * (t&wmask) bytes to align, not wsize-(t&wmask). - */ - src += length; - dst += length; - t = (long)src; - if ((t | (long)dst) & wmask) { - if ((t ^ (long)dst) & wmask || length <= wsize) - t = length; - else - t &= wmask; - length -= t; - TLOOP1(*--dst = *--src); - } - t = length / wsize; - TLOOP(src -= wsize; dst -= wsize; *(word *)dst = *(word *)src); - t = length & wmask; - TLOOP(*--dst = *--src); - } -done: - return (dst0); -} -DEF_BUILTIN(memmove); diff --git a/src/lib/libc/string/memrchr.c b/src/lib/libc/string/memrchr.c deleted file mode 100644 index e123bc1737..0000000000 --- a/src/lib/libc/string/memrchr.c +++ /dev/null @@ -1,39 +0,0 @@ -/* $OpenBSD: memrchr.c,v 1.4 2019/01/25 00:19:25 millert Exp $ */ - -/* - * Copyright (c) 2007 Todd C. Miller - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#include - -/* - * Reverse memchr() - * Find the last occurrence of 'c' in the buffer 's' of size 'n'. - */ -void * -memrchr(const void *s, int c, size_t n) -{ - const unsigned char *cp; - - if (n != 0) { - cp = (unsigned char *)s + n; - do { - if (*(--cp) == (unsigned char)c) - return((void *)cp); - } while (--n != 0); - } - return(NULL); -} -DEF_WEAK(memrchr); diff --git a/src/lib/libc/string/memset.3 b/src/lib/libc/string/memset.3 deleted file mode 100644 index 34f2ca7888..0000000000 --- a/src/lib/libc/string/memset.3 +++ /dev/null @@ -1,75 +0,0 @@ -.\" $OpenBSD: memset.3,v 1.10 2024/12/11 23:28:20 jsg Exp $ -.\" -.\" Copyright (c) 1990, 1991 The Regents of the University of California. -.\" All rights reserved. -.\" -.\" This code is derived from software contributed to Berkeley by -.\" Chris Torek and the American National Standards Committee X3, -.\" on Information Processing Systems. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.Dd $Mdocdate: December 11 2024 $ -.Dt MEMSET 3 -.Os -.Sh NAME -.Nm memset -.Nd write a byte to byte string -.Sh SYNOPSIS -.In string.h -.Ft void * -.Fn memset "void *b" "int c" "size_t len" -.Sh DESCRIPTION -The -.Fn memset -function writes -.Fa len -bytes of value -.Fa c -(converted to an -.Vt unsigned char ) -to the string -.Fa b . -.Sh RETURN VALUES -The -.Fn memset -function returns the original value of -.Fa b . -.Sh SEE ALSO -.Xr bzero 3 , -.Xr swab 3 , -.Xr wmemset 3 -.Sh STANDARDS -The -.Fn memset -function conforms to -.St -ansiC . -.Sh HISTORY -The -.Fn memset -function first appeared in -.At V -and was reimplemented for -.Bx 4.3 . diff --git a/src/lib/libc/string/memset.c b/src/lib/libc/string/memset.c deleted file mode 100644 index 0c261f0965..0000000000 --- a/src/lib/libc/string/memset.c +++ /dev/null @@ -1,48 +0,0 @@ -/* $OpenBSD: memset.c,v 1.8 2017/11/29 05:13:57 guenther Exp $ */ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Chris Torek. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include - -void * -memset(void *dst, int c, size_t n) -{ - if (n != 0) { - unsigned char *d = dst; - - do - *d++ = (unsigned char)c; - while (--n != 0); - } - return (dst); -} -DEF_BUILTIN(memset); diff --git a/src/lib/libc/string/stpcpy.3 b/src/lib/libc/string/stpcpy.3 deleted file mode 100644 index 973eebecdd..0000000000 --- a/src/lib/libc/string/stpcpy.3 +++ /dev/null @@ -1,184 +0,0 @@ -.\" $OpenBSD: stpcpy.3,v 1.6 2014/02/23 23:09:34 schwarze Exp $ -.\" -.\" Copyright (c) 1990, 1991 The Regents of the University of California. -.\" All rights reserved. -.\" -.\" This code is derived from software contributed to Berkeley by -.\" Chris Torek and the American National Standards Committee X3, -.\" on Information Processing Systems. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.Dd $Mdocdate: February 23 2014 $ -.Dt STPCPY 3 -.Os -.Sh NAME -.Nm stpcpy , -.Nm stpncpy -.Nd copy strings -.Sh SYNOPSIS -.In string.h -.Ft char * -.Fn stpcpy "char *dst" "const char *src" -.Ft char * -.Fn stpncpy "char *dst" "const char *src" "size_t len" -.Sh DESCRIPTION -The -.Fn stpcpy -and -.Fn stpncpy -functions copy the string -.Fa src -to -.Fa dst -(including the terminating -.Ql \e0 -character). -.Pp -The -.Fn stpncpy -function copies not more than -.Fa len -characters into -.Fa dst , -appending -.Ql \e0 -characters if -.Fa src -is less than -.Fa len -characters long, and -.Em not -terminating -.Fa dst -if the length of -.Fa src -is greater than or equal to -.Fa len . -.Pp -If the -.Fa src -and -.Fa dst -strings overlap, the behavior is undefined. -.Sh RETURN VALUES -The -.Fn stpcpy -function returns a pointer to the terminating -.Ql \e0 -character written into -.Fa dst . -.Pp -The -.Fn stpncpy -function returns a pointer to the first -.Ql \e0 -character written into -.Fa dst , -or to -.Fa &dst[len] -if the length of -.Fa src -is greater than or equal to -.Fa len . -.Sh EXAMPLES -The most common use of -.Fn stpcpy -is to build up a string from multiple elements. -The following example builds up a pathname from -directory and file components using -.Fn stpcpy : -.Bd -literal -offset indent -char *dir, *file, pname[PATH_MAX]; - -\&... - -if (strlen(dir) + strlen("/") + strlen(file) >= sizeof(pname)) - goto toolong; -stpcpy(stpcpy(stpcpy(pname, dir), "/"), file); -.Ed -.Pp -However, the size check required to avoid a buffer overflow is error -prone since the check can become out of sync with the code that -performs the copy. -.Pp -One might expect that -.Fn stpncpy -could be safely used instead, but it suffers from the same defects as -.Fn strncpy . -The example below using -.Fn stpncpy -is even more prone to error and will not detect when truncation occurs: -.Bd -literal -offset indent -char *dir, *file, pname[PATH_MAX]; -char *p1, *p2; - -\&... - -p1 = stpncpy(pname, dir, sizeof(pname) - 1); -p2 = stpncpy(p1, "/", sizeof(pname) - 1 - (p1 - pname)); -stpncpy(p2, file, sizeof(pname) - 1 - (p2 - pname)); -pname[sizeof(pname) - 1] = '\e0'; -.Ed -.Pp -A safer (and simpler) approach is to use -.Fn snprintf : -.Bd -literal -offset indent -char *dir, *file, pname[PATH_MAX]; -int len; - -\&... - -len = snprintf(pname, sizeof(pname), "%s/%s", dir, file); -if (len >= sizeof(pname)) - goto toolong; -.Ed -.Pp -In most cases, it is better to use -.Fn snprintf , -.Fn strlcpy , -or -.Fn strlcat . -.Sh SEE ALSO -.Xr snprintf 3 , -.Xr strcpy 3 , -.Xr strlcpy 3 , -.Xr strncpy 3 -.Sh STANDARDS -The -.Fn stpcpy -and -.Fn stpncpy -functions conform to -.St -p1003.1-2008 . -.Sh HISTORY -The function -.Fn stpcpy -first appeared in the Lattice C AmigaDOS compiler (1986 or earlier). -The function -.Fn stpncpy -first appeared in the GNU C library version 1.07 (1993). -Both functions have been available since -.Ox 5.1 . diff --git a/src/lib/libc/string/stpcpy.c b/src/lib/libc/string/stpcpy.c deleted file mode 100644 index 5a86541f08..0000000000 --- a/src/lib/libc/string/stpcpy.c +++ /dev/null @@ -1,44 +0,0 @@ -/* $OpenBSD: stpcpy.c,v 1.3 2017/11/28 06:55:49 tb Exp $ */ - -/* - * Copyright (c) 1988 Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include - -#if defined(APIWARN) -__warn_references(stpcpy, - "stpcpy() is dangerous; do not use it"); -#endif - -char * -stpcpy(char *to, const char *from) -{ - for (; (*to = *from) != '\0'; ++from, ++to); - return(to); -} diff --git a/src/lib/libc/string/stpncpy.c b/src/lib/libc/string/stpncpy.c deleted file mode 100644 index 6bdee5de16..0000000000 --- a/src/lib/libc/string/stpncpy.c +++ /dev/null @@ -1,57 +0,0 @@ -/* $OpenBSD: stpncpy.c,v 1.3 2015/08/31 02:53:57 guenther Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Chris Torek. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include - -char * -stpncpy(char *dst, const char *src, size_t n) -{ - if (n != 0) { - char *d = dst; - const char *s = src; - - dst = &dst[n]; - do { - if ((*d++ = *s++) == 0) { - dst = d - 1; - /* NUL pad the remaining n-1 bytes */ - while (--n != 0) - *d++ = 0; - break; - } - } while (--n != 0); - } - return (dst); -} -DEF_WEAK(stpncpy); diff --git a/src/lib/libc/string/strcasecmp.3 b/src/lib/libc/string/strcasecmp.3 deleted file mode 100644 index bb39df895a..0000000000 --- a/src/lib/libc/string/strcasecmp.3 +++ /dev/null @@ -1,128 +0,0 @@ -.\" $OpenBSD: strcasecmp.3,v 1.14 2017/09/05 03:16:13 schwarze Exp $ -.\" -.\" Copyright (c) 1990, 1991, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" Copyright (c) 2017 Ingo Schwarze -.\" -.\" This code is derived from software contributed to Berkeley by -.\" Chris Torek. -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)strcasecmp.3 8.1 (Berkeley) 6/9/93 -.\" -.Dd $Mdocdate: September 5 2017 $ -.Dt STRCASECMP 3 -.Os -.Sh NAME -.Nm strcasecmp , -.Nm strcasecmp_l , -.Nm strncasecmp , -.Nm strncasecmp_l -.Nd compare strings, ignoring case -.Sh SYNOPSIS -.In strings.h -.Ft int -.Fo strcasecmp -.Fa "const char *s1" -.Fa "const char *s2" -.Fc -.Ft int -.Fo strcasecmp_l -.Fa "const char *s1" -.Fa "const char *s2" -.Fa "locale_t locale" -.Fc -.Ft int -.Fo strncasecmp -.Fa "const char *s1" -.Fa "const char *s2" -.Fa "size_t len" -.Fc -.Ft int -.Fo strncasecmp_l -.Fa "const char *s1" -.Fa "const char *s2" -.Fa "size_t len" -.Fa "locale_t locale" -.Fc -.Sh DESCRIPTION -These functions compare the NUL-terminated strings -.Fa s1 -and -.Fa s2 -and return an integer greater than, equal to, or less than 0, -according to whether -.Fa s1 -is lexicographically greater than, equal to, or less than -.Fa s2 -after translation of each corresponding character to lower-case. -The strings themselves are not modified. -The comparison is done using unsigned characters, so that -.Sq Li \e200 -is greater than -.Ql \e0 . -.Pp -.Fn strncasecmp -and -.Fn strncasecmp_l -compare at most -.Fa len -characters. -.Pp -On -.Ox , -these functions always use the C locale and ignore -the global locale, the thread-specific locale, and the -.Fa locale -argument. -.Sh ENVIRONMENT -On other operating systems, the behaviour of -.Fn strcasecmp -and -.Fn strncasecmp -may depend on the -.Dv LC_CTYPE -.Xr locale 1 . -.Sh SEE ALSO -.Xr strcmp 3 , -.Xr strcoll 3 , -.Xr strxfrm 3 , -.Xr wcscasecmp 3 -.Sh STANDARDS -These functions conform to -.St -p1003.1-2008 . -.Sh HISTORY -The -.Fn strcasecmp -and -.Fn strncasecmp -functions have been available since -.Bx 4.3 Tahoe , -and -.Fn strcasecmp_l -and -.Fn strncasecmp_l -since -.Ox 6.2 . diff --git a/src/lib/libc/string/strcasecmp.c b/src/lib/libc/string/strcasecmp.c deleted file mode 100644 index edbd638722..0000000000 --- a/src/lib/libc/string/strcasecmp.c +++ /dev/null @@ -1,107 +0,0 @@ -/* $OpenBSD: strcasecmp.c,v 1.7 2015/08/31 02:53:57 guenther Exp $ */ - -/* - * Copyright (c) 1987, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include - -typedef unsigned char u_char; - -/* - * This array is designed for mapping upper and lower case letter - * together for a case independent comparison. The mappings are - * based upon ascii character sequences. - */ -static const u_char charmap[] = { - '\000', '\001', '\002', '\003', '\004', '\005', '\006', '\007', - '\010', '\011', '\012', '\013', '\014', '\015', '\016', '\017', - '\020', '\021', '\022', '\023', '\024', '\025', '\026', '\027', - '\030', '\031', '\032', '\033', '\034', '\035', '\036', '\037', - '\040', '\041', '\042', '\043', '\044', '\045', '\046', '\047', - '\050', '\051', '\052', '\053', '\054', '\055', '\056', '\057', - '\060', '\061', '\062', '\063', '\064', '\065', '\066', '\067', - '\070', '\071', '\072', '\073', '\074', '\075', '\076', '\077', - '\100', '\141', '\142', '\143', '\144', '\145', '\146', '\147', - '\150', '\151', '\152', '\153', '\154', '\155', '\156', '\157', - '\160', '\161', '\162', '\163', '\164', '\165', '\166', '\167', - '\170', '\171', '\172', '\133', '\134', '\135', '\136', '\137', - '\140', '\141', '\142', '\143', '\144', '\145', '\146', '\147', - '\150', '\151', '\152', '\153', '\154', '\155', '\156', '\157', - '\160', '\161', '\162', '\163', '\164', '\165', '\166', '\167', - '\170', '\171', '\172', '\173', '\174', '\175', '\176', '\177', - '\200', '\201', '\202', '\203', '\204', '\205', '\206', '\207', - '\210', '\211', '\212', '\213', '\214', '\215', '\216', '\217', - '\220', '\221', '\222', '\223', '\224', '\225', '\226', '\227', - '\230', '\231', '\232', '\233', '\234', '\235', '\236', '\237', - '\240', '\241', '\242', '\243', '\244', '\245', '\246', '\247', - '\250', '\251', '\252', '\253', '\254', '\255', '\256', '\257', - '\260', '\261', '\262', '\263', '\264', '\265', '\266', '\267', - '\270', '\271', '\272', '\273', '\274', '\275', '\276', '\277', - '\300', '\301', '\302', '\303', '\304', '\305', '\306', '\307', - '\310', '\311', '\312', '\313', '\314', '\315', '\316', '\317', - '\320', '\321', '\322', '\323', '\324', '\325', '\326', '\327', - '\330', '\331', '\332', '\333', '\334', '\335', '\336', '\337', - '\340', '\341', '\342', '\343', '\344', '\345', '\346', '\347', - '\350', '\351', '\352', '\353', '\354', '\355', '\356', '\357', - '\360', '\361', '\362', '\363', '\364', '\365', '\366', '\367', - '\370', '\371', '\372', '\373', '\374', '\375', '\376', '\377', -}; - -int -strcasecmp(const char *s1, const char *s2) -{ - const u_char *cm = charmap; - const u_char *us1 = (const u_char *)s1; - const u_char *us2 = (const u_char *)s2; - - while (cm[*us1] == cm[*us2++]) - if (*us1++ == '\0') - return (0); - return (cm[*us1] - cm[*--us2]); -} -DEF_WEAK(strcasecmp); - -int -strncasecmp(const char *s1, const char *s2, size_t n) -{ - if (n != 0) { - const u_char *cm = charmap; - const u_char *us1 = (const u_char *)s1; - const u_char *us2 = (const u_char *)s2; - - do { - if (cm[*us1] != cm[*us2++]) - return (cm[*us1] - cm[*--us2]); - if (*us1++ == '\0') - break; - } while (--n != 0); - } - return (0); -} -DEF_WEAK(strncasecmp); diff --git a/src/lib/libc/string/strcasecmp_l.c b/src/lib/libc/string/strcasecmp_l.c deleted file mode 100644 index a9543dda11..0000000000 --- a/src/lib/libc/string/strcasecmp_l.c +++ /dev/null @@ -1,21 +0,0 @@ -/* $OpenBSD: strcasecmp_l.c,v 1.1 2017/09/05 03:16:13 schwarze Exp $ */ -/* - * Written in 2017 by Ingo Schwarze . - * Released into the public domain. - */ - -#include - -int -strcasecmp_l(const char *s1, const char *s2, - locale_t locale __attribute__((__unused__))) -{ - return strcasecmp(s1, s2); -} - -int -strncasecmp_l(const char *s1, const char *s2, size_t n, - locale_t locale __attribute__((__unused__))) -{ - return strncasecmp(s1, s2, n); -} diff --git a/src/lib/libc/string/strcasestr.c b/src/lib/libc/string/strcasestr.c deleted file mode 100644 index abb3e15549..0000000000 --- a/src/lib/libc/string/strcasestr.c +++ /dev/null @@ -1,61 +0,0 @@ -/* $OpenBSD: strcasestr.c,v 1.4 2015/08/31 02:53:57 guenther Exp $ */ -/* $NetBSD: strcasestr.c,v 1.2 2005/02/09 21:35:47 kleink Exp $ */ - -/*- - * Copyright (c) 1990, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Chris Torek. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#include - -/* - * Find the first occurrence of find in s, ignore case. - */ -char * -strcasestr(const char *s, const char *find) -{ - char c, sc; - size_t len; - - if ((c = *find++) != 0) { - c = (char)tolower((unsigned char)c); - len = strlen(find); - do { - do { - if ((sc = *s++) == 0) - return (NULL); - } while ((char)tolower((unsigned char)sc) != c); - } while (strncasecmp(s, find, len) != 0); - s--; - } - return ((char *)s); -} -DEF_WEAK(strcasestr); diff --git a/src/lib/libc/string/strcat.3 b/src/lib/libc/string/strcat.3 deleted file mode 100644 index 68da4ed4a5..0000000000 --- a/src/lib/libc/string/strcat.3 +++ /dev/null @@ -1,76 +0,0 @@ -.\" $OpenBSD: strcat.3,v 1.19 2022/08/01 00:04:46 jsg Exp $ -.\" -.\" Copyright (c) 1990, 1991 The Regents of the University of California. -.\" All rights reserved. -.\" -.\" This code is derived from software contributed to Berkeley by -.\" Chris Torek and the American National Standards Committee X3, -.\" on Information Processing Systems. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.Dd $Mdocdate: August 1 2022 $ -.Dt STRCAT 3 -.Os -.Sh NAME -.Nm strcat -.Nd concatenate two strings without bounds checking -.Sh SYNOPSIS -.In string.h -.Ft char * -.Fn strcat "char *dst" "const char *append" -.Sh DESCRIPTION -The -.Fn strcat -function appends a copy of the NUL-terminated string -.Fa append -to the end of the NUL-terminated string -.Fa dst , -then adds a terminating -.Ql \e0 . -.Pp -No bounds checking is performed. -If the buffer -.Fa dst -is not large enough to hold the result, -subsequent memory will be damaged. -.Sh RETURN VALUES -The -.Fn strcat -function return the pointer -.Fa dst . -.Sh SEE ALSO -.Xr strlcpy 3 , -.Xr wcscat 3 , -.Xr wcslcpy 3 -.Sh STANDARDS -The -.Fn strcat -function conforms to -.St -ansiC . -.Sh HISTORY -The -.Fn strcat -function first appeared outside of Bell Labs in PWB/UNIX 1.0. diff --git a/src/lib/libc/string/strcat.c b/src/lib/libc/string/strcat.c deleted file mode 100644 index 73da22f75d..0000000000 --- a/src/lib/libc/string/strcat.c +++ /dev/null @@ -1,47 +0,0 @@ -/* $OpenBSD: strcat.c,v 1.10 2017/11/28 06:55:49 tb Exp $ */ - -/* - * Copyright (c) 1988 Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include - -#if defined(APIWARN) -__warn_references(strcat, - "strcat() is almost always misused, please use strlcat()"); -#endif - -char * -strcat(char *s, const char *append) -{ - char *save = s; - - for (; *s; ++s); - while ((*s++ = *append++) != '\0'); - return(save); -} diff --git a/src/lib/libc/string/strchr.3 b/src/lib/libc/string/strchr.3 deleted file mode 100644 index d1dc67e5ec..0000000000 --- a/src/lib/libc/string/strchr.3 +++ /dev/null @@ -1,116 +0,0 @@ -.\" $OpenBSD: strchr.3,v 1.14 2024/12/11 23:28:20 jsg Exp $ -.\" -.\" Copyright (c) 1990, 1991 The Regents of the University of California. -.\" All rights reserved. -.\" -.\" This code is derived from software contributed to Berkeley by -.\" Chris Torek and the American National Standards Committee X3, -.\" on Information Processing Systems. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.Dd $Mdocdate: December 11 2024 $ -.Dt STRCHR 3 -.Os -.Sh NAME -.Nm strchr , -.Nm index -.Nd locate first occurrence of a character in a string -.Sh SYNOPSIS -.In string.h -.Ft char * -.Fn strchr "const char *s" "int c" -.In strings.h -.Ft char * -.Fn index "const char *s" "int c" -.Sh DESCRIPTION -The -.Fn strchr -function locates the first occurrence of the character -.Fa c -.Pq converted to a char -in the string -.Fa s . -The terminating NUL character is considered part of the string. -If -.Fa c -is -.Ql \e0 , -.Fn strchr -locates the terminating -.Ql \e0 . -.Pp -The -.Fn index -function is an old synonym for -.Fn strchr . -.Sh RETURN VALUES -The -.Fn strchr -function returns a pointer to the located character or -.Dv NULL -if the character does not appear in the string. -.Sh EXAMPLES -After the following call to -.Fn strchr , -.Va p -will point to the string -.Qq oobar : -.Bd -literal -offset indent -char *p; -char *s = "foobar"; - -p = strchr(s, 'o'); -.Ed -.Sh SEE ALSO -.Xr memchr 3 , -.Xr strcspn 3 , -.Xr strpbrk 3 , -.Xr strrchr 3 , -.Xr strsep 3 , -.Xr strspn 3 , -.Xr strstr 3 , -.Xr strtok 3 , -.Xr wcschr 3 -.Sh STANDARDS -The -.Fn strchr -function conforms to -.St -ansiC . -.Pp -The -.Fn index -function is deprecated and shouldn't be used in new code. -.Sh HISTORY -The -.Fn index -function first appeared in -.At v7 . -The -.Fn strchr -function first appeared in -.At III -and was reimplemented for -.Bx 4.3 . diff --git a/src/lib/libc/string/strchr.c b/src/lib/libc/string/strchr.c deleted file mode 100644 index 8bfa7ac3aa..0000000000 --- a/src/lib/libc/string/strchr.c +++ /dev/null @@ -1,46 +0,0 @@ -/* $OpenBSD: strchr.c,v 1.4 2018/10/01 06:37:37 martijn Exp $ */ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include - -__weak_alias(index, strchr); - -char * -strchr(const char *p, int ch) -{ - for (;; ++p) { - if (*p == (char) ch) - return((char *)p); - if (!*p) - return((char *)NULL); - } - /* NOTREACHED */ -} -DEF_STRONG(strchr); diff --git a/src/lib/libc/string/strcmp.3 b/src/lib/libc/string/strcmp.3 deleted file mode 100644 index 4ef341e53e..0000000000 --- a/src/lib/libc/string/strcmp.3 +++ /dev/null @@ -1,95 +0,0 @@ -.\" $OpenBSD: strcmp.3,v 1.15 2022/08/01 00:04:46 jsg Exp $ -.\" -.\" Copyright (c) 1990, 1991 The Regents of the University of California. -.\" All rights reserved. -.\" -.\" This code is derived from software contributed to Berkeley by -.\" Chris Torek and the American National Standards Committee X3, -.\" on Information Processing Systems. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.Dd $Mdocdate: August 1 2022 $ -.Dt STRCMP 3 -.Os -.Sh NAME -.Nm strcmp , -.Nm strncmp -.Nd compare strings -.Sh SYNOPSIS -.In string.h -.Ft int -.Fn strcmp "const char *s1" "const char *s2" -.Ft int -.Fn strncmp "const char *s1" "const char *s2" "size_t len" -.Sh DESCRIPTION -The -.Fn strcmp -and -.Fn strncmp -functions lexicographically compare the NUL-terminated strings -.Fa s1 -and -.Fa s2 . -The -.Fn strncmp -function compares at most -.Fa len -characters. -.Sh RETURN VALUES -The -.Fn strcmp -and -.Fn strncmp -functions return an integer greater than, equal to, or less than 0, according -to whether the string -.Fa s1 -is greater than, equal to, or less than the string -.Fa s2 . -The comparison is done using unsigned characters, so that -.Ql \e200 -is greater than -.Ql \e0 . -.Sh SEE ALSO -.Xr bcmp 3 , -.Xr memcmp 3 , -.Xr strcasecmp 3 , -.Xr strcoll 3 , -.Xr strxfrm 3 , -.Xr wcscmp 3 -.Sh STANDARDS -The -.Fn strcmp -and -.Fn strncmp -functions conform to -.St -ansiC . -.Sh HISTORY -The -.Fn strcmp -function first appeared outside of Bell Labs in PWB/UNIX 1.0. -.Fn strncmp -first appeared in -.At v7 . diff --git a/src/lib/libc/string/strcmp.c b/src/lib/libc/string/strcmp.c deleted file mode 100644 index be175563d4..0000000000 --- a/src/lib/libc/string/strcmp.c +++ /dev/null @@ -1,48 +0,0 @@ -/* $OpenBSD: strcmp.c,v 1.9 2015/08/31 02:53:57 guenther Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Chris Torek. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include - -/* - * Compare strings. - */ -int -strcmp(const char *s1, const char *s2) -{ - while (*s1 == *s2++) - if (*s1++ == 0) - return (0); - return (*(unsigned char *)s1 - *(unsigned char *)--s2); -} -DEF_STRONG(strcmp); diff --git a/src/lib/libc/string/strcoll.3 b/src/lib/libc/string/strcoll.3 deleted file mode 100644 index 9daa6cd93f..0000000000 --- a/src/lib/libc/string/strcoll.3 +++ /dev/null @@ -1,103 +0,0 @@ -.\" $OpenBSD: strcoll.3,v 1.11 2019/01/18 07:43:36 schwarze Exp $ -.\" -.\" Copyright (c) 1990, 1991 The Regents of the University of California. -.\" Copyright (c) 2017 Ingo Schwarze -.\" All rights reserved. -.\" -.\" This code is derived from software contributed to Berkeley by -.\" Chris Torek and the American National Standards Committee X3, -.\" on Information Processing Systems. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.Dd $Mdocdate: January 18 2019 $ -.Dt STRCOLL 3 -.Os -.Sh NAME -.Nm strcoll , -.Nm strcoll_l -.Nd compare strings according to current collation -.Sh SYNOPSIS -.In string.h -.Ft int -.Fn strcoll "const char *s1" "const char *s2" -.Ft int -.Fn strcoll_l "const char *s1" "const char *s2" "locale_t locale" -.Sh DESCRIPTION -The -.Fn strcoll -and -.Fn strcoll_l -functions lexicographically compare the NUL-terminated strings -.Fa s1 -and -.Fa s2 -according to the current locale collation -and return an integer greater than, equal to, or less than 0, -according to whether -.Fa s1 -is greater than, equal to, or less than -.Fa s2 . -.Pp -On -.Ox , -they have the same effect as -.Xr strcmp 3 , -and the global locale, the thread-specific locale, and the -.Fa locale -argument are ignored. -On other operating systems, results may depend on the -.Dv LC_CTYPE -and -.Dv LC_COLLATE -locale categories set with -.Xr setlocale 3 , -.Xr uselocale 3 , -or -.Xr newlocale 3 . -.Sh SEE ALSO -.Xr newlocale 3 , -.Xr setlocale 3 , -.Xr strcmp 3 , -.Xr strxfrm 3 , -.Xr wcscoll 3 -.Sh STANDARDS -The -.Fn strcoll -function conforms to -.St -ansiC , -and -.Fn strcoll_l -to -.St -p1003.1-2008 . -.Sh HISTORY -The -.Fn strcoll -function has been available since -.Bx 4.3 Reno , -and -.Fn strcoll_l -since -.Ox 6.2 . diff --git a/src/lib/libc/string/strcoll.c b/src/lib/libc/string/strcoll.c deleted file mode 100644 index 47a6ea4f24..0000000000 --- a/src/lib/libc/string/strcoll.c +++ /dev/null @@ -1,45 +0,0 @@ -/* $OpenBSD: strcoll.c,v 1.6 2015/08/31 02:53:57 guenther Exp $ */ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Chris Torek. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include - -/* - * Compare strings according to LC_COLLATE category of current locale. - */ -int -strcoll(const char *s1, const char *s2) -{ - /* LC_COLLATE is unimplemented, hence always "C" */ - return (strcmp(s1, s2)); -} -DEF_STRONG(strcoll); diff --git a/src/lib/libc/string/strcoll_l.c b/src/lib/libc/string/strcoll_l.c deleted file mode 100644 index bcd5b0f417..0000000000 --- a/src/lib/libc/string/strcoll_l.c +++ /dev/null @@ -1,14 +0,0 @@ -/* $OpenBSD: strcoll_l.c,v 1.1 2017/09/05 03:16:13 schwarze Exp $ */ -/* - * Written in 2017 by Ingo Schwarze . - * Released into the public domain. - */ - -#include - -int -strcoll_l(const char *s1, const char *s2, - locale_t locale __attribute__((__unused__))) -{ - return strcmp(s1, s2); -} diff --git a/src/lib/libc/string/strcpy.3 b/src/lib/libc/string/strcpy.3 deleted file mode 100644 index 4bf690ba76..0000000000 --- a/src/lib/libc/string/strcpy.3 +++ /dev/null @@ -1,82 +0,0 @@ -.\" $OpenBSD: strcpy.3,v 1.22 2022/08/01 00:04:46 jsg Exp $ -.\" -.\" Copyright (c) 1990, 1991 The Regents of the University of California. -.\" All rights reserved. -.\" -.\" This code is derived from software contributed to Berkeley by -.\" Chris Torek and the American National Standards Committee X3, -.\" on Information Processing Systems. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.Dd $Mdocdate: August 1 2022 $ -.Dt STRCPY 3 -.Os -.Sh NAME -.Nm strcpy -.Nd copy a string without bounds checking -.Sh SYNOPSIS -.In string.h -.Ft char * -.Fn strcpy "char *dst" "const char *src" -.Sh DESCRIPTION -The -.Fn strcpy -function copies the string -.Fa src -(including the terminating -.Ql \e0 -character) to the buffer -.Fa dst . -.Pp -No bounds checking is performed. -If the buffer -.Fa dst -is not large enough to hold the result, -subsequent memory will be damaged. -.Pp -If the -.Fa src -string is inside the -.Fa dst -buffer, the behavior is undefined. -.Sh RETURN VALUES -The -.Fn strcpy -function returns -.Fa dst . -.Sh SEE ALSO -.Xr strlcpy 3 , -.Xr wcscpy 3 , -.Xr wcslcpy 3 -.Sh STANDARDS -The -.Fn strcpy -function conforms to -.St -ansiC . -.Sh HISTORY -The -.Fn strcpy -function first appeared outside of Bell Labs in PWB/UNIX 1.0. diff --git a/src/lib/libc/string/strcpy.c b/src/lib/libc/string/strcpy.c deleted file mode 100644 index 290eefeabf..0000000000 --- a/src/lib/libc/string/strcpy.c +++ /dev/null @@ -1,46 +0,0 @@ -/* $OpenBSD: strcpy.c,v 1.10 2017/11/28 06:55:49 tb Exp $ */ - -/* - * Copyright (c) 1988 Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include - -#if defined(APIWARN) -__warn_references(strcpy, - "strcpy() is almost always misused, please use strlcpy()"); -#endif - -char * -strcpy(char *to, const char *from) -{ - char *save = to; - - for (; (*to = *from) != '\0'; ++from, ++to); - return(save); -} diff --git a/src/lib/libc/string/strcspn.3 b/src/lib/libc/string/strcspn.3 deleted file mode 100644 index 91e5c3f1cc..0000000000 --- a/src/lib/libc/string/strcspn.3 +++ /dev/null @@ -1,108 +0,0 @@ -.\" $OpenBSD: strcspn.3,v 1.12 2024/12/11 23:28:20 jsg Exp $ -.\" -.\" Copyright (c) 1990, 1991 The Regents of the University of California. -.\" All rights reserved. -.\" -.\" This code is derived from software contributed to Berkeley by -.\" Chris Torek and the American National Standards Committee X3, -.\" on Information Processing Systems. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.Dd $Mdocdate: December 11 2024 $ -.Dt STRCSPN 3 -.Os -.Sh NAME -.Nm strcspn -.Nd span the complement of a string -.Sh SYNOPSIS -.In string.h -.Ft size_t -.Fn strcspn "const char *s" "const char *charset" -.Sh DESCRIPTION -The -.Fn strcspn -function spans the initial part of the NUL-terminated string -.Fa s -as long as the characters from -.Fa s -do not occur in string -.Fa charset -(it spans the -.Em complement -of -.Fa charset ) . -.Sh RETURN VALUES -The -.Fn strcspn -function returns the number of characters spanned. -.Sh EXAMPLES -The following call to -.Fn strcspn -will return 3, since the first three characters of string -.Fa s -do not occur in string -.Fa charset : -.Bd -literal -offset indent -char *s = "foobar"; -char *charset = "bar"; -size_t span; - -span = strcspn(s, charset); -.Ed -.Pp -The following removes the first (if any) newline character from string -.Fa line . -This is useful for trimming the newline after a -.Xr fgets 3 -call. -.Bd -literal -offset indent -char line[BUFSIZ]; - -if (fgets(line, sizeof(line), fp) != NULL) - line[strcspn(line, "\en")] = '\e0'; -.Ed -.Sh SEE ALSO -.Xr memchr 3 , -.Xr strchr 3 , -.Xr strpbrk 3 , -.Xr strrchr 3 , -.Xr strsep 3 , -.Xr strspn 3 , -.Xr strstr 3 , -.Xr strtok 3 , -.Xr wcscspn 3 -.Sh STANDARDS -The -.Fn strcspn -function conforms to -.St -ansiC . -.Sh HISTORY -The -.Fn strcspn -function first appeared in -.At III -and was reimplemented for -.Bx 4.3 . diff --git a/src/lib/libc/string/strcspn.c b/src/lib/libc/string/strcspn.c deleted file mode 100644 index 3c1f5a4cec..0000000000 --- a/src/lib/libc/string/strcspn.c +++ /dev/null @@ -1,59 +0,0 @@ -/* $OpenBSD: strcspn.c,v 1.6 2015/08/31 02:53:57 guenther Exp $ */ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Chris Torek. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include - -/* - * Span the complement of string s2. - */ -size_t -strcspn(const char *s1, const char *s2) -{ - const char *p, *spanp; - char c, sc; - - /* - * Stop as soon as we find any character from s2. Note that there - * must be a NUL in s2; it suffices to stop when we find that, too. - */ - for (p = s1;;) { - c = *p++; - spanp = s2; - do { - if ((sc = *spanp++) == c) - return (p - 1 - s1); - } while (sc != 0); - } - /* NOTREACHED */ -} -DEF_STRONG(strcspn); diff --git a/src/lib/libc/string/strdup.3 b/src/lib/libc/string/strdup.3 deleted file mode 100644 index 283f3bc0ea..0000000000 --- a/src/lib/libc/string/strdup.3 +++ /dev/null @@ -1,119 +0,0 @@ -.\" $OpenBSD: strdup.3,v 1.22 2015/12/01 01:32:48 mmcc Exp $ -.\" -.\" Copyright (c) 1990, 1991, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)strdup.3 8.1 (Berkeley) 6/9/93 -.\" -.Dd $Mdocdate: December 1 2015 $ -.Dt STRDUP 3 -.Os -.Sh NAME -.Nm strdup , -.Nm strndup -.Nd save a copy of a string -.Sh SYNOPSIS -.In string.h -.Ft char * -.Fn strdup "const char *s" -.Ft char * -.Fn strndup "const char *s" "size_t maxlen" -.Sh DESCRIPTION -The -.Fn strdup -function allocates sufficient memory for a copy of the string -.Fa s , -does the copy, and returns a pointer to it. -The pointer may subsequently be used as an argument to the function -.Xr free 3 . -.Pp -The -.Fn strndup -function behaves similarly to -.Nm strdup -but only copies up to -.Fa maxlen -characters from -.Fa s . -The resulting string is always NUL-terminated. -.Pp -If the memory allocation fails, -.Dv NULL -is returned. -.Sh EXAMPLES -The following will point -.Va p -to an allocated area of memory containing the NUL-terminated string -.Qq foobar : -.Bd -literal -offset indent -char *p; - -p = strdup("foobar"); -if (p == NULL) - err(1, NULL); -.Ed -.Sh ERRORS -The -.Fn strdup -and -.Fn strndup -functions may fail and set the external variable -.Va errno -for any of the errors specified for the library function -.Xr malloc 3 . -.Sh SEE ALSO -.Xr free 3 , -.Xr malloc 3 , -.Xr strcpy 3 , -.Xr strlcpy 3 , -.Xr strlen 3 , -.Xr wcsdup 3 -.Sh STANDARDS -The -.Fn strdup -and -.Fn strndup -functions conform to -.St -p1003.1-2008 . -.Sh HISTORY -A -.Fn strdup -macro was first used in the -.Bx 4.1c -debugger, -.Sy dbx . -It was rewritten as a C function for the -.Bx 4.3 -.Xr inetd 8 -and first appeared in the C library of -.Bx 4.3 Reno . -The -.Fn strndup -function appeared in glibc 2.0, was reimplemented for -.Nx 4.0 , -and ported to -.Ox 4.8 . diff --git a/src/lib/libc/string/strdup.c b/src/lib/libc/string/strdup.c deleted file mode 100644 index 9aebf399c1..0000000000 --- a/src/lib/libc/string/strdup.c +++ /dev/null @@ -1,50 +0,0 @@ -/* $OpenBSD: strdup.c,v 1.7 2015/08/31 02:53:57 guenther Exp $ */ - -/* - * Copyright (c) 1988, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include - -#include -#include -#include - -char * -strdup(const char *str) -{ - size_t siz; - char *copy; - - siz = strlen(str) + 1; - if ((copy = malloc(siz)) == NULL) - return(NULL); - (void)memcpy(copy, str, siz); - return(copy); -} -DEF_WEAK(strdup); diff --git a/src/lib/libc/string/strerror.3 b/src/lib/libc/string/strerror.3 deleted file mode 100644 index 6c5b890fa4..0000000000 --- a/src/lib/libc/string/strerror.3 +++ /dev/null @@ -1,154 +0,0 @@ -.\" $OpenBSD: strerror.3,v 1.16 2019/05/16 13:35:16 schwarze Exp $ -.\" -.\" Copyright (c) 1980, 1991 Regents of the University of California. -.\" Copyright (c) 2017 Ingo Schwarze -.\" All rights reserved. -.\" -.\" This code is derived from software contributed to Berkeley by -.\" the American National Standards Committee X3, on Information -.\" Processing Systems. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.Dd $Mdocdate: May 16 2019 $ -.Dt STRERROR 3 -.Os -.Sh NAME -.Nm strerror , -.Nm strerror_l , -.Nm strerror_r -.Nd get error message string -.Sh SYNOPSIS -.In string.h -.Ft char * -.Fn strerror "int errnum" -.Ft char * -.Fn strerror_l "int errnum" "locale_t locale" -.Ft int -.Fn strerror_r "int errnum" "char *strerrbuf" "size_t buflen" -.Sh DESCRIPTION -These functions map the error number -.Fa errnum -to an error message string. -.Pp -.Fn strerror -and -.Fn strerror_l -return a string containing a maximum of -.Dv NL_TEXTMAX -characters, including the trailing NUL. -This string is not to be modified by the calling program. -The string returned by -.Fn strerror -may be overwritten by subsequent calls to -.Fn strerror -in any thread. -The string returned by -.Fn strerror_l -may be overwritten by subsequent calls to -.Fn strerror_l -in the same thread. -.Pp -.Fn strerror_r -is a thread safe version of -.Fn strerror -that places the error message in the specified buffer -.Fa strerrbuf . -.Pp -On -.Ox , -the global locale, the thread-specific locale, and the -.Fa locale -argument are ignored. -.Sh RETURN VALUES -.Fn strerror -and -.Fn strerror_l -return a pointer to the error message string. -If an error occurs, the error code is stored in -.Va errno . -.Pp -.Fn strerror_r -returns zero upon successful completion. -If an error occurs, the error code is stored in -.Va errno -and the error code is returned. -.Sh ERRORS -All these functions may fail if: -.Bl -tag -width Er -.It Bq Er EINVAL -.Fa errnum -is not a valid error number. -The returned error string will consist of an error message that includes -.Fa errnum . -.El -.Pp -.Fn strerror_r -may also fail if: -.Bl -tag -width Er -.It Bq Er ERANGE -The error message is larger than -.Fa buflen -characters. -The message will be truncated to fit. -.El -.Sh SEE ALSO -.Xr intro 2 , -.Xr newlocale 3 , -.Xr perror 3 , -.Xr setlocale 3 -.Sh STANDARDS -The -.Fn strerror -function conforms to -.St -isoC-99 . -The -.Fn strerror_l -and -.Fn strerror_r -functions conform to -.St -p1003.1-2008 . -.Sh HISTORY -The -.Fn strerror -function has been available since -.Bx 4.3 Reno , -.Fn strerror_r -since -.Ox 3.3 , -and -.Fn strerror_l -since -.Ox 6.2 . -.Sh CAVEATS -On systems other than -.Ox , -the -.Dv LC_MESSAGES -.Xr locale 1 -category can cause different strings to be returned instead of the -normal error messages; see CAVEATS in -.Xr setlocale 3 -for details. diff --git a/src/lib/libc/string/strerror.c b/src/lib/libc/string/strerror.c deleted file mode 100644 index c6f05446fd..0000000000 --- a/src/lib/libc/string/strerror.c +++ /dev/null @@ -1,42 +0,0 @@ -/* $OpenBSD: strerror.c,v 1.8 2015/08/31 02:53:57 guenther Exp $ */ -/* - * Copyright (c) 1988 Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#include - -char * -strerror(int num) -{ - static char buf[NL_TEXTMAX]; - - (void)strerror_r(num, buf, sizeof(buf)); - return (buf); -} -DEF_STRONG(strerror); diff --git a/src/lib/libc/string/strerror_l.c b/src/lib/libc/string/strerror_l.c deleted file mode 100644 index c16be7a0cc..0000000000 --- a/src/lib/libc/string/strerror_l.c +++ /dev/null @@ -1,33 +0,0 @@ -/* $OpenBSD: strerror_l.c,v 1.1 2017/09/05 03:16:13 schwarze Exp $ */ -/* - * Copyright (c) 2017 Ingo Schwarze - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#include -#include - -#include "thread_private.h" - -char * -strerror_l(int errnum, locale_t locale) -{ - static char sel_buf[NL_TEXTMAX]; - _THREAD_PRIVATE_KEY(strerror_l); - char *p = _THREAD_PRIVATE(strerror_l, sel_buf, NULL); - - return p == NULL ? "no buffer available in strerror_l" : - strerror_r(errnum, p, sizeof(sel_buf)) ? - "strerror_r failure" : p; -} diff --git a/src/lib/libc/string/strerror_r.c b/src/lib/libc/string/strerror_r.c deleted file mode 100644 index b45dee12d8..0000000000 --- a/src/lib/libc/string/strerror_r.c +++ /dev/null @@ -1,107 +0,0 @@ -/* $OpenBSD: strerror_r.c,v 1.13 2016/10/19 16:26:16 bluhm Exp $ */ -/* Public Domain */ - -#include -#include -#include -#include - -static size_t -__digits10(unsigned int num) -{ - size_t i = 0; - - do { - num /= 10; - i++; - } while (num != 0); - - return i; -} - -static int -__itoa(int num, int sign, char *buffer, size_t start, size_t end) -{ - size_t pos; - unsigned int a; - int neg; - - if (sign && num < 0) { - a = -num; - neg = 1; - } - else { - a = num; - neg = 0; - } - - pos = start + __digits10(a); - if (neg) - pos++; - - if (pos < end) - buffer[pos] = '\0'; - else - return ERANGE; - pos--; - do { - buffer[pos] = (a % 10) + '0'; - pos--; - a /= 10; - } while (a != 0); - if (neg) - buffer[pos] = '-'; - return 0; -} - - -static int -__num2string(int num, int sign, int setid, char *buf, size_t buflen, - const char * const list[], size_t max, const char *def) -{ - int ret = 0; - size_t len; - - if (0 <= num && num < max) { - len = strlcpy(buf, list[num], buflen); - if (len >= buflen) - ret = ERANGE; - } else { - len = strlcpy(buf, def, buflen); - if (len >= buflen) - ret = ERANGE; - else { - ret = __itoa(num, sign, buf, len, buflen); - if (ret == 0) - ret = EINVAL; - } - } - - return ret; -} - -#define UPREFIX "Unknown error: " - -int -strerror_r(int errnum, char *strerrbuf, size_t buflen) -{ - int ret_errno; - - ret_errno = __num2string(errnum, 1, 1, strerrbuf, buflen, - sys_errlist, sys_nerr, UPREFIX); - - if (ret_errno) - errno = ret_errno; - return (ret_errno); -} -DEF_WEAK(strerror_r); - -#define USIGPREFIX "Unknown signal: " - -char * -__strsignal(int num, char *buf) -{ - __num2string(num, 0, 2, buf, NL_TEXTMAX, sys_siglist, NSIG, - USIGPREFIX); - return buf; -} diff --git a/src/lib/libc/string/strlcat.c b/src/lib/libc/string/strlcat.c deleted file mode 100644 index aa3db7ab37..0000000000 --- a/src/lib/libc/string/strlcat.c +++ /dev/null @@ -1,56 +0,0 @@ -/* $OpenBSD: strlcat.c,v 1.19 2019/01/25 00:19:25 millert Exp $ */ - -/* - * Copyright (c) 1998, 2015 Todd C. Miller - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#include -#include - -/* - * Appends src to string dst of size dsize (unlike strncat, dsize is the - * full size of dst, not space left). At most dsize-1 characters - * will be copied. Always NUL terminates (unless dsize <= strlen(dst)). - * Returns strlen(src) + MIN(dsize, strlen(initial dst)). - * If retval >= dsize, truncation occurred. - */ -size_t -strlcat(char *dst, const char *src, size_t dsize) -{ - const char *odst = dst; - const char *osrc = src; - size_t n = dsize; - size_t dlen; - - /* Find the end of dst and adjust bytes left but don't go past end. */ - while (n-- != 0 && *dst != '\0') - dst++; - dlen = dst - odst; - n = dsize - dlen; - - if (n-- == 0) - return(dlen + strlen(src)); - while (*src != '\0') { - if (n != 0) { - *dst++ = *src; - n--; - } - src++; - } - *dst = '\0'; - - return(dlen + (src - osrc)); /* count does not include NUL */ -} -DEF_WEAK(strlcat); diff --git a/src/lib/libc/string/strlcpy.3 b/src/lib/libc/string/strlcpy.3 deleted file mode 100644 index 4607289883..0000000000 --- a/src/lib/libc/string/strlcpy.3 +++ /dev/null @@ -1,195 +0,0 @@ -.\" $OpenBSD: strlcpy.3,v 1.28 2024/08/03 20:13:23 guenther Exp $ -.\" -.\" Copyright (c) 1998, 2000 Todd C. Miller -.\" -.\" Permission to use, copy, modify, and distribute this software for any -.\" purpose with or without fee is hereby granted, provided that the above -.\" copyright notice and this permission notice appear in all copies. -.\" -.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -.\" -.Dd $Mdocdate: August 3 2024 $ -.Dt STRLCPY 3 -.Os -.Sh NAME -.Nm strlcpy , -.Nm strlcat -.Nd size-bounded string copying and concatenation -.Sh SYNOPSIS -.In string.h -.Ft size_t -.Fn strlcpy "char * restrict dst" "const char * restrict src" "size_t dstsize" -.Ft size_t -.Fn strlcat "char * restrict dst" "const char * restrict src" "size_t dstsize" -.Sh DESCRIPTION -The -.Fn strlcpy -and -.Fn strlcat -functions copy and concatenate strings with the -same input parameters and output result as -.Xr snprintf 3 . -They are designed to be safer, more consistent, and less error -prone replacements for the easily misused functions -.Xr strncpy 3 -and -.Xr strncat 3 . -.Pp -.Fn strlcpy -and -.Fn strlcat -take the full size of the destination buffer and guarantee -NUL-termination if there is room. -Note that room for the NUL should be included in -.Fa dstsize . -.Pp -.Fn strlcpy -copies up to -.Fa dstsize -\- 1 characters from the string -.Fa src -to -.Fa dst , -NUL-terminating the result if -.Fa dstsize -is not 0. -.Pp -.Fn strlcat -appends string -.Fa src -to the end of -.Fa dst . -It will append at most -.Fa dstsize -\- strlen(dst) \- 1 characters. -It will then NUL-terminate, unless -.Fa dstsize -is 0 or the original -.Fa dst -string was longer than -.Fa dstsize -(in practice this should not happen -as it means that either -.Fa dstsize -is incorrect or that -.Fa dst -is not a proper string). -.Pp -If the -.Fa src -and -.Fa dst -strings overlap, the behavior is undefined. -.Sh RETURN VALUES -Besides quibbles over the return type -.Pf ( Va size_t -versus -.Va int ) -and signal handler safety -.Pf ( Xr snprintf 3 -is not entirely safe on some systems), the -following two are equivalent: -.Bd -literal -offset indent -n = strlcpy(dst, src, len); -n = snprintf(dst, len, "%s", src); -.Ed -.Pp -Like -.Xr snprintf 3 , -the -.Fn strlcpy -and -.Fn strlcat -functions return the total length of the string they tried to create. -For -.Fn strlcpy -that means the length of -.Fa src . -For -.Fn strlcat -that means the initial length of -.Fa dst -plus -the length of -.Fa src . -.Pp -If the return value is -.Cm >= -.Va dstsize , -the output string has been truncated. -It is the caller's responsibility to handle this. -.Sh EXAMPLES -The following code fragment illustrates the simple case: -.Bd -literal -offset indent -char *s, *p, buf[BUFSIZ]; - -\&... - -(void)strlcpy(buf, s, sizeof(buf)); -(void)strlcat(buf, p, sizeof(buf)); -.Ed -.Pp -To detect truncation, perhaps while building a pathname, something -like the following might be used: -.Bd -literal -offset indent -char *dir, *file, pname[PATH_MAX]; - -\&... - -if (strlcpy(pname, dir, sizeof(pname)) >= sizeof(pname)) - goto toolong; -if (strlcat(pname, file, sizeof(pname)) >= sizeof(pname)) - goto toolong; -.Ed -.Pp -Since it is known how many characters were copied the first time, things -can be sped up a bit by using a copy instead of an append: -.Bd -literal -offset indent -char *dir, *file, pname[PATH_MAX]; -size_t n; - -\&... - -n = strlcpy(pname, dir, sizeof(pname)); -if (n >= sizeof(pname)) - goto toolong; -if (strlcpy(pname + n, file, sizeof(pname) - n) >= sizeof(pname) - n) - goto toolong; -.Ed -.Pp -However, one may question the validity of such optimizations, as they -defeat the whole purpose of -.Fn strlcpy -and -.Fn strlcat . -As a matter of fact, the first version of this manual page got it wrong. -.Sh SEE ALSO -.Xr snprintf 3 , -.Xr strncat 3 , -.Xr strncpy 3 , -.Xr wcslcpy 3 -.Sh STANDARDS -The -.Fn strlcat -and -.Fn strlcpy -functions conform to -.St -p1003.1-2024 . -.Sh HISTORY -.Fn strlcpy -and -.Fn strlcat -first appeared in -.Ox 2.4 . -.Sh AUTHORS -.Fn strlcpy -and -.Fn strlcat -were created by -.An Todd C. Miller Aq Mt millert@openbsd.org . diff --git a/src/lib/libc/string/strlcpy.c b/src/lib/libc/string/strlcpy.c deleted file mode 100644 index 7e3b9aef6f..0000000000 --- a/src/lib/libc/string/strlcpy.c +++ /dev/null @@ -1,51 +0,0 @@ -/* $OpenBSD: strlcpy.c,v 1.16 2019/01/25 00:19:25 millert Exp $ */ - -/* - * Copyright (c) 1998, 2015 Todd C. Miller - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#include -#include - -/* - * Copy string src to buffer dst of size dsize. At most dsize-1 - * chars will be copied. Always NUL terminates (unless dsize == 0). - * Returns strlen(src); if retval >= dsize, truncation occurred. - */ -size_t -strlcpy(char *dst, const char *src, size_t dsize) -{ - const char *osrc = src; - size_t nleft = dsize; - - /* Copy as many bytes as will fit. */ - if (nleft != 0) { - while (--nleft != 0) { - if ((*dst++ = *src++) == '\0') - break; - } - } - - /* Not enough room in dst, add NUL and traverse rest of src. */ - if (nleft == 0) { - if (dsize != 0) - *dst = '\0'; /* NUL-terminate dst */ - while (*src++) - ; - } - - return(src - osrc - 1); /* count does not include NUL */ -} -DEF_WEAK(strlcpy); diff --git a/src/lib/libc/string/strlen.3 b/src/lib/libc/string/strlen.3 deleted file mode 100644 index 18569d58b9..0000000000 --- a/src/lib/libc/string/strlen.3 +++ /dev/null @@ -1,103 +0,0 @@ -.\" $OpenBSD: strlen.3,v 1.14 2022/07/31 14:50:32 jsg Exp $ -.\" -.\" Copyright (c) 1990, 1991 The Regents of the University of California. -.\" All rights reserved. -.\" -.\" This code is derived from software contributed to Berkeley by -.\" Chris Torek and the American National Standards Committee X3, -.\" on Information Processing Systems. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.Dd $Mdocdate: July 31 2022 $ -.Dt STRLEN 3 -.Os -.Sh NAME -.Nm strlen , -.Nm strnlen -.Nd find length of a string -.Sh SYNOPSIS -.In string.h -.Ft size_t -.Fn strlen "const char *s" -.Ft size_t -.Fn strnlen "const char *s" "size_t maxlen" -.Sh DESCRIPTION -The -.Fn strlen -function computes the length of the string -.Fa s . -.Pp -The -.Fn strnlen -function computes the length of the string -.Fa s , -up to -.Fa maxlen -characters. -The -.Fn strnlen -function will never attempt to address more than -.Fa maxlen -characters, making it suitable for use with character arrays that are -not guaranteed to be NUL-terminated. -.Sh RETURN VALUES -The -.Fn strlen -function returns the number of characters that precede the terminating -.Tn NUL -character. -.Pp -The -.Fn strnlen -function returns the number of characters that precede the terminating -.Tn NUL -or -.Fa maxlen , -whichever is smaller. -.Sh SEE ALSO -.Xr wcslen 3 -.Sh STANDARDS -The -.Fn strlen -function conforms to -.St -ansiC . -.Pp -The -.Fn strlen -and -.Fn strnlen -functions conform to -.St -p1003.1-2008 . -.Sh HISTORY -The -.Fn strlen -function first appeared in -.At v6 . -The -.Fn strnlen -function appeared in glibc 2.0 -and was reimplemented for -.Ox 4.8 . diff --git a/src/lib/libc/string/strlen.c b/src/lib/libc/string/strlen.c deleted file mode 100644 index a5721d3e7f..0000000000 --- a/src/lib/libc/string/strlen.c +++ /dev/null @@ -1,44 +0,0 @@ -/* $OpenBSD: strlen.c,v 1.9 2015/08/31 02:53:57 guenther Exp $ */ - -/*- - * Copyright (c) 1990, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include - -size_t -strlen(const char *str) -{ - const char *s; - - for (s = str; *s; ++s) - ; - return (s - str); -} - -DEF_STRONG(strlen); diff --git a/src/lib/libc/string/strmode.3 b/src/lib/libc/string/strmode.3 deleted file mode 100644 index 8135d30ba1..0000000000 --- a/src/lib/libc/string/strmode.3 +++ /dev/null @@ -1,153 +0,0 @@ -.\" $OpenBSD: strmode.3,v 1.17 2017/07/05 11:44:35 tb Exp $ -.\" -.\" Copyright (c) 1990, 1991, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)strmode.3 8.3 (Berkeley) 7/28/94 -.\" -.Dd $Mdocdate: July 5 2017 $ -.Dt STRMODE 3 -.Os -.Sh NAME -.Nm strmode -.Nd convert inode status information into a symbolic string -.Sh SYNOPSIS -.In string.h -.Ft void -.Fn strmode "mode_t mode" "char *bp" -.Sh DESCRIPTION -The -.Fn strmode -function converts a file -.Fa mode -(the type and permission information associated with an inode, see -.Xr stat 2 ) -into a symbolic string which is stored in the location referenced by -.Fa bp . -This stored string is eleven characters in length plus a trailing NUL byte. -.Pp -The first character is the inode type, and will be one of the following: -.Pp -.Bl -tag -width flag -offset indent -compact -.It \- -regular file -.It b -block special -.It c -character special -.It d -directory -.It l -symbolic link -.It p -FIFO -.It s -socket -.It \&? -unknown inode type -.El -.Pp -The next nine characters encode three sets of permissions, in three -characters each. -The first three characters are the permissions for the owner of the -file, the second three for the group the file belongs to, and the -third for the -.Dq other , -or default, set of users. -.Pp -Permission checking is done as specifically as possible. -If read permission is denied to the owner of a file in the first set -of permissions, the owner of the file will not be able to read the file. -This is true even if the owner is in the file's group and the group -permissions allow reading or the -.Dq other -permissions allow reading. -.Pp -If the first character of the three character set is an -.Sq r , -the file is readable for that set of users; if a dash -.Pq Ql - , -it is not readable. -.Pp -If the second character of the three character set is a -.Sq w , -the file is writable for that set of users; if a dash -.Pq Ql - , -it is not writable. -.Pp -The third character is the first of the following characters that apply: -.Bl -tag -width xxxx -.It S -If the character is part of the owner permissions and the file is not -executable or the directory is not searchable by the owner, and the -set-user-ID bit is set. -.It S -If the character is part of the group permissions and the file is not -executable or the directory is not searchable by the group, and the -set-group-ID bit is set. -.It T -If the character is part of the other permissions and the file is not -executable or the directory is not searchable by others, and the -.Dq sticky -.Pq Dv S_ISVTX -bit is set. -.It s -If the character is part of the owner permissions and the file is -executable or the directory searchable by the owner, and the set-user-ID -bit is set. -.It s -If the character is part of the group permissions and the file is -executable or the directory searchable by the group, and the set-group-ID -bit is set. -.It t -If the character is part of the other permissions and the file is -executable or the directory searchable by others, and the -.Dq sticky -.Pq Dv S_ISVTX -bit is set. -.It x -The file is executable or the directory is searchable. -.It \- -None of the above apply. -.El -.Pp -The last character is a plus sign -.Pq Ql + -if there are any alternate -or additional access control methods associated with the inode, otherwise -it will be a space. -.Sh SEE ALSO -.Xr chmod 1 , -.Xr find 1 , -.Xr stat 2 , -.Xr getmode 3 , -.Xr setmode 3 -.Sh HISTORY -The -.Fn strmode -function first appeared in -.Bx 4.3 Reno . diff --git a/src/lib/libc/string/strmode.c b/src/lib/libc/string/strmode.c deleted file mode 100644 index c57fe74b23..0000000000 --- a/src/lib/libc/string/strmode.c +++ /dev/null @@ -1,139 +0,0 @@ -/* $OpenBSD: strmode.c,v 1.9 2024/06/23 07:08:26 otto Exp $ */ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#include -#include - -void -strmode(mode_t mode, char *p) -{ - /* print type */ - switch (mode & S_IFMT) { - case S_IFDIR: /* directory */ - *p++ = 'd'; - break; - case S_IFCHR: /* character special */ - *p++ = 'c'; - break; - case S_IFBLK: /* block special */ - *p++ = 'b'; - break; - case S_IFREG: /* regular */ - *p++ = '-'; - break; - case S_IFLNK: /* symbolic link */ - *p++ = 'l'; - break; - case S_IFSOCK: /* socket */ - *p++ = 's'; - break; -#ifdef S_IFIFO - case S_IFIFO: /* fifo */ - *p++ = 'p'; - break; -#endif - default: /* unknown */ - *p++ = '?'; - break; - } - /* usr */ - if (mode & S_IRUSR) - *p++ = 'r'; - else - *p++ = '-'; - if (mode & S_IWUSR) - *p++ = 'w'; - else - *p++ = '-'; - switch (mode & (S_IXUSR | S_ISUID)) { - case 0: - *p++ = '-'; - break; - case S_IXUSR: - *p++ = 'x'; - break; - case S_ISUID: - *p++ = 'S'; - break; - case S_IXUSR | S_ISUID: - *p++ = 's'; - break; - } - /* group */ - if (mode & S_IRGRP) - *p++ = 'r'; - else - *p++ = '-'; - if (mode & S_IWGRP) - *p++ = 'w'; - else - *p++ = '-'; - switch (mode & (S_IXGRP | S_ISGID)) { - case 0: - *p++ = '-'; - break; - case S_IXGRP: - *p++ = 'x'; - break; - case S_ISGID: - *p++ = 'S'; - break; - case S_IXGRP | S_ISGID: - *p++ = 's'; - break; - } - /* other */ - if (mode & S_IROTH) - *p++ = 'r'; - else - *p++ = '-'; - if (mode & S_IWOTH) - *p++ = 'w'; - else - *p++ = '-'; - switch (mode & (S_IXOTH | S_ISVTX)) { - case 0: - *p++ = '-'; - break; - case S_IXOTH: - *p++ = 'x'; - break; - case S_ISVTX: - *p++ = 'T'; - break; - case S_IXOTH | S_ISVTX: - *p++ = 't'; - break; - } - *p++ = ' '; /* will be a '+' if ACL's implemented */ - *p = '\0'; -} -DEF_WEAK(strmode); diff --git a/src/lib/libc/string/strncat.3 b/src/lib/libc/string/strncat.3 deleted file mode 100644 index d314a9999a..0000000000 --- a/src/lib/libc/string/strncat.3 +++ /dev/null @@ -1,132 +0,0 @@ -.\" $OpenBSD: strncat.3,v 1.4 2014/04/19 16:50:46 jmc Exp $ -.\" -.\" Copyright (c) 1990, 1991 The Regents of the University of California. -.\" All rights reserved. -.\" -.\" This code is derived from software contributed to Berkeley by -.\" Chris Torek and the American National Standards Committee X3, -.\" on Information Processing Systems. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.Dd $Mdocdate: April 19 2014 $ -.Dt STRNCAT 3 -.Os -.Sh NAME -.Nm strncat -.Nd concatenate a string with part of another -.Sh SYNOPSIS -.In string.h -.Ft char * -.Fn strncat "char *dst" "const char *append" "size_t count" -.Sh DESCRIPTION -The -.Fn strncat -function appends not more than -.Fa count -characters of the string -.Fa append -to the end of the string found in the buffer -.Fa dst . -Space for the terminating -.Ql \e0 -should not be included in -.Fa count . -.Pp -Bounds checking must be performed manually with great care. -If the buffer -.Fa dst -is not large enough to hold the result, -subsequent memory will be damaged. -.Sh RETURN VALUES -The -.Fn strncat -function returns the pointer -.Fa dst . -.Sh EXAMPLES -The following example shows how to use -.Fn strncat -in conjunction with -.Xr strncpy 3 : -.Bd -literal -offset indent -char buf[BUFSIZ]; -char *base, *suffix; - -(void)strncpy(buf, base, sizeof(buf) - 1); -buf[sizeof(buf) - 1] = '\e0'; -(void)strncat(buf, suffix, sizeof(buf) - 1 - strlen(buf)); -.Ed -.Pp -The above will copy as many characters from -.Va base -to -.Va buf -as will fit. -It then appends as many characters from -.Va suffix -as will fit. -If either -.Va base -or -.Va suffix -are too large, truncation will occur without detection. -.Pp -The above example shows dangerous coding patterns, including an -inability to detect truncation. -.Fn strncat -and -.Fn strncpy -are dangerously easy to misuse. -The -.Xr strlcpy 3 -and -.Xr strlcat 3 -functions are safer for this kind of operation: -.Bd -literal -offset indent -if (strlcpy(buf, base, sizeof(buf)) >= sizeof(buf) || - strlcat(buf, suffix, sizeof(buf)) >= sizeof(buf)) - goto toolong; - -.Ed -or for greatest portability, -.Bd -literal -offset indent -if (snprintf(buf, sizeof(buf), "%s%s", - base, suffix) >= sizeof(buf)) - goto toolong; -.Ed -.Sh SEE ALSO -.Xr strlcpy 3 , -.Xr wcscat 3 , -.Xr wcslcpy 3 -.Sh STANDARDS -The -.Fn strncat -function conforms to -.St -ansiC . -.Sh HISTORY -The -.Fn strncat -function first appeared in -.At v7 . diff --git a/src/lib/libc/string/strncat.c b/src/lib/libc/string/strncat.c deleted file mode 100644 index b3388accf3..0000000000 --- a/src/lib/libc/string/strncat.c +++ /dev/null @@ -1,58 +0,0 @@ -/* $OpenBSD: strncat.c,v 1.6 2015/08/31 02:53:57 guenther Exp $ */ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Chris Torek. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include - -/* - * Concatenate src on the end of dst. At most strlen(dst)+n+1 bytes - * are written at dst (at most n+1 bytes being appended). Return dst. - */ -char * -strncat(char *dst, const char *src, size_t n) -{ - if (n != 0) { - char *d = dst; - const char *s = src; - - while (*d != 0) - d++; - do { - if ((*d = *s++) == 0) - break; - d++; - } while (--n != 0); - *d = 0; - } - return (dst); -} -DEF_STRONG(strncat); diff --git a/src/lib/libc/string/strncmp.c b/src/lib/libc/string/strncmp.c deleted file mode 100644 index 535d2a60fd..0000000000 --- a/src/lib/libc/string/strncmp.c +++ /dev/null @@ -1,48 +0,0 @@ -/* $OpenBSD: strncmp.c,v 1.9 2015/08/31 02:53:57 guenther Exp $ */ - -/* - * Copyright (c) 1989 The Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include - -int -strncmp(const char *s1, const char *s2, size_t n) -{ - - if (n == 0) - return (0); - do { - if (*s1 != *s2++) - return (*(unsigned char *)s1 - *(unsigned char *)--s2); - if (*s1++ == 0) - break; - } while (--n != 0); - return (0); -} -DEF_STRONG(strncmp); diff --git a/src/lib/libc/string/strncpy.3 b/src/lib/libc/string/strncpy.3 deleted file mode 100644 index 3a68a0bd5b..0000000000 --- a/src/lib/libc/string/strncpy.3 +++ /dev/null @@ -1,138 +0,0 @@ -.\" $OpenBSD: strncpy.3,v 1.2 2014/04/19 11:30:40 deraadt Exp $ -.\" -.\" Copyright (c) 1990, 1991 The Regents of the University of California. -.\" All rights reserved. -.\" -.\" This code is derived from software contributed to Berkeley by -.\" Chris Torek and the American National Standards Committee X3, -.\" on Information Processing Systems. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.Dd $Mdocdate: April 19 2014 $ -.Dt STRNCPY 3 -.Os -.Sh NAME -.Nm strncpy -.Nd copy part of a string to another -.Sh SYNOPSIS -.In string.h -.Ft char * -.Fn strncpy "char *dst" "const char *src" "size_t len" -.Sh DESCRIPTION -The -.Fn strncpy -function copies not more than -.Fa len -characters from the string -.Fa src -to the buffer -.Fa dst . -If -.Fa src -is less than -.Fa len -characters long, -it fills the remaining buffer with -.Ql \e0 -characters. -If the length of -.Fa src -is greater than or equal to -.Fa len , -.Fa dst -will -.Em not -be NUL-terminated. -.Pp -.Fn strncpy -.Em only -NUL terminates the destination string when the length of the source -string is less than the length parameter. -.Pp -If the -.Fa src -and -.Fa dst -strings overlap, the behavior is undefined. -.Sh RETURN VALUES -The -.Fn strncpy -function returns -.Fa dst . -.Sh EXAMPLES -The following sets -.Va chararray -to -.Dq abc\e0\e0\e0 : -.Bd -literal -offset indent -(void)strncpy(chararray, "abc", 6); -.Ed -.Pp -The following sets -.Va chararray -to -.Dq abcdef , -without a NUL-terminator: -.Bd -literal -offset indent -(void)strncpy(chararray, "abcdefgh", 6); -.Ed -.Pp -The following sequence copies as many characters from -.Va input -to -.Va buf -as will fit, and then NUL terminates the result by hand: -.Bd -literal -offset indent -char buf[BUFSIZ]; - -(void)strncpy(buf, input, sizeof(buf) - 1); -buf[sizeof(buf) - 1] = '\e0'; -.Ed -.Pp -By now it is clear that -.Nm strncpy -is dangerously easy to misuse. -The -.Xr strlcpy 3 -function is safer for this kind of operation: -.Bd -literal -offset indent -if (strlcpy(buf, input, sizeof(buf)) >= sizeof(buf)) - goto toolong; -.Ed -.Sh SEE ALSO -.Xr strlcpy 3 , -.Xr wcscpy 3 , -.Xr wcslcpy 3 -.Sh STANDARDS -The -.Fn strncpy -function conforms to -.St -ansiC . -.Sh HISTORY -The -.Fn strncpy -function first appeared in -.At v7 . diff --git a/src/lib/libc/string/strncpy.c b/src/lib/libc/string/strncpy.c deleted file mode 100644 index d6d8647fc7..0000000000 --- a/src/lib/libc/string/strncpy.c +++ /dev/null @@ -1,59 +0,0 @@ -/* $OpenBSD: strncpy.c,v 1.8 2015/08/31 02:53:57 guenther Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Chris Torek. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include - -/* - * Copy src to dst, truncating or null-padding to always copy n bytes. - * Return dst. - */ -char * -strncpy(char *dst, const char *src, size_t n) -{ - if (n != 0) { - char *d = dst; - const char *s = src; - - do { - if ((*d++ = *s++) == 0) { - /* NUL pad the remaining n-1 bytes */ - while (--n != 0) - *d++ = 0; - break; - } - } while (--n != 0); - } - return (dst); -} -DEF_STRONG(strncpy); diff --git a/src/lib/libc/string/strndup.c b/src/lib/libc/string/strndup.c deleted file mode 100644 index 499f9a028a..0000000000 --- a/src/lib/libc/string/strndup.c +++ /dev/null @@ -1,40 +0,0 @@ -/* $OpenBSD: strndup.c,v 1.3 2019/01/25 00:19:25 millert Exp $ */ - -/* - * Copyright (c) 2010 Todd C. Miller - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#include - -#include -#include -#include - -char * -strndup(const char *str, size_t maxlen) -{ - char *copy; - size_t len; - - len = strnlen(str, maxlen); - copy = malloc(len + 1); - if (copy != NULL) { - (void)memcpy(copy, str, len); - copy[len] = '\0'; - } - - return copy; -} -DEF_WEAK(strndup); diff --git a/src/lib/libc/string/strnlen.c b/src/lib/libc/string/strnlen.c deleted file mode 100644 index d50a927f28..0000000000 --- a/src/lib/libc/string/strnlen.c +++ /dev/null @@ -1,33 +0,0 @@ -/* $OpenBSD: strnlen.c,v 1.9 2019/01/25 00:19:25 millert Exp $ */ - -/* - * Copyright (c) 2010 Todd C. Miller - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#include - -#include - -size_t -strnlen(const char *str, size_t maxlen) -{ - const char *cp; - - for (cp = str; maxlen != 0 && *cp != '\0'; cp++, maxlen--) - ; - - return (size_t)(cp - str); -} -DEF_WEAK(strnlen); diff --git a/src/lib/libc/string/strpbrk.3 b/src/lib/libc/string/strpbrk.3 deleted file mode 100644 index 51d2edf5b8..0000000000 --- a/src/lib/libc/string/strpbrk.3 +++ /dev/null @@ -1,80 +0,0 @@ -.\" $OpenBSD: strpbrk.3,v 1.11 2024/12/11 23:28:20 jsg Exp $ -.\" -.\" Copyright (c) 1990, 1991 The Regents of the University of California. -.\" All rights reserved. -.\" -.\" This code is derived from software contributed to Berkeley by -.\" Chris Torek and the American National Standards Committee X3, -.\" on Information Processing Systems. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.Dd $Mdocdate: December 11 2024 $ -.Dt STRPBRK 3 -.Os -.Sh NAME -.Nm strpbrk -.Nd locate multiple characters in string -.Sh SYNOPSIS -.In string.h -.Ft char * -.Fn strpbrk "const char *s" "const char *charset" -.Sh DESCRIPTION -The -.Fn strpbrk -function locates in the NUL-terminated string -.Fa s -the first occurrence of any character in the string -.Fa charset -and returns a pointer to this character. -If no characters from -.Fa charset -occur anywhere in -.Fa s , -.Fn strpbrk -returns -.Dv NULL . -.Sh SEE ALSO -.Xr memchr 3 , -.Xr strchr 3 , -.Xr strcspn 3 , -.Xr strrchr 3 , -.Xr strsep 3 , -.Xr strspn 3 , -.Xr strstr 3 , -.Xr strtok 3 , -.Xr wcspbrk 3 -.Sh STANDARDS -The -.Fn strpbrk -function conforms to -.St -ansiC . -.Sh HISTORY -The -.Fn strpbrk -function first appeared in -.At III -and was reimplemented for -.Bx 4.3 . diff --git a/src/lib/libc/string/strpbrk.c b/src/lib/libc/string/strpbrk.c deleted file mode 100644 index 336c22dedd..0000000000 --- a/src/lib/libc/string/strpbrk.c +++ /dev/null @@ -1,49 +0,0 @@ -/* $OpenBSD: strpbrk.c,v 1.6 2015/08/31 02:53:57 guenther Exp $ */ -/* - * Copyright (c) 1985 Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include - -/* - * Find the first occurrence in s1 of a character in s2 (excluding NUL). - */ -char * -strpbrk(const char *s1, const char *s2) -{ - const char *scanp; - int c, sc; - - while ((c = *s1++) != 0) { - for (scanp = s2; (sc = *scanp++) != 0;) - if (sc == c) - return ((char *)(s1 - 1)); - } - return (NULL); -} -DEF_STRONG(strpbrk); diff --git a/src/lib/libc/string/strrchr.3 b/src/lib/libc/string/strrchr.3 deleted file mode 100644 index 231260f7f3..0000000000 --- a/src/lib/libc/string/strrchr.3 +++ /dev/null @@ -1,118 +0,0 @@ -.\" $OpenBSD: strrchr.3,v 1.13 2024/12/11 23:28:20 jsg Exp $ -.\" -.\" Copyright (c) 1990, 1991 The Regents of the University of California. -.\" All rights reserved. -.\" -.\" This code is derived from software contributed to Berkeley by -.\" Chris Torek and the American National Standards Committee X3, -.\" on Information Processing Systems. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.Dd $Mdocdate: December 11 2024 $ -.Dt STRRCHR 3 -.Os -.Sh NAME -.Nm strrchr , -.Nm rindex -.Nd locate last occurrence of a character in a string -.Sh SYNOPSIS -.In string.h -.Ft char * -.Fn strrchr "const char *s" "int c" -.In strings.h -.Ft char * -.Fn rindex "const char *s" "int c" -.Sh DESCRIPTION -The -.Fn strrchr -function locates the last occurrence of the character -.Fa c -.Pq converted to a char -in the string -.Fa s . -The terminating -.Tn NUL -character is considered part of the string. -If -.Fa c -is -.Ql \e0 , -.Fn strrchr -locates the terminating -.Ql \e0 . -.Pp -The -.Fn rindex -function is an old synonym for -.Fn strrchr . -.Sh RETURN VALUES -The -.Fn strrchr -function returns a pointer to the located character or -.Dv NULL -if the character does not appear in the string. -.Sh EXAMPLES -After the following call to -.Fn strrchr , -.Va p -will point to the string -.Qq obar : -.Bd -literal -offset indent -char *p; -char *s = "foobar"; - -p = strrchr(s, 'o'); -.Ed -.Sh SEE ALSO -.Xr memchr 3 , -.Xr strchr 3 , -.Xr strcspn 3 , -.Xr strpbrk 3 , -.Xr strsep 3 , -.Xr strspn 3 , -.Xr strstr 3 , -.Xr strtok 3 , -.Xr wcsrchr 3 -.Sh STANDARDS -The -.Fn strrchr -function conforms to -.St -ansiC . -.Pp -The -.Fn rindex -function is deprecated and shouldn't be used in new code. -.Sh HISTORY -The -.Fn rindex -function first appeared in -.At v7 . -The -.Fn strrchr -function first appeared in -.At III -and was reimplemented for -.Bx 4.3 . diff --git a/src/lib/libc/string/strrchr.c b/src/lib/libc/string/strrchr.c deleted file mode 100644 index 848d1ad22e..0000000000 --- a/src/lib/libc/string/strrchr.c +++ /dev/null @@ -1,48 +0,0 @@ -/* $OpenBSD: strrchr.c,v 1.4 2018/10/01 06:37:37 martijn Exp $ */ -/* - * Copyright (c) 1988 Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include - -__weak_alias(rindex, strrchr); - -char * -strrchr(const char *p, int ch) -{ - char *save; - - for (save = NULL;; ++p) { - if (*p == (char) ch) - save = (char *)p; - if (!*p) - return(save); - } - /* NOTREACHED */ -} -DEF_STRONG(strrchr); diff --git a/src/lib/libc/string/strsep.3 b/src/lib/libc/string/strsep.3 deleted file mode 100644 index 77053f66d7..0000000000 --- a/src/lib/libc/string/strsep.3 +++ /dev/null @@ -1,110 +0,0 @@ -.\" $OpenBSD: strsep.3,v 1.14 2013/06/05 03:39:23 tedu Exp $ -.\" -.\" Copyright (c) 1990, 1991, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" This code is derived from software contributed to Berkeley by -.\" Chris Torek. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)strsep.3 8.1 (Berkeley) 6/9/93 -.\" -.Dd $Mdocdate: June 5 2013 $ -.Dt STRSEP 3 -.Os -.Sh NAME -.Nm strsep -.Nd separate strings -.Sh SYNOPSIS -.In string.h -.Ft char * -.Fn strsep "char **stringp" "const char *delim" -.Sh DESCRIPTION -The -.Fn strsep -function locates, in the string referenced by -.Fa *stringp , -the first occurrence of any character in the string -.Fa delim -(or the terminating -.Ql \e0 -character) and replaces it with a -.Ql \e0 . -The location of the next character after the delimiter character -(or -.Dv NULL , -if the end of the string was reached) is stored in -.Fa *stringp . -The original value of -.Fa *stringp -is returned. -.Pp -An -.Dq empty -field, i.e., one caused by two adjacent delimiter characters, -can be detected by comparing the location referenced by the pointer returned -by -.Fn strsep -to -.Ql \e0 . -.Pp -If -.Fa *stringp -is initially -.Dv NULL , -.Fn strsep -returns -.Dv NULL . -.Sh EXAMPLES -The following uses -.Fn strsep -to parse a string, containing tokens delimited by whitespace, into an -argument vector: -.Bd -literal -offset indent -char **ap, *argv[10], *inputstring; - -for (ap = argv; ap < &argv[9] && - (*ap = strsep(&inputstring, " \et")) != NULL;) { - if (**ap != '\e0') - ap++; -} -*ap = NULL; -.Ed -.Sh HISTORY -The -.Fn strsep -function first appeared in -.Bx 4.3 Reno . -It is intended as a replacement for the -.Xr strtok 3 -function. -While the -.Xr strtok 3 -function should be preferred for portability reasons (it conforms to -.St -ansiC ) -it is unable to handle empty fields, i.e., detect fields delimited by -two adjacent delimiter characters, or to be used for more than a single -string at a time. diff --git a/src/lib/libc/string/strsep.c b/src/lib/libc/string/strsep.c deleted file mode 100644 index 97c3cbf1f5..0000000000 --- a/src/lib/libc/string/strsep.c +++ /dev/null @@ -1,71 +0,0 @@ -/* $OpenBSD: strsep.c,v 1.8 2015/08/31 02:53:57 guenther Exp $ */ - -/*- - * Copyright (c) 1990, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include - -/* - * Get next token from string *stringp, where tokens are possibly-empty - * strings separated by characters from delim. - * - * Writes NULs into the string at *stringp to end tokens. - * delim need not remain constant from call to call. - * On return, *stringp points past the last NUL written (if there might - * be further tokens), or is NULL (if there are definitely no more tokens). - * - * If *stringp is NULL, strsep returns NULL. - */ -char * -strsep(char **stringp, const char *delim) -{ - char *s; - const char *spanp; - int c, sc; - char *tok; - - if ((s = *stringp) == NULL) - return (NULL); - for (tok = s;;) { - c = *s++; - spanp = delim; - do { - if ((sc = *spanp++) == c) { - if (c == 0) - s = NULL; - else - s[-1] = 0; - *stringp = s; - return (tok); - } - } while (sc != 0); - } - /* NOTREACHED */ -} -DEF_WEAK(strsep); diff --git a/src/lib/libc/string/strsignal.3 b/src/lib/libc/string/strsignal.3 deleted file mode 100644 index b46be893b5..0000000000 --- a/src/lib/libc/string/strsignal.3 +++ /dev/null @@ -1,78 +0,0 @@ -.\" Copyright (c) 1980, 1991 Regents of the University of California. -.\" All rights reserved. -.\" -.\" This code is derived from software contributed to Berkeley by -.\" the American National Standards Committee X3, on Information -.\" Processing Systems. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" $OpenBSD: strsignal.3,v 1.9 2019/05/16 13:35:16 schwarze Exp $ -.\" -.Dd $Mdocdate: May 16 2019 $ -.Dt STRSIGNAL 3 -.Os -.Sh NAME -.Nm strsignal -.Nd get signal description string -.Sh SYNOPSIS -.In string.h -.Ft char * -.Fn strsignal "int sig" -.Sh DESCRIPTION -The -.Fn strsignal -function returns a pointer to the string describing the signal -.Fa sig . -.Pp -The array pointed to is not to be modified by the program, but may be -overwritten by subsequent calls to -.Fn strsignal . -.Sh SEE ALSO -.Xr intro 2 , -.Xr psignal 3 , -.Xr setlocale 3 -.Sh STANDARDS -The -.Fn strsignal -function conforms to -.St -p1003.1-2008 . -.Sh HISTORY -The -.Fn strsignal -function first appeared in -.At V.4 -and was reimplemented for -.Nx 1.0 . -.Sh CAVEATS -On systems other than -.Ox , -the -.Dv LC_MESSAGES -.Xr locale 1 -category can cause different strings to be returned instead of the -normal signal descriptions; see CAVEATS in -.Xr setlocale 3 -for details. diff --git a/src/lib/libc/string/strsignal.c b/src/lib/libc/string/strsignal.c deleted file mode 100644 index fe2a747943..0000000000 --- a/src/lib/libc/string/strsignal.c +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 1988 Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#include - -char * -strsignal(int sig) -{ - static char buf[NL_TEXTMAX]; - - return __strsignal(sig, buf); -} -DEF_WEAK(strsignal); diff --git a/src/lib/libc/string/strspn.3 b/src/lib/libc/string/strspn.3 deleted file mode 100644 index e677ba15a1..0000000000 --- a/src/lib/libc/string/strspn.3 +++ /dev/null @@ -1,92 +0,0 @@ -.\" $OpenBSD: strspn.3,v 1.12 2024/12/11 23:28:20 jsg Exp $ -.\" -.\" Copyright (c) 1990, 1991 The Regents of the University of California. -.\" All rights reserved. -.\" -.\" This code is derived from software contributed to Berkeley by -.\" Chris Torek and the American National Standards Committee X3, -.\" on Information Processing Systems. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.Dd $Mdocdate: December 11 2024 $ -.Dt STRSPN 3 -.Os -.Sh NAME -.Nm strspn -.Nd span a string -.Sh SYNOPSIS -.In string.h -.Ft size_t -.Fn strspn "const char *s" "const char *charset" -.Sh DESCRIPTION -The -.Fn strspn -function spans the initial part of the NUL-terminated string -.Fa s -as long as the characters from -.Fa s -occur in string -.Fa charset . -.Sh RETURN VALUES -The -.Fn strspn -function returns the number of characters spanned. -.Sh EXAMPLES -The following call to -.Fn strspn -will return 3, since the first three characters of string -.Fa s -are part of string -.Fa charset : -.Bd -literal -offset indent -char *s = "foobar"; -char *charset = "of"; -size_t span; - -span = strspn(s, charset); -.Ed -.Sh SEE ALSO -.Xr memchr 3 , -.Xr strchr 3 , -.Xr strcspn 3 , -.Xr strpbrk 3 , -.Xr strrchr 3 , -.Xr strsep 3 , -.Xr strstr 3 , -.Xr strtok 3 , -.Xr wcsspn 3 -.Sh STANDARDS -The -.Fn strspn -function conforms to -.St -ansiC . -.Sh HISTORY -The -.Fn strspn -function first appeared in -.At III -and was reimplemented for -.Bx 4.3 . diff --git a/src/lib/libc/string/strspn.c b/src/lib/libc/string/strspn.c deleted file mode 100644 index 0ce41cbb49..0000000000 --- a/src/lib/libc/string/strspn.c +++ /dev/null @@ -1,52 +0,0 @@ -/* $OpenBSD: strspn.c,v 1.6 2015/08/31 02:53:57 guenther Exp $ */ -/* - * Copyright (c) 1989 The Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include - -/* - * Span the string s2 (skip characters that are in s2). - */ -size_t -strspn(const char *s1, const char *s2) -{ - const char *p = s1, *spanp; - char c, sc; - - /* - * Skip any characters in s2, excluding the terminating \0. - */ -cont: - c = *p++; - for (spanp = s2; (sc = *spanp++) != 0;) - if (sc == c) - goto cont; - return (p - 1 - s1); -} -DEF_STRONG(strspn); diff --git a/src/lib/libc/string/strstr.3 b/src/lib/libc/string/strstr.3 deleted file mode 100644 index 60d2a721a7..0000000000 --- a/src/lib/libc/string/strstr.3 +++ /dev/null @@ -1,101 +0,0 @@ -.\" $OpenBSD: strstr.3,v 1.13 2016/05/11 17:51:50 schwarze Exp $ -.\" -.\" Copyright (c) 1990, 1991 The Regents of the University of California. -.\" All rights reserved. -.\" -.\" This code is derived from software contributed to Berkeley by -.\" Chris Torek and the American National Standards Committee X3, -.\" on Information Processing Systems. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.Dd $Mdocdate: May 11 2016 $ -.Dt STRSTR 3 -.Os -.Sh NAME -.Nm strstr , strcasestr -.Nd locate a substring in a string -.Sh SYNOPSIS -.In string.h -.Ft char * -.Fn strstr "const char *big" "const char *little" -.Ft char * -.Fn strcasestr "const char *big" "const char *little" -.Sh DESCRIPTION -The -.Fn strstr -function locates the first occurrence of the NUL-terminated string -.Fa little -in the NUL-terminated string -.Fa big . -.Pp -The -.Fn strcasestr -function is similar to -.Fn strstr -but ignores the case of both strings. -.Sh RETURN VALUES -If -.Fa little -is an empty string, -.Fa big -is returned; -if -.Fa little -occurs nowhere in -.Fa big , -.Dv NULL -is returned; -otherwise a pointer to the first character of the first occurrence of -.Fa little -is returned. -.Sh SEE ALSO -.Xr memchr 3 , -.Xr memmem 3 , -.Xr strchr 3 , -.Xr strcspn 3 , -.Xr strpbrk 3 , -.Xr strrchr 3 , -.Xr strsep 3 , -.Xr strspn 3 , -.Xr strtok 3 , -.Xr wcsstr 3 -.Sh STANDARDS -The -.Fn strstr -function conforms to -.St -ansiC . -.Sh HISTORY -The -.Fn strstr -function first appeared in -.Bx 4.3 Reno . -The -.Fn strcasestr -function appeared in glibc 2.1, -was reimplemented for -.Fx 4.5 -and ported to -.Ox 3.8 . diff --git a/src/lib/libc/string/strstr.c b/src/lib/libc/string/strstr.c deleted file mode 100644 index 241a080e7a..0000000000 --- a/src/lib/libc/string/strstr.c +++ /dev/null @@ -1,189 +0,0 @@ -/* $OpenBSD: strstr.c,v 1.9 2020/04/16 12:37:52 claudio Exp $ */ - -/* - * Copyright (c) 2005-2018 Rich Felker - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY - * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include -#include - -static char * -twobyte_strstr(const unsigned char *h, const unsigned char *n) -{ - uint16_t nw = n[0]<<8 | n[1], hw = h[0]<<8 | h[1]; - for (h++; *h && hw != nw; hw = hw<<8 | *++h); - return *h ? (char *)h-1 : 0; -} - -static char * -threebyte_strstr(const unsigned char *h, const unsigned char *n) -{ - uint32_t nw = n[0]<<24 | n[1]<<16 | n[2]<<8; - uint32_t hw = h[0]<<24 | h[1]<<16 | h[2]<<8; - for (h+=2; *h && hw != nw; hw = (hw|*++h)<<8); - return *h ? (char *)h-2 : 0; -} - -static char * -fourbyte_strstr(const unsigned char *h, const unsigned char *n) -{ - uint32_t nw = n[0]<<24 | n[1]<<16 | n[2]<<8 | n[3]; - uint32_t hw = h[0]<<24 | h[1]<<16 | h[2]<<8 | h[3]; - for (h+=3; *h && hw != nw; hw = hw<<8 | *++h); - return *h ? (char *)h-3 : 0; -} - -#define MAX(a,b) ((a)>(b)?(a):(b)) -#define MIN(a,b) ((a)<(b)?(a):(b)) - -#define BITOP(a,b,op) \ - ((a)[(size_t)(b)/(8*sizeof *(a))] op (size_t)1<<((size_t)(b)%(8*sizeof *(a)))) - -/* - * Maxime Crochemore and Dominique Perrin, Two-way string-matching, - * Journal of the ACM, 38(3):651-675, July 1991. - */ -static char * -twoway_strstr(const unsigned char *h, const unsigned char *n) -{ - const unsigned char *z; - size_t l, ip, jp, k, p, ms, p0, mem, mem0; - size_t byteset[32 / sizeof(size_t)] = { 0 }; - size_t shift[256]; - - /* Computing length of needle and fill shift table */ - for (l=0; n[l] && h[l]; l++) - BITOP(byteset, n[l], |=), shift[n[l]] = l+1; - if (n[l]) return 0; /* hit the end of h */ - - /* Compute maximal suffix */ - ip = -1; jp = 0; k = p = 1; - while (jp+k n[jp+k]) { - jp += k; - k = 1; - p = jp - ip; - } else { - ip = jp++; - k = p = 1; - } - } - ms = ip; - p0 = p; - - /* And with the opposite comparison */ - ip = -1; jp = 0; k = p = 1; - while (jp+k ms+1) ms = ip; - else p = p0; - - /* Periodic needle? */ - if (memcmp(n, n+p, ms+1)) { - mem0 = 0; - p = MAX(ms, l-ms-1) + 1; - } else mem0 = l-p; - mem = 0; - - /* Initialize incremental end-of-haystack pointer */ - z = h; - - /* Search loop */ - for (;;) { - /* Update incremental end-of-haystack pointer */ - if (z-h < l) { - /* Fast estimate for MIN(l,63) */ - size_t grow = l | 63; - const unsigned char *z2 = memchr(z, 0, grow); - if (z2) { - z = z2; - if (z-h < l) return 0; - } else z += grow; - } - - /* Check last byte first; advance by shift on mismatch */ - if (BITOP(byteset, h[l-1], &)) { - k = l-shift[h[l-1]]; - if (k) { - if (k < mem) k = mem; - h += k; - mem = 0; - continue; - } - } else { - h += l; - mem = 0; - continue; - } - - /* Compare right half */ - for (k=MAX(ms+1,mem); n[k] && n[k] == h[k]; k++); - if (n[k]) { - h += k-ms; - mem = 0; - continue; - } - /* Compare left half */ - for (k=ms+1; k>mem && n[k-1] == h[k-1]; k--); - if (k <= mem) return (char *)h; - h += p; - mem = mem0; - } -} - -char * -strstr(const char *h, const char *n) -{ - /* Return immediately on empty needle */ - if (!n[0]) return (char *)h; - - /* Use faster algorithms for short needles */ - h = strchr(h, *n); - if (!h || !n[1]) return (char *)h; - if (!h[1]) return 0; - if (!n[2]) return twobyte_strstr((void *)h, (void *)n); - if (!h[2]) return 0; - if (!n[3]) return threebyte_strstr((void *)h, (void *)n); - if (!h[3]) return 0; - if (!n[4]) return fourbyte_strstr((void *)h, (void *)n); - - return twoway_strstr((void *)h, (void *)n); -} -DEF_STRONG(strstr); diff --git a/src/lib/libc/string/strtok.3 b/src/lib/libc/string/strtok.3 deleted file mode 100644 index a28f72d6f2..0000000000 --- a/src/lib/libc/string/strtok.3 +++ /dev/null @@ -1,169 +0,0 @@ -.\" $OpenBSD: strtok.3,v 1.24 2024/12/11 23:28:20 jsg Exp $ -.\" -.\" Copyright (c) 1988, 1991 The Regents of the University of California. -.\" All rights reserved. -.\" -.\" This code is derived from software contributed to Berkeley by -.\" the American National Standards Committee X3, on Information -.\" Processing Systems. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.Dd $Mdocdate: December 11 2024 $ -.Dt STRTOK 3 -.Os -.Sh NAME -.Nm strtok , -.Nm strtok_r -.Nd string token operations -.Sh SYNOPSIS -.In string.h -.Ft char * -.Fn strtok "char *str" "const char *sep" -.Ft char * -.Fn strtok_r "char *str" "const char *sep" "char **last" -.Sh DESCRIPTION -.Bf -symbolic -This interface is obsoleted by -.Xr strsep 3 . -.Ef -.Pp -The -.Fn strtok -function is used to isolate sequential tokens in a NUL-terminated string, -.Fa str . -These tokens are separated in the string by at least one of the -characters in -.Fa sep . -The first time that -.Fn strtok -is called, -.Fa str -should be specified; subsequent calls, wishing to obtain further tokens -from the same string, should pass a null pointer instead. -The separator string, -.Fa sep , -must be supplied each time, and may change between calls. -.Pp -The -.Fn strtok_r -function is a version of -.Fn strtok -that takes an explicit context argument and is reentrant. -.Pp -Since -.Fn strtok -and -.Fn strtok_r -modify the string, -.Fa str -should not point to an area in the initialized data segment. -.Sh RETURN VALUES -The -.Fn strtok -and -.Fn strtok_r -functions return a pointer to the beginning of each subsequent token -in the string, after replacing the separator character itself with -a NUL character. -When no more tokens remain, a null pointer is returned. -.Sh EXAMPLES -The following will construct an array of pointers to each individual word in -the string -.Va s : -.Bd -literal -offset indent -#define MAXTOKENS 128 - -char s[512], *p, *tokens[MAXTOKENS]; -char *last; -int i = 0; - -snprintf(s, sizeof(s), "cat dog horse cow"); - -for ((p = strtok_r(s, " ", &last)); p; - (p = strtok_r(NULL, " ", &last))) { - if (i < MAXTOKENS - 1) - tokens[i++] = p; -} -tokens[i] = NULL; -.Ed -.Pp -That is, -.Li tokens[0] -will point to -.Qq cat , -.Li tokens[1] -will point to -.Qq dog , -.Li tokens[2] -will point to -.Qq horse , -and -.Li tokens[3] -will point to -.Qq cow . -.Sh SEE ALSO -.Xr memchr 3 , -.Xr strchr 3 , -.Xr strcspn 3 , -.Xr strpbrk 3 , -.Xr strrchr 3 , -.Xr strsep 3 , -.Xr strspn 3 , -.Xr strstr 3 , -.Xr wcstok 3 -.Sh STANDARDS -The -.Fn strtok -function conforms to -.St -ansiC . -The -.Fn strtok_r -function conforms to -.St -p1003.1-2001 . -.Sh HISTORY -The -.Fn strtok -function first appeared in -.At III -and was reimplemented for -.Bx 4.3 . -The -.Fn strtok_r -function first appeared in -.Nx 1.3 -and was reimplemented for -.Ox 2.7 . -.Sh BUGS -The System V -.Fn strtok , -if handed a string containing only delimiter characters, -will not alter the next starting point, so that a call to -.Fn strtok -with a different (or empty) delimiter string -may return a non-null value. -Since this implementation always alters the next starting point, -such a sequence of calls would always return -.Dv NULL . diff --git a/src/lib/libc/string/strtok.c b/src/lib/libc/string/strtok.c deleted file mode 100644 index c5765756fc..0000000000 --- a/src/lib/libc/string/strtok.c +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright (c) 1988 Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include - -char * -strtok(char *s, const char *delim) -{ - static char *last; - - return strtok_r(s, delim, &last); -} -DEF_STRONG(strtok); - -char * -strtok_r(char *s, const char *delim, char **last) -{ - const char *spanp; - int c, sc; - char *tok; - - if (s == NULL && (s = *last) == NULL) - return (NULL); - - /* - * Skip (span) leading delimiters (s += strspn(s, delim), sort of). - */ -cont: - c = *s++; - for (spanp = delim; (sc = *spanp++) != 0;) { - if (c == sc) - goto cont; - } - - if (c == 0) { /* no non-delimiter characters */ - *last = NULL; - return (NULL); - } - tok = s - 1; - - /* - * Scan token (scan for delimiters: s += strcspn(s, delim), sort of). - * Note that delim must have one NUL; we stop if we see that, too. - */ - for (;;) { - c = *s++; - spanp = delim; - do { - if ((sc = *spanp++) == c) { - if (c == 0) - s = NULL; - else - s[-1] = '\0'; - *last = s; - return (tok); - } - } while (sc != 0); - } - /* NOTREACHED */ -} -DEF_WEAK(strtok_r); diff --git a/src/lib/libc/string/strxfrm.3 b/src/lib/libc/string/strxfrm.3 deleted file mode 100644 index dab3673f38..0000000000 --- a/src/lib/libc/string/strxfrm.3 +++ /dev/null @@ -1,105 +0,0 @@ -.\" $OpenBSD: strxfrm.3,v 1.12 2019/01/18 07:43:36 schwarze Exp $ -.\" -.\" Copyright (c) 1990, 1991 The Regents of the University of California. -.\" Copyright (c) 2017 Ingo Schwarze -.\" All rights reserved. -.\" -.\" This code is derived from software contributed to Berkeley by -.\" Chris Torek and the American National Standards Committee X3, -.\" on Information Processing Systems. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.Dd $Mdocdate: January 18 2019 $ -.Dt STRXFRM 3 -.Os -.Sh NAME -.Nm strxfrm , -.Nm strxfrm_l -.Nd transform a string under locale -.Sh SYNOPSIS -.In string.h -.Ft size_t -.Fn strxfrm "char *dst" "const char *src" "size_t n" -.Ft size_t -.Fn strxfrm_l "char *dst" "const char *src" "size_t n" "locale_t locale" -.Sh DESCRIPTION -The idea of -.Fn strxfrm -and -.Fn strxfrm_l -is to -.Dq un-localize -a string: the functions transform -.Ar src , -storing the result in -.Ar dst , -such that -.Xr strcmp 3 -on transformed strings returns what -.Xr strcoll 3 -on the original untransformed strings would return. -.Pp -On -.Ox , -both have the same effect as -.Xr strlcpy 3 , -and the global locale, the thread-specific locale, and the -.Fa locale -argument are ignored. -On other operating systems, the behaviour may depend on the -.Dv LC_CTYPE -and -.Dv LC_COLLATE -locale categories set with -.Xr setlocale 3 , -.Xr uselocale 3 , -or -.Xr newlocale 3 . -.Sh SEE ALSO -.Xr newlocale 3 , -.Xr setlocale 3 , -.Xr strcmp 3 , -.Xr strcoll 3 , -.Xr strlcpy 3 , -.Xr wcsxfrm 3 -.Sh STANDARDS -The -.Fn strxfrm -function conforms to -.St -ansiC , -and -.Fn strxfrm_l -to -.St -p1003.1-2008 . -.Sh HISTORY -The -.Fn strxfrm -function has been available since -.Bx 4.3 Reno , -and -.Fn strxfrm_l -since -.Ox 6.2 . diff --git a/src/lib/libc/string/strxfrm.c b/src/lib/libc/string/strxfrm.c deleted file mode 100644 index 97df097b29..0000000000 --- a/src/lib/libc/string/strxfrm.c +++ /dev/null @@ -1,52 +0,0 @@ -/* $OpenBSD: strxfrm.c,v 1.7 2015/08/31 02:53:57 guenther Exp $ */ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Chris Torek. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include - -/* - * Transform src, storing the result in dst, such that - * strcmp() on transformed strings returns what strcoll() - * on the original untransformed strings would return. - */ -size_t -strxfrm(char *dst, const char *src, size_t n) -{ - - /* - * Since locales are unimplemented, this is just a copy. - */ - if (n == 0) - return (strlen(src)); - return (strlcpy(dst, src, n)); -} -DEF_STRONG(strxfrm); diff --git a/src/lib/libc/string/strxfrm_l.c b/src/lib/libc/string/strxfrm_l.c deleted file mode 100644 index ff77947953..0000000000 --- a/src/lib/libc/string/strxfrm_l.c +++ /dev/null @@ -1,14 +0,0 @@ -/* $OpenBSD: strxfrm_l.c,v 1.1 2017/09/05 03:16:14 schwarze Exp $ */ -/* - * Written in 2017 by Ingo Schwarze . - * Released into the public domain. - */ - -#include - -size_t -strxfrm_l(char *dst, const char *src, size_t n, - locale_t locale __attribute__((__unused__))) -{ - return strxfrm(dst, src, n); -} diff --git a/src/lib/libc/string/swab.3 b/src/lib/libc/string/swab.3 deleted file mode 100644 index 777f2833b6..0000000000 --- a/src/lib/libc/string/swab.3 +++ /dev/null @@ -1,79 +0,0 @@ -.\" Copyright (c) 1990, 1991 The Regents of the University of California. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" $OpenBSD: swab.3,v 1.10 2022/09/28 20:27:12 jmc Exp $ -.\" -.Dd $Mdocdate: September 28 2022 $ -.Dt SWAB 3 -.Os -.Sh NAME -.Nm swab -.Nd swap adjacent bytes -.Sh SYNOPSIS -.In unistd.h -.Ft void -.Fo swab -.Fa "const void *restrict src" -.Fa "void *restrict dst" -.Fa "ssize_t len" -.Fc -.Sh DESCRIPTION -The -.Fn swab -function copies -.Fa len -bytes from the location referenced by -.Fa src -to the location referenced by -.Fa dst , -swapping adjacent bytes. -.Pp -If -.Fa len -is zero or less, -.Fn swab -does nothing. -If it is odd, what happens to the last byte is unspecified. -If -.Fa src -and -.Fa dst -overlap, behaviour is undefined. -.Sh SEE ALSO -.Xr bzero 3 , -.Xr memset 3 -.Sh STANDARDS -The -.Fn swab -function is compliant with the X/Open System Interfaces option of the -.St -p1003.1-2008 -specification. -.Sh HISTORY -The -.Fn swab -function first appeared in -.At v7 . diff --git a/src/lib/libc/string/swab.c b/src/lib/libc/string/swab.c deleted file mode 100644 index c7d7d72ce0..0000000000 --- a/src/lib/libc/string/swab.c +++ /dev/null @@ -1,35 +0,0 @@ -/* $OpenBSD: swab.c,v 1.9 2014/12/11 23:05:38 tedu Exp $ */ -/* - * Copyright (c) 2014 Ted Unangst - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ -#include - -void -swab(const void *__restrict from, void *__restrict to, ssize_t len) -{ - const unsigned char *src = from; - unsigned char *dst = to; - unsigned char t0, t1; - - while (len > 1) { - t0 = src[0]; - t1 = src[1]; - dst[0] = t1; - dst[1] = t0; - src += 2; - dst += 2; - len -= 2; - } -} diff --git a/src/lib/libc/string/timingsafe_bcmp.3 b/src/lib/libc/string/timingsafe_bcmp.3 deleted file mode 100644 index 00da769157..0000000000 --- a/src/lib/libc/string/timingsafe_bcmp.3 +++ /dev/null @@ -1,87 +0,0 @@ -.\" $OpenBSD: timingsafe_bcmp.3,v 1.2 2014/06/21 20:22:15 tedu Exp $ -.\" -.\" Copyright (c) 2014 Google Inc. -.\" -.\" Permission to use, copy, modify, and distribute this software for any -.\" purpose with or without fee is hereby granted, provided that the above -.\" copyright notice and this permission notice appear in all copies. -.\" -.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -.Dd $Mdocdate: June 21 2014 $ -.Dt TIMINGSAFE_BCMP 3 -.Os -.Sh NAME -.Nm timingsafe_bcmp , -.Nm timingsafe_memcmp -.Nd timing-safe byte sequence comparisons -.Sh SYNOPSIS -.In string.h -.Ft int -.Fn timingsafe_bcmp "const void *b1" "const void *b2" "size_t len" -.Ft int -.Fn timingsafe_memcmp "const void *b1" "const void *b2" "size_t len" -.Sh DESCRIPTION -The -.Fn timingsafe_bcmp -and -.Fn timingsafe_memcmp -functions lexicographically compare the first -.Fa len -bytes (each interpreted as an -.Vt unsigned char ) -pointed to by -.Fa b1 -and -.Fa b2 . -.Pp -Additionally, their running times are independent of the byte sequences compared, -making them safe to use for comparing secret values such as cryptographic MACs. -In contrast, -.Xr bcmp 3 -and -.Xr memcmp 3 -may short-circuit after finding the first differing byte. -.Sh RETURN VALUES -The -.Fn timingsafe_bcmp -function returns 0 or not zero if the byte sequence pointed to by -.Fa b1 -compares equal to or not equal to (respectively) -the byte sequence pointed to by -.Fa b2 . -.Pp -The -.Fn timingsafe_memcmp -function returns a negative value, 0, or positive value if the byte sequence -pointed to by -.Fa b1 -compares less than, equal to, or greater than (respectively) -the byte sequence pointed to by -.Fa b2 . -.Sh SEE ALSO -.Xr bcmp 3 , -.Xr memcmp 3 -.Sh STANDARDS -The -.Fn timingsafe_bcmp -and -.Fn timingsafe_memcmp -functions are -.Ox -extensions. -.Sh HISTORY -The -.Fn timingsafe_bcmp -function first appeared in -.Ox 4.9 . -.Pp -The -.Fn timingsafe_memcmp -function first appeared in -.Ox 5.6 . diff --git a/src/lib/libc/string/timingsafe_bcmp.c b/src/lib/libc/string/timingsafe_bcmp.c deleted file mode 100644 index 0409ec3244..0000000000 --- a/src/lib/libc/string/timingsafe_bcmp.c +++ /dev/null @@ -1,30 +0,0 @@ -/* $OpenBSD: timingsafe_bcmp.c,v 1.3 2015/08/31 02:53:57 guenther Exp $ */ -/* - * Copyright (c) 2010 Damien Miller. All rights reserved. - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#include - -int -timingsafe_bcmp(const void *b1, const void *b2, size_t n) -{ - const unsigned char *p1 = b1, *p2 = b2; - int ret = 0; - - for (; n > 0; n--) - ret |= *p1++ ^ *p2++; - return (ret != 0); -} -DEF_WEAK(timingsafe_bcmp); diff --git a/src/lib/libc/string/timingsafe_memcmp.c b/src/lib/libc/string/timingsafe_memcmp.c deleted file mode 100644 index 373f8cb197..0000000000 --- a/src/lib/libc/string/timingsafe_memcmp.c +++ /dev/null @@ -1,47 +0,0 @@ -/* $OpenBSD: timingsafe_memcmp.c,v 1.2 2015/08/31 02:53:57 guenther Exp $ */ -/* - * Copyright (c) 2014 Google Inc. - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#include -#include - -int -timingsafe_memcmp(const void *b1, const void *b2, size_t len) -{ - const unsigned char *p1 = b1, *p2 = b2; - size_t i; - int res = 0, done = 0; - - for (i = 0; i < len; i++) { - /* lt is -1 if p1[i] < p2[i]; else 0. */ - int lt = (p1[i] - p2[i]) >> CHAR_BIT; - - /* gt is -1 if p1[i] > p2[i]; else 0. */ - int gt = (p2[i] - p1[i]) >> CHAR_BIT; - - /* cmp is 1 if p1[i] > p2[i]; -1 if p1[i] < p2[i]; else 0. */ - int cmp = lt - gt; - - /* set res = cmp if !done. */ - res |= cmp & ~done; - - /* set done if p1[i] != p2[i]. */ - done |= lt | gt; - } - - return (res); -} -DEF_WEAK(timingsafe_memcmp); diff --git a/src/lib/libc/string/wcscasecmp.3 b/src/lib/libc/string/wcscasecmp.3 deleted file mode 100644 index 9db4a829b9..0000000000 --- a/src/lib/libc/string/wcscasecmp.3 +++ /dev/null @@ -1,134 +0,0 @@ -.\" $OpenBSD: wcscasecmp.3,v 1.5 2017/09/05 03:16:14 schwarze Exp $ -.\" -.\" Copyright (c) 1990, 1991, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" Copyright (c) 2017 Ingo Schwarze -.\" -.\" This code is derived from software contributed to Berkeley by -.\" Chris Torek. -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)strcasecmp.3 8.1 (Berkeley) 6/9/93 -.\" -.Dd $Mdocdate: September 5 2017 $ -.Dt WCSCASECMP 3 -.Os -.Sh NAME -.Nm wcscasecmp , -.Nm wcscasecmp_l , -.Nm wcsncasecmp , -.Nm wcsncasecmp_l -.Nd compare wide strings, ignoring case -.Sh SYNOPSIS -.In wchar.h -.Ft int -.Fo wcscasecmp -.Fa "const wchar_t *s1" -.Fa "const wchar_t *s2" -.Fc -.Ft int -.Fo wcscasecmp_l -.Fa "const wchar_t *s1" -.Fa "const wchar_t *s2" -.Fa "locale_t locale" -.Fc -.Ft int -.Fo wcsncasecmp -.Fa "const wchar_t *s1" -.Fa "const wchar_t *s2" -.Fa "size_t len" -.Fc -.Ft int -.Fo wcsncasecmp_l -.Fa "const wchar_t *s1" -.Fa "const wchar_t *s2" -.Fa "size_t len" -.Fa "locale_t locale" -.Fc -.Sh DESCRIPTION -These functions compare the wide strings -.Fa s1 -and -.Fa s2 -and return an integer greater than, equal to, or less than 0, -according to whether -.Fa s1 -is lexicographically greater than, equal to, or less than -.Fa s2 -after translation of each corresponding wide character to lower case. -The wide strings themselves are not modified. -.Pp -For the translation to lower case, -.Fn wcscasecmp -and -.Fn wcsncasecmp -use the thread-specific locale as defined with -.Xr uselocale 3 , -falling back to the global locale defined with -.Xr setlocale 3 . -.Fn wcscasecmp_l -and -.Fn wcsncasecmp_l -use the -.Fa locale -argument instead. -.Pp -.Fn wcsncasecmp -and -.Fn wcsncasecmp_l -compare at most -.Fa len -wide characters. -.Sh SEE ALSO -.Xr newlocale 3 , -.Xr setlocale 3 , -.Xr strcasecmp 3 , -.Xr wcscmp 3 , -.Xr wmemcmp 3 -.Sh STANDARDS -These functions conform to -.St -p1003.1-2008 . -.Sh HISTORY -The -.Fn wcscasecmp -and -.Fn wcsncasecmp -functions have been available since -.Ox 5.0 , -and -.Fn wcscasecmp_l -and -.Fn wcsncasecmp_l -since -.Ox 6.2 . -.Sh AUTHORS -The -.Ox -versions of -.Fn wcscasecmp -and -.Fn wcsncasecmp -were implemented by -.An Marc Espie Aq Mt espie@openbsd.org . diff --git a/src/lib/libc/string/wcscasecmp.c b/src/lib/libc/string/wcscasecmp.c deleted file mode 100644 index b122e720fe..0000000000 --- a/src/lib/libc/string/wcscasecmp.c +++ /dev/null @@ -1,63 +0,0 @@ -/* $OpenBSD: wcscasecmp.c,v 1.3 2015/09/12 16:23:14 guenther Exp $ */ - -/* - * Copyright (c) 2011 Marc Espie - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE OPENBSD PROJECT AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OPENBSD - * PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include -#include "locale/runetype.h" - -int -wcscasecmp(const wchar_t *s1, const wchar_t *s2) -{ - wchar_t l1, l2; - - while ((l1 = towlower(*s1++)) == (l2 = towlower(*s2++))) { - if (l1 == 0) - return (0); - } - /* XXX assumes wchar_t = int */ - return ((rune_t)l1 - (rune_t)l2); -} -DEF_WEAK(wcscasecmp); - -int -wcsncasecmp(const wchar_t *s1, const wchar_t *s2, size_t n) -{ - wchar_t l1, l2; - - if (n == 0) - return (0); - do { - if (((l1 = towlower(*s1++))) != (l2 = towlower(*s2++))) { - /* XXX assumes wchar_t = int */ - return ((rune_t)l1 - (rune_t)l2); - } - if (l1 == 0) - break; - } while (--n != 0); - return (0); -} -DEF_WEAK(wcsncasecmp); diff --git a/src/lib/libc/string/wcscasecmp_l.c b/src/lib/libc/string/wcscasecmp_l.c deleted file mode 100644 index 35b99225c1..0000000000 --- a/src/lib/libc/string/wcscasecmp_l.c +++ /dev/null @@ -1,63 +0,0 @@ -/* $OpenBSD: wcscasecmp_l.c,v 1.1 2017/09/05 03:16:14 schwarze Exp $ */ - -/* - * Copyright (c) 2011 Marc Espie - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE OPENBSD PROJECT AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OPENBSD - * PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include -#include "locale/runetype.h" - -int -wcscasecmp_l(const wchar_t *s1, const wchar_t *s2, locale_t locale) -{ - wchar_t l1, l2; - - while ((l1 = towlower_l(*s1++, locale)) == - (l2 = towlower_l(*s2++, locale))) { - if (l1 == 0) - return (0); - } - /* XXX assumes wchar_t = int */ - return ((rune_t)l1 - (rune_t)l2); -} - -int -wcsncasecmp_l(const wchar_t *s1, const wchar_t *s2, size_t n, locale_t locale) -{ - wchar_t l1, l2; - - if (n == 0) - return (0); - do { - if (((l1 = towlower_l(*s1++, locale))) != - (l2 = towlower_l(*s2++, locale))) { - /* XXX assumes wchar_t = int */ - return ((rune_t)l1 - (rune_t)l2); - } - if (l1 == 0) - break; - } while (--n != 0); - return (0); -} diff --git a/src/lib/libc/string/wcscat.3 b/src/lib/libc/string/wcscat.3 deleted file mode 100644 index 9b7588cf9e..0000000000 --- a/src/lib/libc/string/wcscat.3 +++ /dev/null @@ -1,115 +0,0 @@ -.\" $OpenBSD: wcscat.3,v 1.3 2013/06/05 03:39:23 tedu Exp $ -.\" -.\" Copyright (c) 1990, 1991 The Regents of the University of California. -.\" All rights reserved. -.\" -.\" This code is derived from software contributed to Berkeley by -.\" Chris Torek and the American National Standards Committee X3, -.\" on Information Processing Systems. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.Dd $Mdocdate: June 5 2013 $ -.Dt WCSCAT 3 -.Os -.Sh NAME -.Nm wcscat , -.Nm wcsncat -.Nd concatenate wide strings -.Sh SYNOPSIS -.In wchar.h -.Ft wchar_t * -.Fn wcscat "wchar_t * restrict s" "const wchar_t * restrict append" -.Ft wchar_t * -.Fo wcsncat -.Fa "wchar_t * restrict s" -.Fa "const wchar_t * restrict append" -.Fa "size_t count" -.Fc -.Sh DESCRIPTION -The -.Fn wcscat -and -.Fn wcsncat -functions append a copy of the wide string -.Fa append -to the end of the wide string -.Fa s , -then add a terminating null wide character (L'\e0'). -The wide string -.Fa s -must have sufficient space to hold the result. -.Pp -The -.Fn wcsncat -function appends not more than -.Fa count -wide characters where space for the terminating null wide character -should not be included in -.Fa count . -.Sh RETURN VALUES -The -.Fn wcscat -and -.Fn wcsncat -functions return the pointer -.Fa s . -.Sh SEE ALSO -.Xr strcat 3 , -.Xr strlcpy 3 , -.Xr wcscpy 3 , -.Xr wcslcpy 3 , -.Xr wmemcpy 3 , -.Xr wmemmove 3 -.Sh STANDARDS -The -.Fn wcscat -and -.Fn wcsncat -functions conform to -.St -isoC-99 -and were first introduced in -.St -isoC-amd1 . -.Sh HISTORY -The -.Fn wcscat -and -.Fn wcsncat -functions were ported from -.Nx -and first appeared in -.Ox 3.8 . -.Sh CAVEATS -Using the functions -.Fn wcscat -and -.Fn wcsncat -is very error-prone with respect to buffer overflows; -see the EXAMPLES section in -.Xr strcat 3 -for correct usage. -Using -.Xr wcslcat 3 -is a better choice in most cases. diff --git a/src/lib/libc/string/wcscat.c b/src/lib/libc/string/wcscat.c deleted file mode 100644 index 0525c3cb14..0000000000 --- a/src/lib/libc/string/wcscat.c +++ /dev/null @@ -1,56 +0,0 @@ -/* $OpenBSD: wcscat.c,v 1.5 2017/11/28 06:55:49 tb Exp $ */ -/* $NetBSD: wcscat.c,v 1.2 2001/01/03 14:29:36 lukem Exp $ */ - -/*- - * Copyright (c)1999 Citrus Project, - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * citrus Id: wcscat.c,v 1.1 1999/12/29 21:47:45 tshiozak Exp - */ - -#include - -#if defined(APIWARN) -__warn_references(wcscat, - "wcscat() is almost always misused, please use wcslcat()"); -#endif - -wchar_t * -wcscat(wchar_t *s1, const wchar_t *s2) -{ - wchar_t *p; - wchar_t *q; - const wchar_t *r; - - p = s1; - while (*p) - p++; - q = p; - r = s2; - while (*r) - *q++ = *r++; - *q = '\0'; - return s1; -} -DEF_STRONG(wcscat); diff --git a/src/lib/libc/string/wcschr.3 b/src/lib/libc/string/wcschr.3 deleted file mode 100644 index bb714b2099..0000000000 --- a/src/lib/libc/string/wcschr.3 +++ /dev/null @@ -1,85 +0,0 @@ -.\" $OpenBSD: wcschr.3,v 1.4 2013/06/05 03:39:23 tedu Exp $ -.\" -.\" Copyright (c) 1990, 1991 The Regents of the University of California. -.\" All rights reserved. -.\" -.\" This code is derived from software contributed to Berkeley by -.\" Chris Torek and the American National Standards Committee X3, -.\" on Information Processing Systems. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.Dd $Mdocdate: June 5 2013 $ -.Dt WCSCHR 3 -.Os -.Sh NAME -.Nm wcschr -.Nd locate first occurrence of a wide character in a wide string -.Sh SYNOPSIS -.In wchar.h -.Ft wchar_t * -.Fn wcschr "const wchar_t *s" "wchar_t c" -.Sh DESCRIPTION -The -.Fn wcschr -function locates the first occurrence of the wide character -.Fa c -in the wide string -.Fa s . -The terminating null wide character is considered part of the wide string. -If -.Fa c -is the null wide character (L'\e0'), -.Fn wcschr -locates the terminating null wide character. -.Sh RETURN VALUES -The -.Fn wcschr -function returns a pointer to the located wide character or -.Dv NULL -if the wide character does not appear in the wide string. -.Sh SEE ALSO -.Xr strchr 3 , -.Xr wcscspn 3 , -.Xr wcspbrk 3 , -.Xr wcsrchr 3 , -.Xr wcsspn 3 , -.Xr wcsstr 3 , -.Xr wcstok 3 , -.Xr wmemchr 3 -.Sh STANDARDS -The -.Fn wcschr -function conforms to -.St -isoC-99 -and was first introduced in -.St -isoC-amd1 . -.Sh HISTORY -The -.Fn wcschr -function was ported from -.Nx -and first appeared in -.Ox 3.8 . diff --git a/src/lib/libc/string/wcschr.c b/src/lib/libc/string/wcschr.c deleted file mode 100644 index 709d4797bb..0000000000 --- a/src/lib/libc/string/wcschr.c +++ /dev/null @@ -1,50 +0,0 @@ -/* $OpenBSD: wcschr.c,v 1.6 2015/10/01 02:32:07 guenther Exp $ */ -/* $NetBSD: wcschr.c,v 1.2 2001/01/03 14:29:36 lukem Exp $ */ - -/*- - * Copyright (c)1999 Citrus Project, - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * citrus Id: wcschr.c,v 1.2 2000/12/21 05:07:25 itojun Exp - */ - -#include - -wchar_t * -wcschr(const wchar_t *s, wchar_t c) -{ - const wchar_t *p; - - p = s; - for (;;) { - if (*p == c) { - return (wchar_t *)p; - } - if (!*p) - return NULL; - p++; - } - /* NOTREACHED */ -} -DEF_STRONG(wcschr); diff --git a/src/lib/libc/string/wcscmp.3 b/src/lib/libc/string/wcscmp.3 deleted file mode 100644 index 53cd15a1f0..0000000000 --- a/src/lib/libc/string/wcscmp.3 +++ /dev/null @@ -1,92 +0,0 @@ -.\" $OpenBSD: wcscmp.3,v 1.3 2013/06/05 03:39:23 tedu Exp $ -.\" -.\" Copyright (c) 1990, 1991 The Regents of the University of California. -.\" All rights reserved. -.\" -.\" This code is derived from software contributed to Berkeley by -.\" Chris Torek and the American National Standards Committee X3, -.\" on Information Processing Systems. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.Dd $Mdocdate: June 5 2013 $ -.Dt WCSCMP 3 -.Os -.Sh NAME -.Nm wcscmp , -.Nm wcsncmp -.Nd compare wide strings -.Sh SYNOPSIS -.In wchar.h -.Ft int -.Fn wcscmp "const wchar_t *s1" "const wchar_t *s2" -.Ft int -.Fn wcsncmp "const wchar_t *s1" "const wchar_t *s2" "size_t len" -.Sh DESCRIPTION -The -.Fn wcscmp -and -.Fn wcsncmp -functions lexicographically compare the wide strings -.Fa s1 -and -.Fa s2 . -The -.Fn wcsncmp -function compares at most -.Fa len -wide characters. -.Sh RETURN VALUES -The -.Fn wcscmp -and -.Fn wcsncmp -functions return an integer greater than, equal to, or less than 0, according -to whether the wide string -.Fa s1 -is greater than, equal to, or less than the wide string -.Fa s2 . -.Sh SEE ALSO -.Xr strcmp 3 , -.Xr wcscasecmp 3 , -.Xr wmemcmp 3 -.Sh STANDARDS -The -.Fn wcscmp -and -.Fn wcsncmp -functions conform to -.St -isoC-99 -and were first introduced in -.St -isoC-amd1 . -.Sh HISTORY -The -.Fn wcscmp -and -.Fn wcsncmp -functions were ported from -.Nx -and first appeared in -.Ox 3.8 . diff --git a/src/lib/libc/string/wcscmp.c b/src/lib/libc/string/wcscmp.c deleted file mode 100644 index 42d6bca3cc..0000000000 --- a/src/lib/libc/string/wcscmp.c +++ /dev/null @@ -1,52 +0,0 @@ -/* $OpenBSD: wcscmp.c,v 1.5 2015/09/12 16:23:14 guenther Exp $ */ -/* $NetBSD: wcscmp.c,v 1.5 2003/08/07 16:43:54 agc Exp $ */ - -/*- - * Copyright (c) 1990, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Chris Torek. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#include "locale/runetype.h" - -/* - * Compare strings. - */ -int -wcscmp(const wchar_t *s1, const wchar_t *s2) -{ - - while (*s1 == *s2++) - if (*s1++ == 0) - return (0); - /* XXX assumes wchar_t = int */ - return (*(const rune_t *)s1 - *(const rune_t *)--s2); -} -DEF_STRONG(wcscmp); diff --git a/src/lib/libc/string/wcscpy.3 b/src/lib/libc/string/wcscpy.3 deleted file mode 100644 index fcf01b5c57..0000000000 --- a/src/lib/libc/string/wcscpy.3 +++ /dev/null @@ -1,129 +0,0 @@ -.\" $OpenBSD: wcscpy.3,v 1.5 2016/11/12 08:58:43 jmc Exp $ -.\" -.\" Copyright (c) 1990, 1991 The Regents of the University of California. -.\" All rights reserved. -.\" -.\" This code is derived from software contributed to Berkeley by -.\" Chris Torek and the American National Standards Committee X3, -.\" on Information Processing Systems. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.Dd $Mdocdate: November 12 2016 $ -.Dt WCSCPY 3 -.Os -.Sh NAME -.Nm wcscpy , -.Nm wcsncpy -.Nd copy wide strings -.Sh SYNOPSIS -.In wchar.h -.Ft wchar_t * -.Fn wcscpy "wchar_t * restrict dst" "const wchar_t * restrict src" -.Ft wchar_t * -.Fo wcsncpy -.Fa "wchar_t * restrict dst" -.Fa "const wchar_t * restrict src" -.Fa "size_t len" -.Fc -.Sh DESCRIPTION -The -.Fn wcscpy -and -.Fn wcsncpy -functions copy the wide string -.Fa src -to -.Fa dst -(including the terminating null wide character). -.Pp -The -.Fn wcsncpy -function copies not more than -.Fa len -wide characters to -.Fa dst , -appending null wide characters if the length of -.Fa src -is less than -.Fa len , -and -.Em not -terminating -.Fa dst -if the length of -.Fa src -is greater than or equal to -.Fa len . -.Pp -If the -.Fa src -and -.Fa dst -strings overlap, the behavior is undefined. -.Sh RETURN VALUES -The -.Fn wcscpy -and -.Fn wcsncpy -functions return -.Fa dst . -.Sh SEE ALSO -.Xr strcpy 3 , -.Xr strlcpy 3 , -.Xr wcscat 3 , -.Xr wcslcpy 3 , -.Xr wmemcpy 3 , -.Xr wmemmove 3 -.Sh STANDARDS -The -.Fn wcscpy -and -.Fn wcsncpy -functions conform to -.St -isoC-99 -and were first introduced in -.St -isoC-amd1 . -.Sh HISTORY -The -.Fn wcscpy -and -.Fn wcsncpy -functions were ported from -.Nx -and first appeared in -.Ox 3.8 . -.Sh CAVEATS -Using the functions -.Fn wcscpy -and -.Fn wcsncpy -is very error-prone with respect to buffer overflows; -see the EXAMPLES section in -.Xr strncpy 3 -for correct usage. -Using -.Xr wcslcpy 3 -is a better choice in most cases. diff --git a/src/lib/libc/string/wcscpy.c b/src/lib/libc/string/wcscpy.c deleted file mode 100644 index f772752413..0000000000 --- a/src/lib/libc/string/wcscpy.c +++ /dev/null @@ -1,52 +0,0 @@ -/* $OpenBSD: wcscpy.c,v 1.5 2017/11/28 06:55:49 tb Exp $ */ -/* $NetBSD: wcscpy.c,v 1.2 2001/01/03 14:29:36 lukem Exp $ */ - -/*- - * Copyright (c)1999 Citrus Project, - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * citrus Id: wcscpy.c,v 1.2 2000/12/21 04:51:09 itojun Exp - */ - -#include - -#if defined(APIWARN) -__warn_references(wcscpy, - "wcscpy() is almost always misused, please use wcslcpy()"); -#endif - -wchar_t * -wcscpy(wchar_t *s1, const wchar_t *s2) -{ - wchar_t *p; - const wchar_t *q; - - p = s1; - q = s2; - while (*q) - *p++ = *q++; - *p = '\0'; - - return s1; -} diff --git a/src/lib/libc/string/wcscspn.3 b/src/lib/libc/string/wcscspn.3 deleted file mode 100644 index 520a739202..0000000000 --- a/src/lib/libc/string/wcscspn.3 +++ /dev/null @@ -1,83 +0,0 @@ -.\" $OpenBSD: wcscspn.3,v 1.3 2013/06/05 03:39:23 tedu Exp $ -.\" -.\" Copyright (c) 1990, 1991 The Regents of the University of California. -.\" All rights reserved. -.\" -.\" This code is derived from software contributed to Berkeley by -.\" Chris Torek and the American National Standards Committee X3, -.\" on Information Processing Systems. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.Dd $Mdocdate: June 5 2013 $ -.Dt WCSCSPN 3 -.Os -.Sh NAME -.Nm wcscspn -.Nd span the complement of a wide string -.Sh SYNOPSIS -.In wchar.h -.Ft size_t -.Fn wcscspn "const wchar_t *s" "const wchar_t *charset" -.Sh DESCRIPTION -The -.Fn wcscspn -function spans the initial part of the wide string -.Fa s -as long as the wide characters from -.Fa s -do not occur in string -.Fa charset -(it spans the -.Em complement -of -.Fa charset ) . -.Sh RETURN VALUES -The -.Fn wcscspn -function returns the number of wide characters spanned. -.Sh SEE ALSO -.Xr strcspn 3 , -.Xr wcschr 3 , -.Xr wcspbrk 3 , -.Xr wcsrchr 3 , -.Xr wcsspn 3 , -.Xr wcsstr 3 , -.Xr wcstok 3 , -.Xr wmemchr 3 -.Sh STANDARDS -The -.Fn wcscspn -function conforms to -.St -isoC-99 -and was first introduced in -.St -isoC-amd1 . -.Sh HISTORY -The -.Fn wcscspn -function was ported from -.Nx -and first appeared in -.Ox 3.8 . diff --git a/src/lib/libc/string/wcscspn.c b/src/lib/libc/string/wcscspn.c deleted file mode 100644 index 23e78ab22f..0000000000 --- a/src/lib/libc/string/wcscspn.c +++ /dev/null @@ -1,54 +0,0 @@ -/* $OpenBSD: wcscspn.c,v 1.4 2015/09/12 16:23:14 guenther Exp $ */ -/* $NetBSD: wcscspn.c,v 1.2 2001/01/03 14:29:36 lukem Exp $ */ - -/*- - * Copyright (c)1999 Citrus Project, - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * citrus Id: wcscspn.c,v 1.1 1999/12/29 21:47:45 tshiozak Exp - */ - -#include - -size_t -wcscspn(const wchar_t *s, const wchar_t *set) -{ - const wchar_t *p; - const wchar_t *q; - - p = s; - while (*p) { - q = set; - while (*q) { - if (*p == *q) - goto done; - q++; - } - p++; - } - -done: - return (p - s); -} -DEF_STRONG(wcscspn); diff --git a/src/lib/libc/string/wcsdup.3 b/src/lib/libc/string/wcsdup.3 deleted file mode 100644 index 588a2571db..0000000000 --- a/src/lib/libc/string/wcsdup.3 +++ /dev/null @@ -1,97 +0,0 @@ -.\" $OpenBSD: wcsdup.3,v 1.4 2011/07/25 00:38:53 schwarze Exp $ -.\" $NetBSD: wcsdup.3,v 1.3 2010/12/16 17:42:28 wiz Exp $ -.\" -.\" Copyright (c) 1990, 1991, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)strdup.3 8.1 (Berkeley) 6/9/93 -.\" -.Dd $Mdocdate: July 25 2011 $ -.Dt WCSDUP 3 -.Os -.Sh NAME -.Nm wcsdup -.Nd save a copy of a wide string -.Sh SYNOPSIS -.In wchar.h -.Ft wchar_t * -.Fn wcsdup "const wchar_t *str" -.Sh DESCRIPTION -The -.Fn wcsdup -function -allocates sufficient memory for a copy -of the wide-character string -.Fa str , -does the copy, and returns a pointer to it. -The pointer may subsequently be used as an -argument to the function -.Xr free 3 . -.Pp -If insufficient memory is available, -.Dv NULL -is returned. -.Sh EXAMPLES -The following will point -.Va p -to an allocated area of memory containing the nul-terminated string -.Qq foobar : -.Bd -literal -offset indent -const char *o = "foobar"; -wchar_t *p, b[32]; -size_t blen; - -blen = sizeof(b) / sizeof(b[0]); -if (mbstowcs(b, o, blen) == (size_t)-1) - err(1, NULL); -b[blen - 1] = 0; -if ((p = wcsdup(b)) == NULL) - err(1, NULL); -.Ed -.Sh ERRORS -The -.Fn wcsdup -function may fail and set the external variable -.Va errno -for any of the errors specified for the library function -.Xr malloc 3 . -.Sh SEE ALSO -.Xr free 3 , -.Xr malloc 3 , -.Xr strdup 3 -.Sh STANDARDS -The -.Fn wcsdup -function conforms to -.St -p1003.1-2008 . -.Sh HISTORY -The -.Fn wcsdup -function was ported from -.Nx -and first appeared in -.Ox 5.0 . diff --git a/src/lib/libc/string/wcsdup.c b/src/lib/libc/string/wcsdup.c deleted file mode 100644 index 36f19186ab..0000000000 --- a/src/lib/libc/string/wcsdup.c +++ /dev/null @@ -1,32 +0,0 @@ -/* $OpenBSD: wcsdup.c,v 1.3 2015/09/12 16:23:14 guenther Exp $ */ -/* $NetBSD: wcsdup.c,v 1.3 2008/05/26 13:17:48 haad Exp $ */ - -/* - * Copyright (C) 2006 Aleksey Cheusov - * - * This material is provided "as is", with absolutely no warranty expressed - * or implied. Any use is at your own risk. - * - * Permission to use or copy this software for any purpose is hereby granted - * without fee. Permission to modify the code and to distribute modified - * code is also granted without any restrictions. - */ - -#include -#include - -wchar_t * -wcsdup(const wchar_t *str) -{ - wchar_t *copy; - size_t len; - - len = wcslen(str) + 1; - copy = reallocarray(NULL, len, sizeof(wchar_t)); - - if (!copy) - return (NULL); - - return (wmemcpy(copy, str, len)); -} -DEF_WEAK(wcsdup); diff --git a/src/lib/libc/string/wcslcat.c b/src/lib/libc/string/wcslcat.c deleted file mode 100644 index 9949057df4..0000000000 --- a/src/lib/libc/string/wcslcat.c +++ /dev/null @@ -1,56 +0,0 @@ -/* $OpenBSD: wcslcat.c,v 1.7 2019/01/25 00:19:25 millert Exp $ */ - -/* - * Copyright (c) 1998, 2015 Todd C. Miller - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#include -#include - -/* - * Appends src to string dst of size dsize (unlike strncat, dsize is the - * full size of dst, not space left). At most dsize-1 characters - * will be copied. Always NUL terminates (unless dsize <= wcslen(dst)). - * Returns wcslen(src) + MIN(dsize, wcslen(initial dst)). - * If retval >= siz, truncation occurred. - */ -size_t -wcslcat(wchar_t *dst, const wchar_t *src, size_t dsize) -{ - const wchar_t *odst = dst; - const wchar_t *osrc = src; - size_t n = dsize; - size_t dlen; - - /* Find the end of dst and adjust bytes left but don't go past end. */ - while (n-- != 0 && *dst != L'\0') - dst++; - dlen = dst - odst; - n = dsize - dlen; - - if (n-- == 0) - return(dlen + wcslen(src)); - while (*src != L'\0') { - if (n != 0) { - *dst++ = *src; - n--; - } - src++; - } - *dst = L'\0'; - - return(dlen + (src - osrc)); /* count does not include NUL */ -} -DEF_WEAK(wcslcat); diff --git a/src/lib/libc/string/wcslcpy.3 b/src/lib/libc/string/wcslcpy.3 deleted file mode 100644 index d279038079..0000000000 --- a/src/lib/libc/string/wcslcpy.3 +++ /dev/null @@ -1,160 +0,0 @@ -.\" $OpenBSD: wcslcpy.3,v 1.8 2024/08/07 04:59:45 guenther Exp $ -.\" -.\" Copyright (c) 1998, 2000 Todd C. Miller -.\" -.\" Permission to use, copy, modify, and distribute this software for any -.\" purpose with or without fee is hereby granted, provided that the above -.\" copyright notice and this permission notice appear in all copies. -.\" -.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -.\" -.Dd $Mdocdate: August 7 2024 $ -.Dt WCSLCPY 3 -.Os -.Sh NAME -.Nm wcslcpy , -.Nm wcslcat -.Nd size-bounded wide string copying and concatenation -.Sh SYNOPSIS -.In wchar.h -.Ft size_t -.Fn wcslcpy "wchar_t * restrict dst" "const wchar_t * restrict src" "size_t size" -.Ft size_t -.Fn wcslcat "wchar_t * restrict dst" "const wchar_t * restrict src" "size_t size" -.Sh DESCRIPTION -The -.Fn wcslcpy -and -.Fn wcslcat -functions copy and concatenate wide strings respectively. -They are designed to be safer, more consistent, and less error prone -replacements for -.Xr wcsncpy 3 -and -.Xr wcsncat 3 . -Unlike those functions, -.Fn wcslcpy -and -.Fn wcslcat -take the full size of the buffer (not just the length) and guarantee to -terminate the result with a null wide character (as long as -.Fa size -is larger than 0 or, in the case of -.Fn wcslcat , -as long as there is at least one wide character free in -.Fa dst ) . -Note that a wide character for the null wide character should be included in -.Fa size . -Also note that -.Fn wcslcpy -and -.Fn wcslcat -only operate on wide strings that are terminated with a null wide character -(L'\e0'). -This means that for -.Fn wcslcpy -.Fa src -must be terminated with a null wide character and for -.Fn wcslcat -both -.Fa src -and -.Fa dst -must be terminated with a null wide character. -.Pp -The -.Fn wcslcpy -function copies up to -.Fa size -\(mi 1 wide characters from the wide string -.Fa src -to -.Fa dst , -terminating the result with a null wide character. -.Pp -The -.Fn wcslcat -function appends the wide string -.Fa src -to the end of -.Fa dst . -It will append at most -.Fa size -\(mi wcslen(dst) \(mi 1 wide characters, terminating the result with a null -wide character. -.Pp -If the -.Fa src -and -.Fa dst -strings overlap, the behavior is undefined. -.Sh RETURN VALUES -The -.Fn wcslcpy -and -.Fn wcslcat -functions return the total length of the wide string they tried to create. -For -.Fn wcslcpy -that means the length of -.Fa src . -For -.Fn wcslcat -that means the initial length of -.Fa dst -plus -the length of -.Fa src . -While this may seem somewhat confusing, it was done to make -truncation detection simple. -.Pp -Note, however, that if -.Fn wcslcat -traverses -.Fa size -wide characters without finding a null wide character, the length of the -string is considered to be -.Fa size -and the destination wide string will not be terminated with a null wide -character (since there was no space for it). -This keeps -.Fn wcslcat -from running off the end of a wide string. -In practice this should not happen (as it means that either -.Fa size -is incorrect or that -.Fa dst -is not terminated with a null wide character). -The check exists to prevent potential security problems in incorrect code. -.Sh SEE ALSO -.Xr strlcpy 3 , -.Xr swprintf 3 , -.Xr wcsncat 3 , -.Xr wcsncpy 3 -.Sh STANDARDS -The -.Fn wcslcpy -and -.Fn wcslcat -functions conform to -.St -p1003.1-2024 . -.Sh HISTORY -The -.Fn wcslcpy -and -.Fn wcslcat -functions first appeared in -.Ox 3.8 . -.Sh AUTHORS -The -.Fn wcslcpy -and -.Fn wcslcat -functions are based on code by -.An Todd C. Miller Aq Mt millert@openbsd.org . diff --git a/src/lib/libc/string/wcslcpy.c b/src/lib/libc/string/wcslcpy.c deleted file mode 100644 index 9c433c83dc..0000000000 --- a/src/lib/libc/string/wcslcpy.c +++ /dev/null @@ -1,51 +0,0 @@ -/* $OpenBSD: wcslcpy.c,v 1.8 2019/01/25 00:19:25 millert Exp $ */ - -/* - * Copyright (c) 1998, 2015 Todd C. Miller - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#include -#include - -/* - * Copy string src to buffer dst of size dsize. At most dsize-1 - * chars will be copied. Always NUL terminates (unless dsize == 0). - * Returns wcslen(src); if retval >= dsize, truncation occurred. - */ -size_t -wcslcpy(wchar_t *dst, const wchar_t *src, size_t dsize) -{ - const wchar_t *osrc = src; - size_t nleft = dsize; - - /* Copy as many bytes as will fit. */ - if (nleft != 0) { - while (--nleft != 0) { - if ((*dst++ = *src++) == L'\0') - break; - } - } - - /* Not enough room in dst, add NUL and traverse rest of src. */ - if (nleft == 0) { - if (dsize != 0) - *dst = L'\0'; /* NUL-terminate dst */ - while (*src++) - ; - } - - return(src - osrc - 1); /* count does not include NUL */ -} -DEF_WEAK(wcslcpy); diff --git a/src/lib/libc/string/wcslen.3 b/src/lib/libc/string/wcslen.3 deleted file mode 100644 index b6d9aafc41..0000000000 --- a/src/lib/libc/string/wcslen.3 +++ /dev/null @@ -1,102 +0,0 @@ -.\" $OpenBSD: wcslen.3,v 1.4 2024/07/14 09:51:18 jca Exp $ -.\" -.\" Copyright (c) 1990, 1991 The Regents of the University of California. -.\" All rights reserved. -.\" -.\" This code is derived from software contributed to Berkeley by -.\" Chris Torek and the American National Standards Committee X3, -.\" on Information Processing Systems. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.Dd $Mdocdate: July 14 2024 $ -.Dt WCSLEN 3 -.Os -.Sh NAME -.Nm wcslen , -.Nm wcsnlen -.Nd find length of a wide string -.Sh SYNOPSIS -.In wchar.h -.Ft size_t -.Fn wcslen "const wchar_t *s" -.Ft size_t -.Fn wcsnlen "const wchar_t *s" "size_t maxlen" -.Sh DESCRIPTION -The -.Fn wcslen -function computes the length of the wide string -.Fa s . -The -.Fn wcsnlen -function computes the length of the wide string -.Fa s , -up to -.Fa maxlen -wide characters. -The -.Fn wcsnlen -function will never attempt to address more than -.Fa maxlen -wide characters, making it suitable for use with wide character arrays -that are not guaranteed to be NUL-terminated. -.Sh RETURN VALUES -The -.Fn wcslen -function returns the number of wide characters that precede the terminating -null wide character. -.Pp -The -.Fn wcsnlen -function returns the number of wide characters that precede the terminating -null wide character -or -.Fa maxlen , -whichever is smaller. -.Sh SEE ALSO -.Xr strlen 3 , -.Xr wcswidth 3 -.Sh STANDARDS -The -.Fn wcslen -function conforms to -.St -isoC-99 -and was first introduced in -.St -isoC-amd1 . -The -.Fn wcsnlen -function conforms to -.St -p1003.1-2008 . -.Sh HISTORY -The -.Fn wcslen -function was ported from -.Nx -and first appeared in -.Ox 3.8 . -The -.Fn wcsnlen -function first appeared in -.Ox 7.6 . diff --git a/src/lib/libc/string/wcslen.c b/src/lib/libc/string/wcslen.c deleted file mode 100644 index 16d4bba128..0000000000 --- a/src/lib/libc/string/wcslen.c +++ /dev/null @@ -1,45 +0,0 @@ -/* $OpenBSD: wcslen.c,v 1.4 2015/09/12 16:23:14 guenther Exp $ */ -/* $NetBSD: wcslen.c,v 1.2 2001/01/03 14:29:36 lukem Exp $ */ - -/*- - * Copyright (c)1999 Citrus Project, - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * citrus Id: wcslen.c,v 1.1 1999/12/29 21:47:45 tshiozak Exp - */ - -#include - -size_t -wcslen(const wchar_t *s) -{ - const wchar_t *p; - - p = s; - while (*p) - p++; - - return p - s; -} -DEF_STRONG(wcslen); diff --git a/src/lib/libc/string/wcsncat.c b/src/lib/libc/string/wcsncat.c deleted file mode 100644 index 2b4b9f0d49..0000000000 --- a/src/lib/libc/string/wcsncat.c +++ /dev/null @@ -1,53 +0,0 @@ -/* $OpenBSD: wcsncat.c,v 1.4 2015/09/12 16:23:14 guenther Exp $ */ -/* $NetBSD: wcsncat.c,v 1.2 2001/01/03 14:29:36 lukem Exp $ */ - -/*- - * Copyright (c)1999 Citrus Project, - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * citrus Id: wcsncat.c,v 1.1 1999/12/29 21:47:45 tshiozak Exp - */ - -#include - -wchar_t * -wcsncat(wchar_t *s1, const wchar_t *s2, size_t n) -{ - wchar_t *p; - wchar_t *q; - const wchar_t *r; - - p = s1; - while (*p) - p++; - q = p; - r = s2; - while (*r && n) { - *q++ = *r++; - n--; - } - *q = '\0'; - return s1; -} -DEF_STRONG(wcsncat); diff --git a/src/lib/libc/string/wcsncmp.c b/src/lib/libc/string/wcsncmp.c deleted file mode 100644 index bdaab33e4c..0000000000 --- a/src/lib/libc/string/wcsncmp.c +++ /dev/null @@ -1,53 +0,0 @@ -/* $OpenBSD: wcsncmp.c,v 1.5 2015/09/12 16:23:14 guenther Exp $ */ -/* $NetBSD: wcsncmp.c,v 1.5 2003/08/07 16:43:54 agc Exp $ */ - -/* - * Copyright (c) 1989, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#include "locale/runetype.h" - -int -wcsncmp(const wchar_t *s1, const wchar_t *s2, size_t n) -{ - - if (n == 0) - return (0); - do { - if (*s1 != *s2++) { - /* XXX assumes wchar_t = int */ - return (*(const rune_t *)s1 - - *(const rune_t *)--s2); - } - if (*s1++ == 0) - break; - } while (--n != 0); - return (0); -} -DEF_STRONG(wcsncmp); diff --git a/src/lib/libc/string/wcsncpy.c b/src/lib/libc/string/wcsncpy.c deleted file mode 100644 index 1be482b114..0000000000 --- a/src/lib/libc/string/wcsncpy.c +++ /dev/null @@ -1,51 +0,0 @@ -/* $OpenBSD: wcsncpy.c,v 1.5 2015/09/12 16:23:14 guenther Exp $ */ -/* $NetBSD: wcsncpy.c,v 1.2 2001/01/03 14:29:37 lukem Exp $ */ - -/*- - * Copyright (c)1999 Citrus Project, - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * citrus Id: wcsncpy.c,v 1.1 1999/12/29 21:47:45 tshiozak Exp - */ - -#include - -wchar_t * -wcsncpy(wchar_t *s1, const wchar_t *s2, size_t n) -{ - wchar_t *p; - - p = s1; - while (n && *s2) { - *p++ = *s2++; - n--; - } - while (n) { - *p++ = L'\0'; - n--; - } - - return s1; -} -DEF_STRONG(wcsncpy); diff --git a/src/lib/libc/string/wcsnlen.c b/src/lib/libc/string/wcsnlen.c deleted file mode 100644 index eb1d08e85b..0000000000 --- a/src/lib/libc/string/wcsnlen.c +++ /dev/null @@ -1,45 +0,0 @@ -/* $OpenBSD: wcsnlen.c,v 1.1 2024/07/14 09:51:18 jca Exp $ */ -/* $NetBSD: wcslen.c,v 1.2 2001/01/03 14:29:36 lukem Exp $ */ - -/*- - * Copyright (c)1999 Citrus Project, - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * citrus Id: wcslen.c,v 1.1 1999/12/29 21:47:45 tshiozak Exp - */ - -#include - -size_t -wcsnlen(const wchar_t *s, size_t maxlen) -{ - const wchar_t *p; - - p = s; - while (maxlen-- && *p) - p++; - - return p - s; -} - diff --git a/src/lib/libc/string/wcspbrk.3 b/src/lib/libc/string/wcspbrk.3 deleted file mode 100644 index 602bfdc3d6..0000000000 --- a/src/lib/libc/string/wcspbrk.3 +++ /dev/null @@ -1,81 +0,0 @@ -.\" $OpenBSD: wcspbrk.3,v 1.3 2013/06/05 03:39:23 tedu Exp $ -.\" -.\" Copyright (c) 1990, 1991 The Regents of the University of California. -.\" All rights reserved. -.\" -.\" This code is derived from software contributed to Berkeley by -.\" Chris Torek and the American National Standards Committee X3, -.\" on Information Processing Systems. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.Dd $Mdocdate: June 5 2013 $ -.Dt WCSPBRK 3 -.Os -.Sh NAME -.Nm wcspbrk -.Nd locate multiple wide characters in a wide string -.Sh SYNOPSIS -.In wchar.h -.Ft wchar_t * -.Fn wcspbrk "const wchar_t *s" "const wchar_t *charset" -.Sh DESCRIPTION -The -.Fn wcspbrk -function locates in the wide string -.Fa s -the first occurrence of any wide character in the wide string -.Fa charset -and returns a pointer to this wide character. -If no wide characters from -.Fa charset -occur anywhere in -.Fa s , -.Fn wcspbrk -returns -.Dv NULL . -.Sh SEE ALSO -.Xr strpbrk 3 , -.Xr wcschr 3 , -.Xr wcscspn 3 , -.Xr wcsrchr 3 , -.Xr wcsspn 3 , -.Xr wcsstr 3 , -.Xr wcstok 3 , -.Xr wmemchr 3 -.Sh STANDARDS -The -.Fn wcspbrk -function conforms to -.St -isoC-99 -and was first introduced in -.St -isoC-amd1 . -.Sh HISTORY -The -.Fn wcspbrk -function was ported from -.Nx -and first appeared in -.Ox 3.8 . diff --git a/src/lib/libc/string/wcspbrk.c b/src/lib/libc/string/wcspbrk.c deleted file mode 100644 index f398fd92ab..0000000000 --- a/src/lib/libc/string/wcspbrk.c +++ /dev/null @@ -1,53 +0,0 @@ -/* $OpenBSD: wcspbrk.c,v 1.5 2015/10/01 02:32:07 guenther Exp $ */ -/* $NetBSD: wcspbrk.c,v 1.2 2001/01/03 14:29:37 lukem Exp $ */ - -/*- - * Copyright (c)1999 Citrus Project, - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * citrus Id: wcspbrk.c,v 1.2 2000/12/21 05:07:25 itojun Exp - */ - -#include - -wchar_t * -wcspbrk(const wchar_t *s, const wchar_t *set) -{ - const wchar_t *p; - const wchar_t *q; - - p = s; - while (*p) { - q = set; - while (*q) { - if (*p == *q) { - return (wchar_t *)p; - } - q++; - } - p++; - } - return NULL; -} -DEF_STRONG(wcspbrk); diff --git a/src/lib/libc/string/wcsrchr.3 b/src/lib/libc/string/wcsrchr.3 deleted file mode 100644 index d4a2e7cf78..0000000000 --- a/src/lib/libc/string/wcsrchr.3 +++ /dev/null @@ -1,85 +0,0 @@ -.\" $OpenBSD: wcsrchr.3,v 1.3 2013/06/05 03:39:23 tedu Exp $ -.\" -.\" Copyright (c) 1990, 1991 The Regents of the University of California. -.\" All rights reserved. -.\" -.\" This code is derived from software contributed to Berkeley by -.\" Chris Torek and the American National Standards Committee X3, -.\" on Information Processing Systems. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.Dd $Mdocdate: June 5 2013 $ -.Dt WCSRCHR 3 -.Os -.Sh NAME -.Nm wcsrchr -.Nd locate last occurrence of a wide character in a wide string -.Sh SYNOPSIS -.In wchar.h -.Ft wchar_t * -.Fn wcsrchr "const wchar_t *s" "wchar_t c" -.Sh DESCRIPTION -The -.Fn wcsrchr -function locates the last occurrence of the wide character -.Fa c -in the wide string -.Fa s . -The terminating null wide character is considered part of the wide string. -If -.Fa c -is the null wide character (L'\e0'), -.Fn wcsrchr -locates the terminating null wide character. -.Sh RETURN VALUES -The -.Fn wcsrchr -function returns a pointer to the located wide character or -.Dv NULL -if the wide character does not appear in the wide string. -.Sh SEE ALSO -.Xr strrchr 3 , -.Xr wcschr 3 , -.Xr wcscspn 3 , -.Xr wcspbrk 3 , -.Xr wcsspn 3 , -.Xr wcsstr 3 , -.Xr wcstok 3 , -.Xr wmemchr 3 -.Sh STANDARDS -The -.Fn wcsrchr -function conforms to -.St -isoC-99 -and was first introduced in -.St -isoC-amd1 . -.Sh HISTORY -The -.Fn wcsrchr -function was ported from -.Nx -and first appeared in -.Ox 3.8 . diff --git a/src/lib/libc/string/wcsrchr.c b/src/lib/libc/string/wcsrchr.c deleted file mode 100644 index aa936de508..0000000000 --- a/src/lib/libc/string/wcsrchr.c +++ /dev/null @@ -1,50 +0,0 @@ -/* $OpenBSD: wcsrchr.c,v 1.5 2015/10/01 02:32:07 guenther Exp $ */ -/* $NetBSD: wcsrchr.c,v 1.2 2001/01/03 14:29:37 lukem Exp $ */ - -/*- - * Copyright (c)1999 Citrus Project, - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * citrus Id: wcsrchr.c,v 1.2 2000/12/21 05:07:25 itojun Exp - */ - -#include - -wchar_t * -wcsrchr(const wchar_t *s, wchar_t c) -{ - const wchar_t *p; - - p = s; - while (*p) - p++; - while (s <= p) { - if (*p == c) { - return (wchar_t *)p; - } - p--; - } - return NULL; -} -DEF_STRONG(wcsrchr); diff --git a/src/lib/libc/string/wcsspn.3 b/src/lib/libc/string/wcsspn.3 deleted file mode 100644 index 3be82344dd..0000000000 --- a/src/lib/libc/string/wcsspn.3 +++ /dev/null @@ -1,79 +0,0 @@ -.\" $OpenBSD: wcsspn.3,v 1.3 2013/06/05 03:39:23 tedu Exp $ -.\" -.\" Copyright (c) 1990, 1991 The Regents of the University of California. -.\" All rights reserved. -.\" -.\" This code is derived from software contributed to Berkeley by -.\" Chris Torek and the American National Standards Committee X3, -.\" on Information Processing Systems. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.Dd $Mdocdate: June 5 2013 $ -.Dt WCSSPN 3 -.Os -.Sh NAME -.Nm wcsspn -.Nd span a wide string -.Sh SYNOPSIS -.In wchar.h -.Ft size_t -.Fn wcsspn "const wchar_t *s" "const wchar_t *charset" -.Sh DESCRIPTION -The -.Fn wcsspn -function spans the initial part of the wide string -.Fa s -as long as the wide characters from -.Fa s -occur in the wide string -.Fa charset . -.Sh RETURN VALUES -The -.Fn wcsspn -function returns the number of wide characters spanned. -.Sh SEE ALSO -.Xr strspn 3 , -.Xr wcschr 3 , -.Xr wcscspn 3 , -.Xr wcspbrk 3 , -.Xr wcsrchr 3 , -.Xr wcsstr 3 , -.Xr wcstok 3 , -.Xr wmemchr 3 -.Sh STANDARDS -The -.Fn wcsspn -function conforms to -.St -isoC-99 -and was first introduced in -.St -isoC-amd1 . -.Sh HISTORY -The -.Fn wcsspn -function was ported from -.Nx -and first appeared in -.Ox 3.8 . diff --git a/src/lib/libc/string/wcsspn.c b/src/lib/libc/string/wcsspn.c deleted file mode 100644 index a3f28e3a49..0000000000 --- a/src/lib/libc/string/wcsspn.c +++ /dev/null @@ -1,56 +0,0 @@ -/* $OpenBSD: wcsspn.c,v 1.4 2015/09/12 16:23:14 guenther Exp $ */ -/* $NetBSD: wcsspn.c,v 1.3 2001/09/21 16:09:15 yamt Exp $ */ - -/*- - * Copyright (c)1999,2001 Citrus Project, - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $Citrus: xpg4dl/FreeBSD/lib/libc/string/wcsspn.c,v 1.3 2001/09/21 16:06:43 yamt Exp $ - */ - -#include - -size_t -wcsspn(const wchar_t *s, const wchar_t *set) -{ - const wchar_t *p; - const wchar_t *q; - - p = s; - while (*p) { - q = set; - while (*q) { - if (*p == *q) - break; - q++; - } - if (!*q) - goto done; - p++; - } - -done: - return (p - s); -} -DEF_STRONG(wcsspn); diff --git a/src/lib/libc/string/wcsstr.3 b/src/lib/libc/string/wcsstr.3 deleted file mode 100644 index 203a76ded3..0000000000 --- a/src/lib/libc/string/wcsstr.3 +++ /dev/null @@ -1,88 +0,0 @@ -.\" $OpenBSD: wcsstr.3,v 1.3 2013/06/05 03:39:23 tedu Exp $ -.\" -.\" Copyright (c) 1990, 1991 The Regents of the University of California. -.\" All rights reserved. -.\" -.\" This code is derived from software contributed to Berkeley by -.\" Chris Torek and the American National Standards Committee X3, -.\" on Information Processing Systems. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.Dd $Mdocdate: June 5 2013 $ -.Dt WCSSTR 3 -.Os -.Sh NAME -.Nm wcsstr -.Nd locate a wide substring in a wide string -.Sh SYNOPSIS -.In wchar.h -.Ft wchar_t * -.Fn wcsstr "const wchar_t *big" "const wchar_t *little" -.Sh DESCRIPTION -The -.Fn wcsstr -function locates the first occurrence of the wide string -.Fa little -in the wide string -.Fa big . -.Pp -If -.Fa little -is an empty wide string, -.Fa big -is returned; -if -.Fa little -occurs nowhere in -.Fa big , -.Dv NULL -is returned; -otherwise a pointer to the first wide character of the first occurrence of -.Fa little -is returned. -.Sh SEE ALSO -.Xr strstr 3 , -.Xr wcschr 3 , -.Xr wcscspn 3 , -.Xr wcspbrk 3 , -.Xr wcsrchr 3 , -.Xr wcsspn 3 , -.Xr wcstok 3 , -.Xr wmemchr 3 -.Sh STANDARDS -The -.Fn wcsstr -function conforms to -.St -isoC-99 -and was first introduced in -.St -isoC-amd1 . -.Sh HISTORY -The -.Fn wcsstr -function was ported from -.Nx -and first appeared in -.Ox 3.8 . diff --git a/src/lib/libc/string/wcsstr.c b/src/lib/libc/string/wcsstr.c deleted file mode 100644 index 6a7b0dac4a..0000000000 --- a/src/lib/libc/string/wcsstr.c +++ /dev/null @@ -1,71 +0,0 @@ -/* $OpenBSD: wcsstr.c,v 1.5 2015/10/01 02:32:07 guenther Exp $ */ -/* $NetBSD: wcsstr.c,v 1.3 2003/03/05 20:18:17 tshiozak Exp $ */ - -/*- - * Copyright (c)1999 Citrus Project, - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * citrus Id: wcsstr.c,v 1.2 2000/12/21 05:07:25 itojun Exp - */ - -#include - -wchar_t * -#ifdef WCSWCS -wcswcs(const wchar_t *big, const wchar_t *little) -#else -wcsstr(const wchar_t *big, const wchar_t *little) -#endif -{ - const wchar_t *p; - const wchar_t *q; - const wchar_t *r; - - if (!*little) { - return (wchar_t *)big; - } - if (wcslen(big) < wcslen(little)) - return NULL; - - p = big; - q = little; - while (*p) { - q = little; - r = p; - while (*q) { - if (*r != *q) - break; - q++; - r++; - } - if (!*q) { - return (wchar_t *)p; - } - p++; - } - return NULL; -} -#ifndef WCSWCS -DEF_STRONG(wcsstr); -#endif diff --git a/src/lib/libc/string/wcstok.3 b/src/lib/libc/string/wcstok.3 deleted file mode 100644 index 33ba1318a1..0000000000 --- a/src/lib/libc/string/wcstok.3 +++ /dev/null @@ -1,151 +0,0 @@ -.\" $OpenBSD: wcstok.3,v 1.7 2011/07/25 00:38:53 schwarze Exp $ -.\" -.\" $NetBSD: wcstok.3,v 1.3 2003/09/08 17:54:33 wiz Exp $ -.\" -.\" Copyright (c) 1998 Softweyr LLC. All rights reserved. -.\" -.\" strtok_r, from Berkeley strtok -.\" Oct 13, 1998 by Wes Peters -.\" -.\" Copyright (c) 1988, 1991, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" This code is derived from software contributed to Berkeley by -.\" the American National Standards Committee X3, on Information -.\" Processing Systems. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" -.\" 1. Redistributions of source code must retain the above copyright -.\" notices, this list of conditions and the following disclaimer. -.\" -.\" 2. Redistributions in binary form must reproduce the above -.\" copyright notices, this list of conditions and the following -.\" disclaimer in the documentation and/or other materials provided -.\" with the distribution. -.\" -.\" 3. All advertising materials mentioning features or use of this -.\" software must display the following acknowledgement: -.\" -.\" This product includes software developed by Softweyr LLC, the -.\" University of California, Berkeley, and its contributors. -.\" -.\" 4. Neither the name of Softweyr LLC, the University nor the names -.\" of its contributors may be used to endorse or promote products -.\" derived from this software without specific prior written -.\" permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY SOFTWEYR LLC, THE REGENTS AND -.\" CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, -.\" INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -.\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -.\" DISCLAIMED. IN NO EVENT SHALL SOFTWEYR LLC, THE REGENTS, OR -.\" CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -.\" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF -.\" USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -.\" ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -.\" OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT -.\" OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" Original version ID: -.\" FreeBSD: src/lib/libc/string/wcstok.3,v 1.4 2002/10/15 09:49:54 tjr Exp -.\" -.Dd $Mdocdate: July 25 2011 $ -.Dt WCSTOK 3 -.Os -.Sh NAME -.Nm wcstok -.Nd split wide-character string into tokens -.Sh SYNOPSIS -.In wchar.h -.Ft wchar_t * -.Fn wcstok "wchar_t * restrict str" "const wchar_t * restrict sep" "wchar_t ** restrict last" -.Sh DESCRIPTION -The -.Fn wcstok -function -is used to isolate sequential tokens in a NUL-terminated wide-character -string, -.Fa str . -These tokens are separated in the string by at least one of the -characters in -.Fa sep . -The first time that -.Fn wcstok -is called, -.Fa str -should be specified; subsequent calls, wishing to obtain further tokens -from the same string, should pass a null pointer instead. -The separator string, -.Fa sep , -must be supplied each time, and may change between calls. -The context pointer -.Fa last -must be provided on each call. -.Pp -The -.Fn wcstok -function is the wide-character counterpart of the -.Xr strtok_r 3 -function. -.Pp -Since -.Fn wcstok -modifies the string, -.Fa str -should not point to an area in the initialized data segment. -.Sh RETURN VALUES -The -.Fn wcstok -function -returns a pointer to the beginning of each subsequent token in the string, -after replacing the token itself with a NUL wide character (L'\e0'). -When no more tokens remain, a null pointer is returned. -.Sh EXAMPLES -The following code fragment splits a wide-character string on -.Tn ASCII -space, tab, and newline characters and writes the tokens to -standard output: -.Bd -literal -offset indent -const wchar_t *seps = L" \et\en"; -wchar_t *last, *tok, text[] = L" \enone\ettwo\et\etthree \en"; - -for (tok = wcstok(text, seps, &last); tok != NULL; - tok = wcstok(NULL, seps, &last)) - wprintf(L"%ls\en", tok); -.Ed -.Sh SEE ALSO -.Xr strtok 3 , -.Xr wcschr 3 , -.Xr wcscspn 3 , -.Xr wcspbrk 3 , -.Xr wcsrchr 3 , -.Xr wcsspn 3 , -.Xr wcsstr 3 , -.Xr wmemchr 3 -.Sh STANDARDS -The -.Fn wcstok -function -conforms to -.St -isoC-99 . -.Sh HISTORY -The -.Fn wcstok -function was ported from -.Nx -and first appeared in -.Ox 3.8 . -.Pp -Some early implementations of -.Fn wcstok -omit the -context pointer argument, -.Fa last , -and maintain state across calls in a static variable like -.Xr strtok 3 -does. diff --git a/src/lib/libc/string/wcstok.c b/src/lib/libc/string/wcstok.c deleted file mode 100644 index bc1ac3e8cb..0000000000 --- a/src/lib/libc/string/wcstok.c +++ /dev/null @@ -1,93 +0,0 @@ -/* $OpenBSD: wcstok.c,v 1.3 2005/08/08 08:05:37 espie Exp $ */ -/* $NetBSD: wcstok.c,v 1.3 2003/07/10 08:50:48 tshiozak Exp $ */ - -/*- - * Copyright (c) 1998 Softweyr LLC. All rights reserved. - * - * strtok_r, from Berkeley strtok - * Oct 13, 1998 by Wes Peters - * - * Copyright (c) 1988, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notices, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notices, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Softweyr LLC, the - * University of California, Berkeley, and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY SOFTWEYR LLC, THE REGENTS AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A - * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SOFTWEYR LLC, THE - * REGENTS, OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED - * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * Original version ID: - * FreeBSD: src/lib/libc/string/wcstok.c,v 1.1 2002/09/07 08:16:57 tjr Exp - */ - -#include - -wchar_t * -wcstok(wchar_t * __restrict s, const wchar_t * __restrict delim, - wchar_t ** __restrict last) -{ - const wchar_t *spanp; - wchar_t c, sc; - wchar_t *tok; - - if (s == NULL && (s = *last) == NULL) - return (NULL); - - /* - * Skip (span) leading delimiters (s += wcsspn(s, delim), sort of). - */ -cont: - c = *s++; - for (spanp = delim; (sc = *spanp++) != L'\0';) { - if (c == sc) - goto cont; - } - - if (c == L'\0') { /* no non-delimiter characters */ - *last = NULL; - return (NULL); - } - tok = s - 1; - - /* - * Scan token (scan for delimiters: s += wcscspn(s, delim), sort of). - * Note that delim must have one NUL; we stop if we see that, too. - */ - for (;;) { - c = *s++; - spanp = delim; - do { - if ((sc = *spanp++) == c) { - if (c == L'\0') - s = NULL; - else - s[-1] = L'\0'; - *last = s; - return (tok); - } - } while (sc != L'\0'); - } - /* NOTREACHED */ -} 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 @@ -/* $OpenBSD: wcswcs.c,v 1.1 2005/04/13 16:35:58 espie Exp $ */ -/* $NetBSD: wcswcs.c,v 1.1 2003/03/05 20:18:17 tshiozak Exp $ */ - -#define WCSWCS -#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 @@ -.\" $OpenBSD: wcswidth.3,v 1.2 2011/07/25 00:38:53 schwarze Exp $ -.\" -.\" Copyright (c) 2002 Tim J. Robbins -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.Dd $Mdocdate: July 25 2011 $ -.Dt WCSWIDTH 3 -.Os -.Sh NAME -.Nm wcswidth -.Nd number of column positions in wide-character string -.Sh SYNOPSIS -.In wchar.h -.Ft int -.Fn wcswidth "const wchar_t *pwcs" "size_t n" -.Sh DESCRIPTION -The -.Fn wcswidth -function determines the number of column positions required for the first -.Fa n -characters of -.Fa pwcs , -or until a null wide character (L'\e0') is encountered. -.Sh RETURN VALUES -The -.Fn wcswidth -function returns 0 if -.Fa pwcs -is an empty string (L""), -\-1 if a non-printing wide character is encountered, -otherwise it returns the number of column positions occupied. -.Sh SEE ALSO -.Xr iswprint 3 , -.Xr strlen 3 , -.Xr wcslen 3 , -.Xr wcwidth 3 -.Sh STANDARDS -The -.Fn wcswidth -function conforms to -.St -p1003.1-2001 . -.Sh HISTORY -The -.Fn wcswidth -function was ported from -.Nx -and first appeared in -.Ox 3.8 . diff --git a/src/lib/libc/string/wcswidth.c b/src/lib/libc/string/wcswidth.c deleted file mode 100644 index 9f003f96c7..0000000000 --- a/src/lib/libc/string/wcswidth.c +++ /dev/null @@ -1,51 +0,0 @@ -/* $OpenBSD: wcswidth.c,v 1.5 2015/09/12 16:23:14 guenther Exp $ */ -/* $NetBSD: wcswidth.c,v 1.2 2001/01/03 14:29:37 lukem Exp $ */ - -/*- - * Copyright (c)1999 Citrus Project, - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * citrus Id: wcswidth.c,v 1.1 1999/12/29 21:47:45 tshiozak Exp - */ - -#include - -int -wcswidth(const wchar_t *s, size_t n) -{ - int w, q; - - w = 0; - while (n && *s) { - q = wcwidth(*s); - if (q == -1) - return (-1); - w += q; - s++; - n--; - } - - return w; -} -DEF_WEAK(wcswidth); diff --git a/src/lib/libc/string/wmemchr.3 b/src/lib/libc/string/wmemchr.3 deleted file mode 100644 index 17fbc9dbc5..0000000000 --- a/src/lib/libc/string/wmemchr.3 +++ /dev/null @@ -1,81 +0,0 @@ -.\" $OpenBSD: wmemchr.3,v 1.10 2013/06/05 03:39:23 tedu Exp $ -.\" -.\" Copyright (c) 1990, 1991 The Regents of the University of California. -.\" All rights reserved. -.\" -.\" This code is derived from software contributed to Berkeley by -.\" Chris Torek and the American National Standards Committee X3, -.\" on Information Processing Systems. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.Dd $Mdocdate: June 5 2013 $ -.Dt WMEMCHR 3 -.Os -.Sh NAME -.Nm wmemchr -.Nd locate wide character in wide string -.Sh SYNOPSIS -.In wchar.h -.Ft wchar_t * -.Fn wmemchr "const wchar_t *b" "wchar_t c" "size_t len" -.Sh DESCRIPTION -The -.Fn wmemchr -function locates the first occurrence of -.Fa c -in wide string -.Fa b . -.Sh RETURN VALUES -The -.Fn wmemchr -function returns a pointer to the wide character located, or -.Dv NULL -if no such wide character exists within -.Fa len -wide characters. -.Sh SEE ALSO -.Xr memchr 3 , -.Xr wcschr 3 , -.Xr wcscspn 3 , -.Xr wcspbrk 3 , -.Xr wcsrchr 3 , -.Xr wcsspn 3 , -.Xr wcsstr 3 , -.Xr wcstok 3 -.Sh STANDARDS -The -.Fn wmemchr -function conforms to -.St -isoC-99 -and was first introduced in -.St -isoC-amd1 . -.Sh HISTORY -The -.Fn wmemchr -function was ported from -.Nx -and first appeared in -.Ox 3.8 . diff --git a/src/lib/libc/string/wmemchr.c b/src/lib/libc/string/wmemchr.c deleted file mode 100644 index 556a0b35cc..0000000000 --- a/src/lib/libc/string/wmemchr.c +++ /dev/null @@ -1,47 +0,0 @@ -/* $OpenBSD: wmemchr.c,v 1.5 2015/10/01 02:32:07 guenther Exp $ */ -/* $NetBSD: wmemchr.c,v 1.2 2001/01/03 14:29:37 lukem Exp $ */ - -/*- - * Copyright (c)1999 Citrus Project, - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * citrus Id: wmemchr.c,v 1.2 2000/12/20 14:08:31 itojun Exp - */ - -#include - -wchar_t * -wmemchr(const wchar_t *s, wchar_t c, size_t n) -{ - size_t i; - - for (i = 0; i < n; i++) { - if (*s == c) { - return (wchar_t *)s; - } - s++; - } - return NULL; -} -DEF_STRONG(wmemchr); diff --git a/src/lib/libc/string/wmemcmp.3 b/src/lib/libc/string/wmemcmp.3 deleted file mode 100644 index bd8ddfd120..0000000000 --- a/src/lib/libc/string/wmemcmp.3 +++ /dev/null @@ -1,78 +0,0 @@ -.\" $OpenBSD: wmemcmp.3,v 1.3 2013/06/05 03:39:23 tedu Exp $ -.\" -.\" Copyright (c) 1990, 1991 The Regents of the University of California. -.\" All rights reserved. -.\" -.\" This code is derived from software contributed to Berkeley by -.\" Chris Torek and the American National Standards Committee X3, -.\" on Information Processing Systems. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.Dd $Mdocdate: June 5 2013 $ -.Dt WMEMCMP 3 -.Os -.Sh NAME -.Nm wmemcmp -.Nd compare wide strings -.Sh SYNOPSIS -.In wchar.h -.Ft int -.Fn wmemcmp "const wchar_t *s1" "const wchar_t *s2" "size_t len" -.Sh DESCRIPTION -The -.Fn wmemcmp -function compares the wide string -.Fa s1 -against the wide string -.Fa s2 . -Both wide strings are assumed to be -.Fa len -wide characters long. -.Sh RETURN VALUES -The -.Fn wmemcmp -function returns zero if the two wide strings are identical, -otherwise the difference between the first two differing wide characters is -returned. -Zero-length wide strings are always identical. -.Sh SEE ALSO -.Xr memcmp 3 , -.Xr wcscasecmp 3 , -.Xr wcscmp 3 -.Sh STANDARDS -The -.Fn wmemcmp -function conforms to -.St -isoC-99 -and was first introduced in -.St -isoC-amd1 . -.Sh HISTORY -The -.Fn wmemcmp -function was ported from -.Nx -and first appeared in -.Ox 3.8 . diff --git a/src/lib/libc/string/wmemcmp.c b/src/lib/libc/string/wmemcmp.c deleted file mode 100644 index 46617e29cf..0000000000 --- a/src/lib/libc/string/wmemcmp.c +++ /dev/null @@ -1,51 +0,0 @@ -/* $OpenBSD: wmemcmp.c,v 1.5 2015/09/12 16:23:14 guenther Exp $ */ -/* $NetBSD: wmemcmp.c,v 1.3 2003/04/06 18:33:23 tshiozak Exp $ */ - -/*- - * Copyright (c)1999 Citrus Project, - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * citrus Id: wmemcmp.c,v 1.2 2000/12/20 14:08:31 itojun Exp - */ - -#include -#include "locale/runetype.h" - -int -wmemcmp(const wchar_t *s1, const wchar_t *s2, size_t n) -{ - size_t i; - - for (i = 0; i < n; i++) { - if (*s1 != *s2) { - /* wchar might be unsigned */ - return *(const rune_t *)s1 > - *(const rune_t *)s2 ? 1 : -1; - } - s1++; - s2++; - } - return 0; -} -DEF_STRONG(wmemcmp); diff --git a/src/lib/libc/string/wmemcpy.3 b/src/lib/libc/string/wmemcpy.3 deleted file mode 100644 index 2a6d528a1a..0000000000 --- a/src/lib/libc/string/wmemcpy.3 +++ /dev/null @@ -1,79 +0,0 @@ -.\" $OpenBSD: wmemcpy.3,v 1.5 2013/06/05 03:39:23 tedu Exp $ -.\" -.\" Copyright (c) 1990, 1991 The Regents of the University of California. -.\" All rights reserved. -.\" -.\" This code is derived from software contributed to Berkeley by -.\" Chris Torek and the American National Standards Committee X3, -.\" on Information Processing Systems. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.Dd $Mdocdate: June 5 2013 $ -.Dt WMEMCPY 3 -.Os -.Sh NAME -.Nm wmemcpy -.Nd copy wide characters -.Sh SYNOPSIS -.In wchar.h -.Ft wchar_t * -.Fn wmemcpy "wchar_t * restrict dst" "const wchar_t * restrict src" "size_t len" -.Sh DESCRIPTION -The -.Fn wmemcpy -function copies -.Fa len -wide characters from buffer -.Fa src -to buffer -.Fa dst . -If the two buffers may overlap, -.Xr wmemmove 3 -must be used instead. -.Sh RETURN VALUES -The -.Fn wmemcpy -function returns the original value of -.Fa dst . -.Sh SEE ALSO -.Xr memcpy 3 , -.Xr wcscpy 3 , -.Xr wcslcpy 3 , -.Xr wmemmove 3 -.Sh STANDARDS -The -.Fn wmemcpy -function conforms to -.St -isoC-99 -and was first introduced in -.St -isoC-amd1 . -.Sh HISTORY -The -.Fn wmemcpy -function was ported from -.Nx -and first appeared in -.Ox 3.8 . diff --git a/src/lib/libc/string/wmemcpy.c b/src/lib/libc/string/wmemcpy.c deleted file mode 100644 index cf02ab9d56..0000000000 --- a/src/lib/libc/string/wmemcpy.c +++ /dev/null @@ -1,41 +0,0 @@ -/* $OpenBSD: wmemcpy.c,v 1.4 2015/09/12 16:23:14 guenther Exp $ */ -/* $NetBSD: wmemcpy.c,v 1.2 2001/01/03 14:29:37 lukem Exp $ */ - -/*- - * Copyright (c)1999 Citrus Project, - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * citrus Id: wmemcpy.c,v 1.2 2000/12/20 14:08:31 itojun Exp - */ - -#include -#include - -wchar_t * -wmemcpy(wchar_t *d, const wchar_t *s, size_t n) -{ - - return (wchar_t *)memcpy(d, s, n * sizeof(wchar_t)); -} -DEF_STRONG(wmemcpy); diff --git a/src/lib/libc/string/wmemmove.3 b/src/lib/libc/string/wmemmove.3 deleted file mode 100644 index 46942e7928..0000000000 --- a/src/lib/libc/string/wmemmove.3 +++ /dev/null @@ -1,78 +0,0 @@ -.\" $OpenBSD: wmemmove.3,v 1.3 2013/06/05 03:39:23 tedu Exp $ -.\" -.\" Copyright (c) 1990, 1991 The Regents of the University of California. -.\" All rights reserved. -.\" -.\" This code is derived from software contributed to Berkeley by -.\" Chris Torek and the American National Standards Committee X3, -.\" on Information Processing Systems. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.Dd $Mdocdate: June 5 2013 $ -.Dt WMEMMOVE 3 -.Os -.Sh NAME -.Nm wmemmove -.Nd copy wide characters -.Sh SYNOPSIS -.In wchar.h -.Ft wchar_t * -.Fn wmemmove "wchar_t *dst" "const wchar_t *src" "size_t len" -.Sh DESCRIPTION -The -.Fn wmemmove -function copies -.Fa len -wide characters from buffer -.Fa src -to buffer -.Fa dst . -The two buffers may overlap; -the copy is always done in a non-destructive manner. -.Sh RETURN VALUES -The -.Fn wmemmove -function returns the original value of -.Fa dst . -.Sh SEE ALSO -.Xr memmove 3 , -.Xr wcscpy 3 , -.Xr wcslcpy 3 , -.Xr wmemcpy 3 -.Sh STANDARDS -The -.Fn wmemmove -function conforms to -.St -isoC-99 -and was first introduced in -.St -isoC-amd1 . -.Sh HISTORY -The -.Fn wmemmove -function was ported from -.Nx -and first appeared in -.Ox 3.8 . diff --git a/src/lib/libc/string/wmemmove.c b/src/lib/libc/string/wmemmove.c deleted file mode 100644 index 8bf8011064..0000000000 --- a/src/lib/libc/string/wmemmove.c +++ /dev/null @@ -1,41 +0,0 @@ -/* $OpenBSD: wmemmove.c,v 1.4 2015/09/12 16:23:14 guenther Exp $ */ -/* $NetBSD: wmemmove.c,v 1.2 2001/01/03 14:29:37 lukem Exp $ */ - -/*- - * Copyright (c)1999 Citrus Project, - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * citrus Id: wmemmove.c,v 1.2 2000/12/20 14:08:31 itojun Exp - */ - -#include -#include - -wchar_t * -wmemmove(wchar_t *d, const wchar_t *s, size_t n) -{ - - return (wchar_t *)memmove(d, s, n * sizeof(wchar_t)); -} -DEF_STRONG(wmemmove); diff --git a/src/lib/libc/string/wmemset.3 b/src/lib/libc/string/wmemset.3 deleted file mode 100644 index 2655d68bcb..0000000000 --- a/src/lib/libc/string/wmemset.3 +++ /dev/null @@ -1,73 +0,0 @@ -.\" $OpenBSD: wmemset.3,v 1.4 2013/06/05 03:39:23 tedu Exp $ -.\" -.\" Copyright (c) 1990, 1991 The Regents of the University of California. -.\" All rights reserved. -.\" -.\" This code is derived from software contributed to Berkeley by -.\" Chris Torek and the American National Standards Committee X3, -.\" on Information Processing Systems. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.Dd $Mdocdate: June 5 2013 $ -.Dt WMEMSET 3 -.Os -.Sh NAME -.Nm wmemset -.Nd write a wide string -.Sh SYNOPSIS -.In wchar.h -.Ft wchar_t * -.Fn wmemset "wchar_t *s" "wchar_t c" "size_t len" -.Sh DESCRIPTION -The -.Fn wmemset -function writes -.Fa len -wide characters of value -.Fa c -to the wide string -.Fa s . -.Sh RETURN VALUES -The -.Fn wmemset -function returns the original value of -.Fa s . -.Sh SEE ALSO -.Xr memset 3 -.Sh STANDARDS -The -.Fn wmemset -function conforms to -.St -isoC-99 -and was first introduced in -.St -isoC-amd1 . -.Sh HISTORY -The -.Fn wmemset -function was ported from -.Nx -and first appeared in -.Ox 3.8 . diff --git a/src/lib/libc/string/wmemset.c b/src/lib/libc/string/wmemset.c deleted file mode 100644 index a2d3295170..0000000000 --- a/src/lib/libc/string/wmemset.c +++ /dev/null @@ -1,47 +0,0 @@ -/* $OpenBSD: wmemset.c,v 1.4 2015/09/12 16:23:14 guenther Exp $ */ -/* $NetBSD: wmemset.c,v 1.2 2001/01/03 14:29:37 lukem Exp $ */ - -/*- - * Copyright (c)1999 Citrus Project, - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * citrus Id: wmemset.c,v 1.2 2000/12/20 14:08:31 itojun Exp - */ - -#include - -wchar_t * -wmemset(wchar_t *s, wchar_t c, size_t n) -{ - size_t i; - wchar_t *p; - - p = s; - for (i = 0; i < n; i++) { - *p = c; - p++; - } - return s; -} -DEF_STRONG(wmemset); -- cgit v1.2.3-55-g6feb