* 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,
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 \
$(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 \
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) \
@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 \
hash-pjw.c hash-pjw.h \
__fpending.h \
addext.c \
+ allocsa.c allocsa.h \
argmatch.c argmatch.h \
backupfile.c backupfile.h \
basename.c \
sig2str.h \
stdio-safer.h \
stripslash.c \
+ strdup.h \
strndup.h \
strverscmp.h \
time_r.c time_r.h \
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 \
@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@
/* 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
}
#include <stdbool.h>
-bool set_cloexec_flag (int desc, bool value);
+int set_cloexec_flag (int desc, bool value);
/* 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
if (S_TYPEISSHM (st))
return _("shared memory object");
+ if (S_TYPEISTMO (st))
+ return _("typed memory object");
+
return _("weird file");
}
/* 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
# 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)
# endif
# endif
-# ifndef S_TYPEISMQ
-# define S_TYPEISMQ(p) 0
-# endif
-
#endif /* FILE_TYPE_H */
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]);
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);
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';
#include "group-member.h"
+#include <stdbool.h>
#include <stdio.h>
#include <sys/types.h>
#include <stdlib.h>
#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 */
#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 */
/* 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
/* 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
# 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
# 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
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++)
#ifndef _PRINTF_ARGS_H
#define _PRINTF_ARGS_H
+/* Get size_t. */
+#include <stddef.h>
+
/* Get wchar_t. */
#ifdef HAVE_WCHAR_T
# include <stddef.h>
typedef struct
{
- unsigned int count;
+ size_t count;
argument *arg;
}
arguments;
/* 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
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
}
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;
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
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':
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;
}
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;
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);
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,
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.
/* 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
/* 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. */
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
# 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
{
/* 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);
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;
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
}
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);
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;
}
/* And remember the value. */
STORE_VALUE (np);
}
-#ifdef USE_TSEARCH
- freea (new_value);
+#if defined USE_TSEARCH && !defined _LIBC
+ freesa (new_value);
#endif
}
-/* 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.
# include <config.h>
#endif
+#ifndef _LIBC
+/* Get specification. */
+# include "strdup.h"
+#endif
+
#include <stdlib.h>
#include <string.h>
# include <config.h>
#endif
+/* Specification. */
+#include "userspec.h"
+
#include <alloca.h>
#include <stdio.h>
# include <unistd.h>
#endif
-#include "userspec.h"
+#include "strdup.h"
#include "xalloc.h"
#include "xstrtol.h"
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. */
#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,
/* 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
/* Specification. */
#include "vasprintf.h"
+#include <limits.h>
+#include <stdlib.h>
+
#include "vasnprintf.h"
int
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;