Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Johnston <jjohnstn@redhat.com>2002-08-29 23:38:25 +0400
committerJeff Johnston <jjohnstn@redhat.com>2002-08-29 23:38:25 +0400
commit890e7a1d1a7d701e6e5e0674e58aebe595575375 (patch)
tree6da470c325a8768eb04188a5bfa6b34b39fe02e6
parent86620e21902f8ad14acf919d15bb49b9455311a6 (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.
-rw-r--r--newlib/ChangeLog34
-rw-r--r--newlib/libc/include/wchar.h47
-rw-r--r--newlib/libc/stdlib/Makefile.am7
-rw-r--r--newlib/libc/stdlib/Makefile.in31
-rw-r--r--newlib/libc/string/Makefile.am28
-rw-r--r--newlib/libc/string/Makefile.in45
-rw-r--r--newlib/libc/string/wcscat.c84
-rw-r--r--newlib/libc/string/wcschr.c81
-rw-r--r--newlib/libc/string/wcscmp.c83
-rw-r--r--newlib/libc/string/wcscpy.c (renamed from newlib/libc/stdlib/wmemmove.c)51
-rw-r--r--newlib/libc/string/wcscspn.c85
-rw-r--r--newlib/libc/string/wcslcat.c108
-rw-r--r--newlib/libc/string/wcslcpy.c102
-rw-r--r--newlib/libc/string/wcslen.c (renamed from newlib/libc/stdlib/wmemchr.c)56
-rw-r--r--newlib/libc/string/wcsncat.c90
-rw-r--r--newlib/libc/string/wcsncmp.c92
-rw-r--r--newlib/libc/string/wcsncpy.c89
-rw-r--r--newlib/libc/string/wcspbrk.c86
-rw-r--r--newlib/libc/string/wcsrchr.c86
-rw-r--r--newlib/libc/string/wcsspn.c (renamed from newlib/libc/stdlib/wmemcmp.c)69
-rw-r--r--newlib/libc/string/wcsstr.c104
-rw-r--r--newlib/libc/string/wmemchr.c88
-rw-r--r--newlib/libc/string/wmemcmp.c88
-rw-r--r--newlib/libc/string/wmemcpy.c (renamed from newlib/libc/stdlib/wmemcpy.c)40
-rw-r--r--newlib/libc/string/wmemmove.c81
-rw-r--r--newlib/libc/string/wmemset.c (renamed from newlib/libc/stdlib/wmemset.c)34
26 files changed, 1700 insertions, 89 deletions
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 <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.
+
2002-08-29 Jeff Johnston <jjohnstn@redhat.com>
* 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 <sys/_types.h>
+#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
+ <<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/stdlib/wmemmove.c b/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
+ <<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.
@@ -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 <string.h>
#include <wchar.h>
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;
+
+ *s1 = '\0';
+ p = s1;
+ q = s2;
+ while (*q)
+ *p++ = *q++;
+ *p = '\0';
- return (wchar_t *)memmove(d, s, n * sizeof(wchar_t));
+ 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/stdlib/wmemchr.c b/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
+ <<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.
@@ -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 <stdlib.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
+_DEFUN (wcslen, (s),
+ _CONST wchar_t * s)
{
- size_t i;
-
- for (i = 0; i < n; i++) {
- if (*s == c) {
- /* LINTED const castaway */
- return (wchar_t *)s;
- }
- s++;
- }
- return NULL;
+ _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/stdlib/wmemcmp.c b/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
+ <<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.
@@ -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 <wchar.h>
-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;
-
- for (i = 0; i < n; i++) {
- if (*s1 != *s2) {
- /* wchar might be unsigned */
- return *s1 > *s2 ? 1 : -1;
- }
- s1++;
- s2++;
+ _CONST wchar_t *p;
+ _CONST wchar_t *q;
+
+ 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
+ <<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/stdlib/wmemcpy.c b/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
+ <<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.
@@ -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>>---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/stdlib/wmemset.c b/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
+ <<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.