From 5a4657941eb051962dc7a9fd6ccbe9677c50aa75 Mon Sep 17 00:00:00 2001 From: kevind Date: Wed, 5 Apr 2000 08:00:41 +0000 Subject: [PATCH] *** empty log message *** --- find/testsuite/Makefile.in | 47 +++++--- lib/Makefile.in | 276 +++++++++++++++++++++++++++++------------- lib/alloca.c | 3 +- lib/ansi2knr.c | 119 ++++++++++++++---- lib/dirname.c | 5 +- lib/error.c | 12 +- lib/fileblocks.c | 7 +- lib/filemode.c | 60 ++++++--- lib/filemode.h | 24 ++-- lib/fnmatch.c | 5 +- lib/getline.c | 58 ++++----- lib/getline.h | 14 +-- lib/getopt.c | 153 +++++++++++------------ lib/getopt.h | 120 +++++++++++------- lib/getopt1.c | 51 ++++---- lib/idcache.c | 3 +- lib/listfile.c | 23 ++-- lib/lstat.c | 57 ++++++++- lib/malloc.c | 5 +- lib/memcmp.c | 20 +-- lib/memset.c | 5 +- lib/mktime.c | 141 ++++++++++------------ lib/modechange.c | 252 +++++++++++++++++++++++++------------- lib/modechange.h | 12 +- lib/pathmax.h | 47 ++++---- lib/regex.c | 92 ++++++++------ lib/regex.h | 65 +++------- lib/savedir.c | 12 +- lib/savedir.h | 2 +- lib/stat.c | 2 +- lib/stpcpy.c | 4 +- lib/strdup.c | 3 +- lib/strftime.c | 52 +++----- lib/strtol.c | 252 ++++++++++++++++++++++++++------------ lib/wait.h | 4 +- lib/xalloc.h | 86 +++++++++++-- lib/xmalloc.c | 61 ++++------ locate/Makefile.in | 294 +++++++++++++++++++++++++++------------------ m4/Makefile.in | 86 ++++++++++--- 39 files changed, 1552 insertions(+), 982 deletions(-) diff --git a/find/testsuite/Makefile.in b/find/testsuite/Makefile.in index 444ad57..73022ac 100644 --- a/find/testsuite/Makefile.in +++ b/find/testsuite/Makefile.in @@ -1,4 +1,4 @@ -# Makefile.in generated automatically by automake 1.4 from Makefile.am +# Makefile.in generated automatically by automake 1.4a from Makefile.am # Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation @@ -10,7 +10,6 @@ # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. - SHELL = @SHELL@ srcdir = @srcdir@ @@ -46,9 +45,10 @@ AUTOMAKE = @AUTOMAKE@ AUTOHEADER = @AUTOHEADER@ INSTALL = @INSTALL@ -INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS) +INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_FLAG = transform = @program_transform_name@ NORMAL_INSTALL = : @@ -57,14 +57,23 @@ POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : + +@SET_MAKE@ +AMDEP = @AMDEP@ +AMTAR = @AMTAR@ +AWK = @AWK@ CATALOGS = @CATALOGS@ CATOBJEXT = @CATOBJEXT@ CC = @CC@ CPP = @CPP@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ DATADIRNAME = @DATADIRNAME@ +DEPDIR = @DEPDIR@ GENCAT = @GENCAT@ GMOFILES = @GMOFILES@ GMSGFMT = @GMSGFMT@ +GNU_PACKAGE = @GNU_PACKAGE@ GT_NO = @GT_NO@ GT_YES = @GT_YES@ INCLUDES = @INCLUDES@ @@ -85,27 +94,36 @@ U = @U@ USE_INCLUDED_LIBINTL = @USE_INCLUDED_LIBINTL@ USE_NLS = @USE_NLS@ VERSION = @VERSION@ +install_sh = @install_sh@ l = @l@ + AUTOMAKE_OPTIONS = dejagnu FIND = ../find FINDFLAGS = DEJATOOL = find -EXTRA_DIST = config/unix.exp find.gnu/depth.exp find.gnu/depth.xo find.gnu/comma.exp find.gnu/comma.xo +EXTRA_DIST = config/unix.exp \ + find.gnu/depth.exp \ + find.gnu/depth.xo \ + find.gnu/comma.exp \ + find.gnu/comma.xo + +CLEANFILES = *.log *.sum site.exp site.bak DIST_SUBDIRS = config +subdir = find/testsuite mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs CONFIG_HEADER = ../../config.h CONFIG_CLEAN_FILES = +DIST_SOURCES = DIST_COMMON = Makefile.am Makefile.in -DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) -TAR = tar GZIP_ENV = --best EXPECT = expect RUNTEST = runtest @@ -124,19 +142,12 @@ TAGS: distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir) -subdir = find/testsuite - distdir: $(DISTFILES) - here=`cd $(top_builddir) && pwd`; \ - top_distdir=`cd $(top_distdir) && pwd`; \ - distdir=`cd $(distdir) && pwd`; \ - cd $(top_srcdir) \ - && $(AUTOMAKE) --include-deps --build-dir=$$here --srcdir-name=$(top_srcdir) --output-dir=$$top_distdir --gnu find/testsuite/Makefile $(mkinstalldirs) $(distdir)/config $(distdir)/find.gnu @for file in $(DISTFILES); do \ d=$(srcdir); \ if test -d $$d/$$file; then \ - cp -pr $$d/$$file $(distdir)/$$file; \ + cp -pR $$d/$$file $(distdir); \ else \ test -f $(distdir)/$$file \ || ln $$d/$$file $(distdir)/$$file 2> /dev/null \ @@ -149,7 +160,7 @@ RUNTESTFLAGS = RUNTESTDEFAULTFLAGS = --tool $(DEJATOOL) --srcdir $$srcdir check-DEJAGNU: site.exp - srcdir=`cd $(srcdir) && pwd`; export srcdir; \ + srcdir=`CDPATH=: && cd $(srcdir) && pwd`; export srcdir; \ EXPECT=$(EXPECT); export EXPECT; \ runtest=$(RUNTEST); \ if $(SHELL) -c "$$runtest --version" > /dev/null 2>&1; then \ @@ -192,19 +203,21 @@ uninstall: uninstall-am all-am: Makefile all-redirect: all-am install-strip: - $(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install + $(MAKE) $(AM_MAKEFLAGS) INSTALL_STRIP_FLAG=-s install installdirs: mostlyclean-generic: clean-generic: + -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) distclean-generic: -rm -f Makefile $(CONFIG_CLEAN_FILES) -rm -f config.cache config.log stamp-h stamp-h[0-9]* maintainer-clean-generic: + -rm -f Makefile.in mostlyclean-am: mostlyclean-generic mostlyclean: mostlyclean-am @@ -226,7 +239,7 @@ maintainer-clean: maintainer-clean-am .PHONY: tags distdir check-DEJAGNU info-am info dvi-am dvi check \ check-am installcheck-am installcheck install-exec-am install-exec \ install-data-am install-data install-am install uninstall-am uninstall \ -all-redirect all-am all installdirs mostlyclean-generic \ +all-redirect all-am all install-strip installdirs mostlyclean-generic \ distclean-generic clean-generic maintainer-clean-generic clean \ mostlyclean distclean maintainer-clean diff --git a/lib/Makefile.in b/lib/Makefile.in index 76acae3..13a85aa 100644 --- a/lib/Makefile.in +++ b/lib/Makefile.in @@ -1,4 +1,4 @@ -# Makefile.in generated automatically by automake 1.4 from Makefile.am +# Makefile.in generated automatically by automake 1.4a from Makefile.am # Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation @@ -10,7 +10,6 @@ # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. - SHELL = @SHELL@ srcdir = @srcdir@ @@ -46,9 +45,10 @@ AUTOMAKE = @AUTOMAKE@ AUTOHEADER = @AUTOHEADER@ INSTALL = @INSTALL@ -INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS) +INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_FLAG = transform = @program_transform_name@ NORMAL_INSTALL = : @@ -57,14 +57,23 @@ POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : + +@SET_MAKE@ +AMDEP = @AMDEP@ +AMTAR = @AMTAR@ +AWK = @AWK@ CATALOGS = @CATALOGS@ CATOBJEXT = @CATOBJEXT@ CC = @CC@ CPP = @CPP@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ DATADIRNAME = @DATADIRNAME@ +DEPDIR = @DEPDIR@ GENCAT = @GENCAT@ GMOFILES = @GMOFILES@ GMSGFMT = @GMSGFMT@ +GNU_PACKAGE = @GNU_PACKAGE@ GT_NO = @GT_NO@ GT_YES = @GT_YES@ INCLUDE_LOCALE_H = @INCLUDE_LOCALE_H@ @@ -84,21 +93,61 @@ U = @U@ USE_INCLUDED_LIBINTL = @USE_INCLUDED_LIBINTL@ USE_NLS = @USE_NLS@ VERSION = @VERSION@ +install_sh = @install_sh@ l = @l@ + AUTOMAKE_OPTIONS = ansi2knr noinst_LIBRARIES = libfind.a localedir = $(datadir)/locale INCLUDES = -I../intl -DLOCALEDIR=\"$(localedir)\" -libfind_a_SOURCES = regex.h dirname.c error.c error.h filemode.c filemode.h getopt.c getopt.h getopt1.c idcache.c listfile.c pathmax.h modechange.c modechange.h nextelem.c savedir.c savedir.h xmalloc.c xalloc.h xstrdup.c xgetcwd.c fnmatch.h getline.c getline.h - - -libfind_a_LIBADD = @LIBOBJS@ @ALLOCA@ +libfind_a_SOURCES = regex.h \ + dirname.c \ + dirname.h \ + error.c \ + error.h \ + filemode.c \ + filemode.h \ + getopt.c \ + getopt.h \ + getopt1.c \ + idcache.c \ + listfile.c \ + modechange.c \ + modechange.h \ + pathmax.h \ + nextelem.c \ + savedir.c \ + savedir.h \ + xmalloc.c \ + xalloc.h \ + xstrdup.c \ + xgetcwd.c \ + fnmatch.h \ + xstrtol.c \ + xstrtol.h \ + xstrtoul.c \ + xstrtoul.h \ + getline.c \ + getline.h \ + basename.c + + +libfind_a_LIBADD = @LIBOBJS@ \ + @ALLOCA@ # Are these really needed? -EXTRA_DIST = modetype.h wait.h alloca.c lstat.c getline.h +EXTRA_DIST = modetype.h \ + wait.h \ + alloca.c \ + getline.h \ + xstat.in + +BUILT_SOURCES = lstat.c stat.c +DISTCLEANFILES = lstat.c stat.c +subdir = lib mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs CONFIG_HEADER = ../config.h CONFIG_CLEAN_FILES = @@ -110,39 +159,48 @@ CPPFLAGS = @CPPFLAGS@ LDFLAGS = @LDFLAGS@ LIBS = @LIBS@ ANSI2KNR = @ANSI2KNR@ +libfind_a_AR = $(AR) cru libfind_a_DEPENDENCIES = @LIBOBJS@ @ALLOCA@ -libfind_a_OBJECTS = dirname$U.o error$U.o filemode$U.o getopt$U.o \ +am_libfind_a_OBJECTS = dirname$U.o error$U.o filemode$U.o getopt$U.o \ getopt1$U.o idcache$U.o listfile$U.o modechange$U.o nextelem$U.o \ -savedir$U.o xmalloc$U.o xstrdup$U.o xgetcwd$U.o getline$U.o +savedir$U.o xmalloc$U.o xstrdup$U.o xgetcwd$U.o xstrtol$U.o \ +xstrtoul$U.o getline$U.o basename$U.o +libfind_a_OBJECTS = $(am_libfind_a_OBJECTS) AR = ar -CFLAGS = @CFLAGS@ COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CFLAGS = @CFLAGS@ CCLD = $(CC) -LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ +LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ +DIST_SOURCES = $(libfind_a_SOURCES) DIST_COMMON = Makefile.am Makefile.in alloca.c ansi2knr.1 ansi2knr.c \ -fileblocks.c fnmatch.c lstat.c malloc.c memcmp.c memset.c mktime.c \ -realloc.c regex.c stat.c stpcpy.c strdup.c strftime.c strspn.c strstr.c \ -strtol.c +fileblocks.c fnmatch.c getline.c malloc.c memcmp.c memset.c mktime.c \ +realloc.c regex.c stpcpy.c strcasecmp.c strdup.c strftime.c \ +strncasecmp.c strspn.c strstr.c strtol.c strtoul.c -DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) -TAR = tar GZIP_ENV = --best -DEP_FILES = .deps/alloca.P .deps/dirname.P .deps/error.P \ -.deps/fileblocks.P .deps/filemode.P .deps/fnmatch.P .deps/getline.P \ -.deps/getopt.P .deps/getopt1.P .deps/idcache.P .deps/listfile.P \ -.deps/lstat.P .deps/malloc.P .deps/memcmp.P .deps/memset.P \ -.deps/mktime.P .deps/modechange.P .deps/nextelem.P .deps/realloc.P \ -.deps/regex.P .deps/savedir.P .deps/stat.P .deps/stpcpy.P \ -.deps/strdup.P .deps/strftime.P .deps/strspn.P .deps/strstr.P \ -.deps/strtol.P .deps/xgetcwd.P .deps/xmalloc.P .deps/xstrdup.P +depcomp = $(SHELL) $(top_srcdir)/depcomp +DEP_FILES = @AMDEP@ $(DEPDIR)/alloca.Po $(DEPDIR)/basename$U.Po \ +$(DEPDIR)/dirname$U.Po $(DEPDIR)/error$U.Po $(DEPDIR)/fileblocks.Po \ +$(DEPDIR)/filemode$U.Po $(DEPDIR)/fnmatch.Po $(DEPDIR)/getline$U.Po \ +$(DEPDIR)/getline.Po $(DEPDIR)/getopt$U.Po $(DEPDIR)/getopt1$U.Po \ +$(DEPDIR)/idcache$U.Po $(DEPDIR)/listfile$U.Po $(DEPDIR)/lstat.Po \ +$(DEPDIR)/malloc.Po $(DEPDIR)/memcmp.Po $(DEPDIR)/memset.Po \ +$(DEPDIR)/mktime.Po $(DEPDIR)/modechange$U.Po $(DEPDIR)/nextelem$U.Po \ +$(DEPDIR)/realloc.Po $(DEPDIR)/regex.Po $(DEPDIR)/savedir$U.Po \ +$(DEPDIR)/stat.Po $(DEPDIR)/stpcpy.Po $(DEPDIR)/strcasecmp.Po \ +$(DEPDIR)/strdup.Po $(DEPDIR)/strftime.Po $(DEPDIR)/strncasecmp.Po \ +$(DEPDIR)/strspn.Po $(DEPDIR)/strstr.Po $(DEPDIR)/strtol.Po \ +$(DEPDIR)/strtoul.Po $(DEPDIR)/xgetcwd$U.Po $(DEPDIR)/xmalloc$U.Po \ +$(DEPDIR)/xstrdup$U.Po $(DEPDIR)/xstrtol$U.Po $(DEPDIR)/xstrtoul$U.Po SOURCES = $(libfind_a_SOURCES) -OBJECTS = $(libfind_a_OBJECTS) +OBJECTS = $(am_libfind_a_OBJECTS) all: all-redirect .SUFFIXES: -.SUFFIXES: .S .c .o .s +.SUFFIXES: .c .h .o $(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) cd $(top_srcdir) && $(AUTOMAKE) --gnu lib/Makefile @@ -160,12 +218,6 @@ distclean-noinstLIBRARIES: maintainer-clean-noinstLIBRARIES: -.s.o: - $(COMPILE) -c $< - -.S.o: - $(COMPILE) -c $< - mostlyclean-compile: -rm -f *.o core *.core @@ -200,10 +252,12 @@ maintainer-clean-kr: libfind.a: $(libfind_a_OBJECTS) $(libfind_a_DEPENDENCIES) -rm -f libfind.a - $(AR) cru libfind.a $(libfind_a_OBJECTS) $(libfind_a_LIBADD) + $(libfind_a_AR) libfind.a $(libfind_a_OBJECTS) $(libfind_a_LIBADD) $(RANLIB) libfind.a alloca_.c: alloca.c $(ANSI2KNR) $(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/alloca.c; then echo $(srcdir)/alloca.c; else echo alloca.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > alloca_.c +basename_.c: basename.c $(ANSI2KNR) + $(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/basename.c; then echo $(srcdir)/basename.c; else echo basename.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > basename_.c dirname_.c: dirname.c $(ANSI2KNR) $(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/dirname.c; then echo $(srcdir)/dirname.c; else echo dirname.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > dirname_.c error_.c: error.c $(ANSI2KNR) @@ -248,48 +302,63 @@ stat_.c: stat.c $(ANSI2KNR) $(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/stat.c; then echo $(srcdir)/stat.c; else echo stat.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > stat_.c stpcpy_.c: stpcpy.c $(ANSI2KNR) $(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/stpcpy.c; then echo $(srcdir)/stpcpy.c; else echo stpcpy.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > stpcpy_.c +strcasecmp_.c: strcasecmp.c $(ANSI2KNR) + $(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/strcasecmp.c; then echo $(srcdir)/strcasecmp.c; else echo strcasecmp.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > strcasecmp_.c strdup_.c: strdup.c $(ANSI2KNR) $(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/strdup.c; then echo $(srcdir)/strdup.c; else echo strdup.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > strdup_.c strftime_.c: strftime.c $(ANSI2KNR) $(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/strftime.c; then echo $(srcdir)/strftime.c; else echo strftime.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > strftime_.c +strncasecmp_.c: strncasecmp.c $(ANSI2KNR) + $(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/strncasecmp.c; then echo $(srcdir)/strncasecmp.c; else echo strncasecmp.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > strncasecmp_.c strspn_.c: strspn.c $(ANSI2KNR) $(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/strspn.c; then echo $(srcdir)/strspn.c; else echo strspn.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > strspn_.c strstr_.c: strstr.c $(ANSI2KNR) $(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/strstr.c; then echo $(srcdir)/strstr.c; else echo strstr.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > strstr_.c strtol_.c: strtol.c $(ANSI2KNR) $(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/strtol.c; then echo $(srcdir)/strtol.c; else echo strtol.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > strtol_.c +strtoul_.c: strtoul.c $(ANSI2KNR) + $(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/strtoul.c; then echo $(srcdir)/strtoul.c; else echo strtoul.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > strtoul_.c xgetcwd_.c: xgetcwd.c $(ANSI2KNR) $(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/xgetcwd.c; then echo $(srcdir)/xgetcwd.c; else echo xgetcwd.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > xgetcwd_.c xmalloc_.c: xmalloc.c $(ANSI2KNR) $(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/xmalloc.c; then echo $(srcdir)/xmalloc.c; else echo xmalloc.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > xmalloc_.c xstrdup_.c: xstrdup.c $(ANSI2KNR) $(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/xstrdup.c; then echo $(srcdir)/xstrdup.c; else echo xstrdup.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > xstrdup_.c -alloca_.o dirname_.o error_.o fileblocks_.o filemode_.o fnmatch_.o \ -getline_.o getopt_.o getopt1_.o idcache_.o listfile_.o lstat_.o \ -malloc_.o memcmp_.o memset_.o mktime_.o modechange_.o nextelem_.o \ -realloc_.o regex_.o savedir_.o stat_.o stpcpy_.o strdup_.o strftime_.o \ -strspn_.o strstr_.o strtol_.o xgetcwd_.o xmalloc_.o xstrdup_.o : \ -$(ANSI2KNR) +xstrtol_.c: xstrtol.c $(ANSI2KNR) + $(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/xstrtol.c; then echo $(srcdir)/xstrtol.c; else echo xstrtol.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > xstrtol_.c +xstrtoul_.c: xstrtoul.c $(ANSI2KNR) + $(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/xstrtoul.c; then echo $(srcdir)/xstrtoul.c; else echo xstrtoul.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > xstrtoul_.c +alloca_.o basename_.o dirname_.o error_.o fileblocks_.o filemode_.o \ +fnmatch_.o getline_.o getopt_.o getopt1_.o idcache_.o listfile_.o \ +lstat_.o malloc_.o memcmp_.o memset_.o mktime_.o modechange_.o \ +nextelem_.o realloc_.o regex_.o savedir_.o stat_.o stpcpy_.o \ +strcasecmp_.o strdup_.o strftime_.o strncasecmp_.o strspn_.o strstr_.o \ +strtol_.o strtoul_.o xgetcwd_.o xmalloc_.o xstrdup_.o xstrtol_.o \ +xstrtoul_.o : $(ANSI2KNR) tags: TAGS -ID: $(HEADERS) $(SOURCES) $(LISP) - list='$(SOURCES) $(HEADERS)'; \ - unique=`for i in $$list; do echo $$i; done | \ - awk ' { files[$$0] = 1; } \ +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ END { for (i in files) print i; }'`; \ - here=`pwd` && cd $(srcdir) \ - && mkid -f$$here/ID $$unique $(LISP) + mkid -f$$here/ID $$unique $(LISP) -TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) $(LISP) +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) tags=; \ here=`pwd`; \ - list='$(SOURCES) $(HEADERS)'; \ - unique=`for i in $$list; do echo $$i; done | \ - awk ' { files[$$0] = 1; } \ + list='$(SOURCES) $(HEADERS) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ END { for (i in files) print i; }'`; \ test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \ - || (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags $$unique $(LISP) -o $$here/TAGS) + || etags $(ETAGS_ARGS) $$tags $$unique $(LISP) mostlyclean-tags: @@ -302,18 +371,11 @@ maintainer-clean-tags: distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir) -subdir = lib - distdir: $(DISTFILES) - here=`cd $(top_builddir) && pwd`; \ - top_distdir=`cd $(top_distdir) && pwd`; \ - distdir=`cd $(distdir) && pwd`; \ - cd $(top_srcdir) \ - && $(AUTOMAKE) --include-deps --build-dir=$$here --srcdir-name=$(top_srcdir) --output-dir=$$top_distdir --gnu lib/Makefile @for file in $(DISTFILES); do \ d=$(srcdir); \ if test -d $$d/$$file; then \ - cp -pr $$d/$$file $(distdir)/$$file; \ + cp -pR $$d/$$file $(distdir); \ else \ test -f $(distdir)/$$file \ || ln $$d/$$file $(distdir)/$$file 2> /dev/null \ @@ -321,37 +383,62 @@ distdir: $(DISTFILES) fi; \ done -DEPS_MAGIC := $(shell mkdir .deps > /dev/null 2>&1 || :) - --include $(DEP_FILES) +@AMDEP@include $(DEPDIR)/alloca.Po +@AMDEP@include $(DEPDIR)/basename$U.Po +@AMDEP@include $(DEPDIR)/dirname$U.Po +@AMDEP@include $(DEPDIR)/error$U.Po +@AMDEP@include $(DEPDIR)/fileblocks.Po +@AMDEP@include $(DEPDIR)/filemode$U.Po +@AMDEP@include $(DEPDIR)/fnmatch.Po +@AMDEP@include $(DEPDIR)/getline$U.Po +@AMDEP@include $(DEPDIR)/getline.Po +@AMDEP@include $(DEPDIR)/getopt$U.Po +@AMDEP@include $(DEPDIR)/getopt1$U.Po +@AMDEP@include $(DEPDIR)/idcache$U.Po +@AMDEP@include $(DEPDIR)/listfile$U.Po +@AMDEP@include $(DEPDIR)/lstat.Po +@AMDEP@include $(DEPDIR)/malloc.Po +@AMDEP@include $(DEPDIR)/memcmp.Po +@AMDEP@include $(DEPDIR)/memset.Po +@AMDEP@include $(DEPDIR)/mktime.Po +@AMDEP@include $(DEPDIR)/modechange$U.Po +@AMDEP@include $(DEPDIR)/nextelem$U.Po +@AMDEP@include $(DEPDIR)/realloc.Po +@AMDEP@include $(DEPDIR)/regex.Po +@AMDEP@include $(DEPDIR)/savedir$U.Po +@AMDEP@include $(DEPDIR)/stat.Po +@AMDEP@include $(DEPDIR)/stpcpy.Po +@AMDEP@include $(DEPDIR)/strcasecmp.Po +@AMDEP@include $(DEPDIR)/strdup.Po +@AMDEP@include $(DEPDIR)/strftime.Po +@AMDEP@include $(DEPDIR)/strncasecmp.Po +@AMDEP@include $(DEPDIR)/strspn.Po +@AMDEP@include $(DEPDIR)/strstr.Po +@AMDEP@include $(DEPDIR)/strtol.Po +@AMDEP@include $(DEPDIR)/strtoul.Po +@AMDEP@include $(DEPDIR)/xgetcwd$U.Po +@AMDEP@include $(DEPDIR)/xmalloc$U.Po +@AMDEP@include $(DEPDIR)/xstrdup$U.Po +@AMDEP@include $(DEPDIR)/xstrtol$U.Po +@AMDEP@include $(DEPDIR)/xstrtoul$U.Po mostlyclean-depend: clean-depend: distclean-depend: - -rm -rf .deps + -rm -rf $(DEPDIR) maintainer-clean-depend: -%.o: %.c - @echo '$(COMPILE) -c $<'; \ - $(COMPILE) -Wp,-MD,.deps/$(*F).pp -c $< - @-cp .deps/$(*F).pp .deps/$(*F).P; \ - tr ' ' '\012' < .deps/$(*F).pp \ - | sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \ - >> .deps/$(*F).P; \ - rm .deps/$(*F).pp - -%.lo: %.c - @echo '$(LTCOMPILE) -c $<'; \ - $(LTCOMPILE) -Wp,-MD,.deps/$(*F).pp -c $< - @-sed -e 's/^\([^:]*\)\.o[ ]*:/\1.lo \1.o :/' \ - < .deps/$(*F).pp > .deps/$(*F).P; \ - tr ' ' '\012' < .deps/$(*F).pp \ - | sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \ - >> .deps/$(*F).P; \ - rm -f .deps/$(*F).pp +@AMDEP@CCDEPMODE = @CCDEPMODE@ + +.c.o: +@AMDEP@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP@ depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@ +@AMDEP@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ + $(COMPILE) -c -o $@ $< + info-am: info: info-am dvi-am: @@ -374,7 +461,7 @@ uninstall: uninstall-am all-am: Makefile $(ANSI2KNR) $(LIBRARIES) all-redirect: all-am install-strip: - $(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install + $(MAKE) $(AM_MAKEFLAGS) INSTALL_STRIP_FLAG=-s install installdirs: @@ -385,8 +472,11 @@ clean-generic: distclean-generic: -rm -f Makefile $(CONFIG_CLEAN_FILES) -rm -f config.cache config.log stamp-h stamp-h[0-9]* + -test -z "$(DISTCLEANFILES)" || rm -f $(DISTCLEANFILES) maintainer-clean-generic: + -rm -f Makefile.in + -test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES) mostlyclean-am: mostlyclean-noinstLIBRARIES mostlyclean-compile \ mostlyclean-krextra mostlyclean-kr mostlyclean-tags \ mostlyclean-depend mostlyclean-generic @@ -424,11 +514,29 @@ clean-tags maintainer-clean-tags distdir mostlyclean-depend \ distclean-depend clean-depend maintainer-clean-depend info-am info \ dvi-am dvi check check-am installcheck-am installcheck install-exec-am \ install-exec install-data-am install-data install-am install \ -uninstall-am uninstall all-redirect all-am all installdirs \ -mostlyclean-generic distclean-generic clean-generic \ +uninstall-am uninstall all-redirect all-am all install-strip \ +installdirs mostlyclean-generic distclean-generic clean-generic \ maintainer-clean-generic clean mostlyclean distclean maintainer-clean +lstat.c: xstat.in + sed \ + -e '/@IGNORE@/d' \ + -e 's/@xstat@/lstat/g' \ + -e '/_LSTAT_ONLY@/d' \ + -e '/@BEGIN_STAT_ONLY@/,/@END_STAT_ONLY@/d' \ + $(srcdir)/xstat.in > $@-t + mv $@-t $@ + +stat.c: xstat.in + sed \ + -e '/@IGNORE@/d' \ + -e 's/@xstat@/stat/g' \ + -e '/_STAT_ONLY@/d' \ + -e '/@BEGIN_LSTAT_ONLY@/,/@END_LSTAT_ONLY@/d' \ + $(srcdir)/xstat.in > $@-t + mv $@-t $@ + # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: diff --git a/lib/alloca.c b/lib/alloca.c index 10e5d65..b102eb1 100644 --- a/lib/alloca.c +++ b/lib/alloca.c @@ -161,8 +161,7 @@ static header *last_alloca_header = NULL; /* -> last alloca header. */ implementations of C, for example under Gould's UTX/32. */ pointer -alloca (size) - unsigned size; +alloca (unsigned size) { auto char probe; /* Probes stack depth: */ register char *depth = ADDRESS_FUNCTION (probe); diff --git a/lib/ansi2knr.c b/lib/ansi2knr.c index 3a305e9..412611a 100644 --- a/lib/ansi2knr.c +++ b/lib/ansi2knr.c @@ -1,6 +1,6 @@ -/* Copyright (C) 1989, 1997, 1998 Aladdin Enterprises. All rights reserved. */ +/* Copyright (C) 1989, 1997, 1998, 1999 Aladdin Enterprises. All rights reserved. */ -/*$Id: ansi2knr.c,v 1.1 2000/01/27 03:54:53 kevind Exp $*/ +/*$Id: ansi2knr.c,v 1.2 2000/04/05 08:02:48 kevind Exp $*/ /* Convert ANSI C function definitions to K&R ("traditional C") syntax */ /* @@ -44,20 +44,34 @@ program under the GPL. * consisting of only * identifier1(identifier2) * will not be considered a function definition unless identifier2 is - * the word "void". ansi2knr will recognize a multi-line header provided + * the word "void", and a line consisting of + * identifier1(identifier2, <>) + * will not be considered a function definition. + * ansi2knr will recognize a multi-line header provided * that no intervening line ends with a left or right brace or a semicolon. * These algorithms ignore whitespace and comments, except that * the function name must be the first thing on the line. * The following constructs will confuse it: * - Any other construct that starts at the left margin and * follows the above syntax (such as a macro or function call). - * - Some macros that tinker with the syntax of the function header. + * - Some macros that tinker with the syntax of function headers. */ /* * The original and principal author of ansi2knr is L. Peter Deutsch * . Other authors are noted in the change history * that follows (in reverse chronological order): + lpd 1999-04-12 added minor fixes from Pavel Roskin + for clean compilation with + gcc -W -Wall + lpd 1999-03-22 added hack to recognize lines consisting of + identifier1(identifier2, xxx) as *not* being procedures + lpd 1999-02-03 made indentation of preprocessor commands consistent + lpd 1999-01-28 fixed two bugs: a '/' in an argument list caused an + endless loop; quoted strings within an argument list + confused the parser + lpd 1999-01-24 added a check for write errors on the output, + suggested by Jim Meyering lpd 1998-11-09 added further hack to recognize identifier(void) as being a procedure lpd 1998-10-23 added hack to recognize lines consisting of @@ -153,19 +167,24 @@ program under the GPL. #endif +/* Define NULL (for *very* old compilers). */ +#ifndef NULL +# define NULL (0) +#endif + /* * The ctype macros don't always handle 8-bit characters correctly. * Compensate for this here. */ #ifdef isascii -# undef HAVE_ISASCII /* just in case */ -# define HAVE_ISASCII 1 +# undef HAVE_ISASCII /* just in case */ +# define HAVE_ISASCII 1 #else #endif #if STDC_HEADERS || !HAVE_ISASCII -# define is_ascii(c) 1 +# define is_ascii(c) 1 #else -# define is_ascii(c) isascii(c) +# define is_ascii(c) isascii(c) #endif #define is_space(c) (is_ascii(c) && isspace(c)) @@ -178,6 +197,7 @@ program under the GPL. /* Forward references */ char *skipspace(); +char *scanstring(); int writeblanks(); int test1(); int convert1(); @@ -190,6 +210,8 @@ main(argc, argv) { FILE *in = stdin; FILE *out = stdout; char *filename = 0; + char *program_name = argv[0]; + char *output_name = 0; #define bufsize 5000 /* arbitrary size */ char *buf; char *line; @@ -205,6 +227,7 @@ main(argc, argv) * check for this switch for backward compatibility. */ int convert_varargs = 1; + int output_error; while ( argc > 1 && argv[1][0] == '-' ) { if ( !strcmp(argv[1], "--varargs") ) { @@ -219,7 +242,8 @@ main(argc, argv) argv += 2; continue; } - fprintf(stderr, "Unrecognized switch: %s\n", argv[1]); + fprintf(stderr, "%s: Unrecognized switch: %s\n", program_name, + argv[1]); fprintf(stderr, usage); exit(1); } @@ -229,16 +253,19 @@ main(argc, argv) fprintf(stderr, usage); exit(0); case 3: - out = fopen(argv[2], "w"); + output_name = argv[2]; + out = fopen(output_name, "w"); if ( out == NULL ) { - fprintf(stderr, "Cannot open output file %s\n", argv[2]); + fprintf(stderr, "%s: Cannot open output file %s\n", + program_name, output_name); exit(1); } /* falls through */ case 2: in = fopen(argv[1], "r"); if ( in == NULL ) { - fprintf(stderr, "Cannot open input file %s\n", argv[1]); + fprintf(stderr, "%s: Cannot open input file %s\n", + program_name, argv[1]); exit(1); } if ( filename == 0 ) @@ -250,6 +277,11 @@ main(argc, argv) if ( filename ) fprintf(out, "#line 1 \"%s\"\n", filename); buf = malloc(bufsize); + if ( buf == NULL ) + { + fprintf(stderr, "Unable to allocate read buffer!\n"); + exit(1); + } line = buf; while ( fgets(line, (unsigned)(buf + bufsize - line), in) != NULL ) { @@ -300,14 +332,24 @@ wl: fputs(buf, out); if ( line != buf ) fputs(buf, out); free(buf); - if ( out != stdout ) - fclose(out); + if ( output_name ) { + output_error = ferror(out); + output_error |= fclose(out); + } else { /* out == stdout */ + fflush(out); + output_error = ferror(out); + } + if ( output_error ) { + fprintf(stderr, "%s: error writing to %s\n", program_name, + (output_name ? output_name : "stdout")); + exit(1); + } if ( in != stdin ) fclose(in); return 0; } -/* Skip over space and comments, in either direction. */ +/* Skip over whitespace and comments, in either direction. */ char * skipspace(p, dir) register char *p; @@ -328,6 +370,17 @@ skipspace(p, dir) return p; } +/* Scan over a quoted string, in either direction. */ +char * +scanstring(p, dir) + register char *p; + register int dir; +{ + for (p += dir; ; p += dir) + if (*p == '"' && p[-dir] != '\\') + return p + dir; +} + /* * Write blanks over part of a string. * Don't overwrite end-of-line characters. @@ -396,7 +449,7 @@ test1(buf) }; char **key = words; char *kp; - int len = endfn - buf; + unsigned len = endfn - buf; while ( (kp = *key) != 0 ) { if ( strlen(kp) == len && !strncmp(kp, buf, len) ) @@ -409,14 +462,16 @@ test1(buf) int len; /* * Check for identifier1(identifier2) and not - * identifier1(void). + * identifier1(void), or identifier1(identifier2, xxxx). */ while ( isidchar(*p) ) p++; len = p - id; p = skipspace(p, 1); - if ( *p == ')' && (len != 4 || strncmp(id, "void", 4)) ) + if (*p == ',' || + (*p == ')' && (len != 4 || strncmp(id, "void", 4))) + ) return 0; /* not a function */ } /* @@ -461,7 +516,7 @@ convert1(buf, out, header, convert_varargs) ; top: p = endfn; breaks = (char **)malloc(sizeof(char *) * num_breaks * 2); - if ( breaks == 0 ) + if ( breaks == NULL ) { /* Couldn't allocate break table, give up */ fprintf(stderr, "Unable to allocate break table!\n"); fputs(buf, out); @@ -473,7 +528,7 @@ top: p = endfn; do { int level = 0; char *lp = NULL; - char *rp; + char *rp = NULL; char *end = NULL; if ( bp >= btop ) @@ -500,14 +555,18 @@ top: p = endfn; else rp = p; break; case '/': - p = skipspace(p, 1) - 1; + if (p[1] == '*') + p = skipspace(p, 1) - 1; break; + case '"': + p = scanstring(p, 1) - 1; + break; default: ; } } /* Erase any embedded prototype parameters. */ - if ( lp ) + if ( lp && rp ) writeblanks(lp + 1, rp); p--; /* back up over terminator */ /* Find the name being declared. */ @@ -523,9 +582,19 @@ top: p = endfn; while ( level ) switch ( *--p ) { - case ']': case ')': level++; break; - case '[': case '(': level--; break; - case '/': p = skipspace(p, -1) + 1; break; + case ']': case ')': + level++; + break; + case '[': case '(': + level--; + break; + case '/': + if (p > buf && p[-1] == '*') + p = skipspace(p, -1) + 1; + break; + case '"': + p = scanstring(p, -1) + 1; + break; default: ; } } diff --git a/lib/dirname.c b/lib/dirname.c index 56b66e6..483c338 100644 --- a/lib/dirname.c +++ b/lib/dirname.c @@ -33,14 +33,15 @@ char *malloc (); # endif #endif +#include "dirname.h" + /* Return the leading directories part of PATH, allocated with malloc. If out of memory, return 0. Assumes that trailing slashes have already been removed. */ char * -dirname (path) - char *path; +dir_name (const char *path) { char *newpath; char *slash; diff --git a/lib/error.c b/lib/error.c index 83998bb..53b650c 100644 --- a/lib/error.c +++ b/lib/error.c @@ -1,5 +1,5 @@ /* Error handler for noninteractive utilities - Copyright (C) 1990,91,92,93,94,95,96,97,98 Free Software Foundation, Inc. + Copyright (C) 1990,91,92,93,94,95,96,97,98, 99 Free Software Foundation, Inc. This file is part of the GNU C Library. Its master source is NOT part of the C library, however. The master source lives in /gd/gnu/lib. @@ -152,7 +152,10 @@ error (status, errnum, message, va_alist) { #if defined HAVE_STRERROR_R || defined _LIBC char errbuf[1024]; - fprintf (stderr, ": %s", __strerror_r (errnum, errbuf, sizeof errbuf)); + /* Don't use __strerror_r's return value because on some systems + (at least DEC UNIX 4.0[A-D]) strerror_r returns `int'. */ + __strerror_r (errnum, errbuf, sizeof errbuf); + fprintf (stderr, ": %s", errbuf); #else fprintf (stderr, ": %s", strerror (errnum)); #endif @@ -227,7 +230,10 @@ error_at_line (status, errnum, file_name, line_number, message, va_alist) { #if defined HAVE_STRERROR_R || defined _LIBC char errbuf[1024]; - fprintf (stderr, ": %s", __strerror_r (errnum, errbuf, sizeof errbuf)); + /* Don't use __strerror_r's return value because on some systems + (at least DEC UNIX 4.0[A-D]) strerror_r returns `int'. */ + __strerror_r (errnum, errbuf, sizeof errbuf); + fprintf (stderr, ": %s", errbuf); #else fprintf (stderr, ": %s", strerror (errnum)); #endif diff --git a/lib/fileblocks.c b/lib/fileblocks.c index 0c182d8..2c94430 100644 --- a/lib/fileblocks.c +++ b/lib/fileblocks.c @@ -1,5 +1,5 @@ /* Convert file size to number of blocks on System V-like machines. - Copyright (C) 1990, 1997, 1998 Free Software Foundation, Inc. + Copyright (C) 1990, 1997, 1998, 1999 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 @@ -27,7 +27,7 @@ # include #endif -#if !HAVE_ST_BLOCKS && !defined _POSIX_SOURCE && defined BSIZE +#if !HAVE_STRUCT_STAT_ST_BLOCKS && !defined _POSIX_SOURCE && defined BSIZE # if HAVE_UNISTD_H # include @@ -50,8 +50,7 @@ typedef long daddr_t; /* for disk address */ /* Return the number of 512-byte blocks in a file of SIZE bytes. */ off_t -st_blocks (size) - off_t size; +st_blocks (off_t size) { off_t datablks = size / 512 + (size % 512 != 0); off_t indrblks = 0; diff --git a/lib/filemode.c b/lib/filemode.c index e61f212..ce089ed 100644 --- a/lib/filemode.c +++ b/lib/filemode.c @@ -1,5 +1,5 @@ /* filemode.c -- make a string describing file modes - Copyright (C) 1985, 1990, 1993, 1998 Free Software Foundation, Inc. + Copyright (C) 1985, 1990, 1993, 1998, 1999 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 @@ -48,6 +48,25 @@ # endif #endif +#if !S_IRGRP +# define S_IRGRP (S_IRUSR >> 3) +#endif +#if !S_IWGRP +# define S_IWGRP (S_IWUSR >> 3) +#endif +#if !S_IXGRP +# define S_IXGRP (S_IXUSR >> 3) +#endif +#if !S_IROTH +# define S_IROTH (S_IRUSR >> 6) +#endif +#if !S_IWOTH +# define S_IWOTH (S_IWUSR >> 6) +#endif +#if !S_IXOTH +# define S_IXOTH (S_IXUSR >> 6) +#endif + #ifdef STAT_MACROS_BROKEN # undef S_ISBLK # undef S_ISCHR @@ -89,23 +108,15 @@ #if !defined(S_ISNWK) && defined(S_IFNWK) /* HP/UX */ # define S_ISNWK(m) (((m) & S_IFMT) == S_IFNWK) #endif - -/* Look at read, write, and execute bits in BITS and set - flags in CHARS accordingly. */ - -static void -rwx (short unsigned int bits, char *chars) -{ - chars[0] = (bits & S_IRUSR) ? 'r' : '-'; - chars[1] = (bits & S_IWUSR) ? 'w' : '-'; - chars[2] = (bits & S_IXUSR) ? 'x' : '-'; -} +#if !defined(S_ISDOOR) && defined(S_IFDOOR) /* Solaris 2.5 and up */ +# define S_ISDOOR(m) (((m) & S_IFMT) == S_IFDOOR) +#endif /* Set the 's' and 't' flags in file attributes string CHARS, according to the file mode BITS. */ static void -setst (short unsigned int bits, char *chars) +setst (mode_t bits, char *chars) { #ifdef S_ISUID if (bits & S_ISUID) @@ -142,6 +153,7 @@ setst (short unsigned int bits, char *chars) /* Return a character indicating the type of file described by file mode BITS: 'd' for directories + 'D' for doors 'b' for block special files 'c' for character special files 'm' for multiplexor files @@ -153,7 +165,7 @@ setst (short unsigned int bits, char *chars) '?' for any other file type. */ static char -ftypelet (long int bits) +ftypelet (mode_t bits) { #ifdef S_ISBLK if (S_ISBLK (bits)) @@ -185,6 +197,10 @@ ftypelet (long int bits) if (S_ISNWK (bits)) return 'n'; #endif +#ifdef S_ISDOOR + if (S_ISDOOR (bits)) + return 'D'; +#endif /* The following two tests are for Cray DMF (Data Migration Facility), which is a HSM file system. A migrated file has a @@ -208,12 +224,18 @@ ftypelet (long int bits) is given as an argument. */ void -mode_string (short unsigned int mode, char *str) +mode_string (mode_t mode, char *str) { - str[0] = ftypelet ((long) mode); - rwx ((mode & 0700) << 0, &str[1]); - rwx ((mode & 0070) << 3, &str[4]); - rwx ((mode & 0007) << 6, &str[7]); + str[0] = ftypelet (mode); + str[1] = mode & S_IRUSR ? 'r' : '-'; + str[2] = mode & S_IWUSR ? 'w' : '-'; + str[3] = mode & S_IXUSR ? 'x' : '-'; + str[4] = mode & S_IRGRP ? 'r' : '-'; + str[5] = mode & S_IWGRP ? 'w' : '-'; + str[6] = mode & S_IXGRP ? 'x' : '-'; + str[7] = mode & S_IROTH ? 'r' : '-'; + str[8] = mode & S_IWOTH ? 'w' : '-'; + str[9] = mode & S_IXOTH ? 'x' : '-'; setst (mode, str); } diff --git a/lib/filemode.h b/lib/filemode.h index 162e07a..5b19db2 100644 --- a/lib/filemode.h +++ b/lib/filemode.h @@ -1,9 +1,19 @@ -#ifndef PARAMS -# if defined PROTOTYPES || (defined __STDC__ && __STDC__) -# define PARAMS(Args) Args -# else -# define PARAMS(Args) () +#ifndef FILEMODE_H_ + +# if HAVE_CONFIG_H +# include # endif -#endif -void mode_string PARAMS ((short unsigned int mode, char *str)); +# include + +# ifndef PARAMS +# if defined PROTOTYPES || (defined __STDC__ && __STDC__) +# define PARAMS(Args) Args +# else +# define PARAMS(Args) () +# endif +# endif + +void mode_string PARAMS ((mode_t mode, char *str)); + +#endif diff --git a/lib/fnmatch.c b/lib/fnmatch.c index 7ec417d..d993633 100644 --- a/lib/fnmatch.c +++ b/lib/fnmatch.c @@ -55,10 +55,7 @@ extern int errno; /* Match STRING against the filename pattern PATTERN, returning zero if it matches, nonzero if not. */ int -fnmatch (pattern, string, flags) - const char *pattern; - const char *string; - int flags; +fnmatch (const char *pattern, const char *string, int flags) { register const char *p = pattern, *n = string; register char c; diff --git a/lib/getline.c b/lib/getline.c index c028c65..8557431 100644 --- a/lib/getline.c +++ b/lib/getline.c @@ -1,6 +1,6 @@ /* getline.c -- Replacement for GNU C library function getline -Copyright (C) 1993, 1996, 1997 Free Software Foundation, Inc. +Copyright (C) 1993, 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 @@ -31,20 +31,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include #include -#if defined __GNU_LIBRARY__ && HAVE_GETDELIM - -int -getline (lineptr, n, stream) - char **lineptr; - size_t *n; - FILE *stream; -{ - return getdelim (lineptr, n, '\n', stream); -} - - -#else /* ! have getdelim */ - +/* define getstr even if the other functions are unneeded */ # define NDEBUG # include @@ -63,17 +50,12 @@ char *malloc (), *realloc (); as necessary. Return the number of characters read (not including the null terminator), or -1 on error or EOF. */ -int -getstr (lineptr, n, stream, terminator, offset) - char **lineptr; - size_t *n; - FILE *stream; - char terminator; - size_t offset; +ssize_t +getstr (char **lineptr, size_t *n, FILE *stream, char terminator, size_t offset) { int nchars_avail; /* Allocated but unused chars in *LINEPTR. */ char *read_pos; /* Where we're reading into *LINEPTR. */ - int ret; + ssize_t ret; if (!lineptr || !n || !stream) return -1; @@ -137,21 +119,29 @@ getstr (lineptr, n, stream, terminator, offset) return ret; } -int -getline (lineptr, n, stream) - char **lineptr; - size_t *n; - FILE *stream; +#ifndef HAVE_GETLINE +#if defined __GNU_LIBRARY__ && HAVE_GETDELIM +ssize_t +getline (char **lineptr, size_t *n, FILE *stream) +{ + return getdelim (lineptr, n, '\n', stream); +} + +#else /* ! have getdelim */ + +ssize_t +getline (char **lineptr, size_t *n, FILE *stream) { return getstr (lineptr, n, stream, '\n', 0); } -int -getdelim (lineptr, n, delimiter, stream) - char **lineptr; - size_t *n; - int delimiter; - FILE *stream; +#endif +#endif + + +#if ! (defined __GNU_LIBRARY__ && HAVE_GETDELIM) +ssize_t +getdelim (char **lineptr, size_t *n, int delimiter, FILE *stream) { return getstr (lineptr, n, stream, delimiter, 0); } diff --git a/lib/getline.h b/lib/getline.h index 7592a3c..3f72e60 100644 --- a/lib/getline.h +++ b/lib/getline.h @@ -1,4 +1,4 @@ -/* Copyright (C) 1995, 1997 Free Software Foundation, Inc. +/* Copyright (C) 1995, 1997, 1999 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 @@ -27,14 +27,14 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ # endif # endif -int +# if __GLIBC__ < 2 +ssize_t getline PARAMS ((char **_lineptr, size_t *_n, FILE *_stream)); -int +#if ! (defined __GNU_LIBRARY__ && HAVE_GETDELIM) +ssize_t getdelim PARAMS ((char **_lineptr, size_t *_n, int _delimiter, FILE *_stream)); - -int -getstr PARAMS ((char **lineptr, size_t *n, FILE *stream, - char terminator, size_t offset)); +#endif +# endif #endif /* not GETLINE_H_ */ diff --git a/lib/getopt.c b/lib/getopt.c index 6bf37d9..d176d3e 100644 --- a/lib/getopt.c +++ b/lib/getopt.c @@ -1,47 +1,40 @@ /* Getopt for GNU. - NOTE: getopt is now part of the C library, so if you don't know what - "Keep this file name-space clean" means, talk to roland@gnu.ai.mit.edu - before changing it! + NOTE: The canonical source of this file is maintained with the GNU + C Library. Bugs can be reported to bug-glibc@gnu.org. - Copyright (C) 1987, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97 + Copyright (C) 1987, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99 Free Software Foundation, Inc. - the C library, however. The master source lives in /gd/gnu/lib. + 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. -NOTE: The canonical source of this file is maintained with the GNU C Library. -Bugs can be reported to bug-glibc@prep.ai.mit.edu. + 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. -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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, -USA. */ + 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* This tells Alpha OSF/1 not to define a getopt prototype in . Ditto for AIX 3.2 and . */ #ifndef _NO_PROTO -#define _NO_PROTO +# define _NO_PROTO #endif #ifdef HAVE_CONFIG_H -#include -#endif - -#if !defined (__STDC__) || !__STDC__ +# include +#else +# if !defined __STDC__ || !__STDC__ /* This is a separate conditional since some stdc systems reject `defined (const)'. */ -#ifndef const -#define const -#endif +# ifndef const +# define const +# endif +# endif #endif #include @@ -55,11 +48,11 @@ USA. */ it is simpler to just do this in the source for each such file. */ #define GETOPT_INTERFACE_VERSION 2 -#if !defined (_LIBC) && defined (__GLIBC__) && __GLIBC__ >= 2 -#include -#if _GNU_GETOPT_INTERFACE_VERSION == GETOPT_INTERFACE_VERSION -#define ELIDE_CODE -#endif +#if !defined _LIBC && defined __GLIBC__ && __GLIBC__ >= 2 +# include +# if _GNU_GETOPT_INTERFACE_VERSION == GETOPT_INTERFACE_VERSION +# define ELIDE_CODE +# endif #endif #ifndef ELIDE_CODE @@ -70,33 +63,26 @@ USA. */ #ifdef __GNU_LIBRARY__ /* Don't include stdlib.h for non-GNU C libraries because some of them contain conflicting prototypes for getopt. */ -#include -#include +# include +# include #endif /* GNU C library. */ #ifdef VMS -#include -#if HAVE_STRING_H - 0 -#include -#endif -#endif - -#if defined (WIN32) && !defined (__CYGWIN32__) -/* It's not Unix, really. See? Capital letters. */ -#include -#define getpid() GetCurrentProcessId() +# include +# if HAVE_STRING_H - 0 +# include +# endif #endif -#if ENABLE_NLS -# include -# define _(Text) gettext (Text) -#else -# define _(Text) Text -#endif -#ifdef gettext_noop -# define N_(String) gettext_noop (String) -#else -# define N_(String) (String) +#ifndef _ +/* This is for other GNU distributions with internationalized messages. + When compiling libc, the _ macro is predefined. */ +# ifdef HAVE_LIBINTL_H +# include +# define _(msgid) gettext (msgid) +# else +# define _(msgid) (msgid) +# endif #endif /* This version of `getopt' appears to the caller like standard Unix `getopt' @@ -121,7 +107,7 @@ USA. */ Also, when `ordering' is RETURN_IN_ORDER, each non-option ARGV-element is returned here. */ -char *optarg = NULL; +char *optarg; /* Index in ARGV of the next element to be scanned. This is used for communication to and from the caller @@ -142,7 +128,7 @@ int optind = 1; causes problems with re-calling getopt as programs generally don't know that. */ -int __getopt_initialized = 0; +int __getopt_initialized; /* The next char to be scanned in the option-element in which the last option character we returned was found. @@ -206,14 +192,22 @@ static char *posixly_correct; because there are many ways it can cause trouble. On some systems, it contains special magic macros that don't work in GCC. */ -#include -#define my_index strchr +# include +# define my_index strchr #else +# if HAVE_STRING_H +# include +# else +# include +# endif + /* Avoid depending on library functions or files whose names are inconsistent. */ -char *getenv (); +#ifndef getenv +extern char *getenv (); +#endif static char * my_index (str, chr) @@ -234,11 +228,11 @@ my_index (str, chr) #ifdef __GNUC__ /* Note that Motorola Delta 68k R3V7 comes with GCC but not stddef.h. That was relevant to code that was here before. */ -#if !defined (__STDC__) || !__STDC__ +# if (!defined __STDC__ || !__STDC__) && !defined strlen /* gcc with -traditional declares the built-in strlen to return int, and has done so at least since version 2.4.5. -- rms. */ extern int strlen (const char *); -#endif /* not __STDC__ */ +# endif /* not __STDC__ */ #endif /* __GNUC__ */ #endif /* not __GNU_LIBRARY__ */ @@ -265,8 +259,6 @@ static int nonoption_flags_len; static int original_argc; static char *const *original_argv; -extern pid_t __libc_pid; - /* Make sure the environment variable bash 2.0 puts in the environment is valid for the getopt call we must make sure that the ARGV passed to getopt is that one passed to the process. */ @@ -279,7 +271,9 @@ store_args_and_env (int argc, char *const *argv) original_argc = argc; original_argv = argv; } +# ifdef text_set_element text_set_element (__libc_subinit, store_args_and_env); +# endif /* text_set_element */ # define SWAP_FLAGS(ch1, ch2) \ if (nonoption_flags_len > 0) \ @@ -301,7 +295,7 @@ text_set_element (__libc_subinit, store_args_and_env); `first_nonopt' and `last_nonopt' are relocated so that they describe the new indices of the non-options in ARGV after they are moved. */ -#if defined (__STDC__) && __STDC__ +#if defined __STDC__ && __STDC__ static void exchange (char **); #endif @@ -332,9 +326,9 @@ exchange (argv) nonoption_flags_len = nonoption_flags_max_len = 0; else { - memcpy (new_str, __getopt_nonoption_flags, nonoption_flags_max_len); - memset (&new_str[nonoption_flags_max_len], '\0', - top + 1 - nonoption_flags_max_len); + memset (__mempcpy (new_str, __getopt_nonoption_flags, + nonoption_flags_max_len), + '\0', top + 1 - nonoption_flags_max_len); nonoption_flags_max_len = top + 1; __getopt_nonoption_flags = new_str; } @@ -387,7 +381,7 @@ exchange (argv) /* Initialize the internal data when the first call is made. */ -#if defined (__STDC__) && __STDC__ +#if defined __STDC__ && __STDC__ static const char *_getopt_initialize (int, char *const *, const char *); #endif static const char * @@ -443,11 +437,8 @@ _getopt_initialize (argc, argv, optstring) if (__getopt_nonoption_flags == NULL) nonoption_flags_max_len = -1; else - { - memcpy (__getopt_nonoption_flags, orig_str, len); - memset (&__getopt_nonoption_flags[len], '\0', - nonoption_flags_max_len - len); - } + memset (__mempcpy (__getopt_nonoption_flags, orig_str, len), + '\0', nonoption_flags_max_len - len); } } nonoption_flags_len = nonoption_flags_max_len; @@ -539,11 +530,11 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only) from the shell indicating it is not an option. The later information is only used when the used in the GNU libc. */ #ifdef _LIBC -#define NONOPTION_P (argv[optind][0] != '-' || argv[optind][1] == '\0' \ - || (optind < nonoption_flags_len \ - && __getopt_nonoption_flags[optind] == '1')) +# define NONOPTION_P (argv[optind][0] != '-' || argv[optind][1] == '\0' \ + || (optind < nonoption_flags_len \ + && __getopt_nonoption_flags[optind] == '1')) #else -#define NONOPTION_P (argv[optind][0] != '-' || argv[optind][1] == '\0') +# define NONOPTION_P (argv[optind][0] != '-' || argv[optind][1] == '\0') #endif if (nextchar == NULL || *nextchar == '\0') @@ -706,12 +697,12 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only) if (argv[optind - 1][1] == '-') /* --option */ fprintf (stderr, - _("%s: option `--%s' doesn't allow an argument\n"), + _("%s: option `--%s' doesn't allow an argument\n"), argv[0], pfound->name); else /* +option or -option */ fprintf (stderr, - _("%s: option `%c%s' doesn't allow an argument\n"), + _("%s: option `%c%s' doesn't allow an argument\n"), argv[0], argv[optind - 1][0], pfound->name); } diff --git a/lib/getopt.h b/lib/getopt.h index c454924..ac6728f 100644 --- a/lib/getopt.h +++ b/lib/getopt.h @@ -1,28 +1,27 @@ /* Declarations for getopt. - Copyright (C) 1989,90,91,92,93,94,96,97 Free Software Foundation, Inc. - - the C library, however. The master source lives in /gd/gnu/lib. - -NOTE: The canonical source of this file is maintained with the GNU C Library. -Bugs can be reported to bug-glibc@prep.ai.mit.edu. - -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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, -USA. */ + Copyright (C) 1989,90,91,92,93,94,96,97,98 Free Software Foundation, Inc. + NOTE: The canonical source of this file is maintained with the GNU C Library. + Bugs can be reported to bug-glibc@gnu.org. + 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, + USA. */ #ifndef _GETOPT_H -#define _GETOPT_H 1 + +#ifndef __need_getopt +# define _GETOPT_H 1 +#endif #ifdef __cplusplus extern "C" { @@ -59,6 +58,7 @@ extern int opterr; extern int optopt; +#ifndef __need_getopt /* Describe the long-named options requested by the application. The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector of `struct option' terminated by an element containing a name which is @@ -82,11 +82,11 @@ extern int optopt; struct option { -#if defined (__STDC__) && __STDC__ +# if defined __STDC__ && __STDC__ const char *name; -#else +# else char *name; -#endif +# endif /* has_arg can't be an enum because some compilers complain about type mismatches in all the code that assumes it is an int. */ int has_arg; @@ -96,40 +96,74 @@ struct option /* Names for the values of the `has_arg' field of `struct option'. */ -#define no_argument 0 -#define required_argument 1 -#define optional_argument 2 +# define no_argument 0 +# define required_argument 1 +# define optional_argument 2 +#endif /* need getopt */ + -#if defined (__STDC__) && __STDC__ -#ifdef __GNU_LIBRARY__ +/* Get definitions and prototypes for functions to process the + arguments in ARGV (ARGC of them, minus the program name) for + options given in OPTS. + + Return the option character from OPTS just read. Return -1 when + there are no more options. For unrecognized options, or options + missing arguments, `optopt' is set to the option letter, and '?' is + returned. + + The OPTS string is a list of characters which are recognized option + letters, optionally followed by colons, specifying that that letter + takes an argument, to be placed in `optarg'. + + If a letter in OPTS is followed by two colons, its argument is + optional. This behavior is specific to the GNU `getopt'. + + The argument `--' causes premature termination of argument + scanning, explicitly telling `getopt' that there are no more + options. + + If OPTS begins with `--', then non-option arguments are treated as + arguments to the option '\0'. This behavior is specific to the GNU + `getopt'. */ + +#if defined __STDC__ && __STDC__ +# ifdef __GNU_LIBRARY__ /* Many other libraries have conflicting prototypes for getopt, with differences in the consts, in stdlib.h. To avoid compilation errors, only prototype getopt for the GNU C library. */ -extern int getopt (int argc, char *const *argv, const char *shortopts); -#else /* not __GNU_LIBRARY__ */ +extern int getopt (int __argc, char *const *__argv, const char *__shortopts); +# else /* not __GNU_LIBRARY__ */ extern int getopt (); -#endif /* __GNU_LIBRARY__ */ -extern int getopt_long (int argc, char *const *argv, const char *shortopts, - const struct option *longopts, int *longind); -extern int getopt_long_only (int argc, char *const *argv, - const char *shortopts, - const struct option *longopts, int *longind); +# endif /* __GNU_LIBRARY__ */ + +# ifndef __need_getopt +extern int getopt_long (int __argc, char *const *__argv, const char *__shortopts, + const struct option *__longopts, int *__longind); +extern int getopt_long_only (int __argc, char *const *__argv, + const char *__shortopts, + const struct option *__longopts, int *__longind); /* Internal only. Users should not call this directly. */ -extern int _getopt_internal (int argc, char *const *argv, - const char *shortopts, - const struct option *longopts, int *longind, - int long_only); +extern int _getopt_internal (int __argc, char *const *__argv, + const char *__shortopts, + const struct option *__longopts, int *__longind, + int __long_only); +# endif #else /* not __STDC__ */ extern int getopt (); +# ifndef __need_getopt extern int getopt_long (); extern int getopt_long_only (); extern int _getopt_internal (); +# endif #endif /* __STDC__ */ #ifdef __cplusplus } #endif -#endif /* _GETOPT_H */ +/* Make sure we later can get all the definitions and declarations. */ +#undef __need_getopt + +#endif /* getopt.h */ diff --git a/lib/getopt1.c b/lib/getopt1.c index b51be7f..9c82565 100644 --- a/lib/getopt1.c +++ b/lib/getopt1.c @@ -1,39 +1,36 @@ /* getopt_long and getopt_long_only entry points for GNU getopt. - Copyright (C) 1987,88,89,90,91,92,93,94,96,97 Free Software Foundation, Inc. - - the C library, however. The master source lives in /gd/gnu/lib. - -NOTE: The canonical source of this file is maintained with the GNU C Library. -Bugs can be reported to bug-glibc@prep.ai.mit.edu. - -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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, -USA. */ + Copyright (C) 1987,88,89,90,91,92,93,94,96,97,98 + Free Software Foundation, Inc. + NOTE: The canonical source of this file is maintained with the GNU C Library. + Bugs can be reported to bug-glibc@gnu.org. + + 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifdef HAVE_CONFIG_H #include -#endif - -#include "getopt.h" - -#if !defined (__STDC__) || !__STDC__ +#else +#if !defined __STDC__ || !__STDC__ /* This is a separate conditional since some stdc systems reject `defined (const)'. */ #ifndef const #define const #endif #endif +#endif + +#include "getopt.h" #include @@ -46,7 +43,7 @@ USA. */ it is simpler to just do this in the source for each such file. */ #define GETOPT_INTERFACE_VERSION 2 -#if !defined (_LIBC) && defined (__GLIBC__) && __GLIBC__ >= 2 +#if !defined _LIBC && defined __GLIBC__ && __GLIBC__ >= 2 #include #if _GNU_GETOPT_INTERFACE_VERSION == GETOPT_INTERFACE_VERSION #define ELIDE_CODE diff --git a/lib/idcache.c b/lib/idcache.c index b8104f1..7a827e3 100644 --- a/lib/idcache.c +++ b/lib/idcache.c @@ -1,5 +1,6 @@ /* idcache.c -- map user and group IDs, cached for speed - Copyright (C) 1985, 1988, 1989, 1990, 1997, 1998 Free Software Foundation, Inc. + Copyright (C) 1985, 1988, 1989, 1990, 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 diff --git a/lib/listfile.c b/lib/listfile.c index 9e63e11..2a938eb 100644 --- a/lib/listfile.c +++ b/lib/listfile.c @@ -15,8 +15,8 @@ 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 +#if HAVE_CONFIG_H +# include #endif #include @@ -28,14 +28,16 @@ #include #include "pathmax.h" -#if defined(HAVE_STRING_H) || defined(STDC_HEADERS) +#if HAVE_STRING_H || STDC_HEADERS #include #else #include #endif -#ifdef STDC_HEADERS -#include + +#if STDC_HEADERS +# include #else +char *getenv (); extern int errno; #endif @@ -65,6 +67,9 @@ extern int errno; #define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK) #endif +#if defined(S_ISLNK) +int readlink (); +#endif /* Extract or fake data from a `struct stat'. ST_NBLOCKS: Number of 512-byte blocks in the file @@ -85,9 +90,10 @@ extern int errno; # endif #endif -/* Convert B 512-byte blocks to kilobytes if K is nonzero, +/* Convert NUMBER 512-byte blocks to kilobytes if KILOFLAG is nonzero, otherwise return it unchanged. */ -#define convert_blocks(b, k) ((k) ? ((b) + 1) / 2 : (b)) +#define convert_blocks(Number, Kiloflag) \ + ((Kiloflag) ? ((Number) + 1) / 2 : (Number)) #ifndef _POSIX_VERSION struct passwd *getpwuid (); @@ -151,7 +157,8 @@ list_file (name, relname, statp, stream) fprintf (stream, "%6lu ", statp->st_ino); - fprintf (stream, "%4lu ", convert_blocks (ST_NBLOCKS (statp), kilobytes)); + fprintf (stream, "%4lu ", + (long) convert_blocks (ST_NBLOCKS (statp), kilobytes)); /* The space between the mode and the number of links is the POSIX "optional alternate access method flag". */ diff --git a/lib/lstat.c b/lib/lstat.c index 6dca99c..a973f7c 100644 --- a/lib/lstat.c +++ b/lib/lstat.c @@ -1,7 +1,7 @@ /* Work around the bug in some systems whereby lstat succeeds when given the zero-length file name argument. The lstat from SunOS4.1.4 has this bug. - Copyright (C) 1997, 1998 Free Software Foundation, Inc. + Copyright (C) 1997-2000 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 @@ -28,6 +28,56 @@ extern int errno; #endif +#ifdef STAT_MACROS_BROKEN +# undef S_ISLNK +#endif +#if !defined(S_ISLNK) && defined(S_IFLNK) +# define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK) +#endif + +char *xmalloc (); + +/* lstat works different on Linux and Solaris systems. POSIX (see + `pathname resolution' in the glossary) requires that programs like `ls' + take into consideration the fact that FILE has a trailing slash when + FILE is a symbolic link. On Linux systems, the lstat function already + has the desired semantics (in treating `lstat("symlink/",sbuf)' just like + `lstat("symlink/.",sbuf)', but on Solaris it does not. + + If FILE has a trailing slash and specifies a symbolic link, + then append a `.' to FILE and call lstat a second time. */ + +static int +slash_aware_lstat (const char *file, struct stat *sbuf) +{ + size_t len; + char *new_file; + + int lstat_result = lstat (file, sbuf); + + if (lstat_result != 0 || !S_ISLNK (sbuf->st_mode)) + return lstat_result; + + len = strlen (file); + if (file[len - 1] != '/') + return lstat_result; + + /* FILE refers to a symbolic link and the name ends with a slash. + Append a `.' to FILE and repeat the lstat call. */ + + /* Add one for the `.' we might have to append, and one more + for the trailing NUL. */ + new_file = xmalloc (len + 1 + 1); + memcpy (new_file, file, len); + new_file[len] = '.'; + new_file[len + 1] = 0; + + lstat_result = lstat (new_file, sbuf); + free (new_file); + + return lstat_result; +} + /* This is a wrapper for lstat(2). If FILE is the empty string, fail with errno == ENOENT. Otherwise, return the result of calling the real lstat. @@ -36,6 +86,9 @@ extern int errno; given the zero-length file name argument. The lstat from SunOS4.1.4 has this bug. */ +/* This function also provides a version of lstat with consistent semantics + when FILE specifies a symbolic link and has a trailing slash. */ + int rpl_lstat (const char *file, struct stat *sbuf) { @@ -45,5 +98,5 @@ rpl_lstat (const char *file, struct stat *sbuf) return -1; } - return lstat (file, sbuf); + return slash_aware_lstat (file, sbuf); } diff --git a/lib/malloc.c b/lib/malloc.c index b859e58..5e7674b 100644 --- a/lib/malloc.c +++ b/lib/malloc.c @@ -1,5 +1,5 @@ /* Work around bug on some systems where malloc (0) fails. - Copyright (C) 1997 Free Software Foundation, Inc. + Copyright (C) 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 @@ -30,8 +30,7 @@ char *malloc (); If N is zero, allocate a 1-byte block. */ char * -rpl_malloc (n) - size_t n; +rpl_malloc (size_t n) { if (n == 0) n = 1; diff --git a/lib/memcmp.c b/lib/memcmp.c index 6c21696..98dcb76 100644 --- a/lib/memcmp.c +++ b/lib/memcmp.c @@ -20,7 +20,7 @@ USA. */ #ifdef HAVE_CONFIG_H -# include +# include "config.h" #endif #undef __ptr_t @@ -104,8 +104,7 @@ static int memcmp_bytes __P((op_t, op_t)); __inline # endif static int -memcmp_bytes (a, b) - op_t a, b; +memcmp_bytes (long unsigned int a, long unsigned int b) { long int srcp1 = (long int) &a; long int srcp2 = (long int) &b; @@ -132,10 +131,7 @@ static int memcmp_common_alignment __P((long, long, size_t)); __inline #endif static int -memcmp_common_alignment (srcp1, srcp2, len) - long int srcp1; - long int srcp2; - size_t len; +memcmp_common_alignment (long int srcp1, long int srcp2, size_t len) { op_t a0, a1; op_t b0, b1; @@ -222,10 +218,7 @@ static int memcmp_not_common_alignment __P((long, long, size_t)); __inline #endif static int -memcmp_not_common_alignment (srcp1, srcp2, len) - long int srcp1; - long int srcp2; - size_t len; +memcmp_not_common_alignment (long int srcp1, long int srcp2, size_t len) { op_t a0, a1, a2, a3; op_t b0, b1, b2, b3; @@ -325,10 +318,7 @@ memcmp_not_common_alignment (srcp1, srcp2, len) } int -rpl_memcmp (s1, s2, len) - const __ptr_t s1; - const __ptr_t s2; - size_t len; +rpl_memcmp (const void *s1, const void *s2, size_t len) { op_t a0; op_t b0; diff --git a/lib/memset.c b/lib/memset.c index a0db560..5744bcb 100644 --- a/lib/memset.c +++ b/lib/memset.c @@ -16,10 +16,7 @@ Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ char * -memset (str, c, len) - char *str; - int c; - unsigned len; +memset (char *str, int c, unsigned int len) { register char *st = str; diff --git a/lib/mktime.c b/lib/mktime.c index b63fa05..c8ecd07 100644 --- a/lib/mktime.c +++ b/lib/mktime.c @@ -1,24 +1,22 @@ -/* mktime: convert a `struct tm' to a time_t value - Copyright (C) 1993-1997, 1998 Free Software Foundation, Inc. +/* Convert a `struct tm' to a time_t value. + Copyright (C) 1993, 94, 95, 96, 97, 98, 99 Free Software Foundation, Inc. + This file is part of the GNU C Library. Contributed by Paul Eggert (eggert@twinsun.com). - NOTE: The canonical source of this file is maintained with the GNU C Library. - Bugs can be reported to bug-glibc@prep.ai.mit.edu. + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. - 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, + 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 General Public License for more details. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, - USA. */ + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ /* Define this to have a standalone program to test this implementation of mktime. */ @@ -57,7 +55,7 @@ #endif /* DEBUG */ #ifndef __P -# if defined (__GNUC__) || (defined (__STDC__) && __STDC__) +# if defined __GNUC__ || (defined __STDC__ && __STDC__) # define __P(args) args # else # define __P(args) () @@ -109,14 +107,6 @@ const unsigned short int __mon_yday[2][13] = { 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366 } }; -static struct tm *ranged_convert __P ((struct tm *(*) __P ((const time_t *, - struct tm *)), - time_t *, struct tm *)); -static time_t ydhms_tm_diff __P ((int, int, int, int, int, const struct tm *)); -time_t __mktime_internal __P ((struct tm *, - struct tm *(*) (const time_t *, struct tm *), - time_t *)); - #ifdef _LIBC # define my_mktime_localtime_r __localtime_r @@ -124,11 +114,8 @@ time_t __mktime_internal __P ((struct tm *, /* If we're a mktime substitute in a GNU program, then prefer localtime to localtime_r, since many localtime_r implementations are buggy. */ -static struct tm *my_mktime_localtime_r __P ((const time_t *, struct tm *)); static struct tm * -my_mktime_localtime_r (t, tp) - const time_t *t; - struct tm *tp; +my_mktime_localtime_r (const time_t *t, struct tm *tp) { struct tm *l = localtime (t); if (! l) @@ -146,9 +133,8 @@ my_mktime_localtime_r (t, tp) If TP is null, return a nonzero value. If overflow occurs, yield the low order bits of the correct answer. */ static time_t -ydhms_tm_diff (year, yday, hour, min, sec, tp) - int year, yday, hour, min, sec; - const struct tm *tp; +ydhms_tm_diff (int year, int yday, int hour, int min, int sec, + const struct tm *tp) { if (!tp) return 1; @@ -175,32 +161,12 @@ ydhms_tm_diff (year, yday, hour, min, sec, tp) } } - -static time_t localtime_offset; - -/* Convert *TP to a time_t value. */ -time_t -mktime (tp) - struct tm *tp; -{ -#ifdef _LIBC - /* POSIX.1 8.1.1 requires that whenever mktime() is called, the - time zone names contained in the external variable `tzname' shall - be set as if the tzset() function had been called. */ - __tzset (); -#endif - - return __mktime_internal (tp, my_mktime_localtime_r, &localtime_offset); -} - /* Use CONVERT to convert *T to a broken down time in *TP. If *T is out of range for conversion, adjust it so that it is the nearest in-range value and then convert that. */ static struct tm * -ranged_convert (convert, t, tp) - struct tm *(*convert) __P ((const time_t *, struct tm *)); - time_t *t; - struct tm *tp; +ranged_convert (struct tm *(*convert) (const time_t *, struct tm *), + time_t *t, struct tm *tp) { struct tm *r; @@ -247,10 +213,9 @@ ranged_convert (convert, t, tp) compared to what the result would be for UTC without leap seconds. If *OFFSET's guess is correct, only one CONVERT call is needed. */ time_t -__mktime_internal (tp, convert, offset) - struct tm *tp; - struct tm *(*convert) __P ((const time_t *, struct tm *)); - time_t *offset; +__mktime_internal (struct tm *tp, + struct tm *(*convert) (const time_t *, struct tm *), + time_t *offset) { time_t t, dt, t0, t1, t2; struct tm tm; @@ -325,28 +290,32 @@ __mktime_internal (tp, convert, offset) /* If we have a match, check whether tm.tm_isdst has the requested value, if any. */ - if (dt == 0 && 0 <= isdst && 0 <= tm.tm_isdst) + if (dt == 0 && isdst != tm.tm_isdst && 0 <= isdst && 0 <= tm.tm_isdst) { - int dst_diff = (isdst != 0) - (tm.tm_isdst != 0); - if (dst_diff) + /* tm.tm_isdst has the wrong value. Look for a neighboring + time with the right value, and use its UTC offset. + Heuristic: probe the previous three calendar quarters (approximately), + looking for the desired isdst. This isn't perfect, + but it's good enough in practice. */ + int quarter = 7889238; /* seconds per average 1/4 Gregorian year */ + int i; + + /* If we're too close to the time_t limit, look in future quarters. */ + if (t < TIME_T_MIN + 3 * quarter) + quarter = -quarter; + + for (i = 1; i <= 3; i++) { - /* Move two hours in the direction indicated by the disagreement, - probe some more, and switch to a new time if found. - The largest known fallback due to daylight savings is two hours: - once, in Newfoundland, 1988-10-30 02:00 -> 00:00. */ - time_t ot = t - 2 * 60 * 60 * dst_diff; - while (--remaining_probes != 0) + time_t ot = t - i * quarter; + struct tm otm; + ranged_convert (convert, &ot, &otm); + if (otm.tm_isdst == isdst) { - struct tm otm; - if (! (dt = ydhms_tm_diff (year, yday, hour, min, sec, - ranged_convert (convert, &ot, &otm)))) - { - t = ot; - tm = otm; - break; - } - if ((ot += dt) == t) - break; /* Avoid a redundant probe. */ + /* We found the desired tm_isdst. + Extrapolate back to the desired time. */ + t = ot + ydhms_tm_diff (year, yday, hour, min, sec, &otm); + ranged_convert (convert, &t, &tm); + break; } } } @@ -392,6 +361,24 @@ __mktime_internal (tp, convert, offset) return t; } + +static time_t localtime_offset; + +/* Convert *TP to a time_t value. */ +time_t +mktime (tp) + struct tm *tp; +{ +#ifdef _LIBC + /* POSIX.1 8.1.1 requires that whenever mktime() is called, the + time zone names contained in the external variable `tzname' shall + be set as if the tzset() function had been called. */ + __tzset (); +#endif + + return __mktime_internal (tp, my_mktime_localtime_r, &localtime_offset); +} + #ifdef weak_alias weak_alias (mktime, timelocal) #endif diff --git a/lib/modechange.c b/lib/modechange.c index 4dccdb0..71432fa 100644 --- a/lib/modechange.c +++ b/lib/modechange.c @@ -1,5 +1,5 @@ /* modechange.c -- file mode manipulation - Copyright (C) 1989, 1990, 1997, 1998 Free Software Foundation, Inc. + Copyright (C) 1989, 1990, 1997, 1998, 1999 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 @@ -28,9 +28,9 @@ # include #endif -#include -#include #include "modechange.h" +#include +#include "xstrtol.h" #if STDC_HEADERS # include @@ -50,26 +50,93 @@ char *malloc (); # define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR) #endif +#ifndef S_ISUID +# define S_ISUID 04000 +#endif +#ifndef S_ISGID +# define S_ISGID 04000 +#endif +#ifndef S_ISVTX +# define S_ISVTX 01000 +#endif +#ifndef S_IRUSR +# define S_IRUSR 0400 +#endif +#ifndef S_IWUSR +# define S_IWUSR 0200 +#endif +#ifndef S_IXUSR +# define S_IXUSR 0100 +#endif +#ifndef S_IRGRP +# define S_IRGRP 0040 +#endif +#ifndef S_IWGRP +# define S_IWGRP 0020 +#endif +#ifndef S_IXGRP +# define S_IXGRP 0010 +#endif +#ifndef S_IROTH +# define S_IROTH 0004 +#endif +#ifndef S_IWOTH +# define S_IWOTH 0002 +#endif +#ifndef S_IXOTH +# define S_IXOTH 0001 +#endif +#ifndef S_IRWXU +# define S_IRWXU 0700 +#endif +#ifndef S_IRWXG +# define S_IRWXG 0070 +#endif +#ifndef S_IRWXO +# define S_IRWXO 0007 +#endif + +/* All the mode bits that can be affected by chmod. */ +#define CHMOD_MODE_BITS \ + (S_ISUID | S_ISGID | S_ISVTX | S_IRWXU | S_IRWXG | S_IRWXO) + /* Return newly allocated memory to hold one element of type TYPE. */ #define talloc(type) ((type *) malloc (sizeof (type))) -#define isodigit(c) ((c) >= '0' && (c) <= '7') +/* Create a mode_change entry with the specified `=ddd'-style + mode change operation, where NEW_MODE is `ddd'. Return the + new entry, or NULL upon failure. */ -/* Return a positive integer containing the value of the ASCII - octal number S. If S is not an octal number, return -1. */ +static struct mode_change * +make_node_op_equals (mode_t new_mode) +{ + struct mode_change *p; + p = talloc (struct mode_change); + if (p == NULL) + return p; + p->next = NULL; + p->op = '='; + p->flags = 0; + p->value = new_mode; + p->affected = CHMOD_MODE_BITS; /* Affect all permissions. */ + return p; +} + +/* Append entry E to the end of the link list with the specified + HEAD and TAIL. */ -static int -oatoi (const char *s) +static void +mode_append_entry (struct mode_change **head, + struct mode_change **tail, + struct mode_change *e) { - register int i; - - if (*s == 0) - return -1; - for (i = 0; isodigit (*s); ++s) - i = i * 8 + *s - '0'; - if (*s) - return -1; - return i; + if (*head == NULL) + *head = *tail = e; + else + { + (*tail)->next = e; + *tail = e; + } } /* Return a linked list of file mode change operations created from @@ -89,41 +156,44 @@ struct mode_change * mode_compile (const char *mode_string, unsigned int masked_ops) { struct mode_change *head; /* First element of the linked list. */ - struct mode_change *change; /* An element of the linked list. */ - int i; /* General purpose temporary. */ - int umask_value; /* The umask value (surprise). */ - unsigned short affected_bits; /* Which bits in the mode are operated on. */ - unsigned short affected_masked; /* `affected_bits' modified by umask. */ - unsigned ops_to_mask; /* Operators to actually use umask on. */ - - i = oatoi (mode_string); - if (i >= 0) + struct mode_change *tail; /* An element of the linked list. */ + unsigned long mode_value; /* The mode value, if octal. */ + char *string_end; /* Pointer to end of parsed value. */ + mode_t umask_value; /* The umask value (surprise). */ + + head = NULL; +#ifdef lint + tail = NULL; +#endif + + if (xstrtoul (mode_string, &string_end, 8, &mode_value, "") == LONGINT_OK) { - if (i > 07777) + struct mode_change *p; + if (mode_value > CHMOD_MODE_BITS) return MODE_INVALID; - head = talloc (struct mode_change); - if (head == NULL) + p = make_node_op_equals ((mode_t) mode_value); + if (p == NULL) return MODE_MEMORY_EXHAUSTED; - head->next = NULL; - head->op = '='; - head->flags = 0; - head->value = i; - head->affected = 07777; /* Affect all permissions. */ + mode_append_entry (&head, &tail, p); return head; } umask_value = umask (0); umask (umask_value); /* Restore the old value. */ - - head = NULL; -#ifdef lint - change = NULL; -#endif --mode_string; /* One loop iteration for each "ugoa...=+-rwxXstugo...[=+-rwxXstugo...]". */ do { + /* Which bits in the mode are operated on. */ + mode_t affected_bits = 0; + /* `affected_bits' modified by umask. */ + mode_t affected_masked; + /* Operators to actually use umask on. */ + unsigned ops_to_mask = 0; + + int who_specified_p; + affected_bits = 0; ops_to_mask = 0; /* Turn on all the bits in `affected_bits' for each group given. */ @@ -131,16 +201,16 @@ mode_compile (const char *mode_string, unsigned int masked_ops) switch (*mode_string) { case 'u': - affected_bits |= 04700; + affected_bits |= S_ISUID | S_IRWXU; break; case 'g': - affected_bits |= 02070; + affected_bits |= S_ISGID | S_IRWXG; break; case 'o': - affected_bits |= 01007; + affected_bits |= S_ISVTX | S_IRWXO; break; case 'a': - affected_bits |= 07777; + affected_bits |= CHMOD_MODE_BITS; break; default: goto no_more_affected; @@ -149,37 +219,39 @@ mode_compile (const char *mode_string, unsigned int masked_ops) no_more_affected: /* If none specified, affect all bits, except perhaps those set in the umask. */ - if (affected_bits == 0) + if (affected_bits) + who_specified_p = 1; + else { - affected_bits = 07777; + who_specified_p = 0; + affected_bits = CHMOD_MODE_BITS; ops_to_mask = masked_ops; } while (*mode_string == '=' || *mode_string == '+' || *mode_string == '-') { - /* Add the element to the tail of the list, so the operations - are performed in the correct order. */ - if (head == NULL) + struct mode_change *change = talloc (struct mode_change); + if (change == NULL) { - head = talloc (struct mode_change); - if (head == NULL) - return MODE_MEMORY_EXHAUSTED; - change = head; - } - else - { - change->next = talloc (struct mode_change); - if (change->next == NULL) - { - mode_free (change); - return MODE_MEMORY_EXHAUSTED; - } - change = change->next; + mode_free (head); + return MODE_MEMORY_EXHAUSTED; } change->next = NULL; change->op = *mode_string; /* One of "=+-". */ affected_masked = affected_bits; + + /* Per the Single Unix Spec, if `who' is not specified and the + `=' operator is used, then clear all the bits first. */ + if (!who_specified_p && + ops_to_mask & (*mode_string == '=' ? MODE_MASK_EQUALS : 0)) + { + struct mode_change *p = make_node_op_equals (0); + if (p == NULL) + return MODE_MEMORY_EXHAUSTED; + mode_append_entry (&head, &tail, p); + } + if (ops_to_mask & (*mode_string == '=' ? MODE_MASK_EQUALS : *mode_string == '+' ? MODE_MASK_PLUS : MODE_MASK_MINUS)) @@ -188,36 +260,43 @@ mode_compile (const char *mode_string, unsigned int masked_ops) change->value = 0; change->flags = 0; + /* Add the element to the tail of the list, so the operations + are performed in the correct order. */ + mode_append_entry (&head, &tail, change); + /* Set `value' according to the bits set in `affected_masked'. */ for (++mode_string;; ++mode_string) switch (*mode_string) { case 'r': - change->value |= 00444 & affected_masked; + change->value |= ((S_IRUSR | S_IRGRP | S_IROTH) + & affected_masked); break; case 'w': - change->value |= 00222 & affected_masked; + change->value |= ((S_IWUSR | S_IWGRP | S_IWOTH) + & affected_masked); break; case 'X': change->flags |= MODE_X_IF_ANY_X; /* Fall through. */ case 'x': - change->value |= 00111 & affected_masked; + change->value |= ((S_IXUSR | S_IXGRP | S_IXOTH) + & affected_masked); break; case 's': /* Set the setuid/gid bits if `u' or `g' is selected. */ - change->value |= 06000 & affected_masked; + change->value |= (S_ISUID | S_ISGID) & affected_masked; break; case 't': /* Set the "save text image" bit if `o' is selected. */ - change->value |= 01000 & affected_masked; + change->value |= S_ISVTX & affected_masked; break; case 'u': /* Set the affected bits to the value of the `u' bits on the same file. */ if (change->value) goto invalid; - change->value = 00700; + change->value = S_IRWXU; change->flags |= MODE_COPY_EXISTING; break; case 'g': @@ -225,7 +304,7 @@ mode_compile (const char *mode_string, unsigned int masked_ops) on the same file. */ if (change->value) goto invalid; - change->value = 00070; + change->value = S_IRWXG; change->flags |= MODE_COPY_EXISTING; break; case 'o': @@ -233,7 +312,7 @@ mode_compile (const char *mode_string, unsigned int masked_ops) on the same file. */ if (change->value) goto invalid; - change->value = 00007; + change->value = S_IRWXO; change->flags |= MODE_COPY_EXISTING; break; default: @@ -268,7 +347,7 @@ mode_create_from_ref (const char *ref_file) change->op = '='; change->flags = 0; - change->affected = 07777; + change->affected = CHMOD_MODE_BITS; change->value = ref_stats.st_mode; change->next = NULL; @@ -280,13 +359,13 @@ mode_create_from_ref (const char *ref_file) change affects it even if no execute bits were set in OLDMODE. The returned value has the S_IFMT bits cleared. */ -unsigned short -mode_adjust (unsigned int oldmode, const struct mode_change *changes) +mode_t +mode_adjust (mode_t oldmode, const struct mode_change *changes) { - unsigned short newmode; /* The adjusted mode and one operand. */ - unsigned short value; /* The other operand. */ + mode_t newmode; /* The adjusted mode and one operand. */ + mode_t value; /* The other operand. */ - newmode = oldmode & 07777; + newmode = oldmode & CHMOD_MODE_BITS; for (; changes; changes = changes->next) { @@ -296,15 +375,21 @@ mode_adjust (unsigned int oldmode, const struct mode_change *changes) the mask `changes->value'. */ value = newmode & changes->value; - if (changes->value & 00700) + if (changes->value & S_IRWXU) /* Copy `u' permissions onto `g' and `o'. */ - value |= (value >> 3) | (value >> 6); - else if (changes->value & 00070) + value |= ((value & S_IRUSR ? S_IRGRP | S_IROTH : 0) + | (value & S_IWUSR ? S_IWGRP | S_IROTH : 0) + | (value & S_IXUSR ? S_IXGRP | S_IXOTH : 0)); + else if (changes->value & S_IRWXG) /* Copy `g' permissions onto `u' and `o'. */ - value |= (value << 3) | (value >> 3); + value |= ((value & S_IRGRP ? S_IRUSR | S_IROTH : 0) + | (value & S_IWGRP ? S_IWUSR | S_IROTH : 0) + | (value & S_IXGRP ? S_IXUSR | S_IXOTH : 0)); else /* Copy `o' permissions onto `u' and `g'. */ - value |= (value << 3) | (value << 6); + value |= ((value & S_IROTH ? S_IRUSR | S_IRGRP : 0) + | (value & S_IWOTH ? S_IWUSR | S_IRGRP : 0) + | (value & S_IXOTH ? S_IXUSR | S_IXGRP : 0)); /* In order to change only `u', `g', or `o' permissions, or some combination thereof, clear unselected bits. @@ -320,8 +405,9 @@ mode_adjust (unsigned int oldmode, const struct mode_change *changes) directory and no execute bits are already set. */ if ((changes->flags & MODE_X_IF_ANY_X) && !S_ISDIR (oldmode) - && (newmode & 00111) == 0) - value &= ~00111; /* Clear the execute bits. */ + && (newmode & (S_IXUSR | S_IXGRP | S_IXOTH)) == 0) + /* Clear the execute bits. */ + value &= ~ (S_IXUSR | S_IXGRP | S_IXOTH); } switch (changes->op) diff --git a/lib/modechange.h b/lib/modechange.h index c10ab91..922f85a 100644 --- a/lib/modechange.h +++ b/lib/modechange.h @@ -20,6 +20,12 @@ #if ! defined MODECHANGE_H_ # define MODECHANGE_H_ +# if HAVE_CONFIG_H +# include +# endif + +# include + /* Affect the execute bits only if at least one execute bit is set already, or if the file is a directory. */ # define MODE_X_IF_ANY_X 01 @@ -33,8 +39,8 @@ struct mode_change { char op; /* One of "=+-". */ char flags; /* Special operations. */ - unsigned short affected; /* Set for u/g/o/s/s/t, if to be affected. */ - unsigned short value; /* Bits to add/remove. */ + mode_t affected; /* Set for u/g/o/s/s/t, if to be affected. */ + mode_t value; /* Bits to add/remove. */ struct mode_change *next; /* Link to next change in list. */ }; @@ -59,7 +65,7 @@ struct mode_change struct mode_change *mode_compile PARAMS ((const char *, unsigned)); struct mode_change *mode_create_from_ref PARAMS ((const char *)); -unsigned short mode_adjust PARAMS ((unsigned, const struct mode_change *)); +mode_t mode_adjust PARAMS ((mode_t, const struct mode_change *)); void mode_free PARAMS ((struct mode_change *)); #endif diff --git a/lib/pathmax.h b/lib/pathmax.h index 74f5792..19d4304 100644 --- a/lib/pathmax.h +++ b/lib/pathmax.h @@ -1,5 +1,5 @@ /* Define PATH_MAX somehow. Requires sys/types.h. - Copyright (C) 1992 Free Software Foundation, Inc. + Copyright (C) 1992, 1999 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 @@ -16,38 +16,39 @@ Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef _PATHMAX_H -#define _PATHMAX_H +# define _PATHMAX_H -#ifdef HAVE_UNISTD_H -#include -#endif +# ifdef HAVE_UNISTD_H +# include +# endif /* Non-POSIX BSD systems might have gcc's limits.h, which doesn't define PATH_MAX but might cause redefinition warnings when sys/param.h is later included (as on MORE/BSD 4.3). */ -#if defined(_POSIX_VERSION) || (defined(HAVE_LIMITS_H) && !defined(__GNUC__)) -#include -#endif +# if defined(_POSIX_VERSION) || (defined(HAVE_LIMITS_H) && !defined(__GNUC__)) +# include +# endif -#ifndef _POSIX_PATH_MAX -#define _POSIX_PATH_MAX 255 -#endif +# ifndef _POSIX_PATH_MAX +# define _POSIX_PATH_MAX 255 +# endif -#if !defined(PATH_MAX) && defined(_PC_PATH_MAX) -#define PATH_MAX (pathconf ("/", _PC_PATH_MAX) < 1 ? 1024 : pathconf ("/", _PC_PATH_MAX)) -#endif +# if !defined(PATH_MAX) && defined(_PC_PATH_MAX) +# define PATH_MAX (pathconf ("/", _PC_PATH_MAX) < 1 ? 1024 \ + : pathconf ("/", _PC_PATH_MAX)) +# endif /* Don't include sys/param.h if it already has been. */ -#if defined(HAVE_SYS_PARAM_H) && !defined(PATH_MAX) && !defined(MAXPATHLEN) -#include -#endif +# if defined(HAVE_SYS_PARAM_H) && !defined(PATH_MAX) && !defined(MAXPATHLEN) +# include +# endif -#if !defined(PATH_MAX) && defined(MAXPATHLEN) -#define PATH_MAX MAXPATHLEN -#endif +# if !defined(PATH_MAX) && defined(MAXPATHLEN) +# define PATH_MAX MAXPATHLEN +# endif -#ifndef PATH_MAX -#define PATH_MAX _POSIX_PATH_MAX -#endif +# ifndef PATH_MAX +# define PATH_MAX _POSIX_PATH_MAX +# endif #endif /* _PATHMAX_H */ diff --git a/lib/regex.c b/lib/regex.c index 38810f7..74fcf9c 100644 --- a/lib/regex.c +++ b/lib/regex.c @@ -2,25 +2,22 @@ version 0.12. (Implements POSIX draft P1003.2/D11.2, except for some of the internationalization features.) - Copyright (C) 1993, 94, 95, 96, 97, 98 Free Software Foundation, Inc. + Copyright (C) 1993, 94, 95, 96, 97, 98, 99 Free Software Foundation, Inc. - NOTE: The canonical source of this file is maintained with the GNU C Library. - Bugs can be reported to bug-glibc@prep.ai.mit.edu. + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. - 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, + 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 General Public License for more details. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, - USA. */ + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ /* AIX requires this to be the first thing in the file. */ #if defined _AIX && !defined REGEX_MALLOC @@ -49,12 +46,11 @@ # include #endif -#define WIDE_CHAR_SUPPORT \ - defined _LIBC || (HAVE_WCTYPE_H && HAVE_WCHAR_H && HAVE_BTOWC) +#define WIDE_CHAR_SUPPORT (HAVE_WCTYPE_H && HAVE_WCHAR_H && HAVE_BTOWC) /* For platform which support the ISO C amendement 1 functionality we support user defined character classes. */ -#if WIDE_CHAR_SUPPORT +#if defined _LIBC || WIDE_CHAR_SUPPORT /* Solaris 2.5 has a bug: must be included before . */ # include # include @@ -85,7 +81,8 @@ #define btowc __btowc #endif -#if ENABLE_NLS +/* This is for other GNU distributions with internationalized messages. */ +#if HAVE_LIBINTL_H || defined _LIBC # include #else # define gettext(msgid) (msgid) @@ -210,7 +207,7 @@ init_syntax_once () #endif /* not emacs */ /* Get the interface, including the syntax bits. */ -#include "regex.h" +#include /* isalpha etc. are used for the character classes. */ #include @@ -257,6 +254,12 @@ init_syntax_once () #define ISUPPER(c) (ISASCII (c) && isupper (c)) #define ISXDIGIT(c) (ISASCII (c) && isxdigit (c)) +#ifdef _tolower +# define TOLOWER(c) _tolower(c) +#else +# define TOLOWER(c) tolower(c) +#endif + #ifndef NULL # define NULL (void *)0 #endif @@ -1721,7 +1724,7 @@ typedef struct } \ } -#if WIDE_CHAR_SUPPORT +#if defined _LIBC || WIDE_CHAR_SUPPORT /* The GNU C library provides support for user-defined character classes and the functions from ISO C amendement 1. */ # ifdef CHARCLASS_NAME_MAX @@ -2213,10 +2216,13 @@ regex_compile (pattern, size, syntax, bufp) for (;;) { PATFETCH (c); - if ((c == ':' && *p == ']') || p == pend - || c1 == CHAR_CLASS_MAX_LENGTH) + if ((c == ':' && *p == ']') || p == pend) break; - str[c1++] = c; + if (c1 < CHAR_CLASS_MAX_LENGTH) + str[c1++] = c; + else + /* This is in any case an invalid class name. */ + str[0] = '\0'; } str[c1] = '\0'; @@ -2225,7 +2231,7 @@ regex_compile (pattern, size, syntax, bufp) the leading `:' and `[' (but set bits for them). */ if (c == ':' && *p == ']') { -#if WIDE_CHAR_SUPPORT +#if defined _LIBC || WIDE_CHAR_SUPPORT boolean is_lower = STREQ (str, "lower"); boolean is_upper = STREQ (str, "upper"); wctype_t wt; @@ -2246,10 +2252,10 @@ regex_compile (pattern, size, syntax, bufp) # ifdef _LIBC if (__iswctype (__btowc (ch), wt)) SET_LIST_BIT (ch); -#else +# else if (iswctype (btowc (ch), wt)) SET_LIST_BIT (ch); -#endif +# endif if (translate && (is_upper || is_lower) && (ISUPPER (ch) || ISLOWER (ch))) @@ -5573,7 +5579,8 @@ re_exec (s) REG_EXTENDED bit in CFLAGS is set; otherwise, to RE_SYNTAX_POSIX_BASIC; `newline_anchor' to REG_NEWLINE being set in CFLAGS; - `fastmap' and `fastmap_accurate' to zero; + `fastmap' to an allocated space for the fastmap; + `fastmap_accurate' to zero; `re_nsub' to the number of subexpressions in PATTERN. PATTERN is the address of the pattern string. @@ -5612,11 +5619,8 @@ regcomp (preg, pattern, cflags) preg->allocated = 0; preg->used = 0; - /* Don't bother to use a fastmap when searching. This simplifies the - REG_NEWLINE case: if we used a fastmap, we'd have to put all the - characters after newlines into the fastmap. This way, we just try - every character. */ - preg->fastmap = 0; + /* Try to allocate space for the fastmap. */ + preg->fastmap = (char *) malloc (1 << BYTEWIDTH); if (cflags & REG_ICASE) { @@ -5630,7 +5634,7 @@ regcomp (preg, pattern, cflags) /* Map uppercase characters to corresponding lowercase ones. */ for (i = 0; i < CHAR_SET_SIZE; i++) - preg->translate[i] = ISUPPER (i) ? tolower (i) : i; + preg->translate[i] = ISUPPER (i) ? TOLOWER (i) : i; } else preg->translate = NULL; @@ -5656,6 +5660,19 @@ regcomp (preg, pattern, cflags) unmatched close-group: both are REG_EPAREN. */ if (ret == REG_ERPAREN) ret = REG_EPAREN; + if (ret == REG_NOERROR && preg->fastmap) + { + /* Compute the fastmap now, since regexec cannot modify the pattern + buffer. */ + if (re_compile_fastmap (preg) == -2) + { + /* Some error occured while computing the fastmap, just forget + about it. */ + free (preg->fastmap); + preg->fastmap = NULL; + } + } + return (int) ret; } #ifdef _LIBC @@ -5704,10 +5721,10 @@ regexec (preg, string, nmatch, pmatch, eflags) if (want_reg_info) { regs.num_regs = nmatch; - regs.start = TALLOC (nmatch, regoff_t); - regs.end = TALLOC (nmatch, regoff_t); - if (regs.start == NULL || regs.end == NULL) + regs.start = TALLOC (nmatch * 2, regoff_t); + if (regs.start == NULL) return (int) REG_NOMATCH; + regs.end = regs.start + nmatch; } /* Perform the searching operation. */ @@ -5731,7 +5748,6 @@ regexec (preg, string, nmatch, pmatch, eflags) /* If we needed the temporary register info, free the space now. */ free (regs.start); - free (regs.end); } /* We want zero return to mean success, unlike `re_search'. */ diff --git a/lib/regex.h b/lib/regex.h index 632a6b5..d88ab92 100644 --- a/lib/regex.h +++ b/lib/regex.h @@ -1,25 +1,24 @@ /* Definitions for data structures and routines for the regular expression library, version 0.12. - Copyright (C) 1985,89,90,91,92,93,95,96,97 Free Software Foundation, Inc. + Copyright (C) 1985,89,90,91,92,93,95,96,97,98 Free Software Foundation, Inc. + This file is part of the GNU C Library. Its master source is NOT part of + the C library, however. The master source lives in /gd/gnu/lib. - NOTE: The canonical source of this file is maintained with the GNU C Library. - Bugs can be reported to bug-glibc@prep.ai.mit.edu. + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. - 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, + 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 General Public License for more details. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, - USA. */ + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ #ifndef _REGEX_H #define _REGEX_H 1 @@ -283,8 +282,8 @@ extern reg_syntax_t re_syntax_options; `re_error_msg' table in regex.c. */ typedef enum { -#if (_XOPEN_SOURCE - 0) == 500 - REG_NOSYS = -1, /* This will never happen for this implementation. */ +#ifdef _XOPEN_SOURCE + REG_ENOSYS = -1, /* This will never happen for this implementation. */ #endif REG_NOERROR = 0, /* Success. */ @@ -442,15 +441,11 @@ typedef struct /* Sets the current default syntax to SYNTAX, and return the old syntax. You can also simply assign to the `re_syntax_options' variable. */ -extern reg_syntax_t __re_set_syntax _RE_ARGS ((reg_syntax_t syntax)); extern reg_syntax_t re_set_syntax _RE_ARGS ((reg_syntax_t syntax)); /* Compile the regular expression PATTERN, with length LENGTH and syntax given by the global `re_syntax_options', into the buffer BUFFER. Return NULL if successful, and an error string if not. */ -extern const char *__re_compile_pattern - _RE_ARGS ((const char *pattern, size_t length, - struct re_pattern_buffer *buffer)); extern const char *re_compile_pattern _RE_ARGS ((const char *pattern, size_t length, struct re_pattern_buffer *buffer)); @@ -459,7 +454,6 @@ extern const char *re_compile_pattern /* Compile a fastmap for the compiled pattern in BUFFER; used to accelerate searches. Return 0 if successful and -2 if was an internal error. */ -extern int __re_compile_fastmap _RE_ARGS ((struct re_pattern_buffer *buffer)); extern int re_compile_fastmap _RE_ARGS ((struct re_pattern_buffer *buffer)); @@ -468,9 +462,6 @@ extern int re_compile_fastmap _RE_ARGS ((struct re_pattern_buffer *buffer)); characters. Return the starting position of the match, -1 for no match, or -2 for an internal error. Also return register information in REGS (if REGS and BUFFER->no_sub are nonzero). */ -extern int __re_search - _RE_ARGS ((struct re_pattern_buffer *buffer, const char *string, - int length, int start, int range, struct re_registers *regs)); extern int re_search _RE_ARGS ((struct re_pattern_buffer *buffer, const char *string, int length, int start, int range, struct re_registers *regs)); @@ -478,10 +469,6 @@ extern int re_search /* Like `re_search', but search in the concatenation of STRING1 and STRING2. Also, stop searching at index START + STOP. */ -extern int __re_search_2 - _RE_ARGS ((struct re_pattern_buffer *buffer, const char *string1, - int length1, const char *string2, int length2, - int start, int range, struct re_registers *regs, int stop)); extern int re_search_2 _RE_ARGS ((struct re_pattern_buffer *buffer, const char *string1, int length1, const char *string2, int length2, @@ -490,19 +477,12 @@ extern int re_search_2 /* Like `re_search', but return how many characters in STRING the regexp in BUFFER matched, starting at position START. */ -extern int __re_match - _RE_ARGS ((struct re_pattern_buffer *buffer, const char *string, - int length, int start, struct re_registers *regs)); extern int re_match _RE_ARGS ((struct re_pattern_buffer *buffer, const char *string, int length, int start, struct re_registers *regs)); /* Relates to `re_match' as `re_search_2' relates to `re_search'. */ -extern int __re_match_2 - _RE_ARGS ((struct re_pattern_buffer *buffer, const char *string1, - int length1, const char *string2, int length2, - int start, struct re_registers *regs, int stop)); extern int re_match_2 _RE_ARGS ((struct re_pattern_buffer *buffer, const char *string1, int length1, const char *string2, int length2, @@ -521,14 +501,11 @@ extern int re_match_2 Unless this function is called, the first search or match using PATTERN_BUFFER will allocate its own register data, without freeing the old data. */ -extern void __re_set_registers - _RE_ARGS ((struct re_pattern_buffer *buffer, struct re_registers *regs, - unsigned num_regs, regoff_t *starts, regoff_t *ends)); extern void re_set_registers _RE_ARGS ((struct re_pattern_buffer *buffer, struct re_registers *regs, unsigned num_regs, regoff_t *starts, regoff_t *ends)); -#ifdef _REGEX_RE_COMP +#if defined _REGEX_RE_COMP || defined _LIBC # ifndef _CRAY /* 4.2 bsd compatibility. */ extern char *re_comp _RE_ARGS ((const char *)); @@ -537,24 +514,16 @@ extern int re_exec _RE_ARGS ((const char *)); #endif /* POSIX compatibility. */ -extern int __regcomp _RE_ARGS ((regex_t *__preg, const char *__pattern, - int __cflags)); extern int regcomp _RE_ARGS ((regex_t *__preg, const char *__pattern, int __cflags)); -extern int __regexec _RE_ARGS ((const regex_t *__preg, - const char *__string, size_t __nmatch, - regmatch_t __pmatch[], int __eflags)); extern int regexec _RE_ARGS ((const regex_t *__preg, const char *__string, size_t __nmatch, regmatch_t __pmatch[], int __eflags)); -extern size_t __regerror _RE_ARGS ((int __errcode, const regex_t *__preg, - char *__errbuf, size_t __errbuf_size)); extern size_t regerror _RE_ARGS ((int __errcode, const regex_t *__preg, char *__errbuf, size_t __errbuf_size)); -extern void __regfree _RE_ARGS ((regex_t *__preg)); extern void regfree _RE_ARGS ((regex_t *__preg)); diff --git a/lib/savedir.c b/lib/savedir.c index 5a9c339..a299723 100644 --- a/lib/savedir.c +++ b/lib/savedir.c @@ -1,5 +1,5 @@ /* savedir.c -- save the list of files in a directory in a string - Copyright (C) 1990, 1997, 1998 Free Software Foundation, Inc. + Copyright (C) 1990, 1997, 1998, 1999, 2000 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 @@ -76,15 +76,17 @@ char *stpcpy (); Return NULL if DIR cannot be opened or if out of memory. */ char * -savedir (dir, name_size) - const char *dir; - unsigned int name_size; +savedir (const char *dir, off_t name_size) { DIR *dirp; struct dirent *dp; char *name_space; char *namep; + /* Be sure name_size is at least `1' so there's room for + the final NUL byte. */ + name_size += !name_size; + dirp = opendir (dir); if (dirp == NULL) return NULL; @@ -104,7 +106,7 @@ savedir (dir, name_size) || (dp->d_name[1] != '\0' && (dp->d_name[1] != '.' || dp->d_name[2] != '\0'))) { - unsigned size_needed = (namep - name_space) + NAMLEN (dp) + 2; + off_t size_needed = (namep - name_space) + NAMLEN (dp) + 2; if (size_needed > name_size) { diff --git a/lib/savedir.h b/lib/savedir.h index 033e567..89be04d 100644 --- a/lib/savedir.h +++ b/lib/savedir.h @@ -10,6 +10,6 @@ # endif char * -savedir PARAMS ((const char *dir, unsigned int name_size)); +savedir PARAMS ((const char *dir, off_t name_size)); #endif diff --git a/lib/stat.c b/lib/stat.c index 9b69fbe..7112335 100644 --- a/lib/stat.c +++ b/lib/stat.c @@ -1,7 +1,7 @@ /* Work around the bug in some systems whereby stat succeeds when given the zero-length file name argument. The stat from SunOS4.1.4 has this bug. - Copyright (C) 1997, 1998 Free Software Foundation, Inc. + Copyright (C) 1997-2000 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/stpcpy.c b/lib/stpcpy.c index 380e65f..a01636c 100644 --- a/lib/stpcpy.c +++ b/lib/stpcpy.c @@ -34,9 +34,7 @@ /* Copy SRC to DEST, returning the address of the terminating '\0' in DEST. */ char * -__stpcpy (dest, src) - char *dest; - const char *src; +__stpcpy (char *dest, const char *src) { register char *d = dest; register const char *s = src; diff --git a/lib/strdup.c b/lib/strdup.c index 4f6bb83..c0b05e2 100644 --- a/lib/strdup.c +++ b/lib/strdup.c @@ -31,8 +31,7 @@ char *strcpy (); or 0 if out of memory. */ char * -strdup (str) - const char *str; +strdup (const char *str) { char *newstr; diff --git a/lib/strftime.c b/lib/strftime.c index f18b340..18977d1 100644 --- a/lib/strftime.c +++ b/lib/strftime.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991,92,93,94,95,96,97,98 Free Software Foundation, Inc. +/* Copyright (C) 1991,92,93,94,95,96,97,98,99 Free Software Foundation, Inc. NOTE: The canonical source of this file is maintained with the GNU C Library. Bugs can be reported to bug-glibc@prep.ai.mit.edu. @@ -10,8 +10,8 @@ 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. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library 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 @@ -100,7 +100,7 @@ extern char *tzname[]; #endif #ifndef __P -# if defined (__GNUC__) || (defined (__STDC__) && __STDC__) +# if defined __GNUC__ || (defined __STDC__ && __STDC__) # define __P(args) args # else # define __P(args) () @@ -157,9 +157,7 @@ extern char *tzname[]; # if ! HAVE_TM_GMTOFF static struct tm *my_strftime_gmtime_r __P ((const time_t *, struct tm *)); static struct tm * -my_strftime_gmtime_r (t, tp) - const time_t *t; - struct tm *tp; +my_strftime_gmtime_r (const time_t *t, struct tm *tp) { struct tm *l = gmtime (t); if (! l) @@ -171,9 +169,7 @@ my_strftime_gmtime_r (t, tp) static struct tm *my_strftime_localtime_r __P ((const time_t *, struct tm *)); static struct tm * -my_strftime_localtime_r (t, tp) - const time_t *t; - struct tm *tp; +my_strftime_localtime_r (const time_t *t, struct tm *tp) { struct tm *l = localtime (t); if (! l) @@ -274,10 +270,7 @@ static const char zeroes[16] = /* "0000000000000000" */ static char *memcpy_lowcase __P ((char *dest, const char *src, size_t len)); static char * -memcpy_lowcase (dest, src, len) - char *dest; - const char *src; - size_t len; +memcpy_lowcase (char *dest, const char *src, size_t len) { while (len-- > 0) dest[len] = TOLOWER ((unsigned char) src[len]); @@ -287,10 +280,7 @@ memcpy_lowcase (dest, src, len) static char *memcpy_uppcase __P ((char *dest, const char *src, size_t len)); static char * -memcpy_uppcase (dest, src, len) - char *dest; - const char *src; - size_t len; +memcpy_uppcase (char *dest, const char *src, size_t len) { while (len-- > 0) dest[len] = TOUPPER ((unsigned char) src[len]); @@ -304,9 +294,7 @@ memcpy_uppcase (dest, src, len) # define tm_diff ftime_tm_diff static int tm_diff __P ((const struct tm *, const struct tm *)); static int -tm_diff (a, b) - const struct tm *a; - const struct tm *b; +tm_diff (const struct tm *a, const struct tm *b) { /* Compute intervening leap days correctly even if year is negative. Take care to avoid int overflow in leap day calculations, @@ -341,9 +329,7 @@ static int iso_week_days __P ((int, int)); __inline__ #endif static int -iso_week_days (yday, wday) - int yday; - int wday; +iso_week_days (int yday, int wday) { /* Add enough to the first operand of % to make it nonnegative. */ int big_enough_multiple_of_7 = (-YDAY_MINIMUM / 7 + 2) * 7; @@ -411,12 +397,8 @@ static char const month_name[][10] = anywhere, so to determine how many characters would be written, use NULL for S and (size_t) UINT_MAX for MAXSIZE. */ size_t -my_strftime (s, maxsize, format, tp ut_argument) - char *s; - size_t maxsize; - const char *format; - const struct tm *tp; - ut_argument_spec +my_strftime (char *s, size_t maxsize, const char *format, const struct tm *tp + ut_argument_spec) { int hour12 = tp->tm_hour; #ifdef _NL_CURRENT @@ -511,7 +493,7 @@ my_strftime (s, maxsize, format, tp ut_argument) case '%': break; - case '\a': case '\b': case '\t': case '\n': + case '\b': case '\t': case '\n': case '\v': case '\f': case '\r': case ' ': case '!': case '"': case '#': case '&': case'\'': case '(': case ')': case '*': case '+': case ',': case '-': @@ -529,10 +511,11 @@ my_strftime (s, maxsize, format, tp ut_argument) case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': case '{': case '|': case '}': case '~': - /* The C Standard requires these 98 characters (plus '%') to + /* The C Standard requires these 97 characters (plus '%', '\a') to be in the basic execution character set. None of these characters can start a multibyte sequence, so they need - not be analyzed further. */ + not be analyzed further. Some old compilers object to + '\a', so don't bother optimizing for it. */ add (1, *p = *f); continue; @@ -1043,7 +1026,6 @@ my_strftime (s, maxsize, format, tp ut_argument) add (1, *p = '\t'); break; - case 'f': case 'u': /* POSIX.2 extension. */ DO_NUMBER (1, (tp->tm_wday - 1 + 7) % 7 + 1); @@ -1238,7 +1220,7 @@ my_strftime (s, maxsize, format, tp ut_argument) } } - if (p && i < maxsize) + if (p && maxsize != 0) *p = '\0'; return i; } diff --git a/lib/strtol.c b/lib/strtol.c index 6d5f4ac..0c9c276 100644 --- a/lib/strtol.c +++ b/lib/strtol.c @@ -1,7 +1,7 @@ -/* strtol - Convert string representation of a number into an integer value. - Copyright (C) 1991, 92, 94, 95, 96, 97 Free Software Foundation, Inc. +/* Convert string representation of a number into an integer value. + Copyright (C) 1991, 92, 94, 95, 96, 97, 98, 99 Free Software Foundation, Inc. NOTE: The canonical source of this file is maintained with the GNU C - Library. Bugs can be reported to bug-glibc@prep.ai.mit.edu. + Library. Bugs can be reported to bug-glibc@gnu.org. 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 @@ -54,7 +54,7 @@ extern int errno; # include "../locale/localeinfo.h" #endif -/* Nonzero if we are defining `strtoul' or `strtouq', operating on +/* Nonzero if we are defining `strtoul' or `strtoull', operating on unsigned integers. */ #ifndef UNSIGNED # define UNSIGNED 0 @@ -64,72 +64,154 @@ extern int errno; #endif /* Determine the name. */ -#if UNSIGNED -# ifdef USE_WIDE_CHAR -# ifdef QUAD -# define strtol wcstouq +#ifdef USE_IN_EXTENDED_LOCALE_MODEL +# if UNSIGNED +# ifdef USE_WIDE_CHAR +# ifdef QUAD +# define strtol __wcstoull_l +# else +# define strtol __wcstoul_l +# endif # else -# define strtol wcstoul +# ifdef QUAD +# define strtol __strtoull_l +# else +# define strtol __strtoul_l +# endif # endif # else -# ifdef QUAD -# define strtol strtouq +# ifdef USE_WIDE_CHAR +# ifdef QUAD +# define strtol __wcstoll_l +# else +# define strtol __wcstol_l +# endif # else -# define strtol strtoul +# ifdef QUAD +# define strtol __strtoll_l +# else +# define strtol __strtol_l +# endif # endif # endif #else -# ifdef USE_WIDE_CHAR -# ifdef QUAD -# define strtol wcstoq +# if UNSIGNED +# ifdef USE_WIDE_CHAR +# ifdef QUAD +# define strtol wcstoull +# else +# define strtol wcstoul +# endif # else -# define strtol wcstol +# ifdef QUAD +# define strtol strtoull +# else +# define strtol strtoul +# endif # endif # else -# ifdef QUAD -# define strtol strtoq +# ifdef USE_WIDE_CHAR +# ifdef QUAD +# define strtol wcstoll +# else +# define strtol wcstol +# endif +# else +# ifdef QUAD +# define strtol strtoll +# endif # endif # endif #endif -/* If QUAD is defined, we are defining `strtoq' or `strtouq', +/* If QUAD is defined, we are defining `strtoll' or `strtoull', operating on `long long int's. */ #ifdef QUAD # define LONG long long -# undef LONG_MIN -# define LONG_MIN LONG_LONG_MIN -# undef LONG_MAX -# define LONG_MAX LONG_LONG_MAX -# undef ULONG_MAX -# define ULONG_MAX ULONG_LONG_MAX +# define STRTOL_LONG_MIN LONG_LONG_MIN +# define STRTOL_LONG_MAX LONG_LONG_MAX +# define STRTOL_ULONG_MAX ULONG_LONG_MAX + +/* The extra casts work around common compiler bugs, + e.g. Cray C 5.0.3.0 when t == time_t. */ +# ifndef TYPE_SIGNED +# define TYPE_SIGNED(t) (! ((t) 0 < (t) -1)) +# endif +# ifndef TYPE_MINIMUM +# define TYPE_MINIMUM(t) ((t) (TYPE_SIGNED (t) \ + ? ~ (t) 0 << (sizeof (t) * CHAR_BIT - 1) \ + : (t) 0)) +# endif +# ifndef TYPE_MAXIMUM +# define TYPE_MAXIMUM(t) ((t) (~ (t) 0 - TYPE_MINIMUM (t))) +# endif + +# ifndef ULONG_LONG_MAX +# define ULONG_LONG_MAX TYPE_MAXIMUM (unsigned long long) +# endif +# ifndef LONG_LONG_MAX +# define LONG_LONG_MAX TYPE_MAXIMUM (long long int) +# endif +# ifndef LONG_LONG_MIN +# define LONG_LONG_MIN TYPE_MINIMUM (long long int) +# endif + # if __GNUC__ == 2 && __GNUC_MINOR__ < 7 /* Work around gcc bug with using this constant. */ static const unsigned long long int maxquad = ULONG_LONG_MAX; -# undef ULONG_MAX -# define ULONG_MAX maxquad +# undef STRTOL_ULONG_MAX +# define STRTOL_ULONG_MAX maxquad # endif #else # define LONG long -#ifndef ULONG_MAX -# define ULONG_MAX ((unsigned long) ~(unsigned long) 0) +# ifndef ULONG_MAX +# define ULONG_MAX ((unsigned long) ~(unsigned long) 0) +# endif +# ifndef LONG_MAX +# define LONG_MAX ((long int) (ULONG_MAX >> 1)) +# endif +# define STRTOL_LONG_MIN LONG_MIN +# define STRTOL_LONG_MAX LONG_MAX +# define STRTOL_ULONG_MAX ULONG_MAX #endif -#ifndef LONG_MAX -# define LONG_MAX ((long int) (ULONG_MAX >> 1)) + + +/* We use this code also for the extended locale handling where the + function gets as an additional argument the locale which has to be + used. To access the values we have to redefine the _NL_CURRENT + macro. */ +#ifdef USE_IN_EXTENDED_LOCALE_MODEL +# undef _NL_CURRENT +# define _NL_CURRENT(category, item) \ + (current->values[_NL_ITEM_INDEX (item)].string) +# define LOCALE_PARAM , loc +# define LOCALE_PARAM_DECL __locale_t loc; +#else +# define LOCALE_PARAM +# define LOCALE_PARAM_DECL #endif + +#if defined _LIBC || defined HAVE_WCHAR_H +# include #endif #ifdef USE_WIDE_CHAR -# include # include # define L_(Ch) L##Ch # define UCHAR_TYPE wint_t # define STRING_TYPE wchar_t -# define ISSPACE(Ch) iswspace (Ch) -# define ISALPHA(Ch) iswalpha (Ch) -# define TOUPPER(Ch) towupper (Ch) +# ifdef USE_IN_EXTENDED_LOCALE_MODEL +# define ISSPACE(Ch) __iswspace_l ((Ch), loc) +# define ISALPHA(Ch) __iswalpha_l ((Ch), loc) +# define TOUPPER(Ch) __towupper_l ((Ch), loc) +# else +# define ISSPACE(Ch) iswspace (Ch) +# define ISALPHA(Ch) iswalpha (Ch) +# define TOUPPER(Ch) towupper (Ch) +# endif #else -# if defined (STDC_HEADERS) || (!defined (isascii) && !defined (HAVE_ISASCII)) +# if defined STDC_HEADERS || (!defined isascii && !defined HAVE_ISASCII) # define IN_CTYPE_DOMAIN(c) 1 # else # define IN_CTYPE_DOMAIN(c) isascii(c) @@ -137,12 +219,20 @@ extern int errno; # define L_(Ch) Ch # define UCHAR_TYPE unsigned char # define STRING_TYPE char -# define ISSPACE(Ch) (IN_CTYPE_DOMAIN (Ch) && isspace (Ch)) -# define ISALPHA(Ch) (IN_CTYPE_DOMAIN (Ch) && isalpha (Ch)) -# define TOUPPER(Ch) (IN_CTYPE_DOMAIN (Ch) ? toupper (Ch) : (Ch)) +# ifdef USE_IN_EXTENDED_LOCALE_MODEL +# define ISSPACE(Ch) __isspace_l ((Ch), loc) +# define ISALPHA(Ch) __isalpha_l ((Ch), loc) +# define TOUPPER(Ch) __toupper_l ((Ch), loc) +# else +# define ISSPACE(Ch) (IN_CTYPE_DOMAIN (Ch) && isspace (Ch)) +# define ISALPHA(Ch) (IN_CTYPE_DOMAIN (Ch) && isalpha (Ch)) +# define TOUPPER(Ch) (IN_CTYPE_DOMAIN (Ch) ? toupper (Ch) : (Ch)) +# endif #endif -#ifdef __STDC__ +/* For compilers which are ansi but don't define __STDC__, like SGI + Irix-4.0.5 cc, also check whether PROTOTYPES is defined. */ +#if defined (__STDC__) || defined (PROTOTYPES) # define INTERNAL(X) INTERNAL1(X) # define INTERNAL1(X) __##X##_internal # define WEAKNAME(X) WEAKNAME1(X) @@ -156,6 +246,7 @@ extern int errno; #endif + /* Convert NPTR to an `unsigned long int' or `long int' in base BASE. If BASE is 0 the base is determined by the presence of a leading zero, indicating octal or a leading "0x" or "0X", indicating hexadecimal. @@ -164,11 +255,12 @@ extern int errno; one converted is stored in *ENDPTR. */ INT -INTERNAL (strtol) (nptr, endptr, base, group) +INTERNAL (strtol) (nptr, endptr, base, group LOCALE_PARAM) const STRING_TYPE *nptr; STRING_TYPE **endptr; int base; int group; + LOCALE_PARAM_DECL { int negative; register unsigned LONG int cutoff; @@ -180,8 +272,11 @@ INTERNAL (strtol) (nptr, endptr, base, group) int overflow; #ifdef USE_NUMBER_GROUPING +# ifdef USE_IN_EXTENDED_LOCALE_MODEL + struct locale_data *current = loc->__locales[LC_NUMERIC]; +# endif /* The thousands character of the current locale. */ - wchar_t thousands; + wchar_t thousands = L'\0'; /* The numeric grouping specification of the current locale, in the format described in . */ const char *grouping; @@ -194,9 +289,11 @@ INTERNAL (strtol) (nptr, endptr, base, group) else { /* Figure out the thousands separator character. */ - if (mbtowc (&thousands, _NL_CURRENT (LC_NUMERIC, THOUSANDS_SEP), - strlen (_NL_CURRENT (LC_NUMERIC, THOUSANDS_SEP))) <= 0) - thousands = (wchar_t) *_NL_CURRENT (LC_NUMERIC, THOUSANDS_SEP); +# if defined _LIBC || defined _HAVE_BTOWC + thousands = __btowc (*_NL_CURRENT (LC_NUMERIC, THOUSANDS_SEP)); + if (thousands == WEOF) + thousands = L'\0'; +# endif if (thousands == L'\0') grouping = NULL; } @@ -233,23 +330,19 @@ INTERNAL (strtol) (nptr, endptr, base, group) else negative = 0; - if (base == 16 && s[0] == L_('0') && TOUPPER (s[1]) == L_('X')) - s += 2; - - /* If BASE is zero, figure it out ourselves. */ - if (base == 0) - if (*s == L_('0')) - { - if (TOUPPER (s[1]) == L_('X')) - { - s += 2; - base = 16; - } - else - base = 8; - } - else - base = 10; + /* Recognize number prefix and if BASE is zero, figure it out ourselves. */ + if (*s == L_('0')) + { + if ((base == 0 || base == 16) && TOUPPER (s[1]) == L_('X')) + { + s += 2; + base = 16; + } + else if (base == 0) + base = 8; + } + else if (base == 0) + base = 10; /* Save the pointer so we can check later if anything happened. */ save = s; @@ -273,8 +366,8 @@ INTERNAL (strtol) (nptr, endptr, base, group) #endif end = NULL; - cutoff = ULONG_MAX / (unsigned LONG int) base; - cutlim = ULONG_MAX % (unsigned LONG int) base; + cutoff = STRTOL_ULONG_MAX / (unsigned LONG int) base; + cutlim = STRTOL_ULONG_MAX % (unsigned LONG int) base; overflow = 0; i = 0; @@ -314,25 +407,23 @@ INTERNAL (strtol) (nptr, endptr, base, group) `unsigned LONG int', but outside the range of `LONG int'. */ if (overflow == 0 && i > (negative - ? -((unsigned LONG int) (LONG_MIN + 1)) + 1 - : (unsigned LONG int) LONG_MAX)) + ? -((unsigned LONG int) (STRTOL_LONG_MIN + 1)) + 1 + : (unsigned LONG int) STRTOL_LONG_MAX)) overflow = 1; -#else - overflow |= negative; #endif if (overflow) { __set_errno (ERANGE); #if UNSIGNED - return ULONG_MAX; + return STRTOL_ULONG_MAX; #else - return negative ? LONG_MIN : LONG_MAX; + return negative ? STRTOL_LONG_MIN : STRTOL_LONG_MAX; #endif } /* Return the result of the appropriate sign. */ - return (negative ? -i : i); + return negative ? -i : i; noconv: /* We must handle a special case here: the base is 0 or 16 and the @@ -340,12 +431,14 @@ noconv: hexadecimal digits. This is no error case. We return 0 and ENDPTR points to the `x`. */ if (endptr != NULL) - if (save - nptr >= 2 && TOUPPER (save[-1]) == L_('X') - && save[-2] == L_('0')) - *endptr = (STRING_TYPE *) &save[-1]; - else - /* There was no number to convert. */ - *endptr = (STRING_TYPE *) nptr; + { + if (save - nptr >= 2 && TOUPPER (save[-1]) == L_('X') + && save[-2] == L_('0')) + *endptr = (STRING_TYPE *) &save[-1]; + else + /* There was no number to convert. */ + *endptr = (STRING_TYPE *) nptr; + } return 0L; } @@ -369,10 +462,11 @@ INT #ifdef weak_function weak_function #endif -strtol (nptr, endptr, base) +strtol (nptr, endptr, base LOCALE_PARAM) const STRING_TYPE *nptr; STRING_TYPE **endptr; int base; + LOCALE_PARAM_DECL { - return INTERNAL (strtol) (nptr, endptr, base, 0); + return INTERNAL (strtol) (nptr, endptr, base, 0 LOCALE_PARAM); } diff --git a/lib/wait.h b/lib/wait.h index b665288..aabd199 100644 --- a/lib/wait.h +++ b/lib/wait.h @@ -12,8 +12,8 @@ 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. */ + along with this program; if not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include /* For pid_t. */ #if HAVE_SYS_WAIT_H diff --git a/lib/xalloc.h b/lib/xalloc.h index 3f8d779..8668e19 100644 --- a/lib/xalloc.h +++ b/lib/xalloc.h @@ -1,21 +1,87 @@ -#ifndef PARAMS -# if defined PROTOTYPES || (defined __STDC__ && __STDC__) -# define PARAMS(Args) Args -# else -# define PARAMS(Args) () +/* xalloc.h -- malloc with out-of-memory checking + Copyright (C) 1990-1998, 1999 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#ifndef XALLOC_H_ +# define XALLOC_H_ + +# ifndef PARAMS +# if defined PROTOTYPES || (defined __STDC__ && __STDC__) +# define PARAMS(Args) Args +# else +# define PARAMS(Args) () +# endif +# endif + +# ifndef __attribute__ +# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 8) || __STRICT_ANSI__ +# define __attribute__(x) +# endif +# endif + +# ifndef ATTRIBUTE_NORETURN +# define ATTRIBUTE_NORETURN __attribute__ ((__noreturn__)) # endif -#endif /* Exit value when the requested amount of memory is not available. - The caller may set it to some other value. */ + It is initialized to EXIT_FAILURE, but the caller may set it to + some other value. */ extern int xalloc_exit_failure; -/* FIXME: describe */ +/* If this pointer is non-zero, run the specified function upon each + allocation failure. It is initialized to zero. */ +extern void (*xalloc_fail_func) PARAMS ((void)); + +/* If XALLOC_FAIL_FUNC is undefined or a function that returns, this + message must be non-NULL. It is translated via gettext. + The default value is "Memory exhausted". */ extern char *const xalloc_msg_memory_exhausted; -/* FIXME: describe */ -extern void (*xalloc_fail_func) (); +/* This function is always triggered when memory is exhausted. It is + in charge of honoring the three previous items. This is the + function to call when one wants the program to die because of a + memory allocation failure. */ +extern void xalloc_die PARAMS ((void)) ATTRIBUTE_NORETURN; void *xmalloc PARAMS ((size_t n)); void *xcalloc PARAMS ((size_t n, size_t s)); void *xrealloc PARAMS ((void *p, size_t n)); +char *xstrdup PARAMS ((const char *str)); + +# define XMALLOC(Type, N_items) ((Type *) xmalloc (sizeof (Type) * (N_items))) +# define XCALLOC(Type, N_items) ((Type *) xcalloc (sizeof (Type), (N_items))) +# define XREALLOC(Ptr, Type, N_items) \ + ((Type *) xrealloc ((void *) (Ptr), sizeof (Type) * (N_items))) + +/* Declare and alloc memory for VAR of type TYPE. */ +# define NEW(Type, Var) Type *(Var) = XMALLOC (Type, 1) + +/* Free VAR only if non NULL. */ +# define XFREE(Var) \ + do { \ + if (Var) \ + free (Var); \ + } while (0) + +/* Return a pointer to a malloc'ed copy of the array SRC of NUM elements. */ +# define CCLONE(Src, Num) \ + (memcpy (xmalloc (sizeof (*Src) * (Num)), (Src), sizeof (*Src) * (Num))) + +/* Return a malloc'ed copy of SRC. */ +# define CLONE(Src) CCLONE (Src, 1) + + +#endif /* !XALLOC_H_ */ diff --git a/lib/xmalloc.c b/lib/xmalloc.c index 85086a8..8206a94 100644 --- a/lib/xmalloc.c +++ b/lib/xmalloc.c @@ -1,5 +1,5 @@ /* xmalloc.c -- malloc with out of memory checking - Copyright (C) 1990, 91, 92, 93, 94, 95, 96, 97 Free Software Foundation, Inc. + Copyright (C) 1990-1997, 98, 99 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 @@ -34,13 +34,10 @@ void free (); # include # define _(Text) gettext (Text) #else +# define textdomain(Domain) # define _(Text) Text #endif -#ifdef gettext_noop -# define N_(String) gettext_noop (String) -#else -# define N_(String) (String) -#endif +#define N_(Text) Text #include "error.h" #include "xalloc.h" @@ -49,13 +46,6 @@ void free (); # define EXIT_FAILURE 1 #endif -/* Prototypes for functions defined here. */ -#if defined (__STDC__) && __STDC__ -void *xmalloc (size_t n); -void *xcalloc (size_t n, size_t s); -void *xrealloc (void *p, size_t n); -#endif - #ifndef HAVE_DONE_WORKING_MALLOC_CHECK you must run the autoconf test for a properly working malloc -- see malloc.m4 #endif @@ -68,37 +58,35 @@ you must run the autoconf test for a properly working realloc -- see realloc.m4 The caller may set it to some other value. */ int xalloc_exit_failure = EXIT_FAILURE; -/* FIXME: describe */ -char *const xalloc_msg_memory_exhausted = N_("Memory exhausted"); - -/* FIXME: describe */ -void (*xalloc_fail_func) () = 0; +/* If non NULL, call this function when memory is exhausted. */ +void (*xalloc_fail_func) PARAMS ((void)) = 0; -#if __STDC__ && (HAVE_VPRINTF || HAVE_DOPRNT) -void error (int, int, const char *, ...); -#else -void error (); -#endif +/* If XALLOC_FAIL_FUNC is NULL, or does return, display this message + before exiting when memory is exhausted. Goes through gettext. */ +char *const xalloc_msg_memory_exhausted = N_("Memory exhausted"); -static void -xalloc_fail () +void +xalloc_die (void) { if (xalloc_fail_func) (*xalloc_fail_func) (); - error (xalloc_exit_failure, 0, xalloc_msg_memory_exhausted); + error (xalloc_exit_failure, 0, "%s", _(xalloc_msg_memory_exhausted)); + /* The `noreturn' cannot be given to error, since it may return if + its first argument is 0. To help compilers understand the + xalloc_die does terminate, call exit. */ + exit (EXIT_FAILURE); } /* Allocate N bytes of memory dynamically, with error checking. */ void * -xmalloc (n) - size_t n; +xmalloc (size_t n) { void *p; p = malloc (n); if (p == 0) - xalloc_fail (); + xalloc_die (); return p; } @@ -107,30 +95,23 @@ xmalloc (n) If P is NULL, run xmalloc. */ void * -xrealloc (p, n) - void *p; - size_t n; +xrealloc (void *p, size_t n) { p = realloc (p, n); if (p == 0) - xalloc_fail (); + xalloc_die (); return p; } -#ifdef NOT_USED - /* Allocate memory for N elements of S bytes, with error checking. */ void * -xcalloc (n, s) - size_t n, s; +xcalloc (size_t n, size_t s) { void *p; p = calloc (n, s); if (p == 0) - xalloc_fail (); + xalloc_die (); return p; } - -#endif /* NOT_USED */ diff --git a/locate/Makefile.in b/locate/Makefile.in index ea38e24..d7d088f 100644 --- a/locate/Makefile.in +++ b/locate/Makefile.in @@ -1,4 +1,4 @@ -# Makefile.in generated automatically by automake 1.4 from Makefile.am +# Makefile.in generated automatically by automake 1.4a from Makefile.am # Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation @@ -10,9 +10,6 @@ # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. -# The default database to build and search. - - SHELL = @SHELL@ srcdir = @srcdir@ @@ -48,9 +45,10 @@ AUTOMAKE = @AUTOMAKE@ AUTOHEADER = @AUTOHEADER@ INSTALL = @INSTALL@ -INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS) +INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_FLAG = transform = @program_transform_name@ NORMAL_INSTALL = : @@ -59,14 +57,23 @@ POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : + +@SET_MAKE@ +AMDEP = @AMDEP@ +AMTAR = @AMTAR@ +AWK = @AWK@ CATALOGS = @CATALOGS@ CATOBJEXT = @CATOBJEXT@ CC = @CC@ CPP = @CPP@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ DATADIRNAME = @DATADIRNAME@ +DEPDIR = @DEPDIR@ GENCAT = @GENCAT@ GMOFILES = @GMOFILES@ GMSGFMT = @GMSGFMT@ +GNU_PACKAGE = @GNU_PACKAGE@ GT_NO = @GT_NO@ GT_YES = @GT_YES@ INCLUDE_LOCALE_H = @INCLUDE_LOCALE_H@ @@ -86,8 +93,13 @@ U = @U@ USE_INCLUDED_LIBINTL = @USE_INCLUDED_LIBINTL@ USE_NLS = @USE_NLS@ VERSION = @VERSION@ +install_sh = @install_sh@ l = @l@ +# The default database to build and search. + + +AUTOMAKE_OPTIONS = ../lib/ansi2knr LOCATE_DB = $(localstatedir)/locatedb localedir = $(datadir)/locale @@ -102,9 +114,10 @@ CLEANFILES = updatedb INCLUDES = -I$(top_srcdir)/lib -I../intl -DLOCATE_DB=\"$(LOCATE_DB)\" -DLOCALEDIR=\"$(localedir)\" LDADD = ../find/version.o ../lib/libfind.a @INTLLIBS@ +subdir = locate mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs CONFIG_HEADER = ../config.h -CONFIG_CLEAN_FILES = updatedb +CONFIG_CLEAN_FILES = PROGRAMS = $(bin_PROGRAMS) $(libexec_PROGRAMS) @@ -112,51 +125,54 @@ DEFS = @DEFS@ -I. -I$(srcdir) -I.. CPPFLAGS = @CPPFLAGS@ LDFLAGS = @LDFLAGS@ LIBS = @LIBS@ -locate_SOURCES = locate.c -locate_OBJECTS = locate.o -locate_LDADD = $(LDADD) -locate_DEPENDENCIES = ../find/version.o ../lib/libfind.a -locate_LDFLAGS = -frcode_SOURCES = frcode.c -frcode_OBJECTS = frcode.o -frcode_LDADD = $(LDADD) -frcode_DEPENDENCIES = ../find/version.o ../lib/libfind.a -frcode_LDFLAGS = -code_SOURCES = code.c -code_OBJECTS = code.o -code_LDADD = $(LDADD) -code_DEPENDENCIES = ../find/version.o ../lib/libfind.a -code_LDFLAGS = +ANSI2KNR = ../lib/ansi2knr bigram_SOURCES = bigram.c -bigram_OBJECTS = bigram.o +bigram_OBJECTS = bigram$U.o bigram_LDADD = $(LDADD) bigram_DEPENDENCIES = ../find/version.o ../lib/libfind.a bigram_LDFLAGS = +code_SOURCES = code.c +code_OBJECTS = code$U.o +code_LDADD = $(LDADD) +code_DEPENDENCIES = ../find/version.o ../lib/libfind.a +code_LDFLAGS = +frcode_SOURCES = frcode.c +frcode_OBJECTS = frcode$U.o +frcode_LDADD = $(LDADD) +frcode_DEPENDENCIES = ../find/version.o ../lib/libfind.a +frcode_LDFLAGS = +locate_SOURCES = locate.c +locate_OBJECTS = locate$U.o +locate_LDADD = $(LDADD) +locate_DEPENDENCIES = ../find/version.o ../lib/libfind.a +locate_LDFLAGS = SCRIPTS = $(bin_SCRIPTS) -CFLAGS = @CFLAGS@ COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CFLAGS = @CFLAGS@ CCLD = $(CC) -LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ +LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ +DIST_SOURCES = bigram.c code.c frcode.c locate.c man1dir = $(mandir)/man1 man5dir = $(mandir)/man5 MANS = $(man_MANS) NROFF = nroff -DIST_COMMON = Makefile.am Makefile.in updatedb.in +DIST_COMMON = Makefile.am Makefile.in -DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) -TAR = tar GZIP_ENV = --best -DEP_FILES = .deps/bigram.P .deps/code.P .deps/frcode.P .deps/locate.P -SOURCES = locate.c frcode.c code.c bigram.c -OBJECTS = locate.o frcode.o code.o bigram.o +depcomp = $(SHELL) $(top_srcdir)/depcomp +DEP_FILES = @AMDEP@ $(DEPDIR)/bigram$U.Po $(DEPDIR)/code$U.Po \ +$(DEPDIR)/frcode$U.Po $(DEPDIR)/locate$U.Po +SOURCES = bigram.c code.c frcode.c locate.c +OBJECTS = bigram$U.o code$U.o frcode$U.o locate$U.o all: all-redirect .SUFFIXES: -.SUFFIXES: .S .c .o .s +.SUFFIXES: .c .o $(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) cd $(top_srcdir) && $(AUTOMAKE) --gnu locate/Makefile @@ -164,8 +180,6 @@ Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status $(BUILT_SOURCES) cd $(top_builddir) \ && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status -updatedb: $(top_builddir)/config.status updatedb.in - cd $(top_builddir) && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status mostlyclean-binPROGRAMS: @@ -181,15 +195,18 @@ install-binPROGRAMS: $(bin_PROGRAMS) $(mkinstalldirs) $(DESTDIR)$(bindir) @list='$(bin_PROGRAMS)'; for p in $$list; do \ if test -f $$p; then \ - echo " $(INSTALL_PROGRAM) $$p $(DESTDIR)$(bindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`"; \ - $(INSTALL_PROGRAM) $$p $(DESTDIR)$(bindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`; \ + f="`echo $$p|sed -e 's/$(EXEEXT)$$//' -e '$(transform)' -e 's/$$/$(EXEEXT)/'`"; \ + echo " $(INSTALL_PROGRAM) $(INSTALL_STRIP_FLAG) $$p $(DESTDIR)$(bindir)/$$f"; \ + $(INSTALL_PROGRAM) $(INSTALL_STRIP_FLAG) $$p $(DESTDIR)$(bindir)/$$f; \ else :; fi; \ done uninstall-binPROGRAMS: @$(NORMAL_UNINSTALL) - list='$(bin_PROGRAMS)'; for p in $$list; do \ - rm -f $(DESTDIR)$(bindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`; \ + @list='$(bin_PROGRAMS)'; for p in $$list; do \ + f="`echo $$p|sed -e 's/$(EXEEXT)$$//' -e '$(transform)' -e 's/$$/$(EXEEXT)/'`"; \ + echo " rm -f $(DESTDIR)$(bindir)/$$f"; \ + rm -f $(DESTDIR)$(bindir)/$$f; \ done mostlyclean-libexecPROGRAMS: @@ -206,23 +223,20 @@ install-libexecPROGRAMS: $(libexec_PROGRAMS) $(mkinstalldirs) $(DESTDIR)$(libexecdir) @list='$(libexec_PROGRAMS)'; for p in $$list; do \ if test -f $$p; then \ - echo " $(INSTALL_PROGRAM) $$p $(DESTDIR)$(libexecdir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`"; \ - $(INSTALL_PROGRAM) $$p $(DESTDIR)$(libexecdir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`; \ + f="`echo $$p|sed -e 's/$(EXEEXT)$$//' -e '$(transform)' -e 's/$$/$(EXEEXT)/'`"; \ + echo " $(INSTALL_PROGRAM) $(INSTALL_STRIP_FLAG) $$p $(DESTDIR)$(libexecdir)/$$f"; \ + $(INSTALL_PROGRAM) $(INSTALL_STRIP_FLAG) $$p $(DESTDIR)$(libexecdir)/$$f; \ else :; fi; \ done uninstall-libexecPROGRAMS: @$(NORMAL_UNINSTALL) - list='$(libexec_PROGRAMS)'; for p in $$list; do \ - rm -f $(DESTDIR)$(libexecdir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`; \ + @list='$(libexec_PROGRAMS)'; for p in $$list; do \ + f="`echo $$p|sed -e 's/$(EXEEXT)$$//' -e '$(transform)' -e 's/$$/$(EXEEXT)/'`"; \ + echo " rm -f $(DESTDIR)$(libexecdir)/$$f"; \ + rm -f $(DESTDIR)$(libexecdir)/$$f; \ done -.s.o: - $(COMPILE) -c $< - -.S.o: - $(COMPILE) -c $< - mostlyclean-compile: -rm -f *.o core *.core @@ -232,41 +246,68 @@ distclean-compile: -rm -f *.tab.c maintainer-clean-compile: +../lib/ansi2knr: ../lib/ansi2knr.o + cd ../lib && $(MAKE) $(AM_MAKEFLAGS) ansi2knr -locate: $(locate_OBJECTS) $(locate_DEPENDENCIES) - @rm -f locate - $(LINK) $(locate_LDFLAGS) $(locate_OBJECTS) $(locate_LDADD) $(LIBS) +../lib/ansi2knr.o: + cd ../lib && $(MAKE) $(AM_MAKEFLAGS) ansi2knr.o -frcode: $(frcode_OBJECTS) $(frcode_DEPENDENCIES) - @rm -f frcode - $(LINK) $(frcode_LDFLAGS) $(frcode_OBJECTS) $(frcode_LDADD) $(LIBS) -code: $(code_OBJECTS) $(code_DEPENDENCIES) - @rm -f code - $(LINK) $(code_LDFLAGS) $(code_OBJECTS) $(code_LDADD) $(LIBS) +mostlyclean-kr: + -rm -f *_.c + +clean-kr: + +distclean-kr: + +maintainer-clean-kr: bigram: $(bigram_OBJECTS) $(bigram_DEPENDENCIES) @rm -f bigram $(LINK) $(bigram_LDFLAGS) $(bigram_OBJECTS) $(bigram_LDADD) $(LIBS) +code: $(code_OBJECTS) $(code_DEPENDENCIES) + @rm -f code + $(LINK) $(code_LDFLAGS) $(code_OBJECTS) $(code_LDADD) $(LIBS) + +frcode: $(frcode_OBJECTS) $(frcode_DEPENDENCIES) + @rm -f frcode + $(LINK) $(frcode_LDFLAGS) $(frcode_OBJECTS) $(frcode_LDADD) $(LIBS) + +locate: $(locate_OBJECTS) $(locate_DEPENDENCIES) + @rm -f locate + $(LINK) $(locate_LDFLAGS) $(locate_OBJECTS) $(locate_LDADD) $(LIBS) + install-binSCRIPTS: $(bin_SCRIPTS) @$(NORMAL_INSTALL) $(mkinstalldirs) $(DESTDIR)$(bindir) @list='$(bin_SCRIPTS)'; for p in $$list; do \ + f="`echo $$p|sed '$(transform)'`"; \ if test -f $$p; then \ - echo " $(INSTALL_SCRIPT) $$p $(DESTDIR)$(bindir)/`echo $$p|sed '$(transform)'`"; \ - $(INSTALL_SCRIPT) $$p $(DESTDIR)$(bindir)/`echo $$p|sed '$(transform)'`; \ - else if test -f $(srcdir)/$$p; then \ - echo " $(INSTALL_SCRIPT) $(srcdir)/$$p $(DESTDIR)$(bindir)/`echo $$p|sed '$(transform)'`"; \ - $(INSTALL_SCRIPT) $(srcdir)/$$p $(DESTDIR)$(bindir)/`echo $$p|sed '$(transform)'`; \ - else :; fi; fi; \ + echo " $(INSTALL_SCRIPT) $$p $(DESTDIR)$(bindir)/$$f"; \ + $(INSTALL_SCRIPT) $$p $(DESTDIR)$(bindir)/$$f; \ + elif test -f $(srcdir)/$$p; then \ + echo " $(INSTALL_SCRIPT) $(srcdir)/$$p $(DESTDIR)$(bindir)/$$f"; \ + $(INSTALL_SCRIPT) $(srcdir)/$$p $(DESTDIR)$(bindir)/$$f; \ + else :; fi; \ done uninstall-binSCRIPTS: @$(NORMAL_UNINSTALL) - list='$(bin_SCRIPTS)'; for p in $$list; do \ - rm -f $(DESTDIR)$(bindir)/`echo $$p|sed '$(transform)'`; \ + @list='$(bin_SCRIPTS)'; for p in $$list; do \ + f="`echo $$p|sed '$(transform)'`"; \ + echo " rm -f $(DESTDIR)$(bindir)/$$f"; \ + rm -f $(DESTDIR)$(bindir)/$$f; \ done +bigram_.c: bigram.c $(ANSI2KNR) + $(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/bigram.c; then echo $(srcdir)/bigram.c; else echo bigram.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > bigram_.c +code_.c: code.c $(ANSI2KNR) + $(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/code.c; then echo $(srcdir)/code.c; else echo code.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > code_.c +frcode_.c: frcode.c $(ANSI2KNR) + $(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/frcode.c; then echo $(srcdir)/frcode.c; else echo frcode.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > frcode_.c +locate_.c: locate.c $(ANSI2KNR) + $(CPP) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/locate.c; then echo $(srcdir)/locate.c; else echo locate.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > locate_.c +bigram_.o code_.o frcode_.o locate_.o : $(ANSI2KNR) install-man1: $(mkinstalldirs) $(DESTDIR)$(man1dir) @@ -281,6 +322,7 @@ install-man1: else file=$$i; fi; \ ext=`echo $$i | sed -e 's/^.*\\.//'`; \ inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \ + inst=`echo $$inst | sed -e 's/^.*\///'`; \ inst=`echo $$inst | sed '$(transform)'`.$$ext; \ echo " $(INSTALL_DATA) $$file $(DESTDIR)$(man1dir)/$$inst"; \ $(INSTALL_DATA) $$file $(DESTDIR)$(man1dir)/$$inst; \ @@ -296,6 +338,7 @@ uninstall-man1: for i in $$list; do \ ext=`echo $$i | sed -e 's/^.*\\.//'`; \ inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \ + inst=`echo $$inst | sed -e 's/^.*\///'`; \ inst=`echo $$inst | sed '$(transform)'`.$$ext; \ echo " rm -f $(DESTDIR)$(man1dir)/$$inst"; \ rm -f $(DESTDIR)$(man1dir)/$$inst; \ @@ -314,6 +357,7 @@ install-man5: else file=$$i; fi; \ ext=`echo $$i | sed -e 's/^.*\\.//'`; \ inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \ + inst=`echo $$inst | sed -e 's/^.*\///'`; \ inst=`echo $$inst | sed '$(transform)'`.$$ext; \ echo " $(INSTALL_DATA) $$file $(DESTDIR)$(man5dir)/$$inst"; \ $(INSTALL_DATA) $$file $(DESTDIR)$(man5dir)/$$inst; \ @@ -329,6 +373,7 @@ uninstall-man5: for i in $$list; do \ ext=`echo $$i | sed -e 's/^.*\\.//'`; \ inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \ + inst=`echo $$inst | sed -e 's/^.*\///'`; \ inst=`echo $$inst | sed '$(transform)'`.$$ext; \ echo " rm -f $(DESTDIR)$(man5dir)/$$inst"; \ rm -f $(DESTDIR)$(man5dir)/$$inst; \ @@ -342,23 +387,27 @@ uninstall-man: tags: TAGS -ID: $(HEADERS) $(SOURCES) $(LISP) - list='$(SOURCES) $(HEADERS)'; \ - unique=`for i in $$list; do echo $$i; done | \ - awk ' { files[$$0] = 1; } \ +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ END { for (i in files) print i; }'`; \ - here=`pwd` && cd $(srcdir) \ - && mkid -f$$here/ID $$unique $(LISP) + mkid -f$$here/ID $$unique $(LISP) -TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) $(LISP) +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) tags=; \ here=`pwd`; \ - list='$(SOURCES) $(HEADERS)'; \ - unique=`for i in $$list; do echo $$i; done | \ - awk ' { files[$$0] = 1; } \ + list='$(SOURCES) $(HEADERS) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ END { for (i in files) print i; }'`; \ test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \ - || (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags $$unique $(LISP) -o $$here/TAGS) + || etags $(ETAGS_ARGS) $$tags $$unique $(LISP) mostlyclean-tags: @@ -371,18 +420,11 @@ maintainer-clean-tags: distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir) -subdir = locate - distdir: $(DISTFILES) - here=`cd $(top_builddir) && pwd`; \ - top_distdir=`cd $(top_distdir) && pwd`; \ - distdir=`cd $(distdir) && pwd`; \ - cd $(top_srcdir) \ - && $(AUTOMAKE) --include-deps --build-dir=$$here --srcdir-name=$(top_srcdir) --output-dir=$$top_distdir --gnu locate/Makefile @for file in $(DISTFILES); do \ d=$(srcdir); \ if test -d $$d/$$file; then \ - cp -pr $$d/$$file $(distdir)/$$file; \ + cp -pR $$d/$$file $(distdir); \ else \ test -f $(distdir)/$$file \ || ln $$d/$$file $(distdir)/$$file 2> /dev/null \ @@ -390,37 +432,28 @@ distdir: $(DISTFILES) fi; \ done -DEPS_MAGIC := $(shell mkdir .deps > /dev/null 2>&1 || :) - --include $(DEP_FILES) +@AMDEP@include $(DEPDIR)/bigram$U.Po +@AMDEP@include $(DEPDIR)/code$U.Po +@AMDEP@include $(DEPDIR)/frcode$U.Po +@AMDEP@include $(DEPDIR)/locate$U.Po mostlyclean-depend: clean-depend: distclean-depend: - -rm -rf .deps + -rm -rf $(DEPDIR) maintainer-clean-depend: -%.o: %.c - @echo '$(COMPILE) -c $<'; \ - $(COMPILE) -Wp,-MD,.deps/$(*F).pp -c $< - @-cp .deps/$(*F).pp .deps/$(*F).P; \ - tr ' ' '\012' < .deps/$(*F).pp \ - | sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \ - >> .deps/$(*F).P; \ - rm .deps/$(*F).pp - -%.lo: %.c - @echo '$(LTCOMPILE) -c $<'; \ - $(LTCOMPILE) -Wp,-MD,.deps/$(*F).pp -c $< - @-sed -e 's/^\([^:]*\)\.o[ ]*:/\1.lo \1.o :/' \ - < .deps/$(*F).pp > .deps/$(*F).P; \ - tr ' ' '\012' < .deps/$(*F).pp \ - | sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \ - >> .deps/$(*F).P; \ - rm -f .deps/$(*F).pp +@AMDEP@CCDEPMODE = @CCDEPMODE@ + +.c.o: +@AMDEP@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP@ depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@ +@AMDEP@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ + $(COMPILE) -c -o $@ $< + info-am: info: info-am dvi-am: @@ -445,7 +478,7 @@ uninstall: uninstall-am all-am: Makefile $(PROGRAMS) $(SCRIPTS) $(MANS) all-redirect: all-am install-strip: - $(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install + $(MAKE) $(AM_MAKEFLAGS) INSTALL_STRIP_FLAG=-s install installdirs: $(mkinstalldirs) $(DESTDIR)$(bindir) $(DESTDIR)$(libexecdir) \ $(DESTDIR)$(bindir) $(DESTDIR)$(mandir)/man1 \ @@ -462,28 +495,30 @@ distclean-generic: -rm -f config.cache config.log stamp-h stamp-h[0-9]* maintainer-clean-generic: + -rm -f Makefile.in mostlyclean-am: mostlyclean-binPROGRAMS mostlyclean-libexecPROGRAMS \ - mostlyclean-compile mostlyclean-tags mostlyclean-depend \ - mostlyclean-generic + mostlyclean-compile mostlyclean-kr mostlyclean-tags \ + mostlyclean-depend mostlyclean-generic mostlyclean: mostlyclean-am clean-am: clean-binPROGRAMS clean-libexecPROGRAMS clean-compile \ - clean-tags clean-depend clean-generic mostlyclean-am + clean-kr clean-tags clean-depend clean-generic \ + mostlyclean-am clean: clean-am distclean-am: distclean-binPROGRAMS distclean-libexecPROGRAMS \ - distclean-compile distclean-tags distclean-depend \ - distclean-generic clean-am + distclean-compile distclean-kr distclean-tags \ + distclean-depend distclean-generic clean-am distclean: distclean-am maintainer-clean-am: maintainer-clean-binPROGRAMS \ maintainer-clean-libexecPROGRAMS \ - maintainer-clean-compile maintainer-clean-tags \ - maintainer-clean-depend maintainer-clean-generic \ - distclean-am + maintainer-clean-compile maintainer-clean-kr \ + maintainer-clean-tags maintainer-clean-depend \ + maintainer-clean-generic distclean-am @echo "This command is intended for maintainers to use;" @echo "it deletes files that may require special tools to rebuild." @@ -494,21 +529,40 @@ maintainer-clean-binPROGRAMS uninstall-binPROGRAMS install-binPROGRAMS \ mostlyclean-libexecPROGRAMS distclean-libexecPROGRAMS \ clean-libexecPROGRAMS maintainer-clean-libexecPROGRAMS \ uninstall-libexecPROGRAMS install-libexecPROGRAMS mostlyclean-compile \ -distclean-compile clean-compile maintainer-clean-compile \ -uninstall-binSCRIPTS install-binSCRIPTS install-man1 uninstall-man1 \ -install-man5 uninstall-man5 install-man uninstall-man tags \ -mostlyclean-tags distclean-tags clean-tags maintainer-clean-tags \ -distdir mostlyclean-depend distclean-depend clean-depend \ +distclean-compile clean-compile maintainer-clean-compile mostlyclean-kr \ +distclean-kr clean-kr maintainer-clean-kr uninstall-binSCRIPTS \ +install-binSCRIPTS install-man1 uninstall-man1 install-man5 \ +uninstall-man5 install-man uninstall-man tags mostlyclean-tags \ +distclean-tags clean-tags maintainer-clean-tags distdir \ +mostlyclean-depend distclean-depend clean-depend \ maintainer-clean-depend info-am info dvi-am dvi check check-am \ installcheck-am installcheck install-exec-am install-exec \ install-data-am install-data install-am install uninstall-am uninstall \ -all-redirect all-am all installdirs mostlyclean-generic \ +all-redirect all-am all install-strip installdirs mostlyclean-generic \ distclean-generic clean-generic maintainer-clean-generic clean \ mostlyclean distclean maintainer-clean $(PROGRAMS) $(LIBPROGRAMS): ../find/version.o ../lib/libfind.a +updatedb: updatedb.sh + rm -f $@ + find=`echo find|sed '$(transform)'`; \ + frcode=`echo frcode|sed '$(transform)'`; \ + bigram=`echo bigram|sed '$(transform)'`; \ + code=`echo code|sed '$(transform)'`; \ + sed \ + -e "s,@""bindir""@,$(bindir)," \ + -e "s,@""libexecdir""@,$(libexecdir)," \ + -e "s,@""LOCATE_DB""@,$(LOCATE_DB)," \ + -e "s,@""VERSION""@,@VERSION@," \ + -e "s,@""find""@,$${find}," \ + -e "s,@""frcode""@,$${frcode}," \ + -e "s,@""bigram""@,$${bigram}," \ + -e "s,@""code""@,$${code}," \ + $(srcdir)/updatedb.sh > $@ + chmod +x $@ + install: $(top_srcdir)/mkinstalldirs $(localstatedir) diff --git a/m4/Makefile.in b/m4/Makefile.in index 1f4a066..955e30f 100644 --- a/m4/Makefile.in +++ b/m4/Makefile.in @@ -1,4 +1,4 @@ -# Makefile.in generated automatically by automake 1.4 from Makefile.am +# Makefile.in generated automatically by automake 1.4a from Makefile.am # Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation @@ -10,7 +10,6 @@ # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. - SHELL = @SHELL@ srcdir = @srcdir@ @@ -46,9 +45,10 @@ AUTOMAKE = @AUTOMAKE@ AUTOHEADER = @AUTOHEADER@ INSTALL = @INSTALL@ -INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS) +INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_FLAG = transform = @program_transform_name@ NORMAL_INSTALL = : @@ -57,14 +57,23 @@ POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : + +@SET_MAKE@ +AMDEP = @AMDEP@ +AMTAR = @AMTAR@ +AWK = @AWK@ CATALOGS = @CATALOGS@ CATOBJEXT = @CATOBJEXT@ CC = @CC@ CPP = @CPP@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ DATADIRNAME = @DATADIRNAME@ +DEPDIR = @DEPDIR@ GENCAT = @GENCAT@ GMOFILES = @GMOFILES@ GMSGFMT = @GMSGFMT@ +GNU_PACKAGE = @GNU_PACKAGE@ GT_NO = @GT_NO@ GT_YES = @GT_YES@ INCLUDES = @INCLUDES@ @@ -85,19 +94,63 @@ U = @U@ USE_INCLUDED_LIBINTL = @USE_INCLUDED_LIBINTL@ USE_NLS = @USE_NLS@ VERSION = @VERSION@ +install_sh = @install_sh@ l = @l@ -EXTRA_DIST = README Makefile.am.in assert.m4 check-decl.m4 check-type.m4 const.m4 decl.m4 error.m4 fnmatch.m4 fstypename.m4 getline.m4 glibc.m4 inttypes_h.m4 isc-posix.m4 jm-glibc-io.m4 jm-macros.m4 jm-mktime.m4 lfs.m4 ls-mntd-fs.m4 lstat.m4 malloc.m4 memcmp.m4 mktime.m4 perl.m4 prereq.m4 putenv.m4 readdir.m4 realloc.m4 regex.m4 st_dm_mode.m4 st_mtim.m4 stat.m4 strftime.m4 uintmax_t.m4 uptime.m4 utimbuf.m4 utime.m4 utimes.m4 +EXTRA_DIST = README Makefile.am.in \ +afs.m4 \ +assert.m4 \ +check-decl.m4 \ +check-type.m4 \ +const.m4 \ +d-ino.m4 \ +d-type.m4 \ +decl.m4 \ +error.m4 \ +fnmatch.m4 \ +fstypename.m4 \ +getline.m4 \ +glibc.m4 \ +inttypes_h.m4 \ +isc-posix.m4 \ +jm-glibc-io.m4 \ +jm-macros.m4 \ +jm-mktime.m4 \ +lfs.m4 \ +ls-mntd-fs.m4 \ +lstat-slash.m4 \ +lstat.m4 \ +malloc.m4 \ +memcmp.m4 \ +mktime.m4 \ +perl.m4 \ +prereq.m4 \ +putenv.m4 \ +readdir.m4 \ +realloc.m4 \ +regex.m4 \ +st_dm_mode.m4 \ +st_mtim.m4 \ +stat.m4 \ +strftime.m4 \ +uintmax_t.m4 \ +ulonglong.m4 \ +uptime.m4 \ +utimbuf.m4 \ +utime.m4 \ +utimes.m4 + +subdir = m4 mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs CONFIG_HEADER = ../config.h CONFIG_CLEAN_FILES = +DIST_SOURCES = DIST_COMMON = README ChangeLog Makefile.am Makefile.in -DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) -TAR = tar GZIP_ENV = --best all: all-redirect .SUFFIXES: @@ -114,18 +167,11 @@ TAGS: distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir) -subdir = m4 - distdir: $(DISTFILES) - here=`cd $(top_builddir) && pwd`; \ - top_distdir=`cd $(top_distdir) && pwd`; \ - distdir=`cd $(distdir) && pwd`; \ - cd $(top_srcdir) \ - && $(AUTOMAKE) --include-deps --build-dir=$$here --srcdir-name=$(top_srcdir) --output-dir=$$top_distdir --gnu m4/Makefile @for file in $(DISTFILES); do \ d=$(srcdir); \ if test -d $$d/$$file; then \ - cp -pr $$d/$$file $(distdir)/$$file; \ + cp -pR $$d/$$file $(distdir); \ else \ test -f $(distdir)/$$file \ || ln $$d/$$file $(distdir)/$$file 2> /dev/null \ @@ -154,7 +200,7 @@ uninstall: uninstall-am all-am: Makefile all-redirect: all-am install-strip: - $(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install + $(MAKE) $(AM_MAKEFLAGS) INSTALL_STRIP_FLAG=-s install installdirs: @@ -167,6 +213,7 @@ distclean-generic: -rm -f config.cache config.log stamp-h stamp-h[0-9]* maintainer-clean-generic: + -rm -f Makefile.in mostlyclean-am: mostlyclean-generic mostlyclean: mostlyclean-am @@ -188,7 +235,7 @@ maintainer-clean: maintainer-clean-am .PHONY: tags distdir info-am info dvi-am dvi check check-am \ installcheck-am installcheck install-exec-am install-exec \ install-data-am install-data install-am install uninstall-am uninstall \ -all-redirect all-am all installdirs mostlyclean-generic \ +all-redirect all-am all install-strip installdirs mostlyclean-generic \ distclean-generic clean-generic maintainer-clean-generic clean \ mostlyclean distclean maintainer-clean @@ -196,10 +243,9 @@ mostlyclean distclean maintainer-clean Makefile.am: Makefile.am.in rm -f $@ $@t sed -n '1,/^##m4-files-begin/p' $< > $@t - ( echo EXTRA_DIST = README Makefile.am.in; \ - find . -type f -name '*.m4' -print |sed 's,^\./,,' |sort ) \ - |fmt | (tr '\012' @; echo) \ - |sed 's/@$$/%/;s/@/ \\@/g' |tr @% '\012\012' \ + ( (echo EXTRA_DIST = README Makefile.am.in | tr '\012' @); \ + (echo *.m4|tr ' ' @) ) \ + |sed 's/@$$/%/;s/@/ \\@/g' |tr @% '\012\012' \ >> $@t sed -n '/^##m4-files-end/,$$p' $< >> $@t chmod a-w $@t -- 2.11.4.GIT