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>2003-10-23 22:07:13 +0400
committerJeff Johnston <jjohnstn@redhat.com>2003-10-23 22:07:13 +0400
commit4340b63bc1e20c0311f7a723b8c3ee3b1760a60a (patch)
tree850fb7887a946302c4af37593d9732788dcc5038 /newlib/libc/string
parent34dd9dbc047a6aa8547d1c6c2f04154d272ee76f (diff)
2003-10-23 Artem B. Bityuckiy <mail_lists@mail.ru>
* libc/string/wcsnlen.c: New file. * libc/include/wchar.h: Add wcsnlen prototype. * libc/string/Makefile.am: Add wcsnlen support. * libc/string/Makefile.in: Regenerated. * libc/string/wcstrings.tex: Add wcsnlen documentation.
Diffstat (limited to 'newlib/libc/string')
-rw-r--r--newlib/libc/string/Makefile.am12
-rw-r--r--newlib/libc/string/Makefile.in33
-rw-r--r--newlib/libc/string/wcsnlen.c74
-rw-r--r--newlib/libc/string/wcstrings.tex4
4 files changed, 104 insertions, 19 deletions
diff --git a/newlib/libc/string/Makefile.am b/newlib/libc/string/Makefile.am
index 6066c9bbf..cac5f1d53 100644
--- a/newlib/libc/string/Makefile.am
+++ b/newlib/libc/string/Makefile.am
@@ -57,6 +57,7 @@ GENERAL_SOURCES = \
wcsncat.c \
wcsncmp.c \
wcsncpy.c \
+ wcsnlen.c \
wcspbrk.c \
wcsrchr.c \
wcsspn.c \
@@ -108,11 +109,12 @@ memcmp.def strchr.def strlen.def strnlen.def strspn.def \
strcasecmp.def strncasecmp.def strlwr.def strupr.def memccpy.def \
mempcpy.def \
wcscat.def wcschr.def wcscmp.def wcscoll.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 \
-wcswidth.def wcwidth.def wmemchr.def wmemcmp.def wmemcpy.def \
-wmemmove.def wmemset.def
+wcscpy.def wcscspn.def \
+wcslcat.def wcslcpy.def wcslen.def wcsncat.def \
+wcsncmp.def wcsncpy.def wcsnlen.def wcspbrk.def \
+wcsrchr.def wcsspn.def wcsstr.def \
+wcswidth.def wcwidth.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 b53356c9e..87adac44b 100644
--- a/newlib/libc/string/Makefile.in
+++ b/newlib/libc/string/Makefile.in
@@ -1,6 +1,6 @@
-# Makefile.in generated automatically by automake 1.4 from Makefile.am
+# Makefile.in generated automatically by automake 1.4-p5 from Makefile.am
-# Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc.
+# Copyright (C) 1994, 1995-8, 1999, 2001 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
@@ -163,6 +163,7 @@ GENERAL_SOURCES = \
wcsncat.c \
wcsncmp.c \
wcsncpy.c \
+ wcsnlen.c \
wcspbrk.c \
wcsrchr.c \
wcsspn.c \
@@ -206,11 +207,12 @@ memcmp.def strchr.def strlen.def strnlen.def strspn.def \
strcasecmp.def strncasecmp.def strlwr.def strupr.def memccpy.def \
mempcpy.def \
wcscat.def wcschr.def wcscmp.def wcscoll.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 \
-wcswidth.def wcwidth.def wmemchr.def wmemcmp.def wmemcpy.def \
-wmemmove.def wmemset.def
+wcscpy.def wcscspn.def \
+wcslcat.def wcslcpy.def wcslen.def wcsncat.def \
+wcsncmp.def wcsncpy.def wcsnlen.def wcspbrk.def \
+wcsrchr.def wcsspn.def wcsstr.def \
+wcswidth.def wcwidth.def wmemchr.def \
+wmemcmp.def wmemcpy.def wmemmove.def wmemset.def
SUFFIXES = .def
@@ -248,10 +250,12 @@ LIBS = @LIBS@
@USE_LIBTOOL_FALSE@wcscpy.$(OBJEXT) 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) wcswidth.$(OBJEXT) wcwidth.$(OBJEXT) \
-@USE_LIBTOOL_FALSE@wmemchr.$(OBJEXT) wmemcmp.$(OBJEXT) wmemcpy.$(OBJEXT) \
-@USE_LIBTOOL_FALSE@wmemmove.$(OBJEXT) wmemset.$(OBJEXT)
+@USE_LIBTOOL_FALSE@wcsnlen.$(OBJEXT) wcspbrk.$(OBJEXT) \
+@USE_LIBTOOL_FALSE@wcsrchr.$(OBJEXT) wcsspn.$(OBJEXT) wcsstr.$(OBJEXT) \
+@USE_LIBTOOL_FALSE@wcswidth.$(OBJEXT) wcwidth.$(OBJEXT) \
+@USE_LIBTOOL_FALSE@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 \
@@ -265,9 +269,10 @@ LTLIBRARIES = $(noinst_LTLIBRARIES)
@USE_LIBTOOL_TRUE@strupr.lo strxfrm.lo strstr.lo swab.lo u_strerr.lo \
@USE_LIBTOOL_TRUE@wcscat.lo wcschr.lo wcscmp.lo wcscoll.lo wcscpy.lo \
@USE_LIBTOOL_TRUE@wcscspn.lo wcslcat.lo wcslcpy.lo wcslen.lo wcsncat.lo \
-@USE_LIBTOOL_TRUE@wcsncmp.lo wcsncpy.lo wcspbrk.lo wcsrchr.lo wcsspn.lo \
-@USE_LIBTOOL_TRUE@wcsstr.lo wcswidth.lo wcwidth.lo wmemchr.lo wmemcmp.lo \
-@USE_LIBTOOL_TRUE@wmemcpy.lo wmemmove.lo wmemset.lo
+@USE_LIBTOOL_TRUE@wcsncmp.lo wcsncpy.lo wcsnlen.lo wcspbrk.lo \
+@USE_LIBTOOL_TRUE@wcsrchr.lo wcsspn.lo wcsstr.lo wcswidth.lo wcwidth.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/wcsnlen.c b/newlib/libc/string/wcsnlen.c
new file mode 100644
index 000000000..e84342d3d
--- /dev/null
+++ b/newlib/libc/string/wcsnlen.c
@@ -0,0 +1,74 @@
+/*
+FUNCTION
+ <<wcsnlen>>---get fixed-size wide character string length
+
+INDEX
+ wcsnlen
+
+ANSI_SYNOPSIS
+ #include <wchar.h>
+ size_t wcsnlen(const wchar_t *<[s]>, size_t <[maxlen]>);
+
+TRAD_SYNOPSIS
+ #include <wchar.h>
+ size_t wcsnlen(<[s]>, <[maxlen]>)
+ wchar_t *<[s]>;
+ size_t <[maxlen]>;
+
+DESCRIPTION
+ The <<wcsnlen>> function computes the number of wide character codes
+ in the wide character string pointed to by <[s]> not including the
+ terminating L'\0' wide character but at most <[maxlen]> wide
+ characters.
+
+RETURNS
+ <<wcsnlen>> returns the length of <[s]> if it is less then <[maxlen]>,
+ or <[maxlen]> if there is no L'\0' wide character in first <[maxlen]>
+ characters.
+
+PORTABILITY
+<<wcsnlen>> is GNU extension..
+<<wcsnlen>> requires no supporting OS subroutines.
+*/
+
+/*
+ * Copyright (c) 2003, Artem B. Bityuckiy (dedekind@mail.ru).
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the above copyright notice,
+ * this condition statement, and the following disclaimer are retained
+ * in any redistributions of the source code.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <_ansi.h>
+#include <sys/types.h>
+#include <wchar.h>
+
+size_t
+_DEFUN(wcsnlen, (s, maxlen),
+ _CONST wchar_t *s _AND
+ size_t maxlen)
+{
+ _CONST wchar_t *p;
+
+ p = s;
+ while (*p && maxlen-- > 0)
+ p++;
+
+ return (size_t)(p - s);
+}
+
+
+
diff --git a/newlib/libc/string/wcstrings.tex b/newlib/libc/string/wcstrings.tex
index 8f82e62c3..ad0a60788 100644
--- a/newlib/libc/string/wcstrings.tex
+++ b/newlib/libc/string/wcstrings.tex
@@ -23,6 +23,7 @@ declarations are in @file{wchar.h}.
* wcsncat:: Concatenate wide-character strings
* wcsncmp:: Wide-character string compare
* wcsncpy:: Counted copy wide-character string
+* wcsnlen:: Wide-character string length with maximum limit
* wcspbrk:: Find wide-chars in string
* wcsrchr:: Reverse search for wide-character in string
* wcsspn:: Find initial match in wide-character string
@@ -83,6 +84,9 @@ declarations are in @file{wchar.h}.
@include string/wcsncpy.def
@page
+@include string/wcsnlen.def
+
+@page
@include string/wcspbrk.def
@page