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-05-25 03:44:39 +0400
committerJeff Johnston <jjohnstn@redhat.com>2002-05-25 03:44:39 +0400
commitd29587b4789426217ace96c1dccb249e3682eaf8 (patch)
tree5eb3816b224b613db0274c8bccd57ef729261b68 /newlib/libc/string
parent8b3e5e2d6e5076769d90662db759ce5009c1ba9c (diff)
2002-05-24 Jeff Johnston <jjohnstn@redhat.com>
* libc/include/string.h: Add strnlen and strerror_r prototypes. * libc/string/Makefile.am: Add strnlen.c and strerror_r.c support. * libc/string/Makefile.in: Regenerated. * libc/string/strerror_r.c: New file. * libc/string/strnlen.c: New file. * libc/sys/linux/Makefile.am: Add rename.c. * libc/sys/linux/Makefile.in: Regenerated. * libc/sys/linux/rename.c: New file to override default rename.
Diffstat (limited to 'newlib/libc/string')
-rw-r--r--newlib/libc/string/Makefile.am6
-rw-r--r--newlib/libc/string/Makefile.in27
-rw-r--r--newlib/libc/string/strerror_r.c53
-rw-r--r--newlib/libc/string/strnlen.c49
4 files changed, 121 insertions, 14 deletions
diff --git a/newlib/libc/string/Makefile.am b/newlib/libc/string/Makefile.am
index a56522121..f90fed168 100644
--- a/newlib/libc/string/Makefile.am
+++ b/newlib/libc/string/Makefile.am
@@ -23,6 +23,7 @@ LIB_SOURCES = \
strcpy.c \
strcspn.c \
strerror.c \
+ strerror_r.c \
strlcat.c \
strlcpy.c \
strlen.c \
@@ -31,6 +32,7 @@ LIB_SOURCES = \
strncmp.c \
strncasecmp.c \
strncpy.c \
+ strnlen.c \
strpbrk.c \
strrchr.c \
strsep.c \
@@ -62,8 +64,8 @@ bcmp.def memcpy.def strcmp.def strncat.def strstr.def \
bcopy.def memmove.def strcoll.def strncmp.def strtok.def \
bzero.def memset.def strcpy.def strncpy.def strxfrm.def \
index.def rindex.def strcspn.def strpbrk.def swab.def \
-memchr.def strcat.def strerror.def strrchr.def \
-memcmp.def strchr.def strlen.def strspn.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
SUFFIXES = .def
diff --git a/newlib/libc/string/Makefile.in b/newlib/libc/string/Makefile.in
index c27d17aad..36bac8869 100644
--- a/newlib/libc/string/Makefile.in
+++ b/newlib/libc/string/Makefile.in
@@ -121,6 +121,7 @@ LIB_SOURCES = \
strcpy.c \
strcspn.c \
strerror.c \
+ strerror_r.c \
strlcat.c \
strlcpy.c \
strlen.c \
@@ -129,6 +130,7 @@ LIB_SOURCES = \
strncmp.c \
strncasecmp.c \
strncpy.c \
+ strnlen.c \
strpbrk.c \
strrchr.c \
strsep.c \
@@ -156,8 +158,8 @@ bcmp.def memcpy.def strcmp.def strncat.def strstr.def \
bcopy.def memmove.def strcoll.def strncmp.def strtok.def \
bzero.def memset.def strcpy.def strncpy.def strxfrm.def \
index.def rindex.def strcspn.def strpbrk.def swab.def \
-memchr.def strcat.def strerror.def strrchr.def \
-memcmp.def strchr.def strlen.def strspn.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
@@ -180,11 +182,12 @@ lib_a_LIBADD =
@USE_LIBTOOL_FALSE@lib_a_OBJECTS = bcmp.o bcopy.o bzero.o index.o \
@USE_LIBTOOL_FALSE@memchr.o memcmp.o memcpy.o memmove.o memset.o \
@USE_LIBTOOL_FALSE@rindex.o strcat.o strchr.o strcmp.o strcasecmp.o \
-@USE_LIBTOOL_FALSE@strcoll.o strcpy.o strcspn.o strerror.o strlcat.o \
-@USE_LIBTOOL_FALSE@strlcpy.o strlen.o strlwr.o strncat.o strncmp.o \
-@USE_LIBTOOL_FALSE@strncasecmp.o strncpy.o strpbrk.o strrchr.o strsep.o \
-@USE_LIBTOOL_FALSE@strspn.o strtok.o strtok_r.o strupr.o strxfrm.o \
-@USE_LIBTOOL_FALSE@strstr.o swab.o u_strerr.o
+@USE_LIBTOOL_FALSE@strcoll.o strcpy.o strcspn.o strerror.o strerror_r.o \
+@USE_LIBTOOL_FALSE@strlcat.o strlcpy.o strlen.o strlwr.o strncat.o \
+@USE_LIBTOOL_FALSE@strncmp.o strncasecmp.o strncpy.o strnlen.o \
+@USE_LIBTOOL_FALSE@strpbrk.o strrchr.o strsep.o strspn.o strtok.o \
+@USE_LIBTOOL_FALSE@strtok_r.o strupr.o strxfrm.o strstr.o swab.o \
+@USE_LIBTOOL_FALSE@u_strerr.o
LTLIBRARIES = $(noinst_LTLIBRARIES)
libstring_la_LIBADD =
@@ -192,11 +195,11 @@ libstring_la_LIBADD =
@USE_LIBTOOL_TRUE@index.lo memchr.lo memcmp.lo memcpy.lo memmove.lo \
@USE_LIBTOOL_TRUE@memset.lo rindex.lo strcat.lo strchr.lo strcmp.lo \
@USE_LIBTOOL_TRUE@strcasecmp.lo strcoll.lo strcpy.lo strcspn.lo \
-@USE_LIBTOOL_TRUE@strerror.lo strlcat.lo strlcpy.lo strlen.lo strlwr.lo \
-@USE_LIBTOOL_TRUE@strncat.lo strncmp.lo strncasecmp.lo strncpy.lo \
-@USE_LIBTOOL_TRUE@strpbrk.lo strrchr.lo strsep.lo strspn.lo strtok.lo \
-@USE_LIBTOOL_TRUE@strtok_r.lo strupr.lo strxfrm.lo strstr.lo swab.lo \
-@USE_LIBTOOL_TRUE@u_strerr.lo
+@USE_LIBTOOL_TRUE@strerror.lo strerror_r.lo strlcat.lo strlcpy.lo \
+@USE_LIBTOOL_TRUE@strlen.lo strlwr.lo strncat.lo strncmp.lo \
+@USE_LIBTOOL_TRUE@strncasecmp.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
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/strerror_r.c b/newlib/libc/string/strerror_r.c
new file mode 100644
index 000000000..956a1f485
--- /dev/null
+++ b/newlib/libc/string/strerror_r.c
@@ -0,0 +1,53 @@
+/*
+FUNCTION
+ <<strerror_r>>---convert error number to string and copy to buffer
+
+INDEX
+ strerror_r
+
+ANSI_SYNOPSIS
+ #include <string.h>
+ char *strerror_r(int <[errnum]>, char *<[buffer]>, size_t <[n]>);
+
+TRAD_SYNOPSIS
+ #include <string.h>
+ char *strerror_r(<[errnum]>, <[buffer]>, <[n]>)
+ int <[errnum]>;
+ char *<[buffer]>;
+ size_t <[n]>;
+
+DESCRIPTION
+<<strerror_r>> converts the error number <[errnum]> into a
+string and copies the result into the supplied <[buffer]> for
+a length up to <[n]>, including the NUL terminator. The value of
+<[errnum]> is usually a copy of <<errno>>. If <<errnum>> is not a known
+error number, the result is the empty string.
+
+See <<strerror>> for how strings are mapped to <<errnum>>.
+
+RETURNS
+This function returns a pointer to a string. Your application must
+not modify that string.
+
+PORTABILITY
+<<strerror_r>> is a gnu extension.
+
+<<strerror_r>> requires no supporting OS subroutines.
+
+*/
+
+#undef __STRICT_ANSI__
+#include <errno.h>
+#include <string.h>
+
+char *
+_DEFUN (strerror_r, (errnum, buffer, n),
+ int errnum _AND
+ char *buffer _AND
+ size_t n)
+{
+ char *error;
+ error = strerror (errnum);
+
+ return strncpy (buffer, (const char *)error, n);
+}
diff --git a/newlib/libc/string/strnlen.c b/newlib/libc/string/strnlen.c
new file mode 100644
index 000000000..b9a3b5e77
--- /dev/null
+++ b/newlib/libc/string/strnlen.c
@@ -0,0 +1,49 @@
+/*
+FUNCTION
+ <<strnlen>>---character string length
+
+INDEX
+ strnlen
+
+ANSI_SYNOPSIS
+ #include <string.h>
+ size_t strnlen(const char *<[str]>, size_t <[n]>);
+
+TRAD_SYNOPSIS
+ #include <string.h>
+ size_t strnlen(<[str]>, <[n]>)
+ char *<[src]>;
+ size_t <[n]>;
+
+DESCRIPTION
+ The <<strnlen>> function works out the length of the string
+ starting at <<*<[str]>>> by counting chararacters until it
+ reaches a NUL character or the maximum: <[n]> number of
+ characters have been inspected.
+
+RETURNS
+ <<strnlen>> returns the character count or <[n]>.
+
+PORTABILITY
+<<strnlen>> is a Gnu extension.
+
+<<strnlen>> requires no supporting OS subroutines.
+
+*/
+
+#undef __STRICT_ANSI__
+#include <_ansi.h>
+#include <string.h>
+
+size_t
+_DEFUN (strnlen, (str, n),
+ _CONST char *str _AND
+ size_t n)
+{
+ _CONST char *start = str;
+
+ while (*str && n-- > 0)
+ str++;
+
+ return str - start;
+}