diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libc/string/Makefile.inc | 6 | ||||
-rw-r--r-- | lib/libc/string/Symbol.map | 2 | ||||
-rw-r--r-- | lib/libc/string/wcpcpy.c | 46 | ||||
-rw-r--r-- | lib/libc/string/wcpncpy.c | 45 | ||||
-rw-r--r-- | lib/libc/string/wmemchr.3 | 12 |
5 files changed, 108 insertions, 3 deletions
diff --git a/lib/libc/string/Makefile.inc b/lib/libc/string/Makefile.inc index cc46ceb..b0a1899 100644 --- a/lib/libc/string/Makefile.inc +++ b/lib/libc/string/Makefile.inc @@ -14,7 +14,7 @@ MISRCS+=bcmp.c bcopy.c bzero.c ffs.c ffsl.c ffsll.c fls.c flsl.c flsll.c \ strdup.c strerror.c strlcat.c strlcpy.c strlen.c strmode.c strncat.c \ strncmp.c strncpy.c strndup.c strnlen.c strnstr.c \ strpbrk.c strrchr.c strsep.c strsignal.c strspn.c strstr.c strtok.c \ - strxfrm.c swab.c wcscasecmp.c wcscat.c \ + strxfrm.c swab.c wcpcpy.c wcpncpy.c wcscasecmp.c wcscat.c \ wcschr.c wcscmp.c wcscoll.c wcscpy.c wcscspn.c wcsdup.c \ wcslcat.c wcslcpy.c wcslen.c wcsncasecmp.c wcsncat.c wcsncmp.c \ wcsncpy.c wcsnlen.c wcspbrk.c \ @@ -61,7 +61,9 @@ MLINKS+=strlen.3 strnlen.3 MLINKS+=strstr.3 strcasestr.3 \ strstr.3 strnstr.3 MLINKS+=strtok.3 strtok_r.3 -MLINKS+=wmemchr.3 wcscasecmp.3 \ +MLINKS+=wmemchr.3 wcpcpy.3 \ + wmemchr.3 wcpncpy.3 \ + wmemchr.3 wcscasecmp.3 \ wmemchr.3 wcscat.3 \ wmemchr.3 wcschr.3 \ wmemchr.3 wcscmp.3 \ diff --git a/lib/libc/string/Symbol.map b/lib/libc/string/Symbol.map index 4829559..19f3382 100644 --- a/lib/libc/string/Symbol.map +++ b/lib/libc/string/Symbol.map @@ -84,6 +84,8 @@ FBSD_1.1 { stpncpy; strndup; strnlen; + wcpcpy; + wcpncpy; wcscasecmp; wcsncasecmp; wcsnlen; diff --git a/lib/libc/string/wcpcpy.c b/lib/libc/string/wcpcpy.c new file mode 100644 index 0000000..df63d72 --- /dev/null +++ b/lib/libc/string/wcpcpy.c @@ -0,0 +1,46 @@ +/* + * Copyright (c) 1999 + * David E. O'Brien + * 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. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +static char sccsid[] = "@(#)strcpy.c 8.1 (Berkeley) 6/4/93"; +#endif /* LIBC_SCCS and not lint */ +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); + +#include <wchar.h> + +wchar_t * +wcpcpy(wchar_t * __restrict to, const wchar_t * __restrict from) +{ + + for (; (*to = *from); ++from, ++to); + return(to); +} diff --git a/lib/libc/string/wcpncpy.c b/lib/libc/string/wcpncpy.c new file mode 100644 index 0000000..87b361c --- /dev/null +++ b/lib/libc/string/wcpncpy.c @@ -0,0 +1,45 @@ +/*- + * Copyright (c) 2009 David Schultz <das@FreeBSD.org> + * 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. + */ + +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); + +#include <wchar.h> + +wchar_t * +wcpncpy(wchar_t * __restrict dst, const wchar_t * __restrict src, size_t n) +{ + + for (; n--; dst++, src++) { + if (!(*dst = *src)) { + wchar_t *ret = dst; + while (n--) + *++dst = L'\0'; + return (ret); + } + } + return (dst); +} diff --git a/lib/libc/string/wmemchr.3 b/lib/libc/string/wmemchr.3 index 8812ca3..30fb091 100644 --- a/lib/libc/string/wmemchr.3 +++ b/lib/libc/string/wmemchr.3 @@ -35,7 +35,7 @@ .\" .\" $FreeBSD$ .\" -.Dd February 28, 2009 +.Dd March 4, 2009 .Dt WMEMCHR 3 .Os .Sh NAME @@ -44,6 +44,8 @@ .Nm wmemcpy , .Nm wmemmove , .Nm wmemset , +.Nm wcpcpy , +.Nm wcpncpy , .Nm wcscasecmp , .Nm wcscat , .Nm wcschr , @@ -78,6 +80,10 @@ .Fn wmemmove "wchar_t *s1" "const wchar_t *s2" "size_t n" .Ft wchar_t * .Fn wmemset "wchar_t *s" "wchar_t c" "size_t n" +.Ft wchar_t * +.Fn wcpcpy "wchar_t *s1" "wchar_t *s2" +.Ft wchar_t * +.Fn wcpncpy "wchar_t *s1" "wchar_t *s2" "size_t n" .Ft int .Fn wcscasecmp "const wchar_t *s1" "const wchar_t *s2" .Ft wchar_t * @@ -128,6 +134,8 @@ counterpart, such as .Xr memcpy 3 , .Xr memmove 3 , .Xr memset 3 , +.Xr stpcpy 3 , +.Xr stpncpy 3 , .Xr strcasecmp 3 , .Xr strcat 3 , .Xr strchr 3 , @@ -150,6 +158,8 @@ counterpart, such as These functions conform to .St -isoC-99 , with the exception of +.Fn wcpcpy , +.Fn wcpncpy , .Fn wcscasecmp , .Fn wcsdup , .Fn wcsncasecmp , |