From 890e7a1d1a7d701e6e5e0674e58aebe595575375 Mon Sep 17 00:00:00 2001 From: Jeff Johnston Date: Thu, 29 Aug 2002 19:38:25 +0000 Subject: [PATCH] 2002-08-29 Kazuhiro Fujieda * 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. --- newlib/ChangeLog | 34 ++++++ newlib/libc/include/wchar.h | 47 +++++--- newlib/libc/stdlib/Makefile.am | 7 +- newlib/libc/stdlib/Makefile.in | 31 ++--- newlib/libc/string/Makefile.am | 28 ++++- newlib/libc/string/Makefile.in | 45 +++++++- newlib/libc/string/wcscat.c | 84 ++++++++++++++ newlib/libc/string/wcschr.c | 81 +++++++++++++ newlib/libc/string/wcscmp.c | 83 ++++++++++++++ .../{stdlib/wmemmove.c => string/wcscpy.c} | 51 +++++++-- newlib/libc/string/wcscspn.c | 85 ++++++++++++++ newlib/libc/string/wcslcat.c | 108 ++++++++++++++++++ newlib/libc/string/wcslcpy.c | 102 +++++++++++++++++ .../{stdlib/wmemchr.c => string/wcslen.c} | 54 ++++++--- newlib/libc/string/wcsncat.c | 90 +++++++++++++++ newlib/libc/string/wcsncmp.c | 92 +++++++++++++++ newlib/libc/string/wcsncpy.c | 89 +++++++++++++++ newlib/libc/string/wcspbrk.c | 86 ++++++++++++++ newlib/libc/string/wcsrchr.c | 86 ++++++++++++++ .../{stdlib/wmemcmp.c => string/wcsspn.c} | 67 ++++++++--- newlib/libc/string/wcsstr.c | 104 +++++++++++++++++ newlib/libc/string/wmemchr.c | 88 ++++++++++++++ newlib/libc/string/wmemcmp.c | 88 ++++++++++++++ newlib/libc/{stdlib => string}/wmemcpy.c | 40 ++++++- newlib/libc/string/wmemmove.c | 81 +++++++++++++ newlib/libc/{stdlib => string}/wmemset.c | 34 ++++++ 26 files changed, 1698 insertions(+), 87 deletions(-) create mode 100644 newlib/libc/string/wcscat.c create mode 100644 newlib/libc/string/wcschr.c create mode 100644 newlib/libc/string/wcscmp.c rename newlib/libc/{stdlib/wmemmove.c => string/wcscpy.c} (57%) create mode 100644 newlib/libc/string/wcscspn.c create mode 100644 newlib/libc/string/wcslcat.c create mode 100644 newlib/libc/string/wcslcpy.c rename newlib/libc/{stdlib/wmemchr.c => string/wcslen.c} (62%) create mode 100644 newlib/libc/string/wcsncat.c create mode 100644 newlib/libc/string/wcsncmp.c create mode 100644 newlib/libc/string/wcsncpy.c create mode 100644 newlib/libc/string/wcspbrk.c create mode 100644 newlib/libc/string/wcsrchr.c rename newlib/libc/{stdlib/wmemcmp.c => string/wcsspn.c} (55%) create mode 100644 newlib/libc/string/wcsstr.c create mode 100644 newlib/libc/string/wmemchr.c create mode 100644 newlib/libc/string/wmemcmp.c rename newlib/libc/{stdlib => string}/wmemcpy.c (59%) create mode 100644 newlib/libc/string/wmemmove.c rename newlib/libc/{stdlib => string}/wmemset.c (61%) diff --git a/newlib/ChangeLog b/newlib/ChangeLog index 799c35027..01e650ae1 100644 --- a/newlib/ChangeLog +++ b/newlib/ChangeLog @@ -1,3 +1,37 @@ +2002-08-29 Kazuhiro Fujieda + + * 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. + 2002-08-29 Jeff Johnston * libc/locale/locale.c (_setlocale_r)[MB_CAPABLE]: Fix so diff --git a/newlib/libc/include/wchar.h b/newlib/libc/include/wchar.h index a8ff9b175..06c187e64 100644 --- a/newlib/libc/include/wchar.h +++ b/newlib/libc/include/wchar.h @@ -11,8 +11,12 @@ /* For _mbstate_t definition. */ #include +#ifndef NULL +#define NULL 0 +#endif + #ifndef WEOF -# define WEOF (0xffffffffu) +# define WEOF ((wint_t)-1) #endif #ifndef MBSTATE_T @@ -20,18 +24,33 @@ typedef _mbstate_t mbstate_t; #endif /* MBSTATE_T */ -wint_t btowc (int c); -int wctob (wint_t c); -int mbsinit(const mbstate_t *ps); -size_t mbrlen(const char *s, size_t n, mbstate_t *ps); -size_t mbrtowc(wchar_t *pwc, const char *s, size_t n, mbstate_t *ps); -size_t wcrtomb(char *s, wchar_t wc, mbstate_t *ps); -size_t mbsrtowcs(wchar_t *dst, const char **src, size_t len, mbstate_t *ps); -size_t wcsrtombs(char *dst, const wchar_t **src, size_t len, mbstate_t *ps); -wchar_t *wmemchr(const wchar_t *ws, wchar_t wc, size_t n); -int wmemcmp(const wchar_t *ws1, const wchar_t *ws2, size_t n); -wchar_t *wmemcpy(wchar_t *ws1, const wchar_t *ws2, size_t n); -wchar_t *wmemmove(wchar_t *ws1, const wchar_t *ws2, size_t n); -wchar_t *wmemset(wchar_t *ws, wchar_t wc, size_t n); +wint_t _EXFUN(btowc, (int)); +int _EXFUN(wctob, (wint_t)); +size_t _EXFUN(mbrlen, (const char * , size_t, mbstate_t *)); +size_t _EXFUN(mbrtowc, (wchar_t * , const char * , size_t, mbstate_t *)); +int _EXFUN(mbsinit, (const mbstate_t *)); +size_t _EXFUN(mbsrtowcs, (wchar_t * , const char ** , size_t, mbstate_t *)); +size_t _EXFUN(wcrtomb, (char * , wchar_t, mbstate_t *)); +size_t _EXFUN(wcsrtombs, (char * , const wchar_t ** , size_t, mbstate_t *)); +wchar_t *_EXFUN(wcscat, (wchar_t * , const wchar_t *)); +wchar_t *_EXFUN(wcschr, (const wchar_t *, wchar_t)); +int _EXFUN(wcscmp, (const wchar_t *, const wchar_t *)); +wchar_t *_EXFUN(wcscpy, (wchar_t * , const wchar_t *)); +size_t _EXFUN(wcscspn, (const wchar_t *, const wchar_t *)); +size_t _EXFUN(wcslcat, (wchar_t *, const wchar_t *, size_t)); +size_t _EXFUN(wcslcpy, (wchar_t *, const wchar_t *, size_t)); +size_t _EXFUN(wcslen, (const wchar_t *)); +wchar_t *_EXFUN(wcsncat, (wchar_t * , const wchar_t * , size_t)); +int _EXFUN(wcsncmp, (const wchar_t *, const wchar_t *, size_t)); +wchar_t *_EXFUN(wcsncpy, (wchar_t * , const wchar_t * , size_t)); +wchar_t *_EXFUN(wcspbrk, (const wchar_t *, const wchar_t *)); +wchar_t *_EXFUN(wcsrchr, (const wchar_t *, wchar_t)); +size_t _EXFUN(wcsspn, (const wchar_t *, const wchar_t *)); +wchar_t *_EXFUN(wcsstr, (const wchar_t *, const wchar_t *)); +wchar_t *_EXFUN(wmemchr, (const wchar_t *, wchar_t, size_t)); +int _EXFUN(wmemcmp, (const wchar_t *, const wchar_t *, size_t)); +wchar_t *_EXFUN(wmemcpy, (wchar_t * , const wchar_t * , size_t)); +wchar_t *_EXFUN(wmemmove, (wchar_t *, const wchar_t *, size_t)); +wchar_t *_EXFUN(wmemset, (wchar_t *, wchar_t, size_t)); #endif /* _WCHAR_H_ */ diff --git a/newlib/libc/stdlib/Makefile.am b/newlib/libc/stdlib/Makefile.am index d90c8fad4..cdd7987a0 100644 --- a/newlib/libc/stdlib/Makefile.am +++ b/newlib/libc/stdlib/Makefile.am @@ -49,12 +49,7 @@ GENERAL_SOURCES = \ wcstombs.c \ wcstombs_r.c \ wctomb.c \ - wctomb_r.c \ - wmemchr.c \ - wmemcmp.c \ - wmemcpy.c \ - wmemmove.c \ - wmemset.c + wctomb_r.c EXTENDED_SOURCES = \ drand48.c \ diff --git a/newlib/libc/stdlib/Makefile.in b/newlib/libc/stdlib/Makefile.in index 6baa24f51..6f72debaf 100644 --- a/newlib/libc/stdlib/Makefile.in +++ b/newlib/libc/stdlib/Makefile.in @@ -155,12 +155,7 @@ GENERAL_SOURCES = \ wcstombs.c \ wcstombs_r.c \ wctomb.c \ - wctomb_r.c \ - wmemchr.c \ - wmemcmp.c \ - wmemcpy.c \ - wmemmove.c \ - wmemset.c + wctomb_r.c EXTENDED_SOURCES = \ @@ -312,15 +307,12 @@ LIBS = @LIBS@ @USE_LIBTOOL_FALSE@realloc.$(OBJEXT) strtod.$(OBJEXT) strtol.$(OBJEXT) \ @USE_LIBTOOL_FALSE@strtoul.$(OBJEXT) wcstombs.$(OBJEXT) \ @USE_LIBTOOL_FALSE@wcstombs_r.$(OBJEXT) wctomb.$(OBJEXT) \ -@USE_LIBTOOL_FALSE@wctomb_r.$(OBJEXT) wmemchr.$(OBJEXT) \ -@USE_LIBTOOL_FALSE@wmemcmp.$(OBJEXT) wmemcpy.$(OBJEXT) \ -@USE_LIBTOOL_FALSE@wmemmove.$(OBJEXT) wmemset.$(OBJEXT) \ -@USE_LIBTOOL_FALSE@drand48.$(OBJEXT) ecvtbuf.$(OBJEXT) efgcvt.$(OBJEXT) \ -@USE_LIBTOOL_FALSE@erand48.$(OBJEXT) jrand48.$(OBJEXT) \ -@USE_LIBTOOL_FALSE@lcong48.$(OBJEXT) lrand48.$(OBJEXT) \ -@USE_LIBTOOL_FALSE@mrand48.$(OBJEXT) msize.$(OBJEXT) mtrim.$(OBJEXT) \ -@USE_LIBTOOL_FALSE@nrand48.$(OBJEXT) rand48.$(OBJEXT) seed48.$(OBJEXT) \ -@USE_LIBTOOL_FALSE@srand48.$(OBJEXT) strtoll.$(OBJEXT) \ +@USE_LIBTOOL_FALSE@wctomb_r.$(OBJEXT) drand48.$(OBJEXT) \ +@USE_LIBTOOL_FALSE@ecvtbuf.$(OBJEXT) efgcvt.$(OBJEXT) erand48.$(OBJEXT) \ +@USE_LIBTOOL_FALSE@jrand48.$(OBJEXT) lcong48.$(OBJEXT) \ +@USE_LIBTOOL_FALSE@lrand48.$(OBJEXT) mrand48.$(OBJEXT) msize.$(OBJEXT) \ +@USE_LIBTOOL_FALSE@mtrim.$(OBJEXT) nrand48.$(OBJEXT) rand48.$(OBJEXT) \ +@USE_LIBTOOL_FALSE@seed48.$(OBJEXT) srand48.$(OBJEXT) strtoll.$(OBJEXT) \ @USE_LIBTOOL_FALSE@strtoll_r.$(OBJEXT) strtoull.$(OBJEXT) \ @USE_LIBTOOL_FALSE@strtoull_r.$(OBJEXT) LTLIBRARIES = $(noinst_LTLIBRARIES) @@ -334,11 +326,10 @@ LTLIBRARIES = $(noinst_LTLIBRARIES) @USE_LIBTOOL_TRUE@mbstowcs.lo mbstowcs_r.lo mbtowc.lo mbtowc_r.lo \ @USE_LIBTOOL_TRUE@mlock.lo mprec.lo mstats.lo rand.lo rand_r.lo \ @USE_LIBTOOL_TRUE@realloc.lo strtod.lo strtol.lo strtoul.lo wcstombs.lo \ -@USE_LIBTOOL_TRUE@wcstombs_r.lo wctomb.lo wctomb_r.lo wmemchr.lo \ -@USE_LIBTOOL_TRUE@wmemcmp.lo wmemcpy.lo wmemmove.lo wmemset.lo \ -@USE_LIBTOOL_TRUE@drand48.lo ecvtbuf.lo efgcvt.lo erand48.lo jrand48.lo \ -@USE_LIBTOOL_TRUE@lcong48.lo lrand48.lo mrand48.lo msize.lo mtrim.lo \ -@USE_LIBTOOL_TRUE@nrand48.lo rand48.lo seed48.lo srand48.lo strtoll.lo \ +@USE_LIBTOOL_TRUE@wcstombs_r.lo wctomb.lo wctomb_r.lo drand48.lo \ +@USE_LIBTOOL_TRUE@ecvtbuf.lo efgcvt.lo erand48.lo jrand48.lo lcong48.lo \ +@USE_LIBTOOL_TRUE@lrand48.lo mrand48.lo msize.lo mtrim.lo nrand48.lo \ +@USE_LIBTOOL_TRUE@rand48.lo seed48.lo srand48.lo strtoll.lo \ @USE_LIBTOOL_TRUE@strtoll_r.lo strtoull.lo strtoull_r.lo CFLAGS = @CFLAGS@ COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) 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 + <>---concatenate two wide-character strings +INDEX + wcscat + +ANSI_SYNOPSIS + #include + 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 <> 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 <> function returns <[s1]>; + no return value is reserved to indicate an error. + +PORTABILITY +<> 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_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 + <>---wide-character string scanning operation + +ANSI_SYNOPSIS + #include + 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 <> 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, <> returns a pointer to the wide-character + code, or a null pointer if the wide-character code is not found. + +PORTABILITY +<> 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_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 + <>---compare two wide-character strings + +ANSI_SYNOPSIS + #include + int wcscmp(const wchar_t *<[s1]>, *<[s2]>); + +TRAD_SYNOPSIS + int wcscmp(<[s1]>, <[s2]> + const wchar_t *<[s1]>, <[s2]>; + +DESCRIPTION + The <> 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, <> 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 +<> 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 + +/* + * 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/stdlib/wmemmove.c b/newlib/libc/string/wcscpy.c similarity index 57% rename from newlib/libc/stdlib/wmemmove.c rename to newlib/libc/string/wcscpy.c index 686a2f7ad..5a72338ce 100644 --- a/newlib/libc/stdlib/wmemmove.c +++ b/newlib/libc/string/wcscpy.c @@ -1,3 +1,33 @@ +/* +FUNCTION + <>---copy a wide-character string + +ANSI_SYNOPSIS + #include + 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 <> 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 <> function returns <[s1]>; no return value is reserved to + indicate an error. + +PORTABILITY +<> 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. @@ -23,19 +53,26 @@ * 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 + * citrus Id: wcscpy.c,v 1.2 2000/12/21 04:51:09 itojun Exp */ #include <_ansi.h> -#include #include wchar_t * -_DEFUN (wmemmove, (d, s, n), - wchar_t *d _AND - const wchar_t *s _AND - size_t n) +_DEFUN (wcscpy, (s1, s2), + wchar_t * s1 _AND + _CONST wchar_t * s2) { + wchar_t *p; + _CONST wchar_t *q; - return (wchar_t *)memmove(d, s, n * sizeof(wchar_t)); + *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 + <>---get length of a complementary wide substring + +ANSI_SYNOPSIS + #include + 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 <> 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 <> function returns the length of the initial substring of + <[s1]>; no return value is reserved to indicate an error. + +PORTABILITY +<> 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 + +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 + <>---concatenate wide-character strings to specified length + +ANSI_SYNOPSIS + #include + size_t wcslcat(wchar_t *<[dst]>, const wchar_t *<[src]>, size_t <[siz]>); + +TRAD_SYNOPSIS + #include + size_t wcslcat(<[dst]>, <[src]>, <[siz]> + wchar_t *<[dst]>; + const wchar_t *<[src]>; + size_t <[siz]>; + +DESCRIPTION + The <> 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 + * 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 + +/* + * 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 + <>---copy a wide-character string to specified length + +ANSI_SYNOPSIS + #include + size_t wcslcpy(wchar_t *<[dst]>, const wchar_t *<[src]>, size_t <[siz]>); + +TRAD_SYNOPSIS + #include + size_t wcslcpy(<[dst]>, <[src]>, <[siz]>) + wchar_t *<[dst]>; + const wchar_t *<[src]>; + size_t <[siz]>; + +DESCRIPTION + <> 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 + <> 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 + * 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 + +/* + * 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/stdlib/wmemchr.c b/newlib/libc/string/wcslen.c similarity index 62% rename from newlib/libc/stdlib/wmemchr.c rename to newlib/libc/string/wcslen.c index f236ce056..d68f00a72 100644 --- a/newlib/libc/stdlib/wmemchr.c +++ b/newlib/libc/string/wcslen.c @@ -1,3 +1,31 @@ +/* +FUNCTION + <>---get wide-character string length + +ANSI_SYNOPSIS + #include + size_t wcslen(const wchar_t *<[s]>); + +TRAD_SYNOPSIS + size_t wcslen(<[s]> + const wchar_t *<[s]>; + +DESCRIPTION + The <> 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 <> function returns the length of <[s]>; no return value is + reserved to indicate an error. + +PORTABILITY +<> 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. @@ -23,27 +51,21 @@ * 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 + * citrus Id: wcslen.c,v 1.1 1999/12/29 21:47:45 tshiozak Exp */ #include <_ansi.h> -#include #include -wchar_t * -_DEFUN (wmemchr, (s, c, n), - const wchar_t *s _AND - wchar_t c _AND - size_t n) +size_t +_DEFUN (wcslen, (s), + _CONST wchar_t * s) { - size_t i; + _CONST wchar_t *p; - for (i = 0; i < n; i++) { - if (*s == c) { - /* LINTED const castaway */ - return (wchar_t *)s; - } - s++; - } - return NULL; + 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 + <>---concatenate part of two wide-character strings + +ANSI_SYNOPSIS + #include + 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 <> 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 <> function returns <[s1]>; no return value is reserved to + indicate an error. + +PORTABILITY +<> 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_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 + <>---compare part of two wide-character strings + +ANSI_SYNOPSIS + #include + 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 <> 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, <> 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 +<> 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 + +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 + <>---copy part of a wide-character string + +ANSI_SYNOPSIS + #include + 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 <> 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 <> function returns <[s1]>; no return value is reserved to + indicate an error. + +PORTABILITY +<> 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_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 + <>----scan wide-character string for a wide-character code + +ANSI_SYNOPSIS + #include + 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 <> 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, <> returns a pointer to the + wide-character code or a null pointer if no wide-character code from + <[set]> occurs in <[s]>. + +PORTABILITY +<> 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_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 + <>---wide-character string scanning operation + +ANSI_SYNOPSIS + #include + wchar_t *wcsrchr(const wchar_t *<[s]>, wchar_t <[c]>); + +TRAD_SYNOPSIS + #include + wchar_t *wcsrchr(<[s]>, <[c]> + const wchar_t *<[s]>; + wchar_t <[c]>; + +DESCRIPTION + The <> 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, <> returns a pointer to the + wide-character code or a null pointer if <[c]> does not occur in the + wide-character string. + +PORTABILITY +<> 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_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/stdlib/wmemcmp.c b/newlib/libc/string/wcsspn.c similarity index 55% rename from newlib/libc/stdlib/wmemcmp.c rename to newlib/libc/string/wcsspn.c index 967acb3bd..f0b2fb99f 100644 --- a/newlib/libc/stdlib/wmemcmp.c +++ b/newlib/libc/string/wcsspn.c @@ -1,3 +1,33 @@ +/* +FUNCTION + <>---get length of a wide substring + +ANSI_SYNOPSIS + #include + 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 <> 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 +<> 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. @@ -23,27 +53,34 @@ * 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 + * citrus Id: wcsspn.c,v 1.1 1999/12/29 21:47:45 tshiozak Exp */ #include <_ansi.h> #include -int -_DEFUN (wmemcmp, (s1, s2, n), - const wchar_t *s1 _AND - const wchar_t *s2 _AND - size_t n) +size_t +_DEFUN (wcsspn, (s, set), + _CONST wchar_t * s _AND + _CONST wchar_t * set) { - size_t i; + _CONST wchar_t *p; + _CONST wchar_t *q; - for (i = 0; i < n; i++) { - if (*s1 != *s2) { - /* wchar might be unsigned */ - return *s1 > *s2 ? 1 : -1; - } - s1++; - s2++; + p = s; + while (*p) + { + q = set; + while (*q) + { + if (*p == *q) + break; } - return 0; + 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 + <>---find a wide-character substring + +ANSI_SYNOPSIS + #include + 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 <> 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, <> 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 +<> 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_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 + <>---find a wide-character in memory + + +ANSI_SYNOPSIS + #include + 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 <> 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 <> function returns a pointer to the located + wide-character, or a null pointer if the wide-character does not occur + in the object. + +PORTABILITY +<> 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_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 + <>---compare wide-characters in memory + +ANSI_SYNOPSIS + #include + 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 <> 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 <> 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 +<> 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 + +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/stdlib/wmemcpy.c b/newlib/libc/string/wmemcpy.c similarity index 59% rename from newlib/libc/stdlib/wmemcpy.c rename to newlib/libc/string/wmemcpy.c index 83ad5fc31..c3a96a32d 100644 --- a/newlib/libc/stdlib/wmemcpy.c +++ b/newlib/libc/string/wmemcpy.c @@ -1,3 +1,37 @@ +/* +FUNCTION + <>---copy wide-characters in memory + +ANSI_SYNOPSIS + #include + 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 <> 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 <> function returns the value of <[d]>. + +PORTABILITY +<> 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. @@ -32,10 +66,10 @@ wchar_t * _DEFUN (wmemcpy, (d, s, n), - wchar_t *d _AND - const wchar_t *s _AND + wchar_t * d _AND + _CONST wchar_t * s _AND size_t n) { - return (wchar_t *)memcpy(d, s, n * sizeof(wchar_t)); + 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 - copy wide-characters in memory with overlapping areas + +ANSI_SYNOPSIS + #include + 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 <> 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 <> function returns the value of <[d]>. + +PORTABILITY +<> 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 +#include + +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/stdlib/wmemset.c b/newlib/libc/string/wmemset.c similarity index 61% rename from newlib/libc/stdlib/wmemset.c rename to newlib/libc/string/wmemset.c index bb4572739..4e05b93b6 100644 --- a/newlib/libc/stdlib/wmemset.c +++ b/newlib/libc/string/wmemset.c @@ -1,3 +1,37 @@ +/* +FUNCTION + <>---set wide-characters in memory + +ANSI_SYNOPSIS + #include + 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 <> 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 <> functions returns the value of <[s]>. + +PORTABILITY +<> 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.