diff options
author | Jeff Johnston <jjohnstn@redhat.com> | 2002-08-29 23:38:25 +0400 |
---|---|---|
committer | Jeff Johnston <jjohnstn@redhat.com> | 2002-08-29 23:38:25 +0400 |
commit | 890e7a1d1a7d701e6e5e0674e58aebe595575375 (patch) | |
tree | 6da470c325a8768eb04188a5bfa6b34b39fe02e6 /newlib/libc/string | |
parent | 86620e21902f8ad14acf919d15bb49b9455311a6 (diff) |
2002-08-29 Kazuhiro Fujieda <fujieda@jaist.ac.jp>
* libc/include/wchar.h: Define NULL. Define WEOF more general
way. Declare functions in newlib manner.
* libc/stdlib/Makefile.am: Delete wmem*.c
* libc/stdlib/Makefile.in: Regenerated.
* libc/stdlib/wmemchr.c: Delete.
* libc/stdlib/wmemcmp.c: Ditto.
* libc/stdlib/wmemcpy.c: Ditto.
* libc/stdlib/wmemmove.c: Ditto.
* libc/stdlib/wmemset.c: Ditto.
* libc/string/Makefile.am: Add wmem*.c and wcs*.c.
* libc/string/Makefile.in: Regenerated.
* libc/string/wcscat.c: New file derived from the NetBSD C Library.
* libc/string/wcschr.c: Ditto.
* libc/string/wcscmp.c: Ditto.
* libc/string/wcscpy.c: Ditto.
* libc/string/wcscspn.c: Ditto.
* libc/string/wcslcat.c: Ditto.
* libc/string/wcslcpy.c: Ditto.
* libc/string/wcslen.c: Ditto.
* libc/string/wcsncat.c: Ditto.
* libc/string/wcsncmp.c: Ditto.
* libc/string/wcsncpy.c: Ditto.
* libc/string/wcspbrk.c: Ditto.
* libc/string/wcsrchr.c: Ditto.
* libc/string/wcsspn.c: Ditto.
* libc/string/wcsstr.c: Ditto.
* libc/string/wmemchr.c: Ditto.
* libc/string/wmemcmp.c: Ditto.
* libc/string/wmemcpy.c: Ditto.
* libc/string/wmemmove.c: Ditto.
* libc/string/wmemset.c: Ditto.
Diffstat (limited to 'newlib/libc/string')
-rw-r--r-- | newlib/libc/string/Makefile.am | 28 | ||||
-rw-r--r-- | newlib/libc/string/Makefile.in | 45 | ||||
-rw-r--r-- | newlib/libc/string/wcscat.c | 84 | ||||
-rw-r--r-- | newlib/libc/string/wcschr.c | 81 | ||||
-rw-r--r-- | newlib/libc/string/wcscmp.c | 83 | ||||
-rw-r--r-- | newlib/libc/string/wcscpy.c | 78 | ||||
-rw-r--r-- | newlib/libc/string/wcscspn.c | 85 | ||||
-rw-r--r-- | newlib/libc/string/wcslcat.c | 108 | ||||
-rw-r--r-- | newlib/libc/string/wcslcpy.c | 102 | ||||
-rw-r--r-- | newlib/libc/string/wcslen.c | 71 | ||||
-rw-r--r-- | newlib/libc/string/wcsncat.c | 90 | ||||
-rw-r--r-- | newlib/libc/string/wcsncmp.c | 92 | ||||
-rw-r--r-- | newlib/libc/string/wcsncpy.c | 89 | ||||
-rw-r--r-- | newlib/libc/string/wcspbrk.c | 86 | ||||
-rw-r--r-- | newlib/libc/string/wcsrchr.c | 86 | ||||
-rw-r--r-- | newlib/libc/string/wcsspn.c | 86 | ||||
-rw-r--r-- | newlib/libc/string/wcsstr.c | 104 | ||||
-rw-r--r-- | newlib/libc/string/wmemchr.c | 88 | ||||
-rw-r--r-- | newlib/libc/string/wmemcmp.c | 88 | ||||
-rw-r--r-- | newlib/libc/string/wmemcpy.c | 75 | ||||
-rw-r--r-- | newlib/libc/string/wmemmove.c | 81 | ||||
-rw-r--r-- | newlib/libc/string/wmemset.c | 81 |
22 files changed, 1805 insertions, 6 deletions
diff --git a/newlib/libc/string/Makefile.am b/newlib/libc/string/Makefile.am index 1e4f4c525..9e9bdb481 100644 --- a/newlib/libc/string/Makefile.am +++ b/newlib/libc/string/Makefile.am @@ -44,7 +44,27 @@ GENERAL_SOURCES = \ strxfrm.c \ strstr.c \ swab.c \ - u_strerr.c + u_strerr.c \ + wcscat.c \ + wcschr.c \ + wcscmp.c \ + wcscpy.c \ + wcscspn.c \ + wcslcat.c \ + wcslcpy.c \ + wcslen.c \ + wcsncat.c \ + wcsncmp.c \ + wcsncpy.c \ + wcspbrk.c \ + wcsrchr.c \ + wcsspn.c \ + wcsstr.c \ + wmemchr.c \ + wmemcmp.c \ + wmemcpy.c \ + wmemmove.c \ + wmemset.c if ELIX_LEVEL_1 LIB_OBJS = @@ -83,7 +103,11 @@ index.def rindex.def strcspn.def strpbrk.def swab.def \ memchr.def strcat.def strerror.def strerror_r.def strrchr.def \ memcmp.def strchr.def strlen.def strnlen.def strspn.def \ strcasecmp.def strncasecmp.def strlwr.def strupr.def memccpy.def \ -mempcpy.def +mempcpy.def \ +wcscat.def wcschr.def wcscmp.def wcscpy.def wcscspn.def \ +wcslcat.def wcslcpy.def wcslen.def wcsncat.def wcsncmp.def \ +wcsncpy.def wcspbrk.def wcsrchr.def wcsspn.def wcsstr.def \ +wmemchr.def wmemcmp.def wmemcpy.def wmemmove.def wmemset.def SUFFIXES = .def diff --git a/newlib/libc/string/Makefile.in b/newlib/libc/string/Makefile.in index 9ecc45cad..e140de8b6 100644 --- a/newlib/libc/string/Makefile.in +++ b/newlib/libc/string/Makefile.in @@ -150,7 +150,27 @@ GENERAL_SOURCES = \ strxfrm.c \ strstr.c \ swab.c \ - u_strerr.c + u_strerr.c \ + wcscat.c \ + wcschr.c \ + wcscmp.c \ + wcscpy.c \ + wcscspn.c \ + wcslcat.c \ + wcslcpy.c \ + wcslen.c \ + wcsncat.c \ + wcsncmp.c \ + wcsncpy.c \ + wcspbrk.c \ + wcsrchr.c \ + wcsspn.c \ + wcsstr.c \ + wmemchr.c \ + wmemcmp.c \ + wmemcpy.c \ + wmemmove.c \ + wmemset.c @ELIX_LEVEL_1_TRUE@LIB_OBJS = @ELIX_LEVEL_1_FALSE@LIB_OBJS = @ELIX_LEVEL_1_FALSE@\ @@ -181,7 +201,11 @@ index.def rindex.def strcspn.def strpbrk.def swab.def \ memchr.def strcat.def strerror.def strerror_r.def strrchr.def \ memcmp.def strchr.def strlen.def strnlen.def strspn.def \ strcasecmp.def strncasecmp.def strlwr.def strupr.def memccpy.def \ -mempcpy.def +mempcpy.def \ +wcscat.def wcschr.def wcscmp.def wcscpy.def wcscspn.def \ +wcslcat.def wcslcpy.def wcslen.def wcsncat.def wcsncmp.def \ +wcsncpy.def wcspbrk.def wcsrchr.def wcsspn.def wcsstr.def \ +wmemchr.def wmemcmp.def wmemcpy.def wmemmove.def wmemset.def SUFFIXES = .def @@ -214,7 +238,15 @@ LIBS = @LIBS@ @USE_LIBTOOL_FALSE@strpbrk.$(OBJEXT) strrchr.$(OBJEXT) strsep.$(OBJEXT) \ @USE_LIBTOOL_FALSE@strspn.$(OBJEXT) strtok.$(OBJEXT) strtok_r.$(OBJEXT) \ @USE_LIBTOOL_FALSE@strupr.$(OBJEXT) strxfrm.$(OBJEXT) strstr.$(OBJEXT) \ -@USE_LIBTOOL_FALSE@swab.$(OBJEXT) u_strerr.$(OBJEXT) +@USE_LIBTOOL_FALSE@swab.$(OBJEXT) u_strerr.$(OBJEXT) wcscat.$(OBJEXT) \ +@USE_LIBTOOL_FALSE@wcschr.$(OBJEXT) wcscmp.$(OBJEXT) wcscpy.$(OBJEXT) \ +@USE_LIBTOOL_FALSE@wcscspn.$(OBJEXT) wcslcat.$(OBJEXT) \ +@USE_LIBTOOL_FALSE@wcslcpy.$(OBJEXT) wcslen.$(OBJEXT) wcsncat.$(OBJEXT) \ +@USE_LIBTOOL_FALSE@wcsncmp.$(OBJEXT) wcsncpy.$(OBJEXT) \ +@USE_LIBTOOL_FALSE@wcspbrk.$(OBJEXT) wcsrchr.$(OBJEXT) wcsspn.$(OBJEXT) \ +@USE_LIBTOOL_FALSE@wcsstr.$(OBJEXT) wmemchr.$(OBJEXT) wmemcmp.$(OBJEXT) \ +@USE_LIBTOOL_FALSE@wmemcpy.$(OBJEXT) wmemmove.$(OBJEXT) \ +@USE_LIBTOOL_FALSE@wmemset.$(OBJEXT) LTLIBRARIES = $(noinst_LTLIBRARIES) @USE_LIBTOOL_TRUE@libstring_la_OBJECTS = bcopy.lo bzero.lo index.lo \ @@ -225,7 +257,12 @@ LTLIBRARIES = $(noinst_LTLIBRARIES) @USE_LIBTOOL_TRUE@strlen.lo strlwr.lo strncasecmp.lo strncat.lo \ @USE_LIBTOOL_TRUE@strncmp.lo strncpy.lo strnlen.lo strpbrk.lo \ @USE_LIBTOOL_TRUE@strrchr.lo strsep.lo strspn.lo strtok.lo strtok_r.lo \ -@USE_LIBTOOL_TRUE@strupr.lo strxfrm.lo strstr.lo swab.lo u_strerr.lo +@USE_LIBTOOL_TRUE@strupr.lo strxfrm.lo strstr.lo swab.lo u_strerr.lo \ +@USE_LIBTOOL_TRUE@wcscat.lo wcschr.lo wcscmp.lo wcscpy.lo wcscspn.lo \ +@USE_LIBTOOL_TRUE@wcslcat.lo wcslcpy.lo wcslen.lo wcsncat.lo wcsncmp.lo \ +@USE_LIBTOOL_TRUE@wcsncpy.lo wcspbrk.lo wcsrchr.lo wcsspn.lo wcsstr.lo \ +@USE_LIBTOOL_TRUE@wmemchr.lo wmemcmp.lo wmemcpy.lo wmemmove.lo \ +@USE_LIBTOOL_TRUE@wmemset.lo CFLAGS = @CFLAGS@ COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) diff --git a/newlib/libc/string/wcscat.c b/newlib/libc/string/wcscat.c new file mode 100644 index 000000000..b3a3bd987 --- /dev/null +++ b/newlib/libc/string/wcscat.c @@ -0,0 +1,84 @@ +/* +FUNCTION + <<wcscat>>---concatenate two wide-character strings +INDEX + wcscat + +ANSI_SYNOPSIS + #include <wchar.h> + wchar_t *wcscat(wchar_t *<[s1]>, const wchar_t *<[s2]>); + +TRAD_SYNOPSIS + wchar_t *wcscat(<[s1]>, <[s2]> + wchar_t *<[s1]>; + const wchar_t *<[s2]>; + +DESCRIPTION + The <<wcscat>> function appends a copy of the wide-character string + pointed to by <[s2]> (including the terminating null wide-character + code) to the end of the wide-character string pointed to by <[s1]>. + The initial wide-character code of <[s2]> overwrites the null + wide-character code at the end of <[s1]>. If copying takes place between + objects that overlap, the behaviour is undefined. + +RETURNS + The <<wcscat>> function returns <[s1]>; + no return value is reserved to indicate an error. + +PORTABILITY +<<wcscat>> is ISO/IEC 9899/AMD1:1995 (ISO C). +No supporting OS subroutines are required. +*/ + +/* $NetBSD: wcscat.c,v 1.1 2000/12/23 23:14:36 itojun 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 <_ansi.h> +#include <wchar.h> + +wchar_t * +_DEFUN (wcscat, (s1, s2), + wchar_t * s1 _AND + _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; +} diff --git a/newlib/libc/string/wcschr.c b/newlib/libc/string/wcschr.c new file mode 100644 index 000000000..2b476f7e4 --- /dev/null +++ b/newlib/libc/string/wcschr.c @@ -0,0 +1,81 @@ +/* +FUNCTION + <<wcschr>>---wide-character string scanning operation + +ANSI_SYNOPSIS + #include <wchar.h> + wchar_t *wcschr(const wchar_t *<[s]>, wchar_t <[c]>); + +TRAD_SYNOPSIS + wchar_t *wcschr(<[s]>, <[c]> + const wchar_t *<[s]>; + wchar_t <[c]>; + +DESCRIPTION + The <<wcschr>> function locates the first occurrence of <[c]> in the + wide-character string pointed to by <[s]>. The value of <[c]> must be a + character representable as a type wchar_t and must be a wide-character + code corresponding to a valid character in the current locale. + The terminating null wide-character string. + +RETURNS + Upon completion, <<wcschr>> returns a pointer to the wide-character + code, or a null pointer if the wide-character code is not found. + +PORTABILITY +<<wcschr>> is ISO/IEC 9899/AMD1:1995 (ISO C). +No supporting OS subroutines are required. +*/ + +/* $NetBSD: wcschr.c,v 1.1 2000/12/23 23:14:36 itojun 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 <_ansi.h> +#include <wchar.h> + +wchar_t * +_DEFUN (wcschr, (s, c), + _CONST wchar_t * s _AND + wchar_t c) +{ + _CONST wchar_t *p; + + p = s; + while (*p) + { + if (*p == c) + { + /* LINTED interface specification */ + return (wchar_t *) p; + } + p++; + } + return NULL; +} diff --git a/newlib/libc/string/wcscmp.c b/newlib/libc/string/wcscmp.c new file mode 100644 index 000000000..01ccf926c --- /dev/null +++ b/newlib/libc/string/wcscmp.c @@ -0,0 +1,83 @@ +/* +FUNCTION + <<wcscmp>>---compare two wide-character strings + +ANSI_SYNOPSIS + #include <wchar.h> + int wcscmp(const wchar_t *<[s1]>, *<[s2]>); + +TRAD_SYNOPSIS + int wcscmp(<[s1]>, <[s2]> + const wchar_t *<[s1]>, <[s2]>; + +DESCRIPTION + The <<wcscmp>> function compares the wide-character string pointed to + by <[s1]> to the wide-character string pointed to by <[s2]>. + + The sign of a non-zero return value is determined by the sign of the + difference between the values of the first pair of wide-character codes + that differ in the objects being compared. + +RETURNS + Upon completion, <<wcscmp>> returns an integer greater than, equal to + or less than 0, if the wide-character string pointed to by <[s1]> is + greater than, equal to or less than the wide-character string pointed + to by <[s2]> respectively. + +PORTABILITY +<<wcscmp>> is ISO/IEC 9899/AMD1:1995 (ISO C). +No supporting OS subroutines are required. +*/ + +/* $NetBSD$ */ + +/*- + * 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 <_ansi.h> +#include <wchar.h> + +/* + * Compare strings. + */ +int +_DEFUN (wcscmp, (s1, s2), + _CONST wchar_t * s1 _AND + _CONST wchar_t * s2) +{ + + while (*s1 == *s2++) + if (*s1++ == 0) + return (0); + /* XXX assumes wchar_t = short */ + return (*(_CONST unsigned short *) s1 - *(_CONST unsigned short *) --s2); +} diff --git a/newlib/libc/string/wcscpy.c b/newlib/libc/string/wcscpy.c new file mode 100644 index 000000000..5a72338ce --- /dev/null +++ b/newlib/libc/string/wcscpy.c @@ -0,0 +1,78 @@ +/* +FUNCTION + <<wcscpy>>---copy a wide-character string + +ANSI_SYNOPSIS + #include <wchar.h> + wchar_t *wcscpy(wchar_t *<[s1]>, const wchar_t *,<[s2]>); + +TRAD_SYNOPSIS + wchar_t *wcscpy(<[s1]>, <[s2]> + wchar_t *<[s1]>; + const wchar_t *<[s2]>; + +DESCRIPTION + The <<wcscpy>> function copies the wide-character string pointed to by + <[s2]> (including the terminating null wide-character code) into the + array pointed to by <[s1]>. If copying takes place between objects that + overlap, the behaviour is undefined. + +RETURNS + The <<wcscpy>> function returns <[s1]>; no return value is reserved to + indicate an error. + +PORTABILITY +<<wcscpy>> is ISO/IEC 9899/AMD1:1995 (ISO C). +No supporting OS subroutines are required. +*/ + +/* $NetBSD: wcscpy.c,v 1.1 2000/12/23 23:14:36 itojun 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 <_ansi.h> +#include <wchar.h> + +wchar_t * +_DEFUN (wcscpy, (s1, s2), + wchar_t * s1 _AND + _CONST wchar_t * s2) +{ + wchar_t *p; + _CONST wchar_t *q; + + *s1 = '\0'; + p = s1; + q = s2; + while (*q) + *p++ = *q++; + *p = '\0'; + + return s1; +} diff --git a/newlib/libc/string/wcscspn.c b/newlib/libc/string/wcscspn.c new file mode 100644 index 000000000..7e53cc15d --- /dev/null +++ b/newlib/libc/string/wcscspn.c @@ -0,0 +1,85 @@ +/* +FUNCTION + <<wcscspn>>---get length of a complementary wide substring + +ANSI_SYNOPSIS + #include <wchar.h> + size_t wcscspn(const wchar_t *<[s]>, wchar_t *<[set]>); + +TRAD_SYNOPSIS + size_t wcscspn(<[s]>, <[set]> + const wchar_t *<[s]>; + const wchar_t *<[set]>; + +DESCRIPTION + The <<wcscspn>> function computes the length of the maximum initial + segment of the wide-character string pointed to by <[s]> which consists + entirely of wide-character codes not from the wide-character string + pointed to by <[set]>. + +RETURNS + The <<wcscspn>> function returns the length of the initial substring of + <[s1]>; no return value is reserved to indicate an error. + +PORTABILITY +<<wcscspn>> is ISO/IEC 9899/AMD1:1995 (ISO C). +No supporting OS subroutines are required. +*/ + +/* $NetBSD: wcscspn.c,v 1.1 2000/12/23 23:14:36 itojun 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 <_ansi.h> +#include <wchar.h> + +size_t +_DEFUN (wcscspn, (s, set), + _CONST wchar_t * s _AND + _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); +} diff --git a/newlib/libc/string/wcslcat.c b/newlib/libc/string/wcslcat.c new file mode 100644 index 000000000..adf683ad5 --- /dev/null +++ b/newlib/libc/string/wcslcat.c @@ -0,0 +1,108 @@ +/* +FUNCTION + <<wcslcat>>---concatenate wide-character strings to specified length + +ANSI_SYNOPSIS + #include <wchar.h> + size_t wcslcat(wchar_t *<[dst]>, const wchar_t *<[src]>, size_t <[siz]>); + +TRAD_SYNOPSIS + #include <wchar.h> + size_t wcslcat(<[dst]>, <[src]>, <[siz]> + wchar_t *<[dst]>; + const wchar_t *<[src]>; + size_t <[siz]>; + +DESCRIPTION + The <<wcslcat>> function appends wide-characters from <[src]> to + end of the <[dst]> wide-character string so that the resultant + wide-character string is not more than <[siz]> wide-characters + including terminating null wide-character code. A terminating + null wide-character is always added unless <[siz]> is 0. Thus, + the maximum number of wide-characters that can be appended from + <[src]> is <[siz]> - 1. If copying takes place between objects + that overlap, the behaviour is undefined. + +RETURNS + Wide-character string length of initial <[dst]> plus the + wide-character string length of <[src]> (does not include + terminating null wide-characters). If the return value is + greater than or equal to <[siz]>, then truncation occurred and + not all wide-characters from <[src]> were appended. + +PORTABILITY +No supporting OS subroutines are required. +*/ + +/* $NetBSD: wcslcat.c,v 1.1 2000/12/23 23:14:36 itojun Exp $ */ +/* from OpenBSD: strlcat.c,v 1.3 2000/11/24 11:10:02 itojun Exp */ + +/* + * Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com> + * 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. 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 ``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 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 <_ansi.h> +#include <wchar.h> + +/* + * Appends src to string dst of size siz (unlike wcsncat, siz is the + * full size of dst, not space left). At most siz-1 characters + * will be copied. Always NUL terminates (unless siz == 0). + * Returns wcslen(initial dst) + wcslen(src); if retval >= siz, + * truncation occurred. + */ +size_t +_DEFUN (wcslcat, (dst, src, siz), + wchar_t * dst _AND + _CONST wchar_t * src _AND + size_t siz) +{ + wchar_t *d = dst; + _CONST wchar_t *s = src; + size_t n = siz; + size_t dlen; + + /* Find the end of dst and adjust bytes left but don't go past end */ + while (*d != '\0' && n-- != 0) + d++; + dlen = d - dst; + n = siz - dlen; + + if (n == 0) + return (dlen + wcslen (s)); + while (*s != '\0') + { + if (n != 1) + { + *d++ = *s; + n--; + } + s++; + } + *d = '\0'; + + return (dlen + (s - src)); /* count does not include NUL */ +} diff --git a/newlib/libc/string/wcslcpy.c b/newlib/libc/string/wcslcpy.c new file mode 100644 index 000000000..ac7d01863 --- /dev/null +++ b/newlib/libc/string/wcslcpy.c @@ -0,0 +1,102 @@ +/* +FUNCTION + <<wcslcpy>>---copy a wide-character string to specified length + +ANSI_SYNOPSIS + #include <wchar.h> + size_t wcslcpy(wchar_t *<[dst]>, const wchar_t *<[src]>, size_t <[siz]>); + +TRAD_SYNOPSIS + #include <wchar.h> + size_t wcslcpy(<[dst]>, <[src]>, <[siz]>) + wchar_t *<[dst]>; + const wchar_t *<[src]>; + size_t <[siz]>; + +DESCRIPTION + <<wcslcpy>> copies wide-characters from <[src]> to <[dst]> + such that up to <[siz]> - 1 characters are copied. A + terminating null is appended to the result, unless <[siz]> + is zero. + +RETURNS + <<wcslcpy>> returns the number of wide-characters in <[src]>, + not including the terminating null wide-character. If the + return value is greater than or equal to <[siz]>, then + not all wide-characters were copied from <[src]> and truncation + occurred. + +PORTABILITY +No supporting OS subroutines are required. +*/ + +/* $NetBSD: wcslcpy.c,v 1.1 2000/12/23 23:14:36 itojun Exp $ */ +/* from OpenBSD: strlcpy.c,v 1.4 1999/05/01 18:56:41 millert Exp */ + +/* + * Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com> + * 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. 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 ``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 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 <_ansi.h> +#include <wchar.h> + +/* + * Copy src to string dst of size siz. At most siz-1 characters + * will be copied. Always NUL terminates (unless siz == 0). + * Returns wcslen(src); if retval >= siz, truncation occurred. + */ +size_t +_DEFUN (wcslcpy, (dst, src, siz), + wchar_t * dst _AND + _CONST wchar_t * src _AND + size_t siz) +{ + wchar_t *d = dst; + _CONST wchar_t *s = src; + size_t n = siz; + + /* 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 */ +} diff --git a/newlib/libc/string/wcslen.c b/newlib/libc/string/wcslen.c new file mode 100644 index 000000000..d68f00a72 --- /dev/null +++ b/newlib/libc/string/wcslen.c @@ -0,0 +1,71 @@ +/* +FUNCTION + <<wcslen>>---get wide-character string length + +ANSI_SYNOPSIS + #include <wchar.h> + size_t wcslen(const wchar_t *<[s]>); + +TRAD_SYNOPSIS + size_t wcslen(<[s]> + const wchar_t *<[s]>; + +DESCRIPTION + The <<wcslen>> function computes the number of wide-character codes + in the wide-character string to which <[s]> points, not including the + terminating null wide-character code. + +RETURNS + The <<wcslen>> function returns the length of <[s]>; no return value is + reserved to indicate an error. + +PORTABILITY +<<wcslen>> is ISO/IEC 9899/AMD1:1995 (ISO C). +No supporting OS subroutines are required. +*/ + +/* $NetBSD: wcslen.c,v 1.1 2000/12/23 23:14:36 itojun 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 <_ansi.h> +#include <wchar.h> + +size_t +_DEFUN (wcslen, (s), + _CONST wchar_t * s) +{ + _CONST wchar_t *p; + + p = s; + while (*p) + p++; + + return p - s; +} diff --git a/newlib/libc/string/wcsncat.c b/newlib/libc/string/wcsncat.c new file mode 100644 index 000000000..2ba293497 --- /dev/null +++ b/newlib/libc/string/wcsncat.c @@ -0,0 +1,90 @@ +/* +FUNCTION + <<wcsncat>>---concatenate part of two wide-character strings + +ANSI_SYNOPSIS + #include <wchar.h> + wchar_t *wcsncat(wchar_t *<[s1]>, const wchar_t *<[s2]>, size_t <[n]>); + +TRAD_SYNOPSIS + wchar_t *wcsncat(<[s1]>, <[s2]>, <[n]> + wchar_t *<[s1]>; + const wchar_t *<[s2]>; + size_t <[n]>; + +DESCRIPTION + The <<wcsncat>> function appends not more than <[n]> wide-character + codes (a null wide-character code and wide-character codes that follow + it are not appended) from the array pointed to by <[s2]> to the end of + the wide-character string pointed to by <[s1]>. The initial + wide-character code of <[s2]> overwrites the null wide-character code + at the end of <[s1]>. + A terminating null wide-character code is always appended to the result. + If copying takes place between objects that overlap, the behaviour is + undefined. + +RETURNS + The <<wcsncat>> function returns <[s1]>; no return value is reserved to + indicate an error. + +PORTABILITY +<<wcsncat>> is ISO/IEC 9899/AMD1:1995 (ISO C). +No supporting OS subroutines are required. +*/ + +/* $NetBSD: wcsncat.c,v 1.1 2000/12/23 23:14:36 itojun 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 <_ansi.h> +#include <wchar.h> + +wchar_t * +_DEFUN (wcsncat, (s1, s2, n), + wchar_t * s1 _AND + _CONST wchar_t * s2 _AND + 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; +} diff --git a/newlib/libc/string/wcsncmp.c b/newlib/libc/string/wcsncmp.c new file mode 100644 index 000000000..1ced7e165 --- /dev/null +++ b/newlib/libc/string/wcsncmp.c @@ -0,0 +1,92 @@ +/* +FUNCTION + <<wcsncmp>>---compare part of two wide-character strings + +ANSI_SYNOPSIS + #include <wchar.h> + int wcsncmp(const wchar_t *<[s1]>, const wchar_t *<[s2]>, size_t <[n]>); + +TRAD_SYNOPSIS + int wcsncmp(<[s1]>, <[s2]>, <[n]> + const wchar_t *<[s1]>; + const wchar_t *<[s2]>; + size_t <[n]>; + +DESCRIPTION + The <<wcsncmp>> function compares not more than <[n]> wide-character + codes (wide-character codes that follow a null wide-character code are + not compared) from the array pointed to by <[s1]> to the array pointed + to by <[s2]>. + + The sign of a non-zero return value is determined by the sign of the + difference between the values of the first pair of wide-character codes + that differ in the objects being compared. + +RETURNS + Upon successful completion, <<wcsncmp>> returns an integer greater than, + equal to or less than 0, if the possibly null-terminated array pointed + to by <[s1]> is greater than, equal to or less than the possibly + null-terminated array pointed to by <[s2]> respectively. + +PORTABILITY +<<wcsncmp>> is ISO/IEC 9899/AMD1:1995 (ISO C). +No supporting OS subroutines are required. +*/ + +/* $NetBSD$ */ + +/* + * 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 <_ansi.h> +#include <wchar.h> + +int +_DEFUN (wcsncmp, (s1, s2, n), + _CONST wchar_t * s1 _AND + _CONST wchar_t * s2 _AND + size_t n) +{ + + if (n == 0) + return (0); + do + { + if (*s1 != *s2++) + { + /* XXX assumes wchar_t = short */ + return (*(_CONST unsigned short *) s1 - + *(_CONST unsigned short *) --s2); + } + if (*s1++ == 0) + break; + } + while (--n != 0); + return (0); +} diff --git a/newlib/libc/string/wcsncpy.c b/newlib/libc/string/wcsncpy.c new file mode 100644 index 000000000..afe75a238 --- /dev/null +++ b/newlib/libc/string/wcsncpy.c @@ -0,0 +1,89 @@ +/* +FUNCTION + <<wcsncpy>>---copy part of a wide-character string + +ANSI_SYNOPSIS + #include <wchar.h> + wchar_t *wcsncpy(wchar_t *<[s1]>, const wchar_t *<[s2]>, size_t <[n]>); + +TRAD_SYNOPSIS + wchar_t *wcsncpy(<[s1]>, <[s2]>, <[n]> + wchar_t *<[s1]>; + const wchar_t *<[s2]>; + size_t <[n]>; + +DESCRIPTION + The <<wcsncpy>> function copies not more than n wide-character codes + (wide-character codes that follow a null wide-character code are not + copied) from the array pointed to by <[s2]> to the array pointed to + by <[s1]>. If copying takes place between objects that overlap, the + behaviour is undefined. + + If the array pointed to by <[s2]> is a wide-character string that is + shorter than <[n]> wide-character codes, null wide-character codes are + appended to the copy in the array pointed to by <[s1]>, until <[n]> + wide-character codes in all are written. + +RETURNS + The <<wcsncpy>> function returns <[s1]>; no return value is reserved to + indicate an error. + +PORTABILITY +<<wcsncpy>> is ISO/IEC 9899/AMD1:1995 (ISO C). +No supporting OS subroutines are required. +*/ + +/* $NetBSD: wcsncpy.c,v 1.1 2000/12/23 23:14:36 itojun 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 <_ansi.h> +#include <wchar.h> + +wchar_t * +_DEFUN (wcsncpy, (s1, s2, n), + wchar_t * s1 _AND + _CONST wchar_t * s2 _AND + size_t n) +{ + wchar_t *p; + _CONST wchar_t *q; + + *s1 = '\0'; + p = s1; + q = s2; + while (n && *q) + { + *p++ = *q++; + n--; + } + *p = '\0'; + + return s1; +} diff --git a/newlib/libc/string/wcspbrk.c b/newlib/libc/string/wcspbrk.c new file mode 100644 index 000000000..e2529d0a4 --- /dev/null +++ b/newlib/libc/string/wcspbrk.c @@ -0,0 +1,86 @@ +/* +FUNCTION + <<wcspbrk>>----scan wide-character string for a wide-character code + +ANSI_SYNOPSIS + #include <wchar.h> + wchar_t *wcspbrk(const wchar_t *<[s]>, const wchar_t *<[set]>); + +TRAD_SYNOPSIS + wchar_t *wcspbrk(<[s]>, <[set]> + const wchar_t *<[s]>; + const wchar_t *<[set]>; + +DESCRIPTION + The <<wcspbrk>> function locates the first occurrence in the + wide-character string pointed to by <[s]> of any wide-character code + from the wide-character string pointed to by <[set]>. + +RETURNS + Upon successful completion, <<wcspbrk>> returns a pointer to the + wide-character code or a null pointer if no wide-character code from + <[set]> occurs in <[s]>. + +PORTABILITY +<<wcspbrk>> is ISO/IEC 9899/AMD1:1995 (ISO C). +No supporting OS subroutines are required. +*/ + +/* $NetBSD: wcspbrk.c,v 1.1 2000/12/23 23:14:37 itojun 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 <_ansi.h> +#include <wchar.h> + +wchar_t * +_DEFUN (wcspbrk, (s, set), + _CONST wchar_t * s _AND + _CONST wchar_t * set) +{ + _CONST wchar_t *p; + _CONST wchar_t *q; + + p = s; + while (*p) + { + q = set; + while (*q) + { + if (*p == *q) + { + /* LINTED interface specification */ + return (wchar_t *) p; + } + q++; + } + p++; + } + return NULL; +} diff --git a/newlib/libc/string/wcsrchr.c b/newlib/libc/string/wcsrchr.c new file mode 100644 index 000000000..143b45fc7 --- /dev/null +++ b/newlib/libc/string/wcsrchr.c @@ -0,0 +1,86 @@ +/* +FUNCTION + <<wcsrchr>>---wide-character string scanning operation + +ANSI_SYNOPSIS + #include <wchar.h> + wchar_t *wcsrchr(const wchar_t *<[s]>, wchar_t <[c]>); + +TRAD_SYNOPSIS + #include <wchar.h> + wchar_t *wcsrchr(<[s]>, <[c]> + const wchar_t *<[s]>; + wchar_t <[c]>; + +DESCRIPTION + The <<wcsrchr>> function locates the last occurrence of <[c]> in the + wide-character string pointed to by <[s]>. The value of <[c]> must be a + character representable as a type wchar_t and must be a wide-character + code corresponding to a valid character in the current locale. + The terminating null wide-character code is considered to be part of + the wide-character string. + +RETURNS + Upon successful completion, <<wcsrchr>> returns a pointer to the + wide-character code or a null pointer if <[c]> does not occur in the + wide-character string. + +PORTABILITY +<<wcsrchr>> is ISO/IEC 9899/AMD1:1995 (ISO C). +No supporting OS subroutines are required. +*/ + +/* $NetBSD: wcsrchr.c,v 1.1 2000/12/23 23:14:37 itojun 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 <_ansi.h> +#include <wchar.h> + +wchar_t * +_DEFUN (wcsrchr, (s, c), + _CONST wchar_t * s _AND + wchar_t c) +{ + _CONST wchar_t *p; + + p = s; + while (*p) + p++; + while (s <= p) + { + if (*p == c) + { + /* LINTED interface specification */ + return (wchar_t *) p; + } + p--; + } + return NULL; +} diff --git a/newlib/libc/string/wcsspn.c b/newlib/libc/string/wcsspn.c new file mode 100644 index 000000000..f0b2fb99f --- /dev/null +++ b/newlib/libc/string/wcsspn.c @@ -0,0 +1,86 @@ +/* +FUNCTION + <<wcsspn>>---get length of a wide substring + +ANSI_SYNOPSIS + #include <wchar.h> + size_t wcsspn(const wchar_t *<[s]>, const wchar_t *<[set]>); + +TRAD_SYNOPSIS + size_t wcsspn(<[s]>, <[set]> + const wchar_t *<[s]>; + const wchar_t *<[set]>; + +DESCRIPTION + The <<wcsspn>> function computes the length of the maximum initial + segment of the wide-character string pointed to by <[s]> which consists + entirely of wide-character codes from the wide-character string + pointed to by <[set]>. + +RETURNS + The wcsspn() function returns the length <[s1]>; no return value is + reserved to indicate an error. + +PORTABILITY +<<wcsspn>> is ISO/IEC 9899/AMD1:1995 (ISO C). +No supporting OS subroutines are required. +*/ + +/* $NetBSD: wcsspn.c,v 1.1 2000/12/23 23:14:37 itojun 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: wcsspn.c,v 1.1 1999/12/29 21:47:45 tshiozak Exp + */ + +#include <_ansi.h> +#include <wchar.h> + +size_t +_DEFUN (wcsspn, (s, set), + _CONST wchar_t * s _AND + _CONST wchar_t * set) +{ + _CONST wchar_t *p; + _CONST wchar_t *q; + + p = s; + while (*p) + { + q = set; + while (*q) + { + if (*p == *q) + break; + } + if (!*q) + goto done; + p++; + } + +done: + return (p - s); +} diff --git a/newlib/libc/string/wcsstr.c b/newlib/libc/string/wcsstr.c new file mode 100644 index 000000000..6a61ac3ae --- /dev/null +++ b/newlib/libc/string/wcsstr.c @@ -0,0 +1,104 @@ +/* +FUNCTION + <<wcsstr>>---find a wide-character substring + +ANSI_SYNOPSIS + #include <wchar.h> + wchar_t *wcsstr(const wchar_t *<[big]>, const wchar_t *<[little]>); + +TRAD_SYNOPSIS + wchar_t *wcsstr(<[big]>, <[little]> + const wchar_t *<[big]>; + const wchar_t *<[little]>; + +DESCRIPTION + The <<wcsstr>> function locates the first occurrence in the + wide-character string pointed to by <[big]> of the sequence of + wide-characters (excluding the terminating null wide-character) in the + wide-character string pointed to by <[little]>. + +RETURNS + On successful completion, <<wcsstr>> returns a pointer to the located + wide-character string, or a null pointer if the wide-character string + is not found. + + If <[little]> points to a wide-character string with zero length, + the function returns <[big]>. + +PORTABILITY +<<wcsstr>> is ISO/IEC 9899/AMD1:1995 (ISO C). + +*/ + +/* $NetBSD: wcsstr.c,v 1.1 2000/12/23 23:14:37 itojun 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 <_ansi.h> +#include <wchar.h> + +wchar_t * +_DEFUN (wcsstr, (big, little), + _CONST wchar_t * big _AND + _CONST wchar_t * little) +{ + _CONST wchar_t *p; + _CONST wchar_t *q; + _CONST wchar_t *r; + + if (!*little) + { + /* LINTED interface specification */ + 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) + { + /* LINTED interface specification */ + return (wchar_t *) p; + } + p++; + } + return NULL; +} diff --git a/newlib/libc/string/wmemchr.c b/newlib/libc/string/wmemchr.c new file mode 100644 index 000000000..e99991324 --- /dev/null +++ b/newlib/libc/string/wmemchr.c @@ -0,0 +1,88 @@ +/* +FUNCTION + <<wmemchr>>---find a wide-character in memory + + +ANSI_SYNOPSIS + #include <wchar.h> + wchar_t *wmemchr(const wchar_t *<[s]>, wchar_t <[c]>, size_t <[n]>); + +TRAD_SYNOPSIS + wchar_t *wmemchr(<[s]>, <[c]>, <[n]> + const wchar_t *<[s]>; + wchar_t <[c]>; + size_t <[n]>; + +DESCRIPTION + The <<wmemchr>> function locates the first occurrence of <[c]> in the + initial <[n]> wide-characters of the object pointed to be <[s]>. This + function is not affected by locale and all wchar_t values are treated + identically. The null wide-character and wchar_t values not + corresponding to valid characters are not treated specially. + + If <[n]> is zero, <[s]> must be a valid pointer and the function + behaves as if no valid occurrence of <[c]> is found. + +RETURNS + The <<wmemchr>> function returns a pointer to the located + wide-character, or a null pointer if the wide-character does not occur + in the object. + +PORTABILITY +<<wmemchr>> is ISO/IEC 9899/AMD1:1995 (ISO C). +No supporting OS subroutines are required. +*/ + +/* $NetBSD: wmemchr.c,v 1.1 2000/12/23 23:14:37 itojun 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 <_ansi.h> +#include <wchar.h> + +wchar_t * +_DEFUN (wmemchr, (s, c, n), + _CONST wchar_t * s _AND + wchar_t c _AND + size_t n) +{ + size_t i; + + for (i = 0; i < n; i++) + { + if (*s == c) + { + /* LINTED const castaway */ + return (wchar_t *) s; + } + s++; + } + return NULL; +} diff --git a/newlib/libc/string/wmemcmp.c b/newlib/libc/string/wmemcmp.c new file mode 100644 index 000000000..51072942c --- /dev/null +++ b/newlib/libc/string/wmemcmp.c @@ -0,0 +1,88 @@ +/* +FUNCTION + <<wmemcmp>>---compare wide-characters in memory + +ANSI_SYNOPSIS + #include <wchar.h> + int wmemcmp(const wchar_t *<[s1]>, const wchar_t *<[s2]>, size_t <[n]>); + +TRAD_SYNOPSIS + int wmemcmp(<[s1]>, <[s2]>, <[n]> + const wchar_t *<[s1]>; + const wchar_t *<[s2]>; + size_t <[n]>; + +DESCRIPTION + The <<wmemcmp>> function compares the first <[n]> wide-characters of the + object pointed to by <[s1]> to the first <[n]> wide-characters of the + object pointed to by <[s2]>. This function is not affected by locale + and all wchar_t values are treated identically. The null wide-character + and wchar_t values not corresponding to valid characters are not treated + specially. + + If <[n]> is zero, <[s1]> and <[s2]> must be a valid pointers and the + function behaves as if the two objects compare equal. + +RETURNS + The <<wmemcmp>> function returns an integer greater than, equal to, + or less than zero, accordingly as the object pointed to by <[s1]> is + greater than, equal to, or less than the object pointed to by <[s2]>. + +PORTABILITY +<<wmemcmp>> is ISO/IEC 9899/AMD1:1995 (ISO C). +No supporting OS subroutines are required. +*/ + +/* $NetBSD: wmemcmp.c,v 1.1 2000/12/23 23:14:37 itojun 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 <_ansi.h> +#include <wchar.h> + +int +_DEFUN (wmemcmp, (s1, s2, n), + _CONST wchar_t * s1 _AND + _CONST wchar_t * s2 _AND + size_t n) +{ + size_t i; + + for (i = 0; i < n; i++) + { + if (*s1 != *s2) + { + /* wchar might be unsigned */ + return *s1 > *s2 ? 1 : -1; + } + s1++; + s2++; + } + return 0; +} diff --git a/newlib/libc/string/wmemcpy.c b/newlib/libc/string/wmemcpy.c new file mode 100644 index 000000000..c3a96a32d --- /dev/null +++ b/newlib/libc/string/wmemcpy.c @@ -0,0 +1,75 @@ +/* +FUNCTION + <<wmemcpy>>---copy wide-characters in memory + +ANSI_SYNOPSIS + #include <wchar.h> + wchar_t *wmemcpy(wchar_t *<[d]>, const wchar_t *<[s]>, size_t <[n]>); + +TRAD_SYNOPSIS + wchar_t *wmemcpy(<[d]>, <[s]>, <[n]> + wchar_t *<[d]>; + const wchar_t *<[s]>; + size_t <[n]>; + +DESCRIPTION + The <<wmemcpy>> function copies <[n]> wide-characters from the object + pointed to by <[s]> to the object pointed to be <[d]>. This function + is not affected by locale and all wchar_t values are treated + identically. The null wide-character and wchar_t values not + corresponding to valid characters are not treated specially. + + If <[n]> is zero, <[d]> and <[s]> must be a valid pointers, and the + function copies zero wide-characters. + +RETURNS + The <<wmemcpy>> function returns the value of <[d]>. + +PORTABILITY +<<wmemcpy>> is ISO/IEC 9899/AMD1:1995 (ISO C). +No supporting OS subroutines are required. +*/ + +/* $NetBSD: wmemcpy.c,v 1.1 2000/12/23 23:14:37 itojun 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 <_ansi.h> +#include <string.h> +#include <wchar.h> + +wchar_t * +_DEFUN (wmemcpy, (d, s, n), + wchar_t * d _AND + _CONST wchar_t * s _AND + size_t n) +{ + + return (wchar_t *) memcpy (d, s, n * sizeof (wchar_t)); +} diff --git a/newlib/libc/string/wmemmove.c b/newlib/libc/string/wmemmove.c new file mode 100644 index 000000000..f49e359f3 --- /dev/null +++ b/newlib/libc/string/wmemmove.c @@ -0,0 +1,81 @@ +/* +FUNCTION + <<wmemmove>>---wmemmove - copy wide-characters in memory with overlapping areas + +ANSI_SYNOPSIS + #include <wchar.h> + wchar_t *wmemmove(wchar_t *<[d]>, const wchar_t *<[s]>, size_t <[n]>); + +TRAD_SYNOPSIS + wchar_t *wmemmove(<[d]>, <[s]>, <[n]> + wchar_t *<[d]>; + const wchar_t *<[s]>; + size_t <[n]>; + +DESCRIPTION + The <<wmemmove>> function copies <[n]> wide-characters from the object + pointed to by <[s]> to the object pointed to by <[d]>. Copying takes + place as if the <[n]> wide-characters from the object pointed to by + <[s]> are first copied into a temporary array of <[n]> wide-characters + that does not overlap the objects pointed to by <[d]> or <[s]>, and then + the <[n]> wide-characters from the temporary array are copied into the + object pointed to by <[d]>. + + This function is not affected by locale and all wchar_t values are + treated identically. The null wide-character and wchar_t values not + corresponding to valid characters are not treated specially. + + If <[n]> is zero, <[d]> and <[s]> must be a valid pointers, and the + function copies zero wide-characters. + +RETURNS + The <<wmemmove>> function returns the value of <[d]>. + +PORTABILITY +<<wmemmove>> is ISO/IEC 9899/AMD1:1995 (ISO C). +No supporting OS subroutines are required. +*/ + +/* $NetBSD: wmemmove.c,v 1.1 2000/12/23 23:14:37 itojun 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 <_ansi.h> +#include <string.h> +#include <wchar.h> + +wchar_t * +_DEFUN (wmemmove, (d, s, n), + wchar_t * d _AND + _CONST wchar_t * s _AND + size_t n) +{ + + return (wchar_t *) memmove (d, s, n * sizeof (wchar_t)); +} diff --git a/newlib/libc/string/wmemset.c b/newlib/libc/string/wmemset.c new file mode 100644 index 000000000..4e05b93b6 --- /dev/null +++ b/newlib/libc/string/wmemset.c @@ -0,0 +1,81 @@ +/* +FUNCTION + <<wmemset>>---set wide-characters in memory + +ANSI_SYNOPSIS + #include <wchar.h> + wchar_t *wmemset(wchar_t *<[s]>, wchar_t <[c]>, size_t <[n]>); + +TRAD_SYNOPSIS + wchar_t *wmemset(<[s]>, <[c]>, <[n]> + wchar_t *<[s]>; + wchar_t <[c]>; + size_t <[n]>; + +DESCRIPTION + The <<wmemset>> function copies the value of <[c]> into each of the + first <[n]> wide-characters of the object pointed to by <[s]>. This + function is not affected by locale and all wchar_t values are treated + identically. The null wide-character and wchar_t values not + corresponding to valid characters are not treated specially. + + If <[n]> is zero, <[s]> must be a valid pointer and the function + copies zero wide-characters. + +RETURNS + The <<wmemset>> functions returns the value of <[s]>. + +PORTABILITY +<<wmemset>> is ISO/IEC 9899/AMD1:1995 (ISO C). +No supporting OS subroutines are required. +*/ + +/* $NetBSD: wmemset.c,v 1.1 2000/12/23 23:14:37 itojun 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 <_ansi.h> +#include <wchar.h> + +wchar_t * +_DEFUN(wmemset, (s, c, n), + wchar_t *s _AND + wchar_t c _AND + size_t n) +{ + size_t i; + wchar_t *p; + + p = (wchar_t *)s; + for (i = 0; i < n; i++) { + *p = c; + p++; + } + return s; +} |