summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2004-04-04 06:51:11 +0000
committerJim Meyering <jim@meyering.net>2004-04-04 06:51:11 +0000
commit8c5584a1513cdbf62e8ed51c69053db4aae44682 (patch)
tree33f6842b5ab8d3e40869af4574990cfe15c3e50e
parentfef16409575921ce744f360ed21800a6207d9f8f (diff)
downloadcoreutils-8c5584a1513cdbf62e8ed51c69053db4aae44682.tar.xz
Sync from gnulib.
-rw-r--r--lib/ChangeLog6
-rw-r--r--lib/Makefile.in164
-rw-r--r--lib/cloexec.c20
-rw-r--r--lib/cloexec.h2
-rw-r--r--lib/file-type.c5
-rw-r--r--lib/file-type.h15
-rw-r--r--lib/getloadavg.c4
-rw-r--r--lib/getndelim2.c17
-rw-r--r--lib/getusershell.c22
-rw-r--r--lib/group-member.c47
-rw-r--r--lib/human.c4
-rw-r--r--lib/path-concat.c11
-rw-r--r--lib/printf-args.c2
-rw-r--r--lib/printf-args.h5
-rw-r--r--lib/quotearg.c56
-rw-r--r--lib/quotearg.h39
-rw-r--r--lib/setenv.c45
-rw-r--r--lib/strdup.c7
-rw-r--r--lib/userspec.c9
-rw-r--r--lib/userspec.h2
-rw-r--r--lib/vasprintf.c13
21 files changed, 291 insertions, 204 deletions
diff --git a/lib/ChangeLog b/lib/ChangeLog
index b36278b30..a92f5df9e 100644
--- a/lib/ChangeLog
+++ b/lib/ChangeLog
@@ -2,9 +2,9 @@
* cloexec.c, cloexec.h, config.charset, file-type.c, file-type.h:
* getloadavg.c, getndelim2.c, getusershell.c, group-member.c:
- * human.c, path-concat.c, printf-args.c, printf-args.h, quotearg.c:
- * quotearg.h, setenv.c, strdup.c, userspec.c:
- * userspec.h, vasprintf.c: Sync from gnulib.
+ * human.c, path-concat.c, printf-args.c, printf-args.h:
+ * quotearg.c, quotearg.h, setenv.c, strdup.c:
+ * userspec.c, userspec.h, vasprintf.c: Sync from gnulib.
* allocsa.c, allocsa.h, strdup.h: New files, from gnulib.
* Makefile.am (libfetish_a_SOURCES): Add allocsa.c, allocsa.h,
diff --git a/lib/Makefile.in b/lib/Makefile.in
index 1462ece27..0b82c1dc4 100644
--- a/lib/Makefile.in
+++ b/lib/Makefile.in
@@ -58,17 +58,18 @@ DIST_COMMON = README $(srcdir)/Makefile.am $(srcdir)/Makefile.in \
tempname.c utime.c vasnprintf.c vasprintf.c
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/m4/acl.m4 $(top_srcdir)/m4/afs.m4 \
- $(top_srcdir)/m4/alloca.m4 $(top_srcdir)/m4/assert.m4 \
- $(top_srcdir)/m4/atexit.m4 $(top_srcdir)/m4/backupfile.m4 \
- $(top_srcdir)/m4/bison.m4 $(top_srcdir)/m4/boottime.m4 \
- $(top_srcdir)/m4/canon-host.m4 \
+ $(top_srcdir)/m4/alloca.m4 $(top_srcdir)/m4/allocsa.m4 \
+ $(top_srcdir)/m4/assert.m4 $(top_srcdir)/m4/atexit.m4 \
+ $(top_srcdir)/m4/backupfile.m4 $(top_srcdir)/m4/bison.m4 \
+ $(top_srcdir)/m4/boottime.m4 $(top_srcdir)/m4/canon-host.m4 \
$(top_srcdir)/m4/canonicalize.m4 \
$(top_srcdir)/m4/check-decl.m4 $(top_srcdir)/m4/chown.m4 \
- $(top_srcdir)/m4/clock_time.m4 $(top_srcdir)/m4/closeout.m4 \
- $(top_srcdir)/m4/codeset.m4 $(top_srcdir)/m4/d-ino.m4 \
- $(top_srcdir)/m4/d-type.m4 $(top_srcdir)/m4/dirfd.m4 \
- $(top_srcdir)/m4/dirname.m4 $(top_srcdir)/m4/dos.m4 \
- $(top_srcdir)/m4/dup2.m4 $(top_srcdir)/m4/error.m4 \
+ $(top_srcdir)/m4/clock_time.m4 $(top_srcdir)/m4/cloexec.m4 \
+ $(top_srcdir)/m4/closeout.m4 $(top_srcdir)/m4/codeset.m4 \
+ $(top_srcdir)/m4/d-ino.m4 $(top_srcdir)/m4/d-type.m4 \
+ $(top_srcdir)/m4/dirfd.m4 $(top_srcdir)/m4/dirname.m4 \
+ $(top_srcdir)/m4/dos.m4 $(top_srcdir)/m4/dup2.m4 \
+ $(top_srcdir)/m4/eealloc.m4 $(top_srcdir)/m4/error.m4 \
$(top_srcdir)/m4/euidaccess.m4 $(top_srcdir)/m4/exclude.m4 \
$(top_srcdir)/m4/exitfail.m4 $(top_srcdir)/m4/extensions.m4 \
$(top_srcdir)/m4/file-type.m4 $(top_srcdir)/m4/fileblocks.m4 \
@@ -88,57 +89,58 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/acl.m4 $(top_srcdir)/m4/afs.m4 \
$(top_srcdir)/m4/hard-locale.m4 $(top_srcdir)/m4/hash.m4 \
$(top_srcdir)/m4/host-os.m4 $(top_srcdir)/m4/human.m4 \
$(top_srcdir)/m4/iconv.m4 $(top_srcdir)/m4/idcache.m4 \
- $(top_srcdir)/m4/intmax_t.m4 $(top_srcdir)/m4/inttypes-pri.m4 \
- $(top_srcdir)/m4/inttypes.m4 $(top_srcdir)/m4/inttypes_h.m4 \
- $(top_srcdir)/m4/jm-macros.m4 $(top_srcdir)/m4/jm-winsz1.m4 \
- $(top_srcdir)/m4/jm-winsz2.m4 $(top_srcdir)/m4/lchown.m4 \
- $(top_srcdir)/m4/lib-check.m4 $(top_srcdir)/m4/lib-ld.m4 \
- $(top_srcdir)/m4/lib-link.m4 $(top_srcdir)/m4/lib-prefix.m4 \
- $(top_srcdir)/m4/link-follow.m4 \
+ $(top_srcdir)/m4/intmax_t.m4 $(top_srcdir)/m4/inttostr.m4 \
+ $(top_srcdir)/m4/inttypes-pri.m4 $(top_srcdir)/m4/inttypes.m4 \
+ $(top_srcdir)/m4/inttypes_h.m4 $(top_srcdir)/m4/jm-macros.m4 \
+ $(top_srcdir)/m4/jm-winsz1.m4 $(top_srcdir)/m4/jm-winsz2.m4 \
+ $(top_srcdir)/m4/lchown.m4 $(top_srcdir)/m4/lib-check.m4 \
+ $(top_srcdir)/m4/lib-ld.m4 $(top_srcdir)/m4/lib-link.m4 \
+ $(top_srcdir)/m4/lib-prefix.m4 $(top_srcdir)/m4/link-follow.m4 \
$(top_srcdir)/m4/long-options.m4 \
$(top_srcdir)/m4/longdouble.m4 $(top_srcdir)/m4/longlong.m4 \
$(top_srcdir)/m4/ls-mntd-fs.m4 $(top_srcdir)/m4/lstat.m4 \
$(top_srcdir)/m4/makepath.m4 $(top_srcdir)/m4/mbrtowc.m4 \
- $(top_srcdir)/m4/mbswidth.m4 $(top_srcdir)/m4/md5.m4 \
- $(top_srcdir)/m4/memchr.m4 $(top_srcdir)/m4/memcmp.m4 \
- $(top_srcdir)/m4/memcoll.m4 $(top_srcdir)/m4/memcpy.m4 \
- $(top_srcdir)/m4/memmove.m4 $(top_srcdir)/m4/memrchr.m4 \
- $(top_srcdir)/m4/memset.m4 $(top_srcdir)/m4/mkdir-slash.m4 \
- $(top_srcdir)/m4/mkstemp.m4 $(top_srcdir)/m4/mktime.m4 \
- $(top_srcdir)/m4/modechange.m4 $(top_srcdir)/m4/mountlist.m4 \
- $(top_srcdir)/m4/nanosleep.m4 $(top_srcdir)/m4/nls.m4 \
- $(top_srcdir)/m4/obstack.m4 $(top_srcdir)/m4/onceonly.m4 \
- $(top_srcdir)/m4/path-concat.m4 $(top_srcdir)/m4/pathmax.m4 \
- $(top_srcdir)/m4/perl.m4 $(top_srcdir)/m4/physmem.m4 \
- $(top_srcdir)/m4/po.m4 $(top_srcdir)/m4/posixtm.m4 \
- $(top_srcdir)/m4/posixver.m4 $(top_srcdir)/m4/prereq.m4 \
- $(top_srcdir)/m4/progtest.m4 $(top_srcdir)/m4/putenv.m4 \
- $(top_srcdir)/m4/quote.m4 $(top_srcdir)/m4/quotearg.m4 \
- $(top_srcdir)/m4/readdir.m4 $(top_srcdir)/m4/readlink.m4 \
- $(top_srcdir)/m4/readtokens.m4 $(top_srcdir)/m4/readutmp.m4 \
- $(top_srcdir)/m4/regex.m4 $(top_srcdir)/m4/rename.m4 \
- $(top_srcdir)/m4/restrict.m4 $(top_srcdir)/m4/rmdir-errno.m4 \
- $(top_srcdir)/m4/rmdir.m4 $(top_srcdir)/m4/rpmatch.m4 \
- $(top_srcdir)/m4/safe-read.m4 $(top_srcdir)/m4/safe-write.m4 \
- $(top_srcdir)/m4/same.m4 $(top_srcdir)/m4/save-cwd.m4 \
- $(top_srcdir)/m4/savedir.m4 $(top_srcdir)/m4/settime.m4 \
- $(top_srcdir)/m4/sha.m4 $(top_srcdir)/m4/sig2str.m4 \
- $(top_srcdir)/m4/signed.m4 $(top_srcdir)/m4/ssize_t.m4 \
- $(top_srcdir)/m4/st_dm_mode.m4 $(top_srcdir)/m4/st_mtim.m4 \
- $(top_srcdir)/m4/stat.m4 $(top_srcdir)/m4/stdbool.m4 \
- $(top_srcdir)/m4/stdint_h.m4 $(top_srcdir)/m4/stdio-safer.m4 \
- $(top_srcdir)/m4/stpcpy.m4 $(top_srcdir)/m4/strcase.m4 \
- $(top_srcdir)/m4/strcspn.m4 $(top_srcdir)/m4/strdup.m4 \
- $(top_srcdir)/m4/strftime.m4 $(top_srcdir)/m4/strndup.m4 \
- $(top_srcdir)/m4/strnlen.m4 $(top_srcdir)/m4/strpbrk.m4 \
- $(top_srcdir)/m4/strstr.m4 $(top_srcdir)/m4/strtod.m4 \
- $(top_srcdir)/m4/strtoimax.m4 $(top_srcdir)/m4/strtol.m4 \
- $(top_srcdir)/m4/strtoll.m4 $(top_srcdir)/m4/strtoul.m4 \
- $(top_srcdir)/m4/strtoull.m4 $(top_srcdir)/m4/strtoumax.m4 \
- $(top_srcdir)/m4/strverscmp.m4 $(top_srcdir)/m4/timespec.m4 \
- $(top_srcdir)/m4/tm_gmtoff.m4 $(top_srcdir)/m4/tzset.m4 \
- $(top_srcdir)/m4/uintmax_t.m4 $(top_srcdir)/m4/ulonglong.m4 \
- $(top_srcdir)/m4/unicodeio.m4 $(top_srcdir)/m4/unistd-safer.m4 \
+ $(top_srcdir)/m4/mbstate_t.m4 $(top_srcdir)/m4/mbswidth.m4 \
+ $(top_srcdir)/m4/md5.m4 $(top_srcdir)/m4/memchr.m4 \
+ $(top_srcdir)/m4/memcmp.m4 $(top_srcdir)/m4/memcoll.m4 \
+ $(top_srcdir)/m4/memcpy.m4 $(top_srcdir)/m4/memmove.m4 \
+ $(top_srcdir)/m4/memrchr.m4 $(top_srcdir)/m4/memset.m4 \
+ $(top_srcdir)/m4/mkdir-slash.m4 $(top_srcdir)/m4/mkstemp.m4 \
+ $(top_srcdir)/m4/mktime.m4 $(top_srcdir)/m4/modechange.m4 \
+ $(top_srcdir)/m4/mountlist.m4 $(top_srcdir)/m4/nanosleep.m4 \
+ $(top_srcdir)/m4/nls.m4 $(top_srcdir)/m4/obstack.m4 \
+ $(top_srcdir)/m4/onceonly.m4 $(top_srcdir)/m4/path-concat.m4 \
+ $(top_srcdir)/m4/pathmax.m4 $(top_srcdir)/m4/perl.m4 \
+ $(top_srcdir)/m4/physmem.m4 $(top_srcdir)/m4/po.m4 \
+ $(top_srcdir)/m4/posixtm.m4 $(top_srcdir)/m4/posixver.m4 \
+ $(top_srcdir)/m4/prereq.m4 $(top_srcdir)/m4/progtest.m4 \
+ $(top_srcdir)/m4/putenv.m4 $(top_srcdir)/m4/quote.m4 \
+ $(top_srcdir)/m4/quotearg.m4 $(top_srcdir)/m4/readdir.m4 \
+ $(top_srcdir)/m4/readlink.m4 $(top_srcdir)/m4/readtokens.m4 \
+ $(top_srcdir)/m4/readutmp.m4 $(top_srcdir)/m4/regex.m4 \
+ $(top_srcdir)/m4/rename.m4 $(top_srcdir)/m4/restrict.m4 \
+ $(top_srcdir)/m4/rmdir-errno.m4 $(top_srcdir)/m4/rmdir.m4 \
+ $(top_srcdir)/m4/rpmatch.m4 $(top_srcdir)/m4/safe-read.m4 \
+ $(top_srcdir)/m4/safe-write.m4 $(top_srcdir)/m4/same.m4 \
+ $(top_srcdir)/m4/save-cwd.m4 $(top_srcdir)/m4/savedir.m4 \
+ $(top_srcdir)/m4/settime.m4 $(top_srcdir)/m4/sha.m4 \
+ $(top_srcdir)/m4/sig2str.m4 $(top_srcdir)/m4/signed.m4 \
+ $(top_srcdir)/m4/ssize_t.m4 $(top_srcdir)/m4/st_dm_mode.m4 \
+ $(top_srcdir)/m4/st_mtim.m4 $(top_srcdir)/m4/stat.m4 \
+ $(top_srcdir)/m4/stdbool.m4 $(top_srcdir)/m4/stdint_h.m4 \
+ $(top_srcdir)/m4/stdio-safer.m4 $(top_srcdir)/m4/stpcpy.m4 \
+ $(top_srcdir)/m4/strcase.m4 $(top_srcdir)/m4/strcspn.m4 \
+ $(top_srcdir)/m4/strdup.m4 $(top_srcdir)/m4/strftime.m4 \
+ $(top_srcdir)/m4/strndup.m4 $(top_srcdir)/m4/strnlen.m4 \
+ $(top_srcdir)/m4/strpbrk.m4 $(top_srcdir)/m4/strstr.m4 \
+ $(top_srcdir)/m4/strtod.m4 $(top_srcdir)/m4/strtoimax.m4 \
+ $(top_srcdir)/m4/strtol.m4 $(top_srcdir)/m4/strtoll.m4 \
+ $(top_srcdir)/m4/strtoul.m4 $(top_srcdir)/m4/strtoull.m4 \
+ $(top_srcdir)/m4/strtoumax.m4 $(top_srcdir)/m4/strverscmp.m4 \
+ $(top_srcdir)/m4/timespec.m4 $(top_srcdir)/m4/tm_gmtoff.m4 \
+ $(top_srcdir)/m4/tzset.m4 $(top_srcdir)/m4/uintmax_t.m4 \
+ $(top_srcdir)/m4/ulonglong.m4 $(top_srcdir)/m4/unicodeio.m4 \
+ $(top_srcdir)/m4/unistd-safer.m4 \
$(top_srcdir)/m4/unlink-busy.m4 \
$(top_srcdir)/m4/unlocked-io.m4 $(top_srcdir)/m4/uptime.m4 \
$(top_srcdir)/m4/userspec.m4 $(top_srcdir)/m4/utimbuf.m4 \
@@ -165,16 +167,16 @@ am__DEPENDENCIES_2 = @ALLOCA@
am_libfetish_a_OBJECTS = acl.$(OBJEXT) getdate.$(OBJEXT) \
posixtm.$(OBJEXT) posixver.$(OBJEXT) strftime.$(OBJEXT) \
getopt.$(OBJEXT) getopt1.$(OBJEXT) hash.$(OBJEXT) \
- hash-pjw.$(OBJEXT) addext.$(OBJEXT) argmatch.$(OBJEXT) \
- backupfile.$(OBJEXT) basename.$(OBJEXT) c-strtod.$(OBJEXT) \
- canon-host.$(OBJEXT) cloexec.$(OBJEXT) closeout.$(OBJEXT) \
- cycle-check.$(OBJEXT) diacrit.$(OBJEXT) dirname.$(OBJEXT) \
- dup-safer.$(OBJEXT) exclude.$(OBJEXT) exitfail.$(OBJEXT) \
- filemode.$(OBJEXT) file-type.$(OBJEXT) fopen-safer.$(OBJEXT) \
- fts.$(OBJEXT) full-read.$(OBJEXT) full-write.$(OBJEXT) \
- gettime.$(OBJEXT) getugroups.$(OBJEXT) hard-locale.$(OBJEXT) \
- human.$(OBJEXT) idcache.$(OBJEXT) isdir.$(OBJEXT) \
- imaxtostr.$(OBJEXT) linebuffer.$(OBJEXT) \
+ hash-pjw.$(OBJEXT) addext.$(OBJEXT) allocsa.$(OBJEXT) \
+ argmatch.$(OBJEXT) backupfile.$(OBJEXT) basename.$(OBJEXT) \
+ c-strtod.$(OBJEXT) canon-host.$(OBJEXT) cloexec.$(OBJEXT) \
+ closeout.$(OBJEXT) cycle-check.$(OBJEXT) diacrit.$(OBJEXT) \
+ dirname.$(OBJEXT) dup-safer.$(OBJEXT) exclude.$(OBJEXT) \
+ exitfail.$(OBJEXT) filemode.$(OBJEXT) file-type.$(OBJEXT) \
+ fopen-safer.$(OBJEXT) fts.$(OBJEXT) full-read.$(OBJEXT) \
+ full-write.$(OBJEXT) gettime.$(OBJEXT) getugroups.$(OBJEXT) \
+ hard-locale.$(OBJEXT) human.$(OBJEXT) idcache.$(OBJEXT) \
+ isdir.$(OBJEXT) imaxtostr.$(OBJEXT) linebuffer.$(OBJEXT) \
localcharset.$(OBJEXT) long-options.$(OBJEXT) \
makepath.$(OBJEXT) mbswidth.$(OBJEXT) md5.$(OBJEXT) \
memcasecmp.$(OBJEXT) memcoll.$(OBJEXT) modechange.$(OBJEXT) \
@@ -235,18 +237,19 @@ am__depfiles_maybe = depfiles
@AMDEP_TRUE@ $(DEPDIR)/tempname.Po $(DEPDIR)/utime.Po \
@AMDEP_TRUE@ $(DEPDIR)/vasnprintf.Po $(DEPDIR)/vasprintf.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/acl.Po ./$(DEPDIR)/addext.Po \
-@AMDEP_TRUE@ ./$(DEPDIR)/argmatch.Po ./$(DEPDIR)/backupfile.Po \
-@AMDEP_TRUE@ ./$(DEPDIR)/basename.Po ./$(DEPDIR)/c-strtod.Po \
-@AMDEP_TRUE@ ./$(DEPDIR)/canon-host.Po ./$(DEPDIR)/cloexec.Po \
-@AMDEP_TRUE@ ./$(DEPDIR)/closeout.Po ./$(DEPDIR)/cycle-check.Po \
-@AMDEP_TRUE@ ./$(DEPDIR)/diacrit.Po ./$(DEPDIR)/dirname.Po \
-@AMDEP_TRUE@ ./$(DEPDIR)/dup-safer.Po ./$(DEPDIR)/exclude.Po \
-@AMDEP_TRUE@ ./$(DEPDIR)/exitfail.Po ./$(DEPDIR)/file-type.Po \
-@AMDEP_TRUE@ ./$(DEPDIR)/filemode.Po ./$(DEPDIR)/fopen-safer.Po \
-@AMDEP_TRUE@ ./$(DEPDIR)/fts.Po ./$(DEPDIR)/full-read.Po \
-@AMDEP_TRUE@ ./$(DEPDIR)/full-write.Po ./$(DEPDIR)/getdate.Po \
-@AMDEP_TRUE@ ./$(DEPDIR)/getopt.Po ./$(DEPDIR)/getopt1.Po \
-@AMDEP_TRUE@ ./$(DEPDIR)/gettime.Po ./$(DEPDIR)/getugroups.Po \
+@AMDEP_TRUE@ ./$(DEPDIR)/allocsa.Po ./$(DEPDIR)/argmatch.Po \
+@AMDEP_TRUE@ ./$(DEPDIR)/backupfile.Po ./$(DEPDIR)/basename.Po \
+@AMDEP_TRUE@ ./$(DEPDIR)/c-strtod.Po ./$(DEPDIR)/canon-host.Po \
+@AMDEP_TRUE@ ./$(DEPDIR)/cloexec.Po ./$(DEPDIR)/closeout.Po \
+@AMDEP_TRUE@ ./$(DEPDIR)/cycle-check.Po ./$(DEPDIR)/diacrit.Po \
+@AMDEP_TRUE@ ./$(DEPDIR)/dirname.Po ./$(DEPDIR)/dup-safer.Po \
+@AMDEP_TRUE@ ./$(DEPDIR)/exclude.Po ./$(DEPDIR)/exitfail.Po \
+@AMDEP_TRUE@ ./$(DEPDIR)/file-type.Po ./$(DEPDIR)/filemode.Po \
+@AMDEP_TRUE@ ./$(DEPDIR)/fopen-safer.Po ./$(DEPDIR)/fts.Po \
+@AMDEP_TRUE@ ./$(DEPDIR)/full-read.Po ./$(DEPDIR)/full-write.Po \
+@AMDEP_TRUE@ ./$(DEPDIR)/getdate.Po ./$(DEPDIR)/getopt.Po \
+@AMDEP_TRUE@ ./$(DEPDIR)/getopt1.Po ./$(DEPDIR)/gettime.Po \
+@AMDEP_TRUE@ ./$(DEPDIR)/getugroups.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/hard-locale.Po ./$(DEPDIR)/hash-pjw.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/hash.Po ./$(DEPDIR)/human.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/idcache.Po ./$(DEPDIR)/imaxtostr.Po \
@@ -417,6 +420,7 @@ libfetish_a_SOURCES = \
hash-pjw.c hash-pjw.h \
__fpending.h \
addext.c \
+ allocsa.c allocsa.h \
argmatch.c argmatch.h \
backupfile.c backupfile.h \
basename.c \
@@ -485,6 +489,7 @@ libfetish_a_SOURCES = \
sig2str.h \
stdio-safer.h \
stripslash.c \
+ strdup.h \
strndup.h \
strverscmp.h \
time_r.c time_r.h \
@@ -504,7 +509,7 @@ libfetish_a_SOURCES = \
xmemcoll.c xmemcoll.h \
xnanosleep.c xnanosleep.h \
xreadlink.c xreadlink.h \
- xstrdup.c \
+ xstrdup.c \
xstrndup.c xstrndup.h \
xstrtod.c xstrtod.h \
xstrtoimax.c \
@@ -659,6 +664,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/vasprintf.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/acl.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/addext.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/allocsa.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/argmatch.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/backupfile.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/basename.Po@am__quote@
diff --git a/lib/cloexec.c b/lib/cloexec.c
index 20f30db45..e07cdd3d5 100644
--- a/lib/cloexec.c
+++ b/lib/cloexec.c
@@ -37,27 +37,29 @@
/* Set the `FD_CLOEXEC' flag of DESC if VALUE is true,
or clear the flag if VALUE is false.
- Return true on success, or false on error with `errno' set. */
+ Return 0 on success, or -1 on error with `errno' set. */
-bool
+int
set_cloexec_flag (int desc, bool value)
{
#if defined F_GETFD && defined F_SETFD
int flags = fcntl (desc, F_GETFD, 0);
- int newflags;
- if (flags < 0)
- return false;
+ if (0 <= flags)
+ {
+ int newflags = (value ? flags | FD_CLOEXEC : flags & ~FD_CLOEXEC);
- newflags = (value ? flags | FD_CLOEXEC : flags & ~FD_CLOEXEC);
+ if (flags == newflags
+ || fcntl (desc, F_SETFD, newflags) != -1)
+ return 0;
+ }
- return (flags == newflags
- || fcntl (desc, F_SETFD, newflags) != -1);
+ return -1;
#else
- return true;
+ return 0;
#endif
}
diff --git a/lib/cloexec.h b/lib/cloexec.h
index ecad8d712..c25921d6b 100644
--- a/lib/cloexec.h
+++ b/lib/cloexec.h
@@ -1,2 +1,2 @@
#include <stdbool.h>
-bool set_cloexec_flag (int desc, bool value);
+int set_cloexec_flag (int desc, bool value);
diff --git a/lib/file-type.c b/lib/file-type.c
index 87919a591..3c58c7fb0 100644
--- a/lib/file-type.c
+++ b/lib/file-type.c
@@ -1,6 +1,6 @@
/* Return a string describing the type of a file.
- Copyright (C) 1993, 1994, 2001, 2002 Free Software Foundation, Inc.
+ Copyright (C) 1993, 1994, 2001, 2002, 2004 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
@@ -68,5 +68,8 @@ file_type (struct stat const *st)
if (S_TYPEISSHM (st))
return _("shared memory object");
+ if (S_TYPEISTMO (st))
+ return _("typed memory object");
+
return _("weird file");
}
diff --git a/lib/file-type.h b/lib/file-type.h
index c766d6c21..502f09163 100644
--- a/lib/file-type.h
+++ b/lib/file-type.h
@@ -1,6 +1,6 @@
/* Return a string describing the type of a file.
- Copyright (C) 1993, 1994, 2001, 2002 Free Software Foundation, Inc.
+ Copyright (C) 1993, 1994, 2001, 2002, 2004 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
@@ -138,6 +138,15 @@ char const *file_type (struct stat const *);
# endif
+# ifndef S_TYPEISMQ
+# define S_TYPEISMQ(p) 0
+# endif
+
+# ifndef S_TYPEISTMO
+# define S_TYPEISTMO(p) 0
+# endif
+
+
# ifndef S_TYPEISSEM
# ifdef S_INSEM
# define S_TYPEISSEM(p) (S_ISNAM ((p)->st_mode) && (p)->st_rdev == S_INSEM)
@@ -154,8 +163,4 @@ char const *file_type (struct stat const *);
# endif
# endif
-# ifndef S_TYPEISMQ
-# define S_TYPEISMQ(p) 0
-# endif
-
#endif /* FILE_TYPE_H */
diff --git a/lib/getloadavg.c b/lib/getloadavg.c
index dce4117f0..ed079b2ec 100644
--- a/lib/getloadavg.c
+++ b/lib/getloadavg.c
@@ -606,7 +606,9 @@ getloadavg (double loadavg[], int nelem)
return -1;
/* The following sscanf must use the C locale. */
- old_locale = xstrdup (setlocale (LC_NUMERIC, NULL));
+ old_locale = setlocale (LC_NUMERIC, NULL);
+ if (old_locale)
+ old_locale = xstrdup (old_locale);
setlocale (LC_NUMERIC, "C");
count = sscanf (ldavgbuf, "%lf %lf %lf",
&load_ave[0], &load_ave[1], &load_ave[2]);
diff --git a/lib/getndelim2.c b/lib/getndelim2.c
index 6f0868999..395946259 100644
--- a/lib/getndelim2.c
+++ b/lib/getndelim2.c
@@ -81,18 +81,15 @@ getndelim2 (char **lineptr, size_t *linesize, size_t nmax,
size_t newlinesize =
(*linesize > MIN_CHUNK ? 2 * *linesize : *linesize + MIN_CHUNK);
- if (newlinesize > nmax)
+ if (! (*linesize < newlinesize && newlinesize <= nmax))
newlinesize = nmax;
- if (newlinesize > *linesize)
- {
- *linesize = newlinesize;
- nbytes_avail = *linesize + *lineptr - read_pos;
- *lineptr = realloc (*lineptr, *linesize);
- if (!*lineptr)
- return -1;
- read_pos = *linesize - nbytes_avail + *lineptr;
- }
+ *linesize = newlinesize;
+ nbytes_avail = *linesize + *lineptr - read_pos;
+ *lineptr = realloc (*lineptr, *linesize);
+ if (!*lineptr)
+ return -1;
+ read_pos = *linesize - nbytes_avail + *lineptr;
}
c = getc (stream);
diff --git a/lib/getusershell.c b/lib/getusershell.c
index c026ec0a9..9b60f18d5 100644
--- a/lib/getusershell.c
+++ b/lib/getusershell.c
@@ -145,29 +145,17 @@ readname (char **name, size_t *size, FILE *stream)
int c;
size_t name_index = 0;
- if (*name == NULL)
- {
- /* The initial size must be a power of two, so that the overflow
- check works. */
- *size = 16;
-
- *name = xmalloc (*size);
- }
-
/* Skip blank space. */
while ((c = getc (stream)) != EOF && ISSPACE (c))
/* Do nothing. */ ;
- while (c != EOF && !ISSPACE (c))
+ for (;;)
{
+ if (*size <= name_index)
+ *name = x2nrealloc (*name, size, sizeof **name);
+ if (c == EOF || ISSPACE (c))
+ break;
(*name)[name_index++] = c;
- if (*size < name_index)
- {
- *size *= 2;
- if (! *size)
- xalloc_die ();
- *name = xrealloc (*name, *size);
- }
c = getc (stream);
}
(*name)[name_index] = '\0';
diff --git a/lib/group-member.c b/lib/group-member.c
index 8823506b0..9ba49a853 100644
--- a/lib/group-member.c
+++ b/lib/group-member.c
@@ -21,6 +21,7 @@
#include "group-member.h"
+#include <stdbool.h>
#include <stdio.h>
#include <sys/types.h>
#include <stdlib.h>
@@ -40,47 +41,38 @@ struct group_info
#if HAVE_GETGROUPS
static void
-free_group_info (struct group_info *g)
+free_group_info (struct group_info const *g)
{
free (g->group);
- free (g);
}
-static struct group_info *
-get_group_info (void)
+static bool
+get_group_info (struct group_info *gi)
{
int n_groups;
- int n_group_slots;
- struct group_info *gi;
+ int n_group_slots = getgroups (0, NULL);
GETGROUPS_T *group;
- /* getgroups () returns the number of elements that it was able to
- place into the array. We simply continue to call getgroups ()
- until the number of elements placed into the array is smaller than
- the physical size of the array. */
+ if (n_group_slots < 0)
+ return false;
- group = NULL;
- n_groups = 0;
- n_group_slots = 0;
- while (n_groups == n_group_slots)
- {
- n_group_slots += 64;
- group = xrealloc (group, n_group_slots * sizeof (GETGROUPS_T));
- n_groups = getgroups (n_group_slots, group);
- }
+ /* Avoid xnmalloc, as it goes awry when SIZE_MAX < n_group_slots. */
+ if (xalloc_oversized (n_group_slots, sizeof *group))
+ xalloc_die ();
+ group = xmalloc (n_group_slots * sizeof *group);
+ n_groups = getgroups (n_group_slots, group);
/* In case of error, the user loses. */
if (n_groups < 0)
{
free (group);
- return NULL;
+ return false;
}
- gi = xmalloc (sizeof (*gi));
gi->n_groups = n_groups;
gi->group = group;
- return gi;
+ return true;
}
#endif /* not HAVE_GETGROUPS */
@@ -97,24 +89,23 @@ group_member (gid_t gid)
#else
int i;
int found;
- struct group_info *gi;
+ struct group_info gi;
- gi = get_group_info ();
- if (gi == NULL)
+ if (! get_group_info (&gi))
return 0;
/* Search through the list looking for GID. */
found = 0;
- for (i = 0; i < gi->n_groups; i++)
+ for (i = 0; i < gi.n_groups; i++)
{
- if (gid == gi->group[i])
+ if (gid == gi.group[i])
{
found = 1;
break;
}
}
- free_group_info (gi);
+ free_group_info (&gi);
return found;
#endif /* HAVE_GETGROUPS */
diff --git a/lib/human.c b/lib/human.c
index 806292707..dbf536b1e 100644
--- a/lib/human.c
+++ b/lib/human.c
@@ -1,7 +1,7 @@
/* human.c -- print human readable file size
- Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003 Free
- Software Foundation, Inc.
+ Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004
+ 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
diff --git a/lib/path-concat.c b/lib/path-concat.c
index 7f3bc5a49..db96debad 100644
--- a/lib/path-concat.c
+++ b/lib/path-concat.c
@@ -1,6 +1,6 @@
/* path-concat.c -- concatenate two arbitrary pathnames
- Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003 Free
+ Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004 Free
Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
@@ -23,6 +23,9 @@
# include <config.h>
#endif
+/* Specification. */
+#include "path-concat.h"
+
#ifndef HAVE_MEMPCPY
# define mempcpy(D, S, N) ((void *) ((char *) memcpy (D, S, N) + (N)))
#endif
@@ -35,13 +38,9 @@
# include <unistd.h>
#endif
-#ifndef strdup
-char *strdup ();
-#endif
-
+#include "strdup.h"
#include "dirname.h"
#include "xalloc.h"
-#include "path-concat.h"
/* Concatenate two pathname components, DIR and BASE, in
newly-allocated storage and return the result. Return 0 if out of
diff --git a/lib/printf-args.c b/lib/printf-args.c
index 6972cfd42..926ae8ffe 100644
--- a/lib/printf-args.c
+++ b/lib/printf-args.c
@@ -28,7 +28,7 @@ STATIC
int
printf_fetchargs (va_list args, arguments *a)
{
- unsigned int i;
+ size_t i;
argument *ap;
for (i = 0, ap = &a->arg[0]; i < a->count; i++, ap++)
diff --git a/lib/printf-args.h b/lib/printf-args.h
index c938192b7..4b75c723f 100644
--- a/lib/printf-args.h
+++ b/lib/printf-args.h
@@ -18,6 +18,9 @@
#ifndef _PRINTF_ARGS_H
#define _PRINTF_ARGS_H
+/* Get size_t. */
+#include <stddef.h>
+
/* Get wchar_t. */
#ifdef HAVE_WCHAR_T
# include <stddef.h>
@@ -116,7 +119,7 @@ argument;
typedef struct
{
- unsigned int count;
+ size_t count;
argument *arg;
}
arguments;
diff --git a/lib/quotearg.c b/lib/quotearg.c
index c695646f1..fe747fb0b 100644
--- a/lib/quotearg.c
+++ b/lib/quotearg.c
@@ -1,5 +1,7 @@
/* quotearg.c - quote arguments for output
- Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
+
+ Copyright (C) 1998, 1999, 2000, 2001, 2002, 2004 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
@@ -174,7 +176,7 @@ gettext_quote (char const *msgid, enum quoting_style s)
size of the output, not counting the terminating null.
If BUFFERSIZE is too small to store the output string, return the
value that would have been returned had BUFFERSIZE been large enough.
- If ARGSIZE is -1, use the string length of the argument for ARGSIZE.
+ If ARGSIZE is SIZE_MAX, use the string length of the argument for ARGSIZE.
This function acts like quotearg_buffer (BUFFER, BUFFERSIZE, ARG,
ARGSIZE, O), except it uses QUOTING_STYLE instead of the quoting
@@ -326,6 +328,10 @@ quotearg_buffer_restyled (char *buffer, size_t buffersize,
}
break;
+ case '{': case '}': /* sometimes special if isolated */
+ if (! (argsize == SIZE_MAX ? arg[1] == '\0' : argsize == 1))
+ break;
+ /* Fall through. */
case '#': case '~':
if (i != 0)
break;
@@ -334,7 +340,9 @@ quotearg_buffer_restyled (char *buffer, size_t buffersize,
case '!': /* special in bash */
case '"': case '$': case '&':
case '(': case ')': case '*': case ';':
- case '<': case '>': case '[':
+ case '<':
+ case '=': /* sometimes special in 0th or (with "set -k") later args */
+ case '>': case '[':
case '^': /* special in old /bin/sh, e.g. SunOS 4.1.4 */
case '`': case '|':
/* A shell special character. In theory, '$' and '`' could
@@ -364,7 +372,7 @@ quotearg_buffer_restyled (char *buffer, size_t buffersize,
case '%': case '+': case ',': case '-': case '.': case '/':
case '0': case '1': case '2': case '3': case '4': case '5':
- case '6': case '7': case '8': case '9': case ':': case '=':
+ case '6': case '7': case '8': case '9': case ':':
case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
case 'G': case 'H': case 'I': case 'J': case 'K': case 'L':
case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R':
@@ -374,7 +382,6 @@ quotearg_buffer_restyled (char *buffer, size_t buffersize,
case 'i': case 'j': case 'k': case 'l': case 'm': case 'n':
case 'o': case 'p': case 'q': case 'r': case 's': case 't':
case 'u': case 'v': case 'w': case 'x': case 'y': case 'z':
- case '{': case '}':
/* These characters don't cause problems, no matter what the
quoting style is. They cannot start multibyte sequences. */
break;
@@ -427,6 +434,22 @@ quotearg_buffer_restyled (char *buffer, size_t buffersize,
}
else
{
+ /* Work around a bug with older shells that "see" a '\'
+ that is really the 2nd byte of a multibyte character.
+ In practice the problem is limited to ASCII
+ chars >= '@' that are shell special chars. */
+ if ('[' == 0x5b && quoting_style == shell_quoting_style)
+ {
+ size_t j;
+ for (j = 1; j < bytes; j++)
+ switch (arg[i + m + j])
+ {
+ case '[': case '\\': case '^':
+ case '`': case '|':
+ goto use_shell_always_quoting_style;
+ }
+ }
+
if (! iswprint (w))
printable = 0;
m += bytes;
@@ -472,6 +495,9 @@ quotearg_buffer_restyled (char *buffer, size_t buffersize,
STORE (c);
}
+ if (i == 0 && quoting_style == shell_quoting_style)
+ goto use_shell_always_quoting_style;
+
if (quote_string)
for (; *quote_string; quote_string++)
STORE (*quote_string);
@@ -492,7 +518,8 @@ quotearg_buffer_restyled (char *buffer, size_t buffersize,
size of the output, not counting the terminating null.
If BUFFERSIZE is too small to store the output string, return the
value that would have been returned had BUFFERSIZE been large enough.
- If ARGSIZE is -1, use the string length of the argument for ARGSIZE. */
+ If ARGSIZE is SIZE_MAX, use the string length of the argument for
+ ARGSIZE. */
size_t
quotearg_buffer (char *buffer, size_t buffersize,
char const *arg, size_t argsize,
@@ -506,8 +533,23 @@ quotearg_buffer (char *buffer, size_t buffersize,
return r;
}
+/* Like quotearg_buffer (..., ARG, ARGSIZE, O), except return newly
+ allocated storage containing the quoted string. */
+char *
+quotearg_alloc (char const *arg, size_t argsize,
+ struct quoting_options const *o)
+{
+ int e = errno;
+ size_t bufsize = quotearg_buffer (0, 0, arg, argsize, o) + 1;
+ char *buf = xmalloc (bufsize);
+ quotearg_buffer (buf, bufsize, arg, argsize, o);
+ errno = e;
+ return buf;
+}
+
/* Use storage slot N to return a quoted version of argument ARG.
- ARG is of size ARGSIZE, but if that is -1, ARG is a null-terminated string.
+ ARG is of size ARGSIZE, but if that is SIZE_MAX, ARG is a
+ null-terminated string.
OPTIONS specifies the quoting options.
The returned value points to static storage that can be
reused by the next call to this function with the same value of N.
diff --git a/lib/quotearg.h b/lib/quotearg.h
index efc933173..2bbf38d92 100644
--- a/lib/quotearg.h
+++ b/lib/quotearg.h
@@ -1,6 +1,6 @@
/* quotearg.h - quote arguments for output
- Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software
+ Copyright (C) 1998, 1999, 2000, 2001, 2002, 2004 Free Software
Foundation, Inc.
This program is free software; you can redistribute it and/or modify
@@ -27,13 +27,31 @@
/* Basic quoting styles. */
enum quoting_style
{
- literal_quoting_style, /* --quoting-style=literal */
- shell_quoting_style, /* --quoting-style=shell */
- shell_always_quoting_style, /* --quoting-style=shell-always */
- c_quoting_style, /* --quoting-style=c */
- escape_quoting_style, /* --quoting-style=escape */
- locale_quoting_style, /* --quoting-style=locale */
- clocale_quoting_style /* --quoting-style=clocale */
+ /* Output names as-is (ls --quoting-style=literal). */
+ literal_quoting_style,
+
+ /* Quote names for the shell if they contain shell metacharacters
+ or would cause ambiguous output (ls --quoting-style=shell). */
+ shell_quoting_style,
+
+ /* Quote names for the shell, even if they would normally not
+ require quoting (ls --quoting-style=shell-always). */
+ shell_always_quoting_style,
+
+ /* Quote names as for a C language string (ls --quoting-style=c). */
+ c_quoting_style,
+
+ /* Like c_quoting_style except omit the surrounding double-quote
+ characters (ls --quoting-style=escape). */
+ escape_quoting_style,
+
+ /* Like clocale_quoting_style, but quote `like this' instead of
+ "like this" in the default C locale (ls --quoting-style=locale). */
+ locale_quoting_style,
+
+ /* Like c_quoting_style except use quotation marks appropriate for
+ the locale (ls --quoting-style=clocale). */
+ clocale_quoting_style
};
/* For now, --quoting-style=literal is the default, but this may change. */
@@ -81,6 +99,11 @@ size_t quotearg_buffer (char *buffer, size_t buffersize,
char const *arg, size_t argsize,
struct quoting_options const *o);
+/* Like quotearg_buffer, except return the result in a newly allocated
+ buffer. It is the caller's responsibility to free the result. */
+char *quotearg_alloc (char const *arg, size_t argsize,
+ struct quoting_options const *o);
+
/* Use storage slot N to return a quoted version of the string ARG.
Use the default quoting options.
The returned value points to static storage that can be
diff --git a/lib/setenv.c b/lib/setenv.c
index f185e04db..c3f9dc4ca 100644
--- a/lib/setenv.c
+++ b/lib/setenv.c
@@ -34,13 +34,8 @@ extern int errno;
# include <unistd.h>
#endif
-/* For those losing systems which don't have 'alloca' we have to add
- some additional code emulating it. */
-#if _LIBC || HAVE_ALLOCA
-# define freea(p) /* nothing */
-#else
-# define alloca(n) malloc (n)
-# define freea(p) free (p)
+#if !_LIBC
+# include "allocsa.h"
#endif
#if !_LIBC
@@ -163,11 +158,18 @@ __add_to_environ (const char *name, const char *value, const char *combined,
{
/* See whether the value is already known. */
#ifdef USE_TSEARCH
- new_value = (char *) alloca (namelen + 1 + vallen);
# ifdef _LIBC
+ new_value = (char *) alloca (namelen + 1 + vallen);
__mempcpy (__mempcpy (__mempcpy (new_value, name, namelen), "=", 1),
value, vallen);
# else
+ new_value = (char *) allocsa (namelen + 1 + vallen);
+ if (new_value == NULL)
+ {
+ __set_errno (ENOMEM);
+ UNLOCK;
+ return -1;
+ }
memcpy (new_value, name, namelen);
new_value[namelen] = '=';
memcpy (&new_value[namelen + 1], value, vallen);
@@ -180,8 +182,8 @@ __add_to_environ (const char *name, const char *value, const char *combined,
new_environ[size] = (char *) malloc (namelen + 1 + vallen);
if (new_environ[size] == NULL)
{
-#ifdef USE_TSEARCH
- freea (new_value);
+#if defined USE_TSEARCH && !defined _LIBC
+ freesa (new_value);
#endif
__set_errno (ENOMEM);
UNLOCK;
@@ -200,8 +202,8 @@ __add_to_environ (const char *name, const char *value, const char *combined,
user string or not. */
STORE_VALUE (new_environ[size]);
}
-#ifdef USE_TSEARCH
- freea (new_value);
+#if defined USE_TSEARCH && !defined _LIBC
+ freesa (new_value);
#endif
}
@@ -223,11 +225,19 @@ __add_to_environ (const char *name, const char *value, const char *combined,
else
{
#ifdef USE_TSEARCH
- char *new_value = alloca (namelen + 1 + vallen);
+ char *new_value;
# ifdef _LIBC
+ new_value = alloca (namelen + 1 + vallen);
__mempcpy (__mempcpy (__mempcpy (new_value, name, namelen), "=", 1),
value, vallen);
# else
+ new_value = allocsa (namelen + 1 + vallen);
+ if (new_value == NULL)
+ {
+ __set_errno (ENOMEM);
+ UNLOCK;
+ return -1;
+ }
memcpy (new_value, name, namelen);
new_value[namelen] = '=';
memcpy (&new_value[namelen + 1], value, vallen);
@@ -240,9 +250,10 @@ __add_to_environ (const char *name, const char *value, const char *combined,
np = malloc (namelen + 1 + vallen);
if (np == NULL)
{
-#ifdef USE_TSEARCH
- freea (new_value);
+#if defined USE_TSEARCH && !defined _LIBC
+ freesa (new_value);
#endif
+ __set_errno (ENOMEM);
UNLOCK;
return -1;
}
@@ -257,8 +268,8 @@ __add_to_environ (const char *name, const char *value, const char *combined,
/* And remember the value. */
STORE_VALUE (np);
}
-#ifdef USE_TSEARCH
- freea (new_value);
+#if defined USE_TSEARCH && !defined _LIBC
+ freesa (new_value);
#endif
}
diff --git a/lib/strdup.c b/lib/strdup.c
index 52667e98e..8c88e310a 100644
--- a/lib/strdup.c
+++ b/lib/strdup.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991, 1996, 1997, 1998, 2002, 2003 Free Software
+/* Copyright (C) 1991, 1996, 1997, 1998, 2002, 2003, 2004 Free Software
Foundation, Inc.
This file is part of the GNU C Library.
@@ -21,6 +21,11 @@
# include <config.h>
#endif
+#ifndef _LIBC
+/* Get specification. */
+# include "strdup.h"
+#endif
+
#include <stdlib.h>
#include <string.h>
diff --git a/lib/userspec.c b/lib/userspec.c
index 474fb6062..a997c6ff4 100644
--- a/lib/userspec.c
+++ b/lib/userspec.c
@@ -22,6 +22,9 @@
# include <config.h>
#endif
+/* Specification. */
+#include "userspec.h"
+
#include <alloca.h>
#include <stdio.h>
@@ -41,7 +44,7 @@
# include <unistd.h>
#endif
-#include "userspec.h"
+#include "strdup.h"
#include "xalloc.h"
#include "xstrtol.h"
@@ -108,10 +111,6 @@ struct group *getgrgid ();
of `digit' even when the host does not conform to POSIX. */
#define ISDIGIT(c) ((unsigned) (c) - '0' <= 9)
-#ifndef strdup
-char *strdup ();
-#endif
-
/* Return nonzero if STR represents an unsigned decimal integer,
otherwise return 0. */
diff --git a/lib/userspec.h b/lib/userspec.h
index 8f01d64d3..8a09eaea0 100644
--- a/lib/userspec.h
+++ b/lib/userspec.h
@@ -1,7 +1,7 @@
#ifndef USERSPEC_H
# define USERSPEC_H 1
-# include <stddef.h>
+# include <sys/types.h>
const char *
parse_user_spec (const char *spec_arg, uid_t *uid, gid_t *gid,
diff --git a/lib/vasprintf.c b/lib/vasprintf.c
index 7c8f212d7..bda9aa1b0 100644
--- a/lib/vasprintf.c
+++ b/lib/vasprintf.c
@@ -1,5 +1,5 @@
/* Formatted output to strings.
- Copyright (C) 1999, 2002 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2002-2003 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
@@ -22,6 +22,9 @@
/* Specification. */
#include "vasprintf.h"
+#include <limits.h>
+#include <stdlib.h>
+
#include "vasnprintf.h"
int
@@ -31,6 +34,14 @@ vasprintf (char **resultp, const char *format, va_list args)
char *result = vasnprintf (NULL, &length, format, args);
if (result == NULL)
return -1;
+ if (length > INT_MAX)
+ {
+ /* We could produce such a big string, but can't return its length
+ as an 'int'. */
+ free (result);
+ return -1;
+ }
+
*resultp = result;
/* Return the number of resulting bytes, excluding the trailing NUL. */
return length;