summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorColin Watson <cjwatson@debian.org>2007-10-14 03:14:50 +0100
committerColin Watson <cjwatson@debian.org>2007-10-14 03:14:50 +0100
commit40322506d8eb0f18bac99baf9c1fd8c1ea34482d (patch)
tree4fca6784baccdc6f0b4b9b215ac77523d5cbc018 /lib
parentf76c8fc1d65319c2db8a274771505f660f4262ac (diff)
import gnulib xstrndup module
Diffstat (limited to 'lib')
-rw-r--r--lib/Makefile.am1
-rw-r--r--lib/Makefile.in38
-rw-r--r--lib/strnlen.c30
-rw-r--r--lib/xstrndup.c49
4 files changed, 13 insertions, 105 deletions
diff --git a/lib/Makefile.am b/lib/Makefile.am
index 57e303aa..f49a825d 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -47,7 +47,6 @@ libman_a_SOURCES = \
pipeline.h \
tempfile.c \
xsigaction.c \
- xstrndup.c \
xstrsignal.c
## Headers that are used conditionally. Automake can't detect these itself.
diff --git a/lib/Makefile.in b/lib/Makefile.in
index 498c043d..1ef39e34 100644
--- a/lib/Makefile.in
+++ b/lib/Makefile.in
@@ -36,8 +36,8 @@ host_triplet = @host@
subdir = lib
DIST_COMMON = README $(dist_noinst_DATA) $(srcdir)/Makefile.am \
$(srcdir)/Makefile.in alloca.c basename.c flock.c memcmp.c \
- putenv.c realpath.c rename.c strcspn.c strnlen.c strsep.c \
- strspn.c strstr.c waitpid.c
+ putenv.c realpath.c rename.c strcspn.c strsep.c strspn.c \
+ strstr.c waitpid.c
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/gnulib/m4/alloca.m4 \
$(top_srcdir)/gnulib/m4/d-type.m4 \
@@ -66,17 +66,21 @@ am__aclocal_m4_deps = $(top_srcdir)/gnulib/m4/alloca.m4 \
$(top_srcdir)/gnulib/m4/stdlib_h.m4 \
$(top_srcdir)/gnulib/m4/strdup.m4 \
$(top_srcdir)/gnulib/m4/string_h.m4 \
+ $(top_srcdir)/gnulib/m4/strndup.m4 \
+ $(top_srcdir)/gnulib/m4/strnlen.m4 \
$(top_srcdir)/gnulib/m4/sys_stat_h.m4 \
$(top_srcdir)/gnulib/m4/sys_time_h.m4 \
$(top_srcdir)/gnulib/m4/tempname.m4 \
$(top_srcdir)/gnulib/m4/unistd_h.m4 \
$(top_srcdir)/gnulib/m4/wchar.m4 \
$(top_srcdir)/gnulib/m4/wctype.m4 \
- $(top_srcdir)/gnulib/m4/xalloc.m4 $(top_srcdir)/m4/codeset.m4 \
- $(top_srcdir)/m4/gettext.m4 $(top_srcdir)/m4/glibc2.m4 \
- $(top_srcdir)/m4/glibc21.m4 $(top_srcdir)/m4/iconv.m4 \
- $(top_srcdir)/m4/intdiv0.m4 $(top_srcdir)/m4/intl.m4 \
- $(top_srcdir)/m4/intmax.m4 $(top_srcdir)/m4/inttypes-pri.m4 \
+ $(top_srcdir)/gnulib/m4/xalloc.m4 \
+ $(top_srcdir)/gnulib/m4/xstrndup.m4 \
+ $(top_srcdir)/m4/codeset.m4 $(top_srcdir)/m4/gettext.m4 \
+ $(top_srcdir)/m4/glibc2.m4 $(top_srcdir)/m4/glibc21.m4 \
+ $(top_srcdir)/m4/iconv.m4 $(top_srcdir)/m4/intdiv0.m4 \
+ $(top_srcdir)/m4/intl.m4 $(top_srcdir)/m4/intmax.m4 \
+ $(top_srcdir)/m4/inttypes-pri.m4 \
$(top_srcdir)/m4/inttypes_h.m4 $(top_srcdir)/m4/lcmessage.m4 \
$(top_srcdir)/m4/lib-ld.m4 $(top_srcdir)/m4/lib-link.m4 \
$(top_srcdir)/m4/lib-prefix.m4 $(top_srcdir)/m4/lock.m4 \
@@ -109,7 +113,7 @@ am_libman_a_OBJECTS = libman_a-appendstr.$(OBJEXT) \
libman_a-hashtable.$(OBJEXT) libman_a-linelength.$(OBJEXT) \
libman_a-pathsearch.$(OBJEXT) libman_a-pipeline.$(OBJEXT) \
libman_a-tempfile.$(OBJEXT) libman_a-xsigaction.$(OBJEXT) \
- libman_a-xstrndup.$(OBJEXT) libman_a-xstrsignal.$(OBJEXT)
+ libman_a-xstrsignal.$(OBJEXT)
libman_a_OBJECTS = $(am_libman_a_OBJECTS)
DEFAULT_INCLUDES = -I. -I$(top_builddir)@am__isrc@
depcomp = $(SHELL) $(top_srcdir)/tools/depcomp
@@ -458,7 +462,7 @@ libman_a_SOURCES = ansidecl.h appendstr.c cleanup.c cleanup.h debug.c \
decompress.c decompress.h getcwdalloc.c getcwdalloc.h \
hashtable.c hashtable.h linelength.c linelength.h pathsearch.c \
pathsearch.h pipeline.c pipeline.h tempfile.c xsigaction.c \
- xstrndup.c xstrsignal.c flock.h gettext.h
+ xstrsignal.c flock.h gettext.h
libman_a_LIBADD = $(LIBOBJS) $(ALLOCA)
all: all-am
@@ -515,7 +519,6 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/realpath.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/rename.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/strcspn.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/strnlen.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/strsep.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/strspn.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/strstr.Po@am__quote@
@@ -531,7 +534,6 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libman_a-pipeline.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libman_a-tempfile.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libman_a-xsigaction.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libman_a-xstrndup.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libman_a-xstrsignal.Po@am__quote@
.c.o:
@@ -702,20 +704,6 @@ libman_a-xsigaction.obj: xsigaction.c
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libman_a_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libman_a-xsigaction.obj `if test -f 'xsigaction.c'; then $(CYGPATH_W) 'xsigaction.c'; else $(CYGPATH_W) '$(srcdir)/xsigaction.c'; fi`
-libman_a-xstrndup.o: xstrndup.c
-@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libman_a_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libman_a-xstrndup.o -MD -MP -MF $(DEPDIR)/libman_a-xstrndup.Tpo -c -o libman_a-xstrndup.o `test -f 'xstrndup.c' || echo '$(srcdir)/'`xstrndup.c
-@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/libman_a-xstrndup.Tpo $(DEPDIR)/libman_a-xstrndup.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='xstrndup.c' object='libman_a-xstrndup.o' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libman_a_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libman_a-xstrndup.o `test -f 'xstrndup.c' || echo '$(srcdir)/'`xstrndup.c
-
-libman_a-xstrndup.obj: xstrndup.c
-@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libman_a_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libman_a-xstrndup.obj -MD -MP -MF $(DEPDIR)/libman_a-xstrndup.Tpo -c -o libman_a-xstrndup.obj `if test -f 'xstrndup.c'; then $(CYGPATH_W) 'xstrndup.c'; else $(CYGPATH_W) '$(srcdir)/xstrndup.c'; fi`
-@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/libman_a-xstrndup.Tpo $(DEPDIR)/libman_a-xstrndup.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='xstrndup.c' object='libman_a-xstrndup.obj' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libman_a_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libman_a-xstrndup.obj `if test -f 'xstrndup.c'; then $(CYGPATH_W) 'xstrndup.c'; else $(CYGPATH_W) '$(srcdir)/xstrndup.c'; fi`
-
libman_a-xstrsignal.o: xstrsignal.c
@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libman_a_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libman_a-xstrsignal.o -MD -MP -MF $(DEPDIR)/libman_a-xstrsignal.Tpo -c -o libman_a-xstrsignal.o `test -f 'xstrsignal.c' || echo '$(srcdir)/'`xstrsignal.c
@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/libman_a-xstrsignal.Tpo $(DEPDIR)/libman_a-xstrsignal.Po
diff --git a/lib/strnlen.c b/lib/strnlen.c
deleted file mode 100644
index d7ef4db4..00000000
--- a/lib/strnlen.c
+++ /dev/null
@@ -1,30 +0,0 @@
-/* Find the length of STRING, but scan at most MAXLEN characters.
- Copyright (C) 1996, 1997, 1998, 2000 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, write to the Free
- Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- 02110-1301 USA. */
-
-#include <string.h>
-
-/* Find the length of STRING, but scan at most MAXLEN characters.
- If no '\0' terminator is found in that many characters, return MAXLEN. */
-
-size_t
-strnlen (const char *string, size_t maxlen)
-{
- const char *end = memchr (string, '\0', maxlen);
- return end ? (size_t) (end - string) : maxlen;
-}
diff --git a/lib/xstrndup.c b/lib/xstrndup.c
deleted file mode 100644
index 3cc3b69c..00000000
--- a/lib/xstrndup.c
+++ /dev/null
@@ -1,49 +0,0 @@
-/* xstrndup.c -- copy a portion of a string with out of memory checking
- Copyright (C) 2001 Colin Watson.
- Based on strndup.c,
- copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2, or (at your option)
- any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
-#if defined(STDC_HEADERS) || defined(HAVE_STRING_H)
-#include <string.h>
-#else
-#include <strings.h>
-#endif
-
-#include "manconfig.h"
-
-extern size_t strnlen (const char *string, size_t maxlen);
-
-/* Return a newly allocated copy of the first SIZE bytes of STRING. */
-
-char *
-xstrndup (string, size)
- const char *string;
- size_t size;
-{
- size_t len;
- char *new;
- if (!string)
- return NULL;
- len = strnlen (string, size);
- new = xmalloc (len + 1);
- new[len] = '\0';
- return (char *) memcpy (new, string, len);
-}