diff options
| author | christos <christos@NetBSD.org> | 2005-12-20 19:31:47 +0000 |
|---|---|---|
| committer | christos <christos@NetBSD.org> | 2005-12-20 19:31:47 +0000 |
| commit | e5548b402ae4c44fb816de42c7bba9581ce23ef5 (patch) | |
| tree | aa46525727f64a730561e59ba27e3f42e87e382a /lib/libc/string | |
| parent | 37c9f0a654f1f14465cded15c4577522438c5585 (diff) | |
Use reach-over sources from common/lib/libc
Diffstat (limited to 'lib/libc/string')
| -rw-r--r-- | lib/libc/string/Makefile.inc | 8 | ||||
| -rw-r--r-- | lib/libc/string/bcmp.c | 70 | ||||
| -rw-r--r-- | lib/libc/string/bcopy.c | 153 | ||||
| -rw-r--r-- | lib/libc/string/bzero.c | 4 | ||||
| -rw-r--r-- | lib/libc/string/ffs.c | 61 | ||||
| -rw-r--r-- | lib/libc/string/index.c | 73 | ||||
| -rw-r--r-- | lib/libc/string/memchr.c | 70 | ||||
| -rw-r--r-- | lib/libc/string/memcmp.c | 72 | ||||
| -rw-r--r-- | lib/libc/string/memcpy.c | 4 | ||||
| -rw-r--r-- | lib/libc/string/memmove.c | 4 | ||||
| -rw-r--r-- | lib/libc/string/memset.c | 144 | ||||
| -rw-r--r-- | lib/libc/string/rindex.c | 75 | ||||
| -rw-r--r-- | lib/libc/string/strcasecmp.c | 90 | ||||
| -rw-r--r-- | lib/libc/string/strcat.c | 65 | ||||
| -rw-r--r-- | lib/libc/string/strchr.c | 4 | ||||
| -rw-r--r-- | lib/libc/string/strcmp.c | 68 | ||||
| -rw-r--r-- | lib/libc/string/strcpy.c | 62 | ||||
| -rw-r--r-- | lib/libc/string/strlcat.c | 87 | ||||
| -rw-r--r-- | lib/libc/string/strlcpy.c | 83 | ||||
| -rw-r--r-- | lib/libc/string/strlen.c | 61 | ||||
| -rw-r--r-- | lib/libc/string/strncmp.c | 69 | ||||
| -rw-r--r-- | lib/libc/string/strncpy.c | 81 | ||||
| -rw-r--r-- | lib/libc/string/strrchr.c | 4 | ||||
| -rw-r--r-- | lib/libc/string/strstr.c | 71 |
24 files changed, 10 insertions, 1473 deletions
diff --git a/lib/libc/string/Makefile.inc b/lib/libc/string/Makefile.inc index cf266efcde2..ac847a0cf17 100644 --- a/lib/libc/string/Makefile.inc +++ b/lib/libc/string/Makefile.inc @@ -1,12 +1,12 @@ # from: @(#)Makefile.inc 8.1 (Berkeley) 6/4/93 -# $NetBSD: Makefile.inc,v 1.58 2005/07/30 15:21:21 christos Exp $ +# $NetBSD: Makefile.inc,v 1.59 2005/12/20 19:31:50 christos Exp $ # string sources .PATH: ${ARCHDIR}/string ${.CURDIR}/string -SRCS+= bm.c strcasecmp.c strcasestr.c strcoll.c strdup.c strerror.c \ - strlcat.c strlcpy.c strmode.c strsignal.c strtok.c strtok_r.c \ - strxfrm.c __strsignal.c strerror_r.c +SRCS+= bm.c strcasecmp.c strncasecmp.c strcasestr.c strcoll.c strdup.c \ + strerror.c strlcat.c strlcpy.c strmode.c strsignal.c strtok.c \ + strtok_r.c strxfrm.c __strsignal.c strerror_r.c # wide char SRCS+= wcscat.c wcschr.c wcscmp.c wcscpy.c wcscspn.c wcslcat.c wcslcpy.c \ diff --git a/lib/libc/string/bcmp.c b/lib/libc/string/bcmp.c deleted file mode 100644 index 9901b31722e..00000000000 --- a/lib/libc/string/bcmp.c +++ /dev/null @@ -1,70 +0,0 @@ -/* $NetBSD: bcmp.c,v 1.14 2003/08/07 16:43:46 agc 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 <sys/cdefs.h> -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)bcmp.c 8.1 (Berkeley) 6/4/93"; -#else -__RCSID("$NetBSD: bcmp.c,v 1.14 2003/08/07 16:43:46 agc Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - - -#if !defined(_KERNEL) && !defined(_STANDALONE) -#include <assert.h> -#include <string.h> -#else -#define _DIAGASSERT(x) (void)0 -#include <lib/libkern/libkern.h> -#endif - -/* - * bcmp -- vax cmpc3 instruction - */ -int -bcmp(b1, b2, length) - const void *b1, *b2; - size_t length; -{ - const char *p1 = b1, *p2 = b2; - - _DIAGASSERT(b1 != 0); - _DIAGASSERT(b2 != 0); - - if (length == 0) - return(0); - do - if (*p1++ != *p2++) - break; - while (--length); - return(length); -} diff --git a/lib/libc/string/bcopy.c b/lib/libc/string/bcopy.c deleted file mode 100644 index 6fd210c5d90..00000000000 --- a/lib/libc/string/bcopy.c +++ /dev/null @@ -1,153 +0,0 @@ -/* $NetBSD: bcopy.c,v 1.15 2003/08/07 16:43:47 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 <sys/cdefs.h> -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)bcopy.c 8.1 (Berkeley) 6/4/93"; -#else -__RCSID("$NetBSD: bcopy.c,v 1.15 2003/08/07 16:43:47 agc Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#if !defined(_KERNEL) && !defined(_STANDALONE) -#include <assert.h> -#include <string.h> -#else -#include <lib/libkern/libkern.h> -#define _DIAGASSERT(x) (void)0 -#endif - -/* - * 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. - * This is the routine that actually implements - * (the portable versions of) bcopy, memcpy, and memmove. - */ -#ifdef MEMCOPY -void * -memcpy(dst0, src0, length) -#else -#ifdef MEMMOVE -void * -memmove(dst0, src0, length) -#else -void -bcopy(src0, dst0, length) -#endif -#endif - void *dst0; - const void *src0; - size_t length; -{ - char *dst = dst0; - const char *src = src0; - size_t t; - unsigned long u; - - _DIAGASSERT(dst0 != 0); - _DIAGASSERT(src0 != 0); - - 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. - */ - u = (unsigned long)src; /* only need low bits */ - if ((u | (unsigned long)dst) & wmask) { - /* - * Try to align operands. This cannot be done - * unless the low bits match. - */ - if ((u ^ (unsigned long)dst) & wmask || length < wsize) - t = length; - else - t = wsize - (size_t)(u & wmask); - length -= t; - TLOOP1(*dst++ = *src++); - } - /* - * Copy whole words, then mop up any trailing bytes. - */ - t = length / wsize; - TLOOP(*(word *)(void *)dst = *(const word *)(const void *)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; - _DIAGASSERT((unsigned long)dst >= (unsigned long)dst0); - _DIAGASSERT((unsigned long)src >= (unsigned long)src0); - u = (unsigned long)src; - if ((u | (unsigned long)dst) & wmask) { - if ((u ^ (unsigned long)dst) & wmask || length <= wsize) - t = length; - else - t = (size_t)(u & wmask); - length -= t; - TLOOP1(*--dst = *--src); - } - t = length / wsize; - TLOOP(src -= wsize; dst -= wsize; *(word *)(void *)dst = *(const word *)(const void *)src); - t = length & wmask; - TLOOP(*--dst = *--src); - } -done: -#if defined(MEMCOPY) || defined(MEMMOVE) - return (dst0); -#else - return; -#endif -} diff --git a/lib/libc/string/bzero.c b/lib/libc/string/bzero.c deleted file mode 100644 index a329af6ac42..00000000000 --- a/lib/libc/string/bzero.c +++ /dev/null @@ -1,4 +0,0 @@ -/* $NetBSD: bzero.c,v 1.8 1998/08/04 06:25:10 perry Exp $ */ - -#define BZERO -#include "memset.c" diff --git a/lib/libc/string/ffs.c b/lib/libc/string/ffs.c deleted file mode 100644 index 4b5c04ff302..00000000000 --- a/lib/libc/string/ffs.c +++ /dev/null @@ -1,61 +0,0 @@ -/* $NetBSD: ffs.c,v 1.10 2003/08/07 16:43:47 agc 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 <sys/cdefs.h> -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)ffs.c 8.1 (Berkeley) 6/4/93"; -#else -__RCSID("$NetBSD: ffs.c,v 1.10 2003/08/07 16:43:47 agc Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#if !defined(_KERNEL) && !defined(_STANDALONE) -#include <string.h> -#else -#include <lib/libkern/libkern.h> -#endif - -/* - * ffs -- vax ffs instruction - */ -int -ffs(mask) - int mask; -{ - int bit; - - if (mask == 0) - return(0); - for (bit = 1; !(mask & 1); bit++) - mask >>= 1; - return(bit); -} diff --git a/lib/libc/string/index.c b/lib/libc/string/index.c index c80981c57c8..6258e6b7741 100644 --- a/lib/libc/string/index.c +++ b/lib/libc/string/index.c @@ -1,70 +1,3 @@ -/* $NetBSD: index.c,v 1.14 2005/11/30 09:35:58 martin 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 <sys/cdefs.h> -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)index.c 8.1 (Berkeley) 6/4/93"; -#else -__RCSID("$NetBSD: index.c,v 1.14 2005/11/30 09:35:58 martin Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#if !defined(_KERNEL) && !defined(_STANDALONE) -#include "namespace.h" -#include <assert.h> -#include <string.h> -#else -#include <lib/libkern/libkern.h> -#define _DIAGASSERT(x) (void)0 -#define NULL ((char *)0) -#endif - -char * -#ifdef STRCHR -strchr(p, ch) -#else -index(p, ch) -#endif - const char *p, ch; -{ - _DIAGASSERT(p != NULL); - - for (;; ++p) { - if (*p == ch) { - /* LINTED const cast-away */ - return(__UNCONST(p)); - } - if (!*p) - return((char *)NULL); - } - /* NOTREACHED */ -} +/* $NetBSD: index.c,v 1.15 2005/12/20 19:31:50 christos Exp $ */ +#define INDEX +#include "strchr.c" diff --git a/lib/libc/string/memchr.c b/lib/libc/string/memchr.c deleted file mode 100644 index 9eb47d81fa9..00000000000 --- a/lib/libc/string/memchr.c +++ /dev/null @@ -1,70 +0,0 @@ -/* $NetBSD: memchr.c,v 1.13 2005/11/29 18:48:02 christos 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 <sys/cdefs.h> -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)memchr.c 8.1 (Berkeley) 6/4/93"; -#else -__RCSID("$NetBSD: memchr.c,v 1.13 2005/11/29 18:48:02 christos Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#if !defined(_KERNEL) && !defined(_STANDALONE) -#include <assert.h> -#include <string.h> -#else -#include <lib/libkern/libkern.h> -#define _DIAGASSERT(x) (void)0 -#define NULL ((char *)0) -#endif - -void * -memchr(s, c, n) - const void *s; - unsigned char c; - size_t n; -{ - _DIAGASSERT(s != NULL); - - if (n != 0) { - const unsigned char *p = s; - - do { - if (*p++ == c) - return __UNCONST(p - 1); - } while (--n != 0); - } - return NULL; -} diff --git a/lib/libc/string/memcmp.c b/lib/libc/string/memcmp.c deleted file mode 100644 index 19426ab7227..00000000000 --- a/lib/libc/string/memcmp.c +++ /dev/null @@ -1,72 +0,0 @@ -/* $NetBSD: memcmp.c,v 1.12 2003/08/07 16:43:48 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 <sys/cdefs.h> -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)memcmp.c 8.1 (Berkeley) 6/4/93"; -#else -__RCSID("$NetBSD: memcmp.c,v 1.12 2003/08/07 16:43:48 agc Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#if !defined(_KERNEL) && !defined(_STANDALONE) -#include <assert.h> -#include <string.h> -#else -#include <lib/libkern/libkern.h> -#define _DIAGASSERT(x) (void)0 -#endif - -/* - * Compare memory regions. - */ -int -memcmp(s1, s2, n) - const void *s1, *s2; - size_t n; -{ - _DIAGASSERT(s1 != 0); - _DIAGASSERT(s2 != 0); - - if (n != 0) { - const unsigned char *p1 = s1, *p2 = s2; - - do { - if (*p1++ != *p2++) - return (*--p1 - *--p2); - } while (--n != 0); - } - return (0); -} diff --git a/lib/libc/string/memcpy.c b/lib/libc/string/memcpy.c deleted file mode 100644 index 9a959423114..00000000000 --- a/lib/libc/string/memcpy.c +++ /dev/null @@ -1,4 +0,0 @@ -/* $NetBSD: memcpy.c,v 1.1 1998/08/04 04:48:17 perry Exp $ */ - -#define MEMCOPY -#include "bcopy.c" diff --git a/lib/libc/string/memmove.c b/lib/libc/string/memmove.c deleted file mode 100644 index 3c2658fab18..00000000000 --- a/lib/libc/string/memmove.c +++ /dev/null @@ -1,4 +0,0 @@ -/* $NetBSD: memmove.c,v 1.1 1998/08/04 04:48:17 perry Exp $ */ - -#define MEMMOVE -#include "bcopy.c" diff --git a/lib/libc/string/memset.c b/lib/libc/string/memset.c deleted file mode 100644 index 3ee0ba267d8..00000000000 --- a/lib/libc/string/memset.c +++ /dev/null @@ -1,144 +0,0 @@ -/* $NetBSD: memset.c,v 1.16 2003/08/07 16:43:49 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 - * Mike Hibler and 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 <sys/cdefs.h> -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)memset.c 8.1 (Berkeley) 6/4/93"; -#else -__RCSID("$NetBSD: memset.c,v 1.16 2003/08/07 16:43:49 agc Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#include <sys/types.h> - -#if !defined(_KERNEL) && !defined(_STANDALONE) -#include <assert.h> -#include <limits.h> -#include <string.h> -#else -#include <lib/libkern/libkern.h> -#include <machine/limits.h> -#define _DIAGASSERT(x) (void)0 -#endif - -#define wsize sizeof(u_int) -#define wmask (wsize - 1) - -#ifdef BZERO -#define RETURN return -#define VAL 0 -#define WIDEVAL 0 - -void -bzero(dst0, length) - void *dst0; - size_t length; -#else -#define RETURN return (dst0) -#define VAL c0 -#define WIDEVAL c - -void * -memset(dst0, c0, length) - void *dst0; - int c0; - size_t length; -#endif -{ - size_t t; -#ifndef BZERO - u_int c; -#endif - u_char *dst; - - _DIAGASSERT(dst0 != 0); - - dst = dst0; - /* - * If not enough words, just fill bytes. A length >= 2 words - * guarantees that at least one of them is `complete' after - * any necessary alignment. For instance: - * - * |-----------|-----------|-----------| - * |00|01|02|03|04|05|06|07|08|09|0A|00| - * ^---------------------^ - * dst dst+length-1 - * - * but we use a minimum of 3 here since the overhead of the code - * to do word writes is substantial. - */ - if (length < 3 * wsize) { - while (length != 0) { - *dst++ = VAL; - --length; - } - RETURN; - } - -#ifndef BZERO - if ((c = (u_char)c0) != 0) { /* Fill the word. */ - c = (c << 8) | c; /* u_int is 16 bits. */ -#if UINT_MAX > 0xffff - c = (c << 16) | c; /* u_int is 32 bits. */ -#endif -#if UINT_MAX > 0xffffffff - c = (c << 32) | c; /* u_int is 64 bits. */ -#endif - } -#endif - /* Align destination by filling in bytes. */ - if ((t = (size_t)((u_long)dst & wmask)) != 0) { - t = wsize - t; - length -= t; - do { - *dst++ = VAL; - } while (--t != 0); - } - - /* Fill words. Length was >= 2*words so we know t >= 1 here. */ - t = length / wsize; - do { - *(u_int *)(void *)dst = WIDEVAL; - dst += wsize; - } while (--t != 0); - - /* Mop up trailing bytes, if any. */ - t = length & wmask; - if (t != 0) - do { - *dst++ = VAL; - } while (--t != 0); - RETURN; -} diff --git a/lib/libc/string/rindex.c b/lib/libc/string/rindex.c index ad0f9366240..1976d7304b4 100644 --- a/lib/libc/string/rindex.c +++ b/lib/libc/string/rindex.c @@ -1,72 +1,3 @@ -/* $NetBSD: rindex.c,v 1.14 2005/11/30 09:55:14 martin 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 <sys/cdefs.h> -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)rindex.c 8.1 (Berkeley) 6/4/93"; -#else -__RCSID("$NetBSD: rindex.c,v 1.14 2005/11/30 09:55:14 martin Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#if !defined(_KERNEL) && !defined(_STANDALONE) -#include <assert.h> -#include <string.h> -#else -#include <lib/libkern/libkern.h> -#define _DIAGASSERT(x) (void)0 -#define NULL ((char *)0) -#endif - -char * -#ifdef STRRCHR -strrchr(p, ch) -#else -rindex(p, ch) -#endif - const char *p; - int ch; -{ - char *save; - - _DIAGASSERT(p != NULL); - - for (save = NULL;; ++p) { - if (*p == ch) { - /* LINTED const cast-away */ - save = __UNCONST(p); - } - if (!*p) - return(save); - } - /* NOTREACHED */ -} +/* $NetBSD: rindex.c,v 1.15 2005/12/20 19:31:50 christos Exp $ */ +#define RINDEX +#include "strrchr.c" diff --git a/lib/libc/string/strcasecmp.c b/lib/libc/string/strcasecmp.c deleted file mode 100644 index 8f1b4aab19f..00000000000 --- a/lib/libc/string/strcasecmp.c +++ /dev/null @@ -1,90 +0,0 @@ -/* $NetBSD: strcasecmp.c,v 1.16 2003/08/07 16:43:49 agc 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 <sys/cdefs.h> -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)strcasecmp.c 8.1 (Berkeley) 6/4/93"; -#else -__RCSID("$NetBSD: strcasecmp.c,v 1.16 2003/08/07 16:43:49 agc Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include <assert.h> -#include <ctype.h> -#include <string.h> - -#ifdef __weak_alias -__weak_alias(strcasecmp,_strcasecmp) -__weak_alias(strncasecmp,_strncasecmp) -#endif - -int -strcasecmp(s1, s2) - const char *s1, *s2; -{ - const unsigned char *us1 = (const unsigned char *)s1, - *us2 = (const unsigned char *)s2; - - _DIAGASSERT(s1 != NULL); - _DIAGASSERT(s2 != NULL); - - while (tolower(*us1) == tolower(*us2++)) - if (*us1++ == '\0') - return (0); - return (tolower(*us1) - tolower(*--us2)); -} - -int -strncasecmp(s1, s2, n) - const char *s1, *s2; - size_t n; -{ - - _DIAGASSERT(s1 != NULL); - _DIAGASSERT(s2 != NULL); - if (s1 == NULL || s2 == NULL) - return (0); - - if (n != 0) { - const unsigned char *us1 = (const unsigned char *)s1, - *us2 = (const unsigned char *)s2; - - do { - if (tolower(*us1) != tolower(*us2++)) - return (tolower(*us1) - tolower(*--us2)); - if (*us1++ == '\0') - break; - } while (--n != 0); - } - return (0); -} diff --git a/lib/libc/string/strcat.c b/lib/libc/string/strcat.c deleted file mode 100644 index 919ade4f41e..00000000000 --- a/lib/libc/string/strcat.c +++ /dev/null @@ -1,65 +0,0 @@ -/* $NetBSD: strcat.c,v 1.13 2003/08/07 16:43:49 agc 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 <sys/cdefs.h> -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)strcat.c 8.1 (Berkeley) 6/4/93"; -#else -__RCSID("$NetBSD: strcat.c,v 1.13 2003/08/07 16:43:49 agc Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#if !defined(_KERNEL) && !defined(_STANDALONE) -#include <assert.h> -#include <string.h> -#else -#include <lib/libkern/libkern.h> -#define _DIAGASSERT(x) (void)0 -#define NULL ((char *)0) -#endif - -char * -strcat(s, append) - char *s; - const char *append; -{ - char *t = s; - - _DIAGASSERT(t != NULL); - _DIAGASSERT(append != NULL); - - for (; *t; ++t) - ; - while ((*t++ = *append++) != '\0') - ; - return (s); -} diff --git a/lib/libc/string/strchr.c b/lib/libc/string/strchr.c deleted file mode 100644 index e2e38a614b4..00000000000 --- a/lib/libc/string/strchr.c +++ /dev/null @@ -1,4 +0,0 @@ -/* $NetBSD: strchr.c,v 1.1 1998/08/04 04:48:17 perry Exp $ */ - -#define STRCHR -#include "index.c" diff --git a/lib/libc/string/strcmp.c b/lib/libc/string/strcmp.c deleted file mode 100644 index 0d68e1108b9..00000000000 --- a/lib/libc/string/strcmp.c +++ /dev/null @@ -1,68 +0,0 @@ -/* $NetBSD: strcmp.c,v 1.13 2003/08/07 16:43:49 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 <sys/cdefs.h> -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)strcmp.c 8.1 (Berkeley) 6/4/93"; -#else -__RCSID("$NetBSD: strcmp.c,v 1.13 2003/08/07 16:43:49 agc Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#if !defined(_KERNEL) && !defined(_STANDALONE) -#include <assert.h> -#include <string.h> -#else -#include <lib/libkern/libkern.h> -#define _DIAGASSERT(x) (void)0 -#define NULL ((char *)0) -#endif - -/* - * Compare strings. - */ -int -strcmp(s1, s2) - const char *s1, *s2; -{ - - _DIAGASSERT(s1 != NULL); - _DIAGASSERT(s2 != NULL); - - while (*s1 == *s2++) - if (*s1++ == 0) - return (0); - return (*(const unsigned char *)s1 - *(const unsigned char *)--s2); -} diff --git a/lib/libc/string/strcpy.c b/lib/libc/string/strcpy.c deleted file mode 100644 index 88c843d9d0a..00000000000 --- a/lib/libc/string/strcpy.c +++ /dev/null @@ -1,62 +0,0 @@ -/* $NetBSD: strcpy.c,v 1.13 2003/08/07 16:43:50 agc 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 <sys/cdefs.h> -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)strcpy.c 8.1 (Berkeley) 6/4/93"; -#else -__RCSID("$NetBSD: strcpy.c,v 1.13 2003/08/07 16:43:50 agc Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#if !defined(_KERNEL) && !defined(_STANDALONE) -#include <assert.h> -#include <string.h> -#else -#include <lib/libkern/libkern.h> -#define _DIAGASSERT(x) (void)0 -#define NULL ((char *)0) -#endif - -char * -strcpy(to, from) - char *to; - const char *from; -{ - char *save = to; - - _DIAGASSERT(to != NULL); - _DIAGASSERT(from != NULL); - - for (; (*to = *from) != '\0'; ++from, ++to); - return(save); -} diff --git a/lib/libc/string/strlcat.c b/lib/libc/string/strlcat.c deleted file mode 100644 index db9d43c2250..00000000000 --- a/lib/libc/string/strlcat.c +++ /dev/null @@ -1,87 +0,0 @@ -/* $NetBSD: strlcat.c,v 1.16 2003/10/27 00:12:42 lukem Exp $ */ -/* $OpenBSD: strlcat.c,v 1.10 2003/04/12 21:56:39 millert Exp $ */ - -/* - * Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com> - * - * 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 TODD C. MILLER DISCLAIMS ALL - * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL TODD C. MILLER 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. - */ - -#if HAVE_NBTOOL_CONFIG_H -#include "nbtool_config.h" -#endif - -#include <sys/cdefs.h> -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: strlcat.c,v 1.16 2003/10/27 00:12:42 lukem Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#ifdef _LIBC -#include "namespace.h" -#endif -#include <sys/types.h> -#include <assert.h> -#include <string.h> - -#ifdef _LIBC -# ifdef __weak_alias -__weak_alias(strlcat, _strlcat) -# endif -#endif - -#if !HAVE_STRLCAT -/* - * Appends src to string dst of size siz (unlike strncat, siz is the - * full size of dst, not space left). At most siz-1 characters - * will be copied. Always NUL terminates (unless siz <= strlen(dst)). - * Returns strlen(src) + MIN(siz, strlen(initial dst)). - * If retval >= siz, truncation occurred. - */ -size_t -#ifdef _LIBC -_strlcat(dst, src, siz) -#else -strlcat(dst, src, siz) -#endif - char *dst; - const char *src; - size_t siz; -{ - char *d = dst; - const char *s = src; - size_t n = siz; - size_t dlen; - - _DIAGASSERT(dst != NULL); - _DIAGASSERT(src != NULL); - - /* Find the end of dst and adjust bytes left but don't go past end */ - while (n-- != 0 && *d != '\0') - d++; - dlen = d - dst; - n = siz - dlen; - - if (n == 0) - return(dlen + strlen(s)); - while (*s != '\0') { - if (n != 1) { - *d++ = *s; - n--; - } - s++; - } - *d = '\0'; - - return(dlen + (s - src)); /* count does not include NUL */ -} -#endif diff --git a/lib/libc/string/strlcpy.c b/lib/libc/string/strlcpy.c deleted file mode 100644 index fab8dac71bf..00000000000 --- a/lib/libc/string/strlcpy.c +++ /dev/null @@ -1,83 +0,0 @@ -/* $NetBSD: strlcpy.c,v 1.14 2003/10/27 00:12:42 lukem Exp $ */ -/* $OpenBSD: strlcpy.c,v 1.7 2003/04/12 21:56:39 millert Exp $ */ - -/* - * Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com> - * - * 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 TODD C. MILLER DISCLAIMS ALL - * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL TODD C. MILLER 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. - */ - -#if HAVE_NBTOOL_CONFIG_H -#include "nbtool_config.h" -#endif - -#include <sys/cdefs.h> -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: strlcpy.c,v 1.14 2003/10/27 00:12:42 lukem Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#ifdef _LIBC -#include "namespace.h" -#endif -#include <sys/types.h> -#include <assert.h> -#include <string.h> - -#ifdef _LIBC -# ifdef __weak_alias -__weak_alias(strlcpy, _strlcpy) -# endif -#endif - -#if !HAVE_STRLCPY -/* - * Copy src to string dst of size siz. At most siz-1 characters - * will be copied. Always NUL terminates (unless siz == 0). - * Returns strlen(src); if retval >= siz, truncation occurred. - */ -size_t -#ifdef _LIBC -_strlcpy(dst, src, siz) -#else -strlcpy(dst, src, siz) -#endif - char *dst; - const char *src; - size_t siz; -{ - char *d = dst; - const char *s = src; - size_t n = siz; - - _DIAGASSERT(dst != NULL); - _DIAGASSERT(src != NULL); - - /* Copy as many bytes as will fit */ - if (n != 0 && --n != 0) { - do { - if ((*d++ = *s++) == 0) - break; - } while (--n != 0); - } - - /* Not enough room in dst, add NUL and traverse rest of src */ - if (n == 0) { - if (siz != 0) - *d = '\0'; /* NUL-terminate dst */ - while (*s++) - ; - } - - return(s - src - 1); /* count does not include NUL */ -} -#endif diff --git a/lib/libc/string/strlen.c b/lib/libc/string/strlen.c deleted file mode 100644 index 622174f1582..00000000000 --- a/lib/libc/string/strlen.c +++ /dev/null @@ -1,61 +0,0 @@ -/* $NetBSD: strlen.c,v 1.13 2004/01/31 16:56:12 uebayasi 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 <sys/cdefs.h> -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)strlen.c 8.1 (Berkeley) 6/4/93"; -#else -__RCSID("$NetBSD: strlen.c,v 1.13 2004/01/31 16:56:12 uebayasi Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#if !defined(_KERNEL) && !defined(_STANDALONE) -#include <assert.h> -#include <string.h> -#else -#include <lib/libkern/libkern.h> -#define _DIAGASSERT(x) (void)0 -#define NULL ((char *)0) -#endif - -size_t -strlen(str) - const char *str; -{ - const char *s; - - _DIAGASSERT(str != NULL); - - for (s = str; *s; ++s) - continue; - return(s - str); -} diff --git a/lib/libc/string/strncmp.c b/lib/libc/string/strncmp.c deleted file mode 100644 index 72adc0a5fd2..00000000000 --- a/lib/libc/string/strncmp.c +++ /dev/null @@ -1,69 +0,0 @@ -/* $NetBSD: strncmp.c,v 1.13 2003/08/07 16:43:51 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 <sys/cdefs.h> -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)strncmp.c 8.1 (Berkeley) 6/4/93"; -#else -__RCSID("$NetBSD: strncmp.c,v 1.13 2003/08/07 16:43:51 agc Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#if !defined(_KERNEL) && !defined(_STANDALONE) -#include <assert.h> -#include <string.h> -#else -#include <lib/libkern/libkern.h> -#define _DIAGASSERT(x) (void)0 -#define NULL ((char *)0) -#endif - -int -strncmp(s1, s2, n) - const char *s1, *s2; - size_t n; -{ - - _DIAGASSERT(s1 != NULL); - _DIAGASSERT(s2 != NULL); - - if (n == 0) - return (0); - do { - if (*s1 != *s2++) - return (*(const unsigned char *)s1 - - *(const unsigned char *)--s2); - if (*s1++ == 0) - break; - } while (--n != 0); - return (0); -} diff --git a/lib/libc/string/strncpy.c b/lib/libc/string/strncpy.c deleted file mode 100644 index 008579dee4b..00000000000 --- a/lib/libc/string/strncpy.c +++ /dev/null @@ -1,81 +0,0 @@ -/* $NetBSD: strncpy.c,v 1.12 2003/08/07 16:43:51 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 <sys/cdefs.h> -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)strncpy.c 8.1 (Berkeley) 6/4/93"; -#else -__RCSID("$NetBSD: strncpy.c,v 1.12 2003/08/07 16:43:51 agc Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#if !defined(_KERNEL) && !defined(_STANDALONE) -#include <assert.h> -#include <string.h> -#else -#include <lib/libkern/libkern.h> -#define _DIAGASSERT(x) (void)0 -#define NULL ((char *)0) -#endif - -/* - * Copy src to dst, truncating or null-padding to always copy n bytes. - * Return dst. - */ -char * -strncpy(dst, src, n) - char *dst; - const char *src; - size_t n; -{ - - _DIAGASSERT(dst != NULL); - _DIAGASSERT(src != NULL); - - 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); -} diff --git a/lib/libc/string/strrchr.c b/lib/libc/string/strrchr.c deleted file mode 100644 index 6c94485e8e9..00000000000 --- a/lib/libc/string/strrchr.c +++ /dev/null @@ -1,4 +0,0 @@ -/* $NetBSD: strrchr.c,v 1.1 1998/08/04 04:48:17 perry Exp $ */ - -#define STRRCHR -#include "rindex.c" diff --git a/lib/libc/string/strstr.c b/lib/libc/string/strstr.c deleted file mode 100644 index d75331f7959..00000000000 --- a/lib/libc/string/strstr.c +++ /dev/null @@ -1,71 +0,0 @@ -/* $NetBSD: strstr.c,v 1.12 2005/11/29 03:12:00 christos 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 <sys/cdefs.h> -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)strstr.c 8.1 (Berkeley) 6/4/93"; -#else -__RCSID("$NetBSD: strstr.c,v 1.12 2005/11/29 03:12:00 christos Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#include <assert.h> -#include <string.h> - -/* - * Find the first occurrence of find in s. - */ -char * -strstr(s, find) - const char *s, *find; -{ - char c, sc; - size_t len; - - _DIAGASSERT(s != NULL); - _DIAGASSERT(find != NULL); - - if ((c = *find++) != 0) { - len = strlen(find); - do { - do { - if ((sc = *s++) == 0) - return (NULL); - } while (sc != c); - } while (strncmp(s, find, len) != 0); - s--; - } - return __UNCONST(s); -} |
