diff options
-rw-r--r-- | ChangeLog | 11 | ||||
-rw-r--r-- | Makefile.in | 58 | ||||
-rw-r--r-- | THANKS | 10 | ||||
-rw-r--r-- | TODO | 56 | ||||
-rw-r--r-- | acconfig.h | 6 | ||||
-rw-r--r-- | config.h.in | 9 | ||||
-rwxr-xr-x | configure | 717 | ||||
-rw-r--r-- | configure.in | 45 | ||||
-rw-r--r-- | depend.out | 26 | ||||
-rw-r--r-- | fid.c | 22 | ||||
-rw-r--r-- | filenames.c | 581 | ||||
-rw-r--r-- | filenames.h | 16 | ||||
-rw-r--r-- | gid.el | 49 | ||||
-rw-r--r-- | idfile.c | 89 | ||||
-rw-r--r-- | idfile.h | 74 | ||||
-rwxr-xr-x | idtest | 27 | ||||
-rw-r--r-- | idx.c | 10 | ||||
-rw-r--r-- | iid.c | 125 | ||||
-rw-r--r-- | iid.y | 59 | ||||
-rw-r--r-- | lid.c | 160 | ||||
-rw-r--r-- | misc.c | 4 | ||||
-rw-r--r-- | misc.h | 12 | ||||
-rw-r--r-- | mkid.c | 256 | ||||
-rw-r--r-- | regex.c | 4 | ||||
-rw-r--r-- | scanners.c | 115 | ||||
-rw-r--r-- | strerror.c | 7 | ||||
-rw-r--r-- | strxtra.h | 2 | ||||
-rw-r--r-- | version.texi | 2 |
28 files changed, 1276 insertions, 1276 deletions
@@ -1,11 +1,12 @@ -Wed May 17 10:10:59 1995 Greg McGary <gkm@magilla.cichlid.com> +Wed Mar 1 11:21:37 1995 Greg McGary <gkm@magilla.cichlid.com> - * lid.c: (find_token, grep_id): Support ISO-8859 8-bit charsets. + * idtest: Write to temp dir rather than current directory + (Thanks, Simon Leinen). -Tue May 16 23:05:36 1995 Greg McGary <gkm@magilla.cichlid.com> +Mon Feb 27 18:43:56 1995 Greg McGary <gkm@magilla.cichlid.com> - * scanners.c (set_args_text, ctype_text, ctype_asm): - Support ISO-8859 8-bit charsets. + * Makefile.in (DIST_DOC_FILES): Removed unsupported man pages. + (DIST_MISC_FILES): Added symfunc.el. Sat Feb 25 16:23:49 1995 Greg McGary <gkm@magilla.cichlid.com> diff --git a/Makefile.in b/Makefile.in index 65ee277..bfb16f7 100644 --- a/Makefile.in +++ b/Makefile.in @@ -55,7 +55,7 @@ DEPEND = @DEPEND@ REGEXP = @REGEXP@ STRCASECMP = @STRCASECMP@ -LIB_OFILES = @ALLOCA@ @GETOPT@ @STRERROR@ +LIB_OFILES = error$o @ALLOCA@ @GETOPT@ @STRERROR@ ############################################################################## @@ -65,7 +65,7 @@ LID_LINKS = eid aid gid pid ######################################## -MKID_OFILES = mkid$o misc$o scanners$o idfile$o filenames$o bitops$o $(LIB_OFILES) +MKID_OFILES = mkid$o misc$o scanners$o idfile$o filenames$o bitops$o hash$o $(LIB_OFILES) LID_OFILES = lid$o misc$o idfile$o filenames$o bitops$o token$o $(REGEXP) $(LIB_OFILES) FID_OFILES = fid$o misc$o idfile$o filenames$o bitops$o token$o $(LIB_OFILES) IDX_OFILES = idx$o scanners$o filenames$o misc$o $(LIB_OFILES) @@ -76,28 +76,29 @@ ALL_OFILES = $(MKID_OFILES) $(LID_OFILES) $(FID_OFILES) $(IDX_OFILES) $(IID_OFIL ######################################## SRC_YFILES = iid.y +GEN_CFILES = iid.c SRC_CFILES = mkid.c lid.c fid.c idx.c misc.c scanners.c idfile.c \ filenames.c bitops.c token.c -GEN_CFILES = $(SRC_YFILES:.y=.c) LIB_CFILES = regex.c alloca.c getopt.c getopt1.c strcasecmp.c strerror.c ALL_CFILES = $(SRC_CFILES) $(LIB_CFILES) $(GEN_CFILES) -SRC_HFILES = alloc.h bitops.h filenames.h idarg.h \ +SRC_HFILES = alloc.h bitops.h filenames.h hash.h \ idfile.h misc.h scanners.h strxtra.h token.h LIB_HFILES = regex.h getopt.h TAG_SRC_FILES = $(SRC_HFILES) $(LIB_HFILES) $(SRC_CFILES) $(LIB_CFILES) $(SRC_YFILES) DIST_SRC_FILES= $(ALL_CFILES) $(SRC_HFILES) $(LIB_HFILES) $(SRC_YFILES) -INFO_FILES = mkid.info -DIST_DOC_FILES= mkid.texinfo version.texi stamp-vti $(INFO_FILES) fid.1 iid.1 lid.1 mkid.1 iid.help +INFO_FILES = id.info +DIST_DOC_FILES= id.texinfo version.texi stamp-vti $(INFO_FILES) iid.help texinfo.tex DIST_CONF_FILES=aclocal.m4 acconfig.h configure.in Makefile.in mkdirhier install-sh \ stamp-h.in config.h.in configure $(DEPEND) ansi2knr.c ansi2knr.1 DIST_MISC_FILES=COPYING README README.alpha-test INSTALL NEWS TODO THANKS \ - idtest gid.el ChangeLog + idtest gid.el symfunc.el ChangeLog DIST_FILES = $(DIST_CONF_FILES) $(DIST_SRC_FILES) $(DIST_DOC_FILES) $(DIST_MISC_FILES) +DIFF_EXCLUDE = -x iid.c -x '*.info*' ######################################## @@ -137,13 +138,13 @@ PRE_PROCESS = $(CPP) $(CC_FLAGS) ######################################## .c._c: - $(ANSI2KNR) $< > $@.tmp && mv $@.tmp $@ + ./ansi2knr $< > $@.tmp && mv $@.tmp $@ ._c._o: @echo $(COMPILE) $< @rm -f _$*.c @ln $< _$*.c && $(COMPILE) _$*.c && mv _$*.o $@ && rm _$*.c .c._o: - $(ANSI2KNR) $< > $*._c.tmp && mv $*._c.tmp $*._c + ./ansi2knr $< > $*._c.tmp && mv $*._c.tmp $*._c @echo $(COMPILE) $*._c @rm -f _$*.c @ln $*._c _$*.c && $(COMPILE) _$*.c && mv _$*.o $@ && rm _$*.c @@ -153,7 +154,7 @@ PRE_PROCESS = $(CPP) $(CC_FLAGS) @rm -f _$*.c @ln $< _$*.c && $(PRE_PROCESS) _$*.c >$@ .c._i: - $(ANSI2KNR) $< > $*._c.tmp && mv $*._c.tmp $*._c + ./ansi2knr $< > $*._c.tmp && mv $*._c.tmp $*._c @echo $(PRE_PROCESS) $*._c @rm -f _$*.c @ln $*._c _$*.c && $(PRE_PROCESS) _$*.c >$@ @@ -194,13 +195,12 @@ ansi2knr: ansi2knr.o info: $(INFO_FILES) -$(INFO_FILES): mkid.texinfo version.texi - cd $(srcdir) && $(MAKEINFO) mkid.texinfo +$(INFO_FILES): id.texinfo version.texi + cd $(srcdir) && $(MAKEINFO) id.texinfo -dvi: mkid.dvi - -mkid.dvi: mkid.texinfo version.texi - $(TEXI2DVI) $(srcdir)/mkid.texinfo +dvi: id.dvi +id.dvi: id.texinfo version.texi + $(TEXI2DVI) $(srcdir)/id.texinfo version.texi: stamp-vti stamp-vti: configure.in @@ -236,7 +236,7 @@ uninstall: (echo $$cmd; eval $$cmd); \ done rm -f $(IID_HELP_FILE) - @for file in `cd $(infodir) && echo mkid.info*`; do \ + @for file in `cd $(infodir) && echo id.info*`; do \ cmd="rm -f $(infodir)/$$file"; \ (echo $$cmd; eval $$cmd); \ done @@ -244,15 +244,15 @@ uninstall: ############################################################################## check: mkid lid fid idx - here=`pwd`; PATH=$$here:$$PATH; export PATH; cd $(srcdir) \ - && $$here/mkid -v -f$$here/ID $(TAG_SRC_FILES) \ + ENV=; here=`pwd`; PATH=$$here:$$PATH; export PATH; cd $(srcdir) \ + && $$here/mkid -f$$here/ID $(TAG_SRC_FILES) \ && $(SHELL) ./idtest -f$$here/ID $(TAG_SRC_FILES) \ && rm -f $$here/ID id: ID ID: $(TAG_SRC_FILES) - here=`pwd`; cd $(srcdir) \ - && PATH=$$here:$$PATH mkid -f$$here/ID $$here/config.h $(TAG_SRC_FILES) + ENV=; here=`pwd`; PATH=$$here:$$PATH; export PATH; cd $(srcdir) \ + && mkid -f$$here/ID $$here/config.h $(TAG_SRC_FILES) tags: TAGS TAGS: $(TAG_SRC_FILES) @@ -275,16 +275,12 @@ distclean: clean maintainer-clean: distclean @echo "This command is intended only for maintainers to use;" @echo "rebuilding the deleted files may require special tools." - rm -f stamp-vti version.texi mkid.info* + rm -f stamp-vti version.texi id.info* ############################################################################## dist: $(DIST_TGZ) $(UDIFF_GZ) $(CDIFF_GZ) -shar: $(DIST_SHAR) -$(DIST_SHAR): $(DIST_TGZ) $(CDIFF_GZ) - shar $(CDIFF_GZ) $(DIST_TGZ) >$@ - dist-tgz: $(DIST_TGZ) $(DIST_TGZ): $(DIST_DIR) tar cfzho $@ $(DIST_DIR) @@ -297,16 +293,6 @@ $(DIST_DIR): $(DIST_FILES) distdir=`pwd`/$@; cd $(srcdir); cp -p $(DIST_FILES) $$distdir chmod -R a+r $@ -######################################## - -cdiff: $(CDIFF_GZ) -$(CDIFF_GZ): $(OLD_DIST_DIR) $(DIST_DIR) - diff -r -c --show-c-function --new-file $(OLD_DIST_DIR) $(DIST_DIR) |gzip >$@ - -udiff: $(UDIFF_GZ) -$(UDIFF_GZ): $(OLD_DIST_DIR) $(DIST_DIR) - diff -r -u $(OLD_DIST_DIR) $(DIST_DIR) |gzip >$@ - ############################################################################## Makefile: Makefile.in config.status $(DEPEND) @@ -2,10 +2,10 @@ mkid, lid, fid, and idx were originally written by Greg McGary. iid and pid were written by Tom Horsley, who also maintained the programs -for a time and released mkid2 to comp.sources.unix. mkid.texinfo was -written by Tom Horsley. +for a time and released mkid2 to comp.sources.unix. id.texinfo was +originally written by Tom Horsley and revised for mkid-3.0 by Karl Berry. -Special thanks go to Francois Pinard worked tirelessly to refine +Special thanks go to Francois Pinard who worked tirelessly to refine mkid's autoconfiscation, ensure mkid's conformance to GNU standards, and generally pick all the nits that were fit to pick. ;-) @@ -15,6 +15,7 @@ these people. If you contributed, but don't see your name here, please notify me (Greg McGary) at the address in the README file. Help keep this list complete and accurate. +Greg McGary <gkm@magilla.cichlid.com> Tom Horsley <Tom.Horsley@mail.hcsc.com> Wolfgang Rupprecht <wolfgang@wsrcc.com> Marty Leisner <leisner@sdsp.mc.xerox.com> @@ -30,3 +31,6 @@ Dave Wiggins <dpw@x.org> Thomas Neumann <tom@smart.ruhr.de> Jim Meyering <meyering@comco.com> Kazushi (Jam)Marukawa <kazusi-m@is.aist-nara.ac.jp> +Simon Leinen <simon@lia.di.epfl.ch> +Nelson H. F. Beebe <beebe@math.utah.edu> +Scott Bartram <scottb@clark.net> @@ -7,16 +7,40 @@ scanner-arg syntax. - Use getopt_long () in all programs to parse command-line arguments - Handle GNU standard arguments: In particular, --version & --help + - use xmalloc -* Portability - - The configure script tests for lots of things, but the code doesn't - use all of the results that it should. +* Portability & uniformity + - configure tests for lots of things, but code doesn't use all + results. Either use the results, or drop the tests. - Fix filenames.c to handle non-UNIX file names properly (notably DOS & OS/2). - Fix assumption that (sizeof (int) == sizeof (long)) + - use alloca + - use xmalloc * all query interfaces - - add environment variable for setting default ID file name. + - add environment variable for setting default ID file name--allow this + variable to be a "path" to handle multiple ID files, e.g., + IDFILE=/usr/src/ID:/usr/local/src/ID:$HOME/src/ID + also allow dirs (considered to contain a file named "ID" by default) + +* mkid & lid + - store & retrieve floating point literals + - automatically crack (optionally gzipped or compressed) tar files, so + you can index and search archived source without having to unpack it. + +* mkid + - add a recursive file tree walker, so a complete list of file names + need not be supplied--implement with ftw(3)? + - (Optinally?) store tokenized contents of comments. + - Store attributes with symbols: type, func, variable struct-tag + enum-tag, keyword, etc. Store caller/callee relationships between + identifiers. Indicate which files have defns vs. uses. This info + is needed to support a cscope interface. + - Add times(2) results to statistics output. + - treat \ specially for TeX files and do likewise with @ for Texinfo. + - add time(1) style output to statistics report at end + - control stats reports with a command-line arg. * lid - change the name of the program to something a bit more @@ -31,22 +55,18 @@ alias lid="findid -e 'echo %t %f'" alias eid="findid -e 'vi +/\\<%t\\>/ %F'" # for vi users alias gid="findid -e 'egrep \\<%t\\> %F'" + - make `pid' a separate program + - standardize & document regexp syntax (currently, it depends on whether + you link rx.o or your vendor's regexp stuff). + - gid bug: "gid -e file_" yeilds nothing. -* mkid & lid - - store & retrieve floating point literals - - automatically crack (optionally gzipped or compressed) tar files, so - you can index and search archived source without having to unpack it. +* iid + - don't use $PS1 for the prompt. Use (iid), or iid> or something like that + - review (revise?) syntax -* mkid - - add a recursive file tree walker, so a complete list of file names - need not be supplied. - - (Optinally?) store tokenized contents of comments. - - Store attributes with symbols: type, func, variable struct-tag - enum-tag, keyword, etc. Store caller/callee relationships between - identifiers. Indicate which files have defns vs. uses. This info - is needed to support a cscope interface. - - Add times(2) results to statistics output. - - treat \ specially for TeX files and do likewise with @ for Texinfo. +* gid.el + - associate ID file with buffers so future `gid's will use the right ID. + - wire completion on token names * cscope - add a cscope work-alike query interface (this is being done by @@ -7,12 +7,18 @@ @TOP@ +/* Define to `unsigned short' if <sys/types.h> doesn't define. */ +#undef dev_t + /* Define if you have the <sys/ioctl.h> header file. */ #undef HAVE_SYS_IOCTL_H /* Define to filename of iid help text. */ #undef IID_HELP_FILE +/* Define to `unsigned long' if <sys/types.h> doesn't define. */ +#undef ino_t + /* Define to the name of the distribution. */ #undef PACKAGE diff --git a/config.h.in b/config.h.in index f2e39db..15c0b45 100644 --- a/config.h.in +++ b/config.h.in @@ -47,9 +47,15 @@ /* Define if you have the ANSI C header files. */ #undef STDC_HEADERS +/* Define to `unsigned short' if <sys/types.h> doesn't define. */ +#undef dev_t + /* Define to filename of iid help text. */ #undef IID_HELP_FILE +/* Define to `unsigned long' if <sys/types.h> doesn't define. */ +#undef ino_t + /* Define to the name of the distribution. */ #undef PACKAGE @@ -88,6 +94,9 @@ /* Define if you have the getwd function. */ #undef HAVE_GETWD +/* Define if you have the link function. */ +#undef HAVE_LINK + /* Define if you have the memcpy function. */ #undef HAVE_MEMCPY @@ -1,7 +1,7 @@ -#!/bin/sh +#! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated automatically using autoconf version 2.1 +# Generated automatically using autoconf version 2.2 # Copyright (C) 1992, 1993, 1994 Free Software Foundation, Inc. # # This configure script is free software; the Free Software Foundation @@ -216,7 +216,7 @@ EOF verbose=yes ;; -version | --version | --versio | --versi | --vers) - echo "configure generated by autoconf version 2.1" + echo "configure generated by autoconf version 2.2" exit 0 ;; -with-* | --with-*) @@ -279,19 +279,20 @@ if test -n "$ac_prev"; then { echo "configure: error: missing argument to --`echo $ac_prev | sed 's/_/-/g'`" 1>&2; exit 1; } fi -trap 'rm -fr conftest* confdefs* core $ac_clean_files; exit 1' 1 2 15 +trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15 # File descriptor usage: -# 0 unused; standard input +# 0 standard input # 1 file creation # 2 errors and warnings -# 3 unused; some systems may open it to /dev/tty -# 4 checking for... messages and results +# 3 some systems may open it to /dev/tty +# 4 used on the Kubota Titan +# 6 checking for... messages and results # 5 compiler messages saved in config.log if test "$silent" = yes; then - exec 4>/dev/null + exec 6>/dev/null else - exec 4>&1 + exec 6>&1 fi exec 5>./config.log @@ -381,8 +382,8 @@ fi ac_ext=c # CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. ac_cpp='$CPP $CPPFLAGS' -ac_compile='${CC-cc} $CFLAGS $CPPFLAGS conftest.$ac_ext -c 1>&5 2>&5' -ac_link='${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext -o conftest $LIBS 1>&5 2>&5' +ac_compile='${CC-cc} conftest.$ac_ext $CFLAGS $CPPFLAGS -c 1>&5 2>&5' +ac_link='${CC-cc} conftest.$ac_ext $CFLAGS $CPPFLAGS $LDFLAGS -o conftest $LIBS 1>&5 2>&5' if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then # Stardent Vistra SVR4 grep lacks -e, says ghazi@caip.rutgers.edu. @@ -399,9 +400,12 @@ fi +############################################################################## +### Package identification + PACKAGE=mkid -VERSION=3.0.8 -PREV_VERSION=3.0.7 +VERSION=3.0.9 +PREV_VERSION=3.0.8 cat >> confdefs.h <<EOF #define PACKAGE "$PACKAGE" EOF @@ -414,13 +418,16 @@ EOF +############################################################################## +### Checks for programs. + for ac_prog in 'bison -y' byacc do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 -echo $ac_n "checking for $ac_word""... $ac_c" 1>&4 -if eval "test \"`echo '${'ac_cv_prog_YACC'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&4 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +if eval "test \"`echo '$''{'ac_cv_prog_YACC'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 else if test -n "$YACC"; then ac_cv_prog_YACC="$YACC" # Let the user override the test. @@ -438,9 +445,9 @@ fi fi YACC="$ac_cv_prog_YACC" if test -n "$YACC"; then - echo "$ac_t""$YACC" 1>&4 + echo "$ac_t""$YACC" 1>&6 else - echo "$ac_t""no" 1>&4 + echo "$ac_t""no" 1>&6 fi test -n "$YACC" && break @@ -449,9 +456,9 @@ test -n "$YACC" || YACC="yacc" # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; ac_word=$2 -echo $ac_n "checking for $ac_word""... $ac_c" 1>&4 -if eval "test \"`echo '${'ac_cv_prog_CC'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&4 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. @@ -470,15 +477,15 @@ fi fi CC="$ac_cv_prog_CC" if test -n "$CC"; then - echo "$ac_t""$CC" 1>&4 + echo "$ac_t""$CC" 1>&6 else - echo "$ac_t""no" 1>&4 + echo "$ac_t""no" 1>&6 fi -echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&4 -if eval "test \"`echo '${'ac_cv_prog_gcc'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&4 +echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6 +if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.c <<EOF #ifdef __GNUC__ @@ -491,16 +498,16 @@ else ac_cv_prog_gcc=no fi fi -echo "$ac_t""$ac_cv_prog_gcc" 1>&4 +echo "$ac_t""$ac_cv_prog_gcc" 1>&6 if test $ac_cv_prog_gcc = yes; then GCC=yes if test "${CFLAGS+set}" != set; then - echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&4 -if eval "test \"`echo '${'ac_cv_prog_gcc_g'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&4 + echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6 +if eval "test \"`echo '$''{'ac_cv_prog_gcc_g'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 else - echo 'void f(void); void f(void){}' > conftest.c -if test -z "`${CC-cc} -g -O -c conftest.c 2>&1`"; then + echo 'void f(){}' > conftest.c +if test -z "`${CC-cc} -g -c conftest.c 2>&1`"; then ac_cv_prog_gcc_g=yes else ac_cv_prog_gcc_g=no @@ -508,7 +515,7 @@ fi rm -f conftest* fi - echo "$ac_t""$ac_cv_prog_gcc_g" 1>&4 + echo "$ac_t""$ac_cv_prog_gcc_g" 1>&6 if test $ac_cv_prog_gcc_g = yes; then CFLAGS="-g -O" else @@ -520,9 +527,9 @@ else test "${CFLAGS+set}" = set || CFLAGS="-g" fi -echo $ac_n "checking whether ln -s works""... $ac_c" 1>&4 -if eval "test \"`echo '${'ac_cv_prog_LN_S'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&4 +echo $ac_n "checking whether ln -s works""... $ac_c" 1>&6 +if eval "test \"`echo '$''{'ac_cv_prog_LN_S'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 else rm -f conftestdata if ln -s X conftestdata 2>/dev/null @@ -535,9 +542,9 @@ fi fi LN_S="$ac_cv_prog_LN_S" if test "$ac_cv_prog_LN_S" = "ln -s"; then - echo "$ac_t""yes" 1>&4 + echo "$ac_t""yes" 1>&6 else - echo "$ac_t""no" 1>&4 + echo "$ac_t""no" 1>&6 fi ac_aux_dir= @@ -569,15 +576,16 @@ ac_configure=$ac_aux_dir/configure # This should be Cygnus configure. # AFS /usr/afsws/bin/install, which mishandles nonexistent args # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" # ./install, which can be erroneously created by make from ./install.sh. -echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&4 +echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6 if test -z "$INSTALL"; then -if eval "test \"`echo '${'ac_cv_path_install'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&4 +if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 else IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:" for ac_dir in $PATH; do - case "$ac_dir" in - ''|.|/etc|/usr/sbin|/usr/etc|/sbin|/usr/afsws/bin|/usr/ucb) ;; + # Account for people who put trailing slashes in PATH elements. + case "$ac_dir/" in + /|./|.//|/etc/*|/usr/sbin/*|/usr/etc/*|/sbin/*|/usr/afsws/bin/*|/usr/ucb/*) ;; *) # OSF1 and SCO ODT 3.0 have their own names for install. for ac_prog in ginstall installbsd scoinst install; do @@ -602,7 +610,7 @@ else fi INSTALL="$ac_cv_path_install" fi -echo "$ac_t""$INSTALL" 1>&4 +echo "$ac_t""$INSTALL" 1>&6 # Use test -z because SunOS4 sh mishandles braces in ${var-val}. # It thinks the first close brace ends the variable substitution. @@ -610,10 +618,10 @@ test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' -echo $ac_n "checking whether ${MAKE-make} sets \$MAKE""... $ac_c" 1>&4 +echo $ac_n "checking whether ${MAKE-make} sets \${MAKE}""... $ac_c" 1>&6 set dummy ${MAKE-make}; ac_make=$2 -if eval "test \"`echo '${'ac_cv_prog_make_${ac_make}_set'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&4 +if eval "test \"`echo '$''{'ac_cv_prog_make_${ac_make}_set'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftestmake <<\EOF all: @@ -629,23 +637,28 @@ fi rm -f conftestmake fi if eval "test \"`echo '$ac_cv_prog_make_'${ac_make}_set`\" = yes"; then - echo "$ac_t""yes" 1>&4 + echo "$ac_t""yes" 1>&6 SET_MAKE= else - echo "$ac_t""no" 1>&4 + echo "$ac_t""no" 1>&6 SET_MAKE="MAKE=${MAKE-make}" fi +############################################################################## +### Checks for libraries. -echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&4 +############################################################################## +### Checks for header files. + +echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6 # On Suns, sometimes $CPP names a directory. if test -n "$CPP" && test -d "$CPP"; then CPP= fi if test -z "$CPP"; then -if eval "test \"`echo '${'ac_cv_prog_CPP'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&4 +if eval "test \"`echo '$''{'ac_cv_prog_CPP'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 else # This must be in double quotes, not single quotes, because CPP may get # substituted into the Makefile and "${CC-cc}" will confuse make. @@ -653,7 +666,7 @@ else # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. cat > conftest.$ac_ext <<EOF -#line 657 "configure" +#line 670 "configure" #include "confdefs.h" #include <assert.h> Syntax Error @@ -667,7 +680,7 @@ else rm -rf conftest* CPP="${CC-cc} -E -traditional-cpp" cat > conftest.$ac_ext <<EOF -#line 671 "configure" +#line 684 "configure" #include "confdefs.h" #include <assert.h> Syntax Error @@ -688,18 +701,18 @@ rm -f conftest* fi fi CPP="$ac_cv_prog_CPP" -echo "$ac_t""$CPP" 1>&4 +echo "$ac_t""$CPP" 1>&6 # If we cannot run a trivial program, we must be cross compiling. -echo $ac_n "checking whether cross-compiling""... $ac_c" 1>&4 -if eval "test \"`echo '${'ac_cv_c_cross'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&4 +echo $ac_n "checking whether cross-compiling""... $ac_c" 1>&6 +if eval "test \"`echo '$''{'ac_cv_c_cross'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 else if test "$cross_compiling" = yes; then - ac_cv_cross=yes + ac_cv_c_cross=yes else cat > conftest.$ac_ext <<EOF -#line 703 "configure" +#line 716 "configure" #include "confdefs.h" main(){return(0);} EOF @@ -713,14 +726,14 @@ fi rm -fr conftest* fi cross_compiling=$ac_cv_c_cross -echo "$ac_t""$ac_cv_c_cross" 1>&4 +echo "$ac_t""$ac_cv_c_cross" 1>&6 -echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&4 -if eval "test \"`echo '${'ac_cv_header_stdc'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&4 +echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6 +if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 724 "configure" +#line 737 "configure" #include "confdefs.h" #include <stdlib.h> #include <stdarg.h> @@ -742,7 +755,7 @@ rm -f conftest* if test $ac_cv_header_stdc = yes; then # SunOS 4.x string.h does not declare mem*, contrary to ANSI. cat > conftest.$ac_ext <<EOF -#line 746 "configure" +#line 759 "configure" #include "confdefs.h" #include <string.h> EOF @@ -760,7 +773,7 @@ fi if test $ac_cv_header_stdc = yes; then # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. cat > conftest.$ac_ext <<EOF -#line 764 "configure" +#line 777 "configure" #include "confdefs.h" #include <stdlib.h> EOF @@ -781,7 +794,7 @@ if test "$cross_compiling" = yes; then ac_cv_header_stdc=no else cat > conftest.$ac_ext <<EOF -#line 785 "configure" +#line 798 "configure" #include "confdefs.h" #include <ctype.h> #define ISLOWER(c) ('a' <= (c) && (c) <= 'z') @@ -802,7 +815,7 @@ fi rm -fr conftest* fi fi -echo "$ac_t""$ac_cv_header_stdc" 1>&4 +echo "$ac_t""$ac_cv_header_stdc" 1>&6 if test $ac_cv_header_stdc = yes; then cat >> confdefs.h <<\EOF #define STDC_HEADERS 1 @@ -810,12 +823,12 @@ EOF fi -echo $ac_n "checking for sys/wait.h that is POSIX.1 compatible""... $ac_c" 1>&4 -if eval "test \"`echo '${'ac_cv_header_sys_wait_h'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&4 +echo $ac_n "checking for sys/wait.h that is POSIX.1 compatible""... $ac_c" 1>&6 +if eval "test \"`echo '$''{'ac_cv_header_sys_wait_h'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 819 "configure" +#line 832 "configure" #include "confdefs.h" #include <sys/types.h> #include <sys/wait.h> @@ -842,7 +855,7 @@ fi rm -f conftest* fi -echo "$ac_t""$ac_cv_header_sys_wait_h" 1>&4 +echo "$ac_t""$ac_cv_header_sys_wait_h" 1>&6 if test $ac_cv_header_sys_wait_h = yes; then cat >> confdefs.h <<\EOF #define HAVE_SYS_WAIT_H 1 @@ -853,12 +866,12 @@ fi for ac_hdr in limits.h stddef.h sys/types.h sys/stat.h sys/param.h do ac_safe=`echo "$ac_hdr" | tr './\055' '___'` -echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&4 -if eval "test \"`echo '${'ac_cv_header_$ac_safe'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&4 +echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 +if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 862 "configure" +#line 875 "configure" #include "confdefs.h" #include <$ac_hdr> EOF @@ -875,26 +888,26 @@ fi rm -f conftest* fi if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then - echo "$ac_t""yes" 1>&4 + echo "$ac_t""yes" 1>&6 ac_tr_hdr=HAVE_`echo $ac_hdr | tr '[a-z]./\055' '[A-Z]___'` cat >> confdefs.h <<EOF #define $ac_tr_hdr 1 EOF else - echo "$ac_t""no" 1>&4 + echo "$ac_t""no" 1>&6 fi done for ac_hdr in stdlib.h unistd.h string.h malloc.h memory.h assert.h ctype.h errno.h do ac_safe=`echo "$ac_hdr" | tr './\055' '___'` -echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&4 -if eval "test \"`echo '${'ac_cv_header_$ac_safe'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&4 +echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 +if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 898 "configure" +#line 911 "configure" #include "confdefs.h" #include <$ac_hdr> EOF @@ -911,26 +924,26 @@ fi rm -f conftest* fi if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then - echo "$ac_t""yes" 1>&4 + echo "$ac_t""yes" 1>&6 ac_tr_hdr=HAVE_`echo $ac_hdr | tr '[a-z]./\055' '[A-Z]___'` cat >> confdefs.h <<EOF #define $ac_tr_hdr 1 EOF else - echo "$ac_t""no" 1>&4 + echo "$ac_t""no" 1>&6 fi done for ac_hdr in sys/ioctl.h termios.h termio.h sgtty.h regex.h do ac_safe=`echo "$ac_hdr" | tr './\055' '___'` -echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&4 -if eval "test \"`echo '${'ac_cv_header_$ac_safe'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&4 +echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 +if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 934 "configure" +#line 947 "configure" #include "confdefs.h" #include <$ac_hdr> EOF @@ -947,24 +960,88 @@ fi rm -f conftest* fi if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then - echo "$ac_t""yes" 1>&4 + echo "$ac_t""yes" 1>&6 ac_tr_hdr=HAVE_`echo $ac_hdr | tr '[a-z]./\055' '[A-Z]___'` cat >> confdefs.h <<EOF #define $ac_tr_hdr 1 EOF else - echo "$ac_t""no" 1>&4 + echo "$ac_t""no" 1>&6 +fi +done + + +############################################################################## +### Checks for typedefs, structures, and compiler characteristics. + +echo $ac_n "checking for ${CC-cc} option to accept ANSI C""... $ac_c" 1>&6 +if eval "test \"`echo '$''{'ac_cv_prog_cc_stdc'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + ac_cv_prog_cc_stdc=no +ac_save_CFLAGS="$CFLAGS" +# Don't try gcc -ansi; that turns off useful extensions and +# breaks some systems' header files. +# AIX -qlanglvl=ansi +# Ultrix and OSF/1 -std1 +# HP-UX -Aa -D_HPUX_SOURCE +# CX/UX -Xa (-Xc is strict ANSI) +# SVR4 -Xc +for ac_arg in "" -qlanglvl=ansi -std1 "-Aa -D_HPUX_SOURCE" -Xa -Xc +do + CFLAGS="$ac_save_CFLAGS $ac_arg" + cat > conftest.$ac_ext <<EOF +#line 996 "configure" +#include "confdefs.h" +#if !defined(__STDC__) || __STDC__ != 1 +choke me +#endif + +int main() { return 0; } +int t() { +int test (int i, double x); +struct s1 {int (*f) (int a);}; +struct s2 {int (*f) (double a);}; +; return 0; } +EOF +if eval $ac_compile; then + rm -rf conftest* + ac_cv_prog_cc_stdc="$ac_arg"; break fi +rm -f conftest* + done +CFLAGS="$ac_save_CFLAGS" + +fi + +echo "$ac_t""$ac_cv_prog_cc_stdc" 1>&6 +case "x$ac_cv_prog_cc_stdc" in + x|xno) ;; + *) CC="$CC $ac_cv_prog_cc_stdc" ;; +esac + +echo $ac_n "checking for function prototypes""... $ac_c" 1>&6 +if test "$ac_cv_prog_cc_stdc" != no; then + echo "$ac_t""yes" 1>&6 + cat >> confdefs.h <<\EOF +#define PROTOTYPES 1 +EOF -echo $ac_n "checking for working const""... $ac_c" 1>&4 -if eval "test \"`echo '${'ac_cv_c_const'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&4 + U= ANSI2KNR= +else + echo "$ac_t""no" 1>&6 + U=_ ANSI2KNR=ansi2knr +fi + +echo $ac_n "checking for working const""... $ac_c" 1>&6 +if eval "test \"`echo '$''{'ac_cv_c_const'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 968 "configure" +#line 1045 "configure" #include "confdefs.h" int main() { return 0; } @@ -1024,7 +1101,7 @@ fi rm -f conftest* fi -echo "$ac_t""$ac_cv_c_const" 1>&4 +echo "$ac_t""$ac_cv_c_const" 1>&6 if test $ac_cv_c_const = no; then cat >> confdefs.h <<\EOF #define const @@ -1032,80 +1109,22 @@ EOF fi -echo $ac_n "checking for ${CC-cc} option to accept ANSI C""... $ac_c" 1>&4 -if eval "test \"`echo '${'ac_cv_prog_cc_stdc'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&4 +echo $ac_n "checking return type of signal handlers""... $ac_c" 1>&6 +if eval "test \"`echo '$''{'ac_cv_type_signal'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 else - ac_cv_prog_cc_stdc=no -ac_save_CFLAGS="$CFLAGS" -# Don't try gcc -ansi; that turns off useful extensions and -# breaks some systems' header files. -# AIX -qlanglvl=ansi -# Ultrix and OSF/1 -std1 -# HP-UX -Aa -D_HPUX_SOURCE -# CX/UX -Xa (-Xc is strict ANSI) -# SVR4 -Xc -for ac_arg in "" -qlanglvl=ansi -std1 "-Aa -D_HPUX_SOURCE" -Xa -Xc -do - CFLAGS="$ac_save_CFLAGS $ac_arg" cat > conftest.$ac_ext <<EOF -#line 1053 "configure" -#include "confdefs.h" -#if !defined(__STDC__) || __STDC__ != 1 -choke me -#endif - -int main() { return 0; } -int t() { -int test (int i, double x); -struct s1 {int (*f) (int a);}; -struct s2 {int (*f) (double a);}; -; return 0; } -EOF -if eval $ac_compile; then - rm -rf conftest* - ac_cv_prog_cc_stdc="$ac_arg"; break -fi -rm -f conftest* - -done -CFLAGS="$ac_save_CFLAGS" - -fi - -echo "$ac_t""$ac_cv_prog_cc_stdc" 1>&4 -case "x$ac_cv_prog_cc_stdc" in - x|xno) ;; - *) CC="$CC $ac_cv_prog_cc_stdc" ;; -esac - - -echo $ac_n "checking for function prototypes""... $ac_c" 1>&4 -if test "$ac_cv_prog_cc_stdc" != no; then - echo "$ac_t""yes" 1>&4 - cat >> confdefs.h <<\EOF -#define PROTOTYPES 1 -EOF - - U= ANSI2KNR= -else - echo "$ac_t""no" 1>&4 - U=_ ANSI2KNR=ansi2knr -fi - -echo $ac_n "checking return type of signal handlers""... $ac_c" 1>&4 -if eval "test \"`echo '${'ac_cv_type_signal'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&4 -else - cat > conftest.$ac_ext <<EOF -#line 1102 "configure" +#line 1118 "configure" #include "confdefs.h" #include <sys/types.h> #include <signal.h> #ifdef signal #undef signal #endif -extern void (*signal ()) (); +#ifdef __cplusplus +extern "C" +#endif +void (*signal ()) (); int main() { return 0; } int t() { int i; @@ -1121,18 +1140,18 @@ fi rm -f conftest* fi -echo "$ac_t""$ac_cv_type_signal" 1>&4 +echo "$ac_t""$ac_cv_type_signal" 1>&6 cat >> confdefs.h <<EOF #define RETSIGTYPE $ac_cv_type_signal EOF -echo $ac_n "checking for off_t""... $ac_c" 1>&4 -if eval "test \"`echo '${'ac_cv_type_off_t'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&4 +echo $ac_n "checking for off_t""... $ac_c" 1>&6 +if eval "test \"`echo '$''{'ac_cv_type_off_t'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 1136 "configure" +#line 1155 "configure" #include "confdefs.h" #include <sys/types.h> #if STDC_HEADERS @@ -1150,7 +1169,7 @@ fi rm -f conftest* fi -echo "$ac_t""$ac_cv_type_off_t" 1>&4 +echo "$ac_t""$ac_cv_type_off_t" 1>&6 if test $ac_cv_type_off_t = no; then cat >> confdefs.h <<\EOF #define off_t long @@ -1158,12 +1177,12 @@ EOF fi -echo $ac_n "checking for size_t""... $ac_c" 1>&4 -if eval "test \"`echo '${'ac_cv_type_size_t'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&4 +echo $ac_n "checking for size_t""... $ac_c" 1>&6 +if eval "test \"`echo '$''{'ac_cv_type_size_t'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 1167 "configure" +#line 1186 "configure" #include "confdefs.h" #include <sys/types.h> #if STDC_HEADERS @@ -1181,7 +1200,7 @@ fi rm -f conftest* fi -echo "$ac_t""$ac_cv_type_size_t" 1>&4 +echo "$ac_t""$ac_cv_type_size_t" 1>&6 if test $ac_cv_type_size_t = no; then cat >> confdefs.h <<\EOF #define size_t unsigned @@ -1189,20 +1208,85 @@ EOF fi +echo $ac_n "checking for dev_t""... $ac_c" 1>&6 +if eval "test \"`echo '$''{'ac_cv_type_dev_t'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext <<EOF +#line 1217 "configure" +#include "confdefs.h" +#include <sys/types.h> +#if STDC_HEADERS +#include <stdlib.h> +#endif +EOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + egrep "dev_t" >/dev/null 2>&1; then + rm -rf conftest* + ac_cv_type_dev_t=yes +else + rm -rf conftest* + ac_cv_type_dev_t=no +fi +rm -f conftest* + +fi +echo "$ac_t""$ac_cv_type_dev_t" 1>&6 +if test $ac_cv_type_dev_t = no; then + cat >> confdefs.h <<\EOF +#define dev_t unsigned short +EOF + +fi + +echo $ac_n "checking for ino_t""... $ac_c" 1>&6 +if eval "test \"`echo '$''{'ac_cv_type_ino_t'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext <<EOF +#line 1248 "configure" +#include "confdefs.h" +#include <sys/types.h> +#if STDC_HEADERS +#include <stdlib.h> +#endif +EOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + egrep "ino_t" >/dev/null 2>&1; then + rm -rf conftest* + ac_cv_type_ino_t=yes +else + rm -rf conftest* + ac_cv_type_ino_t=no +fi +rm -f conftest* + +fi +echo "$ac_t""$ac_cv_type_ino_t" 1>&6 +if test $ac_cv_type_ino_t = no; then + cat >> confdefs.h <<\EOF +#define ino_t unsigned long +EOF + +fi + CFLAGS=${CFLAGS--g} LDFLAGS=${LDFLAGS--g} +############################################################################## +### Checks for library functions & system calls. + if test $ac_cv_prog_gcc = yes; then - echo $ac_n "checking whether ${CC-cc} needs -traditional""... $ac_c" 1>&4 -if eval "test \"`echo '${'ac_cv_prog_gcc_traditional'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&4 + echo $ac_n "checking whether ${CC-cc} needs -traditional""... $ac_c" 1>&6 +if eval "test \"`echo '$''{'ac_cv_prog_gcc_traditional'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 else ac_pattern="Autoconf.*'x'" cat > conftest.$ac_ext <<EOF -#line 1206 "configure" +#line 1290 "configure" #include "confdefs.h" #include <sgtty.h> Autoconf TIOCGETP @@ -1220,7 +1304,7 @@ rm -f conftest* if test $ac_cv_prog_gcc_traditional = no; then cat > conftest.$ac_ext <<EOF -#line 1224 "configure" +#line 1308 "configure" #include "confdefs.h" #include <termio.h> Autoconf TCGETA @@ -1234,7 +1318,7 @@ rm -f conftest* fi fi - echo "$ac_t""$ac_cv_prog_gcc_traditional" 1>&4 + echo "$ac_t""$ac_cv_prog_gcc_traditional" 1>&6 if test $ac_cv_prog_gcc_traditional = yes; then CC="$CC -traditional" fi @@ -1242,14 +1326,16 @@ fi for ac_func in getwd getcwd getopt_long basename dirname do -echo $ac_n "checking for $ac_func""... $ac_c" 1>&4 -if eval "test \"`echo '${'ac_cv_func_$ac_func'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&4 +echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 +if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 1251 "configure" +#line 1335 "configure" #include "confdefs.h" -#include <ctype.h> /* Arbitrary system header to define __stub macros. */ +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $ac_func(); below. */ +#include <assert.h> /* Override any gcc2 internal prototype to avoid an error. */ char $ac_func(); @@ -1278,27 +1364,29 @@ rm -f conftest* fi if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then - echo "$ac_t""yes" 1>&4 + echo "$ac_t""yes" 1>&6 ac_tr_func=HAVE_`echo $ac_func | tr '[a-z]' '[A-Z]'` cat >> confdefs.h <<EOF #define $ac_tr_func 1 EOF else - echo "$ac_t""no" 1>&4 + echo "$ac_t""no" 1>&6 fi done for ac_func in strdup strchr strrchr strcasecmp strerror do -echo $ac_n "checking for $ac_func""... $ac_c" 1>&4 -if eval "test \"`echo '${'ac_cv_func_$ac_func'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&4 +echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 +if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 1300 "configure" +#line 1386 "configure" #include "confdefs.h" -#include <ctype.h> /* Arbitrary system header to define __stub macros. */ +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $ac_func(); below. */ +#include <assert.h> /* Override any gcc2 internal prototype to avoid an error. */ char $ac_func(); @@ -1327,27 +1415,29 @@ rm -f conftest* fi if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then - echo "$ac_t""yes" 1>&4 + echo "$ac_t""yes" 1>&6 ac_tr_func=HAVE_`echo $ac_func | tr '[a-z]' '[A-Z]'` cat >> confdefs.h <<EOF #define $ac_tr_func 1 EOF else - echo "$ac_t""no" 1>&4 + echo "$ac_t""no" 1>&6 fi done for ac_func in memcpy bcopy memset bzero do -echo $ac_n "checking for $ac_func""... $ac_c" 1>&4 -if eval "test \"`echo '${'ac_cv_func_$ac_func'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&4 +echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 +if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 1349 "configure" +#line 1437 "configure" #include "confdefs.h" -#include <ctype.h> /* Arbitrary system header to define __stub macros. */ +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $ac_func(); below. */ +#include <assert.h> /* Override any gcc2 internal prototype to avoid an error. */ char $ac_func(); @@ -1376,27 +1466,29 @@ rm -f conftest* fi if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then - echo "$ac_t""yes" 1>&4 + echo "$ac_t""yes" 1>&6 ac_tr_func=HAVE_`echo $ac_func | tr '[a-z]' '[A-Z]'` cat >> confdefs.h <<EOF #define $ac_tr_func 1 EOF else - echo "$ac_t""no" 1>&4 + echo "$ac_t""no" 1>&6 fi done -for ac_func in regcomp regcmp re_comp +for ac_func in regcomp regcmp re_comp link do -echo $ac_n "checking for $ac_func""... $ac_c" 1>&4 -if eval "test \"`echo '${'ac_cv_func_$ac_func'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&4 +echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 +if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 1398 "configure" +#line 1488 "configure" #include "confdefs.h" -#include <ctype.h> /* Arbitrary system header to define __stub macros. */ +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $ac_func(); below. */ +#include <assert.h> /* Override any gcc2 internal prototype to avoid an error. */ char $ac_func(); @@ -1425,25 +1517,25 @@ rm -f conftest* fi if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then - echo "$ac_t""yes" 1>&4 + echo "$ac_t""yes" 1>&6 ac_tr_func=HAVE_`echo $ac_func | tr '[a-z]' '[A-Z]'` cat >> confdefs.h <<EOF #define $ac_tr_func 1 EOF else - echo "$ac_t""no" 1>&4 + echo "$ac_t""no" 1>&6 fi done # The Ultrix 4.2 mips builtin alloca declared by alloca.h only works # for constant arguments. Useless! -echo $ac_n "checking for working alloca.h""... $ac_c" 1>&4 -if eval "test \"`echo '${'ac_cv_header_alloca_h'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&4 +echo $ac_n "checking for working alloca.h""... $ac_c" 1>&6 +if eval "test \"`echo '$''{'ac_cv_header_alloca_h'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 1447 "configure" +#line 1539 "configure" #include "confdefs.h" #include <alloca.h> int main() { return 0; } @@ -1461,7 +1553,7 @@ fi rm -f conftest* fi -echo "$ac_t""$ac_cv_header_alloca_h" 1>&4 +echo "$ac_t""$ac_cv_header_alloca_h" 1>&6 if test $ac_cv_header_alloca_h = yes; then cat >> confdefs.h <<\EOF #define HAVE_ALLOCA_H 1 @@ -1469,12 +1561,12 @@ EOF fi -echo $ac_n "checking for alloca""... $ac_c" 1>&4 -if eval "test \"`echo '${'ac_cv_func_alloca'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&4 +echo $ac_n "checking for alloca""... $ac_c" 1>&6 +if eval "test \"`echo '$''{'ac_cv_func_alloca'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 1478 "configure" +#line 1570 "configure" #include "confdefs.h" #ifdef __GNUC__ @@ -1508,7 +1600,7 @@ fi rm -f conftest* fi -echo "$ac_t""$ac_cv_func_alloca" 1>&4 +echo "$ac_t""$ac_cv_func_alloca" 1>&6 if test $ac_cv_func_alloca = yes; then cat >> confdefs.h <<\EOF #define HAVE_ALLOCA 1 @@ -1527,12 +1619,12 @@ if test $ac_cv_func_alloca = no; then EOF -echo $ac_n "checking whether alloca needs Cray hooks""... $ac_c" 1>&4 -if eval "test \"`echo '${'ac_cv_os_cray'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&4 +echo $ac_n "checking whether alloca needs Cray hooks""... $ac_c" 1>&6 +if eval "test \"`echo '$''{'ac_cv_os_cray'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 1536 "configure" +#line 1628 "configure" #include "confdefs.h" #if defined(CRAY) && ! defined(CRAY2) webecray @@ -1552,104 +1644,21 @@ fi rm -f conftest* fi -echo "$ac_t""$ac_cv_os_cray" 1>&4 +echo "$ac_t""$ac_cv_os_cray" 1>&6 if test $ac_cv_os_cray = yes; then -echo $ac_n "checking for _getb67""... $ac_c" 1>&4 -if eval "test \"`echo '${'ac_cv_func__getb67'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&4 -else - cat > conftest.$ac_ext <<EOF -#line 1563 "configure" -#include "confdefs.h" -#include <ctype.h> /* Arbitrary system header to define __stub macros. */ -/* Override any gcc2 internal prototype to avoid an error. */ -char _getb67(); - -int main() { return 0; } -int t() { - -/* The GNU C library defines this for functions which it implements - to always fail with ENOSYS. Some functions are actually named - something starting with __ and the normal name is an alias. */ -#if defined (__stub__getb67) || defined (__stub____getb67) -choke me -#else -_getb67(); -#endif - -; return 0; } -EOF -if eval $ac_link; then - rm -rf conftest* - eval "ac_cv_func__getb67=yes" -else - rm -rf conftest* - eval "ac_cv_func__getb67=no" -fi -rm -f conftest* - -fi -if eval "test \"`echo '$ac_cv_func_'_getb67`\" = yes"; then - echo "$ac_t""yes" 1>&4 - cat >> confdefs.h <<\EOF -#define CRAY_STACKSEG_END _getb67 -EOF - -else - echo "$ac_t""no" 1>&4 -echo $ac_n "checking for GETB67""... $ac_c" 1>&4 -if eval "test \"`echo '${'ac_cv_func_GETB67'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&4 +for ac_func in _getb67 GETB67 getb67; do + echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 +if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 1606 "configure" +#line 1656 "configure" #include "confdefs.h" -#include <ctype.h> /* Arbitrary system header to define __stub macros. */ -/* Override any gcc2 internal prototype to avoid an error. */ -char GETB67(); - -int main() { return 0; } -int t() { - -/* The GNU C library defines this for functions which it implements - to always fail with ENOSYS. Some functions are actually named - something starting with __ and the normal name is an alias. */ -#if defined (__stub_GETB67) || defined (__stub___GETB67) -choke me -#else -GETB67(); -#endif - -; return 0; } -EOF -if eval $ac_link; then - rm -rf conftest* - eval "ac_cv_func_GETB67=yes" -else - rm -rf conftest* - eval "ac_cv_func_GETB67=no" -fi -rm -f conftest* - -fi -if eval "test \"`echo '$ac_cv_func_'GETB67`\" = yes"; then - echo "$ac_t""yes" 1>&4 - cat >> confdefs.h <<\EOF -#define CRAY_STACKSEG_END GETB67 -EOF - -else - echo "$ac_t""no" 1>&4 -echo $ac_n "checking for getb67""... $ac_c" 1>&4 -if eval "test \"`echo '${'ac_cv_func_getb67'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&4 -else - cat > conftest.$ac_ext <<EOF -#line 1649 "configure" -#include "confdefs.h" -#include <ctype.h> /* Arbitrary system header to define __stub macros. */ +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $ac_func(); below. */ +#include <assert.h> /* Override any gcc2 internal prototype to avoid an error. */ -char getb67(); +char $ac_func(); int main() { return 0; } int t() { @@ -1657,49 +1666,47 @@ int t() { /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ -#if defined (__stub_getb67) || defined (__stub___getb67) +#if defined (__stub_$ac_func) || defined (__stub___$ac_func) choke me #else -getb67(); +$ac_func(); #endif ; return 0; } EOF if eval $ac_link; then rm -rf conftest* - eval "ac_cv_func_getb67=yes" + eval "ac_cv_func_$ac_func=yes" else rm -rf conftest* - eval "ac_cv_func_getb67=no" + eval "ac_cv_func_$ac_func=no" fi rm -f conftest* fi -if eval "test \"`echo '$ac_cv_func_'getb67`\" = yes"; then - echo "$ac_t""yes" 1>&4 - cat >> confdefs.h <<\EOF -#define CRAY_STACKSEG_END getb67 +if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then + echo "$ac_t""yes" 1>&6 + cat >> confdefs.h <<EOF +#define CRAY_STACKSEG_END $ac_func EOF + break else - echo "$ac_t""no" 1>&4 -fi - -fi - + echo "$ac_t""no" 1>&6 fi +done fi -echo $ac_n "checking stack direction for C alloca""... $ac_c" 1>&4 -if eval "test \"`echo '${'ac_cv_c_stack_direction'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&4 +echo $ac_n "checking stack direction for C alloca""... $ac_c" 1>&6 +if eval "test \"`echo '$''{'ac_cv_c_stack_direction'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 else if test "$cross_compiling" = yes; then ac_cv_c_stack_direction=0 else cat > conftest.$ac_ext <<EOF -#line 1703 "configure" +#line 1710 "configure" #include "confdefs.h" find_stack_direction () { @@ -1727,7 +1734,7 @@ fi fi rm -fr conftest* fi -echo "$ac_t""$ac_cv_c_stack_direction" 1>&4 +echo "$ac_t""$ac_cv_c_stack_direction" 1>&6 cat >> confdefs.h <<EOF #define STACK_DIRECTION $ac_cv_c_stack_direction EOF @@ -1744,6 +1751,9 @@ if test "$ac_cv_func_strcasecmp" = no; then STRCASECMP="strcasecmp.o"; fi if test "$ac_cv_func_strerror" = no; then STRERROR="strerror.o"; fi +############################################################################## +### Directory locations. + if test "x$prefix" != xNONE; then datadir=$prefix/share else @@ -1757,6 +1767,9 @@ cat >> confdefs.h <<EOF EOF +############################################################################## +### Makefile dependencies. + case x$srcdir in x) DEPEND=depend.out;; *) DEPEND=$srcdir/depend.out;; @@ -1765,10 +1778,11 @@ DEPEND_FILE=$DEPEND +############################################################################## +### Autoconf results generation. + trap '' 1 2 15 -if test -w $cache_file; then -echo "updating cache $cache_file" -cat > $cache_file <<\EOF +cat > confcache <<\EOF # This file is a shell script that caches the results of configure # tests run on this system so they can be shared between configure # scripts and configure runs. It is not useful on other systems. @@ -1784,15 +1798,24 @@ cat > $cache_file <<\EOF # --recheck option to rerun configure. # EOF -# Ultrix sh set writes to stderr and can't be redirected directly. +# Ultrix sh set writes to stderr and can't be redirected directly, +# and sets the high bit in the cache file unless we assign to the vars. (set) 2>&1 | - sed -n "s/^\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\)=\(.*\)/: \${\1='\2'}/p" \ - >> $cache_file + sed -n "s/^\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\)=\(.*\)/\1=\${\1='\2'}/p" \ + >> confcache +if cmp -s $cache_file confcache; then + : else -echo "not updating unwritable cache $cache_file" + if test -w $cache_file; then + echo "updating cache $cache_file" + cat confcache > $cache_file + else + echo "not updating unwritable cache $cache_file" + fi fi +rm -f confcache -trap 'rm -fr conftest* confdefs* core $ac_clean_files; exit 1' 1 2 15 +trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15 test "x$prefix" = xNONE && prefix=$ac_default_prefix # Let make expand exec_prefix. @@ -1815,7 +1838,7 @@ DEFS=-DHAVE_CONFIG_H echo creating $CONFIG_STATUS rm -f $CONFIG_STATUS cat > $CONFIG_STATUS <<EOF -#!/bin/sh +#! /bin/sh # Generated automatically by configure. # Run this file to recreate the current configuration. # This directory was configured as follows, @@ -1834,7 +1857,7 @@ do echo "running \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion" exec \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion ;; -version | --version | --versio | --versi | --vers | --ver | --ve | --v) - echo "$CONFIG_STATUS generated by autoconf version 2.1" + echo "$CONFIG_STATUS generated by autoconf version 2.2" exit 0 ;; -help | --help | --hel | --he | --h) echo "\$ac_cs_usage"; exit 0 ;; @@ -1845,7 +1868,7 @@ done ac_given_srcdir=$srcdir ac_given_INSTALL="$INSTALL" -trap 'rm -fr Makefile config.h conftest*; exit 1' 1 2 15 +trap 'rm -fr `echo Makefile config.h | tr : " "` conftest*; exit 1' 1 2 15 # Protect against being on the right side of a sed subst in config.status. sed 's/%@/@@/; s/@%/@@/; s/%g$/@g/; /@g$/s/[\\\\&%]/\\\\&/g; @@ -1906,7 +1929,7 @@ for ac_file in .. $CONFIG_FILES; do if test "x$ac_file" != x..; then if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then # The file is in a subdirectory. test ! -d "$ac_dir" && mkdir "$ac_dir" - ac_dir_suffix="/$ac_dir" + ac_dir_suffix="/`echo $ac_dir|sed 's%^\./%%'`" # A "../" for each directory in $ac_dir_suffix. ac_dots=`echo $ac_dir_suffix|sed 's%/[^/]*%../%g'` else @@ -2046,5 +2069,5 @@ exit 0 EOF chmod +x $CONFIG_STATUS rm -fr confdefs* $ac_clean_files -test "$no_create" = yes || ${CONFIG_SHELL-/bin/sh} $CONFIG_STATUS +test "$no_create" = yes || ${CONFIG_SHELL-/bin/sh} $CONFIG_STATUS || exit 1 diff --git a/configure.in b/configure.in index 3d8b63c..3c4755b 100644 --- a/configure.in +++ b/configure.in @@ -1,26 +1,38 @@ dnl Process this file with autoconf to produce a configure script. + +############################################################################## +### Autoconf setup + AC_INIT(mkid.c) AC_CONFIG_HEADER(config.h) +############################################################################## +### Package identification + PACKAGE=mkid -VERSION=3.0.8 -PREV_VERSION=3.0.7 +VERSION=3.0.9 +PREV_VERSION=3.0.8 AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE") AC_DEFINE_UNQUOTED(VERSION, "$VERSION") AC_SUBST(PACKAGE) AC_SUBST(VERSION) AC_SUBST(PREV_VERSION) -dnl Checks for programs. +############################################################################## +### Checks for programs. + AC_PROG_YACC AC_PROG_CC AC_PROG_LN_S AC_PROG_INSTALL AC_PROG_MAKE_SET -dnl Checks for libraries. +############################################################################## +### Checks for libraries. + +############################################################################## +### Checks for header files. -dnl Checks for header files. dnl AC_HEADER_DIRENT AC_HEADER_STDC AC_HEADER_SYS_WAIT @@ -28,24 +40,30 @@ AC_CHECK_HEADERS(limits.h stddef.h sys/types.h sys/stat.h sys/param.h) AC_CHECK_HEADERS(stdlib.h unistd.h string.h malloc.h memory.h assert.h ctype.h errno.h) AC_CHECK_HEADERS(sys/ioctl.h termios.h termio.h sgtty.h regex.h) -dnl Checks for typedefs, structures, and compiler characteristics. -AC_C_CONST +############################################################################## +### Checks for typedefs, structures, and compiler characteristics. + fp_C_PROTOTYPES +AC_C_CONST AC_TYPE_SIGNAL AC_TYPE_OFF_T AC_TYPE_SIZE_T +AC_CHECK_TYPE(dev_t, unsigned short) +AC_CHECK_TYPE(ino_t, unsigned long) CFLAGS=${CFLAGS--g} LDFLAGS=${LDFLAGS--g} AC_SUBST(CFLAGS) AC_SUBST(LDFLAGS) -dnl Checks for library functions. +############################################################################## +### Checks for library functions & system calls. + AC_PROG_GCC_TRADITIONAL AC_CHECK_FUNCS(getwd getcwd getopt_long basename dirname) AC_CHECK_FUNCS(strdup strchr strrchr strcasecmp strerror) AC_CHECK_FUNCS(memcpy bcopy memset bzero) -AC_CHECK_FUNCS(regcomp regcmp re_comp) +AC_CHECK_FUNCS(regcomp regcmp re_comp link) AC_FUNC_ALLOCA AC_SUBST(ALLOCA) if test "$ac_cv_func_re_comp" = no; then REGEXP="regex.o"; fi @@ -57,6 +75,9 @@ AC_SUBST(STRCASECMP) if test "$ac_cv_func_strerror" = no; then STRERROR="strerror.o"; fi AC_SUBST(STRERROR) +############################################################################## +### Directory locations. + if test "x$prefix" != xNONE; then datadir=$prefix/share else @@ -67,6 +88,9 @@ AC_SUBST(datadir) AC_SUBST(IID_HELP_FILE) AC_DEFINE_UNQUOTED(IID_HELP_FILE, "$datadir/iid.help") +############################################################################## +### Makefile dependencies. + case x$srcdir in x) DEPEND=depend.out;; *) DEPEND=$srcdir/depend.out;; @@ -75,5 +99,8 @@ DEPEND_FILE=$DEPEND AC_SUBST(DEPEND) AC_SUBST_FILE(DEPEND_FILE) +############################################################################## +### Autoconf results generation. + AC_OUTPUT(Makefile, [test -z "$CONFIG_HEADERS" || echo timestamp >stamp-h]) @@ -1,20 +1,18 @@ -mkid$o: mkid.c config.h strxtra.h alloc.h idfile.h idarg.h token.h bitops.h misc.h \ +mkid$o: mkid.c strxtra.h alloc.h idfile.h hash.h token.h bitops.h misc.h \ filenames.h scanners.h -lid$o: lid.c config.h alloc.h idfile.h idarg.h token.h bitops.h strxtra.h misc.h \ - filenames.h -fid$o: fid.c config.h idfile.h idarg.h bitops.h filenames.h misc.h strxtra.h \ - alloc.h token.h -idx$o: idx.c config.h misc.h filenames.h scanners.h -misc$o: misc.c config.h strxtra.h misc.h -scanners$o: scanners.c config.h strxtra.h token.h alloc.h scanners.h -idfile$o: idfile.c config.h alloc.h idfile.h idarg.h strxtra.h -filenames$o: filenames.c config.h strxtra.h filenames.h misc.h -bitops$o: bitops.c config.h bitops.h -token$o: token.c config.h token.h -regex$o: regex.c config.h regex.h +lid$o: lid.c alloc.h idfile.h hash.h token.h bitops.h strxtra.h misc.h filenames.h +fid$o: fid.c idfile.h hash.h bitops.h filenames.h misc.h strxtra.h alloc.h token.h +idx$o: idx.c misc.h filenames.h scanners.h +misc$o: misc.c strxtra.h misc.h +scanners$o: scanners.c strxtra.h token.h alloc.h scanners.h +idfile$o: idfile.c alloc.h idfile.h hash.h strxtra.h +filenames$o: filenames.c strxtra.h filenames.h misc.h error.h +bitops$o: bitops.c bitops.h +token$o: token.c token.h +regex$o: regex.c regex.h alloca$o: alloca.c getopt$o: getopt.c getopt1$o: getopt1.c getopt.h strcasecmp$o: strcasecmp.c strerror$o: strerror.c -iid$o: iid.c ./config.h ./strxtra.h +iid$o: iid.c ./strxtra.h ./obstack.h ./xmalloc.h @@ -22,7 +22,6 @@ #include <config.h> #include "idfile.h" -#include "idarg.h" #include "bitops.h" #include "filenames.h" #include "misc.h" @@ -51,7 +50,7 @@ usage (void) int main (int argc, char **argv) { - char const *id_file = IDFILE; + char const *id_file_name = IDFILE; char *buf; int op; int i; @@ -76,7 +75,7 @@ main (int argc, char **argv) switch (*arg++) { case 'f': - id_file = arg; + id_file_name = arg; goto nextarg; default: usage (); @@ -85,18 +84,13 @@ main (int argc, char **argv) } argsdone: - id_file = look_up (id_file); - if (id_file == NULL) + id_file_name = find_id_file (id_file_name); + if (id_file_name == NULL) { - filerr ("open", id_file); - return 1; - } - id_FILE = init_idfile (id_file, &idh, &idarg_0); - if (id_FILE == NULL) - { - filerr ("open", id_file); + filerr ("open", id_file_name); return 1; } + id_FILE = init_id_file (id_file_name, &idh, &idarg_0); switch (argc) { case 2: @@ -114,7 +108,7 @@ argsdone: buf = MALLOC (char, idh.idh_buf_size); fseek (id_FILE, idh.idh_tokens_offset, 0); - tree8_levels = tree8_count_levels (idh.idh_paths); + tree8_levels = tree8_count_levels (idh.idh_files); for (i = 0; i < idh.idh_tokens; i++) { @@ -134,7 +128,7 @@ get_idarg_index (char const *file_name) { struct idarg *idarg; int file_name_length = strlen (file_name); - struct idarg *end = &idarg_0[idh.idh_paths]; + struct idarg *end = &idarg_0[idh.idh_files]; for (idarg = idarg_0; idarg < end; ++idarg) { diff --git a/filenames.c b/filenames.c index 20c0c23..ad6a23d 100644 --- a/filenames.c +++ b/filenames.c @@ -20,7 +20,6 @@ #include <unistd.h> #include <string.h> #include <stdio.h> -#include <sys/param.h> #include <sys/types.h> #include <sys/stat.h> @@ -28,116 +27,100 @@ #include "strxtra.h" #include "filenames.h" #include "misc.h" +#include "error.h" + +#ifdef S_IFLNK +static char const *unsymlink __P((char *n)); +#endif +static void canonical_name __P((char *n)); +static char const *lex_name __P((void)); +static int same_link __P((struct stat *x, struct stat *y)); + +FILE *popen (); /* relative_file_name takes two arguments: - * 1) an absolute path name for a directory. - * (This name MUST have a trailing /). - * 2) an absolute path name for a file. - * - * It looks for common components at the front of the file and - * directory names and generates a relative path name for the file - * (relative to the specified directory). - * - * This may result in a huge number of ../s if the names - * have no components in common. - * - * The output from this concatenated with the input directory name - * and run through span_file_name should result in the original input - * absolute path name of the file. - * - * Examples: - * dir arg return value - * /x/y/z/ /x/y/q/file -> ../q/file - * /x/y/z/ /q/t/p/file -> ../../../q/t/p/file - * /x/y/z/ /x/y/z/file -> file - */ + 1) an absolute path name for a directory. (*must* have a trailing "/"). + 2) an absolute path name for a file. + + It looks for a common directory prefix and generates a name for the + given file that is relative to the given directory. The result + might begin with a long sequence of "../"s, if the given names are + long but have a short common prefix. + + (Note: If the the result of relative_file_name is appended to its + directory argument and passed to span_file_name, span_file_name's + result should match relative_file_name's file name argument.) + + Examples: + dir arg return value + /x/y/z/ /x/y/q/file ../q/file + /x/y/z/ /q/t/p/file ../../../q/t/p/file + /x/y/z/ /x/y/z/file file */ + char const * -relative_file_name (char const *dir, char const *arg) +relative_file_name (char const *dir_name, char const *file_name) { - char const *a; - char const *d; - char const *lasta; - char const *lastd; - static char file_name_buffer[BUFSIZ]; - char *buf = file_name_buffer; - - lasta = a = arg; - lastd = d = dir; - while (*a == *d) + static char file_name_buffer[MAXPATHLEN]; + char *bp = file_name_buffer; + + while (*file_name && *file_name++ == *dir_name++) + ; + while (*--dir_name != '/') + ; + dir_name++; + while (*--file_name != '/') + ; + file_name++; + /* file_name and dir_name now point past their common directory prefix */ + + /* copy "../" into the buffer for each component of the directory + that remains. */ + + while (*dir_name) { - if (*a == '/') + if (*dir_name++ == '/') { - lasta = a; - lastd = d; + strcpy (bp, "../"); + bp += 3; } - ++a; - ++d; } - /* lasta and lastd now point to the last / in each - * file name where the leading file components were - * identical. - */ - ++lasta; - ++lastd; - /* copy a ../ into the buffer for each component of - * the directory that remains. - */ - - while (*lastd != '\0') - { - if (*lastd == '/') - { - strcpy (buf, "../"); - buf += 3; - } - ++lastd; - } - /* now tack on remainder of arg */ - strcpy (buf, lasta); + + strcpy (bp, file_name); return file_name_buffer; } -/* span_file_name accepts a directory name and a file name and returns - a cannonical form of the full file name within that directory. It - gets rid of ./ and things like that. If the file is an absolute - name then the directory is ignored. */ +/* span_file_name accepts a canonical directory name and a file name + and returns a canonical path to the file name relative to the + directory. If the file name is absolute, then the directory is + ignored. */ + char const * -span_file_name (char const *dir, char const *arg) +span_file_name (char const *dir_name, char const *file_name) { - char *argptr; - static char file_name_buffer[BUFSIZ]; - - /* reduce directory to cannonical form */ - strcpy (file_name_buffer, dir); - cannoname (file_name_buffer); - /* tack the obilgatory / on the end */ - strcat (file_name_buffer, "/"); - /* stick file name in buffer after directory */ - argptr = file_name_buffer + strlen (file_name_buffer); - strcpy (argptr, arg); - /* and reduce it to cannonical form also */ - cannoname (argptr); + char *fnp; + static char file_name_buffer[MAXPATHLEN]; + + strcpy (file_name_buffer, dir_name); + fnp = file_name_buffer + strlen (file_name_buffer); + *fnp++ = '/'; + strcpy (fnp, file_name); + canonical_name (fnp); /* If it is an absolute name, just return it */ - if (*argptr == '/') - return argptr; - /* otherwise, combine the names to cannonical form */ - cannoname (file_name_buffer); + if (*fnp == '/') + return fnp; + /* otherwise, combine the names to canonical form */ + canonical_name (file_name_buffer); return file_name_buffer; } -/* root_name returns the base name of the file with any leading - * directory information or trailing suffix stripped off. Examples: - * - * /usr/include/stdio.h -> stdio - * fred -> fred - * barney.c -> barney - * bill/bob -> bob - * / -> < null string > - */ +/* root_name strips off the directory prefix and one suffix. If there + is neither prefix nor suffix, (i.e., "/"), it returns the empty + string. */ + char const * root_name (char const *path) { - static char file_name_buffer[BUFSIZ]; + static char file_name_buffer[MAXPATHLEN]; char const *root; char const *dot; @@ -158,15 +141,9 @@ root_name (char const *path) return file_name_buffer; } -/* suff_name returns the suffix (including the dot) or a null string - * if there is no suffix. Examples: - * - * /usr/include/stdio.h -> .h - * fred -> < null string > - * barney.c -> .c - * bill/bob -> < null string > - * / -> < null string > - */ +/* suff_name returns the suffix (including the dot), or the + empty-string if there is none. */ + char const * suff_name (char const *path) { @@ -178,66 +155,57 @@ suff_name (char const *path) return dot; } -int -can_crunch (char const *path1, char const *path2) +/* Return non-zero if the two stat bufs refer to the same file or + directory */ + +static int +same_link (struct stat *x, struct stat *y) { - char const *slash1; - char const *slash2; - - slash1 = strrchr (path1, '/'); - slash2 = strrchr (path2, '/'); - - if (slash1 == NULL && slash2 == NULL) - return strequ (suff_name (path1), suff_name (path2)); - if ((slash1 - path1) != (slash2 - path2)) - return 0; - if (!strnequ (path1, path2, slash1 - path1)) - return 0; - return strequ (suff_name (slash1), suff_name (slash2)); + return ((x->st_ino == y->st_ino) && (x->st_dev == y->st_dev)); } -/* look_up adds ../s to the beginning of a file name until it finds - * the one that really exists. Returns NULL if it gets all the way - * to / and never finds it. - * - * If the file name starts with /, just return it as is. - * - * This routine is used to locate the ID database file. - */ +/* find_id_file adds "../"s to the beginning of a file name until it + finds the one that really exists. If the file name starts with + "/", just return it as is. If we fail for any reason, report the + error and exit. */ + char const * -look_up (char const *arg) +find_id_file (char const *arg) { - static char file_name_buffer[BUFSIZ]; - char *buf = file_name_buffer; - struct stat rootb; - struct stat statb; + static char file_name_buffer[MAXPATHLEN]; + char *name; + char *dir_end; + struct stat root_buf; + struct stat stat_buf; - /* if we got absolute name, just use it. */ if (arg[0] == '/') return arg; - /* if the name we were give exists, don't bother searching */ - if (stat (arg, &statb) == 0) + if (stat (arg, &stat_buf) == 0) return arg; - /* search up the tree until we find a directory where this - * relative file name is visible. - * (or we run out of tree to search by hitting root). - */ - if (stat ("/", &rootb) != 0) - return NULL; + name = &file_name_buffer[sizeof (file_name_buffer) - strlen (arg) - 1]; + strcpy (name, arg); + dir_end = name - 1; + + if (stat ("/", &root_buf) < 0) + { + error (1, errno, "Can't stat `/'"); + return NULL; + } do { - strcpy (buf, "../"); - buf += 3; - strcpy (buf, arg); - if (stat (file_name_buffer, &statb) == 0) - return file_name_buffer; - *buf = '\0'; - if (stat (file_name_buffer, &statb) != 0) + *--name = '/'; + *--name = '.'; + *--name = '.'; + if (stat (name, &stat_buf) == 0) + return name; + *dir_end = '\0'; + if (stat (name, &stat_buf) < 0) return NULL; + *dir_end = '/'; } - while (!((statb.st_ino == rootb.st_ino) || - (statb.st_dev == rootb.st_dev))); + while (name >= &file_name_buffer[3] && !same_link(&stat_buf, &root_buf)); + error (1, errno, "Can't stat `%s' anywhere between here and `/'", arg); return NULL; } @@ -255,123 +223,101 @@ static char dotdot[] = ".."; static char const *nextc = NULL; static char *namep; -/* lexname - Return next name component. Uses global variables initialized - * by cannoname to figure out what it is scanning. +/* lex_name - Return next name component. Uses global variables initialized + * by canonical_name to figure out what it is scanning. */ static char const * -lexname (void) +lex_name (void) { char c; char const *d; - if (nextc) + if (nextc == NULL) + return NULL; + + c = *nextc++; + if (c == '\0') { - c = *nextc++; - if (c == '\0') - { - nextc = NULL; - return NULL; - } - if (c == '/') - { - return &slash[0]; - } - if (c == '.') - { - if ((*nextc == '/') || (*nextc == '\0')) - return &dot[0]; - if (*nextc == '.' && (*(nextc + 1) == '/' || *(nextc + 1) == '\0')) - { - ++nextc; - return &dotdot[0]; - } - } - d = namep; - *namep++ = c; - while ((c = *nextc) != '/') + nextc = NULL; + return NULL; + } + if (c == '/') + return slash; + if (c == '.') + { + if ((*nextc == '/') || (*nextc == '\0')) + return dot; + if (*nextc == '.' && (*(nextc + 1) == '/' || *(nextc + 1) == '\0')) { - *namep++ = c; - if (c == '\0') - { - nextc = NULL; - return d; - } ++nextc; + return dotdot; } - *namep++ = '\0'; - return d; } - else + d = namep; + *namep++ = c; + while ((c = *nextc) != '/') { - return NULL; + *namep++ = c; + if (c == '\0') + { + nextc = NULL; + return d; + } + ++nextc; } + *namep++ = '\0'; + return d; } -/* cannoname - Put a file name in cannonical form. Looks for all the - * whacky wonderful things a demented *ni* programmer might put - * in a file name and reduces the name to cannonical form. - */ -void -cannoname (char *n) +/* canonical_name puts a file name in canonical form. It looks for all + the whacky wonderful things a demented *ni* programmer might put in + a file name and reduces the name to canonical form. */ + +static void +canonical_name (char *file_name) { char const *components[1024]; - char const **cap = &components[0]; + char const **cap = components; char const **cad; char const *cp; - char namebuf[2048]; + char name_buf[2048]; char const *s; /* initialize scanner */ - nextc = n; - namep = &namebuf[0]; - - /* break the file name into individual components */ - while ((cp = lexname ())) - { - *cap++ = cp; - } + nextc = file_name; + namep = name_buf; - /* If name is empty, leave it that way */ - if (cap == &components[0]) + while ((cp = lex_name ())) + *cap++ = cp; + if (cap == components) return; - - /* flag end of component list */ *cap = NULL; /* remove all trailing slashes and dots */ - while ((--cap != &components[0]) && - ((*cap == &slash[0]) || (*cap == &dot[0]))) + while ((--cap != components) && + ((*cap == slash) || (*cap == dot))) *cap = NULL; - /* squeeze out all . / component sequences */ - cap = &components[0]; - cad = cap; + /* squeeze out all "./" sequences */ + cad = cap = components; while (*cap) { - if ((*cap == &dot[0]) && (*(cap + 1) == &slash[0])) - { - cap += 2; - } + if ((*cap == dot) && (*(cap + 1) == slash)) + cap += 2; else - { - *cad++ = *cap++; - } + *cad++ = *cap++; } *cad++ = NULL; /* find multiple // and use last slash as root, except on apollo which - * apparently actually uses // in real file names (don't ask me why). - */ + apparently actually uses // in real file names (don't ask me why). */ #ifndef apollo s = NULL; - cap = &components[0]; - cad = cap; + cad = cap = components; while (*cap) { - if ((s == &slash[0]) && (*cap == &slash[0])) - { - cad = &components[0]; - } + if ((s == slash) && (*cap == slash)) + cad = components; s = *cap++; *cad++ = s; } @@ -379,16 +325,15 @@ cannoname (char *n) #endif /* if this is absolute name get rid of any /.. at beginning */ - if ((components[0] == &slash[0]) && (components[1] == &dotdot[0])) + if ((components[0] == slash) && (components[1] == dotdot)) { - cap = &components[1]; - cad = cap; - while (*cap == &dotdot[0]) + cad = cap = &components[1]; + while (*cap == dotdot) { ++cap; if (*cap == NULL) break; - if (*cap == &slash[0]) + if (*cap == slash) ++cap; } while (*cap) @@ -397,13 +342,11 @@ cannoname (char *n) } /* squeeze out any name/.. sequences (but leave leading ../..) */ - cap = &components[0]; + cap = components; cad = cap; while (*cap) { - if ((*cap == &dotdot[0]) && - ((cad - 2) >= &components[0]) && - ((*(cad - 2)) != &dotdot[0])) + if ((*cap == dotdot) && ((cad - 2) >= components) && (*(cad - 2) != dotdot)) { cad -= 2; ++cap; @@ -411,117 +354,104 @@ cannoname (char *n) ++cap; } else - { - *cad++ = *cap++; - } + *cad++ = *cap++; } /* squeezing out a trailing /.. can leave unsightly trailing /s */ - if ((cad >= &components[2]) && ((*(cad - 1)) == &slash[0])) + if ((cad >= &components[2]) && ((*(cad - 1)) == slash)) --cad; *cad = NULL; /* if it was just name/.. it now becomes . */ if (components[0] == NULL) { - components[0] = &dot[0]; + components[0] = dot; components[1] = NULL; } /* re-assemble components */ - cap = &components[0]; + cap = components; while ((s = *cap++)) { while (*s) - *n++ = *s++; + *file_name++ = *s++; } - *n++ = '\0'; + *file_name++ = '\0'; } -/* kshgetwd is a routine that acts just like getwd, but is optimized - * for ksh users, taking advantage of the fact that ksh maintains - * an environment variable named PWD holding path name of the - * current working directory. - * - * The primary motivation for this is not really that it is algorithmically - * simpler, but that it is much less likely to bother NFS if we can just - * guess the name of the current working directory using the hint that - * ksh maintains. Anything that avoids NFS gettar failed messages is - * worth doing. - */ +/* get_PWD is an optimized getwd(3) or getcwd(3) that takes advantage + of the shell's $PWD environment-variable, if present. This is + particularly worth doing on NFS mounted filesystems. */ + char const * -kshgetwd (char *pathname) +get_PWD (char *pwd_buf) { - struct stat kshstat, dotstat; - char kshname[MAXPATHLEN]; - char const *kshp; + struct stat pwd_stat; + struct stat dot_stat; + char *pwd = getenv ("PWD"); - kshp = getenv ("PWD"); - if (kshp) + if (pwd) { - /* OK, there was a PWD environment variable */ - strcpy (kshname, kshp); - if (unsymlink (kshname) - /* And we could resolve the symbolic links through it */ - && kshname[0] == '/' - /* And the name we have is an absolute path name */ - && stat (kshname, &kshstat) == 0 - /* And we can stat the name */ - && stat (".", &dotstat) == 0 - /* And we can stat "." */ - && (kshstat.st_dev == dotstat.st_dev) - && (kshstat.st_ino == dotstat.st_ino)) - /* By golly, that name is the same file as "." ! */ - return strcpy (pathname, kshname); + pwd = strcpy (pwd_buf, pwd); + if (pwd[0] != '/' + || stat (".", &dot_stat) < 0 + || stat (pwd, &pwd_stat) < 0 + || !same_link(&pwd_stat, &dot_stat) +#ifdef S_IFLNK + || !unsymlink (pwd) + || pwd[0] != '/' + || stat (pwd, &pwd_stat) < 0 + || !same_link(&pwd_stat, &dot_stat) +#endif + ) + pwd = 0; } - /* Oh well, something did not work out right, do it the hard way */ + if (pwd == 0) + { + /* Oh well, something did not work out right, so do it the hard way... */ #if HAVE_GETCWD - return getcwd (pathname, BUFSIZ); + pwd = getcwd (pwd_buf, MAXPATHLEN); #else #if HAVE_GETWD - return getwd (pathname); + pwd = getwd (pwd_buf); #endif #endif + } + if (pwd) + strcat (pwd, "/"); + else + error (1, errno, "Can't determine current working directory!"); + + return pwd; } -/* unsymlink is a routine that resolves all symbolic links in - * a file name, transforming a name to the "actual" file name - * instead of the name in terms of symbolic links. - * - * If it can resolve all links and discover an actual file - * it returns a pointer to its argument string and transforms - * the argument in place to the actual name. - * - * If no such actual file exists, or for some reason the links - * cannot be resolved, it returns a NULL pointer and leaves the - * name alone. - */ -char const * -unsymlink (char *n) +#ifdef S_IFLNK + +/* unsymlink resolves all symbolic links in a file name into hard + links. If successful, it returns its argument and transforms + the file name in situ. If unsuccessful, it returns NULL, and leaves + the argument untouched. */ + +static char const * +unsymlink (char *file_name_buf) { - char newname[MAXPATHLEN]; - char partname[MAXPATHLEN]; - char linkname[MAXPATHLEN]; + char new_buf[MAXPATHLEN]; + char part_buf[MAXPATHLEN]; + char link_buf[MAXPATHLEN]; char const *s; char *d; char *lastcomp; - int linksize; - struct stat statb; - - /* Just stat the file to automagically do all the symbolic - * link verification checks and make sure we have access to - * directories, etc. - */ - if (stat (n, &statb) != 0) - return NULL; - strcpy (newname, n); + struct stat stat_buf; + + strcpy (new_buf, file_name_buf); + /* Now loop, lstating each component to see if it is a symbolic - * link. For symbolic link components, use readlink() to get - * the real name, put the read link name in place of the - * last component, and start again. - */ - cannoname (newname); - s = &newname[0]; - d = &partname[0]; + link. For symbolic link components, use readlink() to get the + real name, put the read link name in place of the last component, + and start again. */ + + canonical_name (new_buf); + s = new_buf; + d = part_buf; if (*s == '/') *d++ = *s++; lastcomp = d; @@ -531,28 +461,25 @@ unsymlink (char *n) { /* we have a complete component name in partname, check it out */ *d = '\0'; - if (lstat (partname, &statb) != 0) + if (lstat (part_buf, &stat_buf) < 0) return NULL; - if ((statb.st_mode & S_IFMT) == S_IFLNK) + if ((stat_buf.st_mode & S_IFMT) == S_IFLNK) { /* This much of name is a symbolic link, do a readlink - * and tack the bits and pieces together - */ - linksize = readlink (partname, linkname, MAXPATHLEN); - if (linksize < 0) + and tack the bits and pieces together */ + int link_size = readlink (part_buf, link_buf, MAXPATHLEN); + if (link_size < 0) return NULL; - linkname[linksize] = '\0'; - strcpy (lastcomp, linkname); - lastcomp += linksize; + link_buf[link_size] = '\0'; + strcpy (lastcomp, link_buf); + lastcomp += link_size; strcpy (lastcomp, s); - strcpy (newname, partname); - cannoname (newname); - s = &newname[0]; - d = &partname[0]; + strcpy (new_buf, part_buf); + canonical_name (new_buf); + s = new_buf; + d = part_buf; if (*s == '/') - { - *d++ = *s++; - } + *d++ = *s++; lastcomp = d; } else @@ -569,10 +496,12 @@ unsymlink (char *n) *d++ = *s++; } } - strcpy (n, newname); - return n; + strcpy (file_name_buf, new_buf); + return file_name_buf; } +#endif + FILE * open_source_FILE (char *file_name, char const *filter) { diff --git a/filenames.h b/filenames.h index 587e16a..6d5b9f2 100644 --- a/filenames.h +++ b/filenames.h @@ -19,18 +19,18 @@ #ifndef _filenames_h_ #define _filenames_h_ -char const *relative_file_name __P((char const *dir, char const *arg)); +#include <sys/param.h> +#ifndef MAXPATHLEN +#define MAXPATHLEN 1024 +#endif + +char const *relative_file_name __P((char const *dir_name, char const *file_name)); char const *span_file_name __P((char const *dir, char const *arg)); char const *root_name __P((char const *path)); char const *suff_name __P((char const *path)); -int can_crunch __P((char const *path1, char const *path2)); -char const *look_up __P((char const *arg)); -void cannoname __P((char *n)); -char const *kshgetwd __P((char *pathname)); -char const *unsymlink __P((char *n)); +char const *find_id_file __P((char const *arg)); +char const *get_PWD __P((char *pathname)); FILE *open_source_FILE __P((char *file_name, char const *filter)); void close_source_FILE __P((FILE *fp, char const *filter)); -char const *get_sccs __P((char const *dir, char const *base, char const *sccs_dir)); -char const *co_rcs __P((char const *dir, char const *base, char const *rcs_dir)); #endif /* not _filenames_h_ */ @@ -1,22 +1,33 @@ -;;; put this in your GnuEmacs startup file '~/.emacs' . -;;; or autoload it from some other file. -wsr +;;; put this in your GNU emacs startup file '~/.emacs' . +;;; or byte-compile it and autoload from somewhere else. -(require 'symfunc) +(require 'compile) +(provide 'gid) -(defun gid (command) - "Run gid, with user-specified args, and collect output in a buffer. -While gid runs asynchronously, you can use the \\[next-error] command -to find the text that gid hits refer to." - (interactive (list (read-input "Run gid (with args): " - (symbol-around-point)))) - (require 'compile) - (setq command (concat "gid " command)) - (compile1 command "No more gid hits" command)) +(defvar gid-command "gid" "The command run by the gid function.") -(defun aid (command) - "Run aid, with user-specified args, and collect output in a buffer." - (interactive (list (read-input "Run aid (with args): " - (symbol-around-point)))) - (require 'compile) - (setq command (concat "aid " command)) - (compile1 command "No aid hits" command)) +(defun gid (args) + "Run gid, with user-specified ARGS, and collect output in a buffer. +While gid runs asynchronously, you can use the \\[next-error] command to +find the text that gid hits refer to. The command actually run is +defined by the gid-command variable." + (interactive (list (read-input + (concat "Run " gid-command " (with args): ") (word-around-point)))) + (let (compile-command + (compilation-error-regexp-alist grep-regexp-alist) + (compilation-buffer-name-function (lambda (mode) + (concat "*" gid-command " " args "*")))) + ;; For portability to v19, use compile rather than compile-internal. + (compile (concat gid-command " " args)))) + +(defun word-around-point () + "Return the word around the point as a string." + (save-excursion + (if (not (eobp)) + (forward-char 1)) + (forward-word -1) + (forward-word 1) + (forward-sexp -1) + (buffer-substring (point) (progn + (forward-sexp 1) + (point))))) @@ -22,7 +22,6 @@ #include <config.h> #include "alloc.h" #include "idfile.h" -#include "idarg.h" #include "strxtra.h" typedef int (*iof_t) __P((FILE *, void *, unsigned int, int)); @@ -33,39 +32,53 @@ static int io_size __P((FILE *, void *, unsigned int size, int)); extern char *program_name; -/* init_id opens id_file, reads the header into idhp (and verifies the magic - * number), then builds the id_args list holding the names of all the - * files recorded in the database. - */ +/* init_id_file opens the ID file, reads header fields into idh, + verifies the magic number and version, and reads the constituent + file names. Any errors are considered fatal and cause an exit. */ + +FILE * +init_id_file (char const *id_file_name, struct idhead *idh) +{ + FILE *id_FILE = maybe_init_id_file (id_file_name, idh); + if (id_FILE) + return id_FILE; + error (1, errno, "Can't open `%s'", id_file_name); + return NULL; +} + +/* maybe_init_id_file does everything that init_id_file does, but is + tolerant of errors opening the ID file, returning NULL in this case + (this is called from mkid where an ID might or might not already + exist). All other errors are considered fatal. */ + FILE * -init_idfile (char const *id_file, struct idhead *idh, struct idarg **id_args) +maybe_init_id_file (char const *id_file_name, struct idhead *idh) { FILE *id_FILE; unsigned int i; char *strings; struct idarg *ida; - id_FILE = fopen (id_file, "r"); + id_FILE = fopen (id_file_name, "r"); if (id_FILE == NULL) return NULL; read_idhead (id_FILE, idh); if (idh->idh_magic[0] != IDH_MAGIC_0 || idh->idh_magic[1] != IDH_MAGIC_1) - { - fprintf (stderr, "%s: Not an id file: `%s'\n", program_name, id_file); - exit (1); - } + error (1, 0, "`%s' is not an ID file! (bad magic #)", id_file_name); if (idh->idh_version != IDH_VERSION) - { - fprintf (stderr, "%s: ID version mismatch (want: %d, got: %d)\n", program_name, IDH_VERSION, idh->idh_version); - exit (1); - } + error (1, 0, "`%s' is version %d, but I only grok version %d", + id_file_name, idh->idh_version, IDH_VERSION); fseek (id_FILE, idh->idh_args_offset, 0); - strings = malloc (i = idh->idh_tokens_offset - idh->idh_args_offset); + /* NEEDSWORK */ + fseek (id_FILE, idh->idh_files_offset, 0); + + i = idh->idh_tokens_offset - idh->idh_args_offset; + strings = malloc (i); fread (strings, i, 1, id_FILE); - ida = *id_args = CALLOC (struct idarg, idh->idh_paths); - for (i = 0; i < idh->idh_paths; i++) + ida = *id_args = CALLOC (struct idarg, idh->idh_files); + for (i = 0; i < idh->idh_files; i++) { while (*strings == '+' || *strings == '-') { @@ -84,6 +97,39 @@ init_idfile (char const *id_file, struct idhead *idh, struct idarg **id_args) return id_FILE; } + +unsigned long +file_link_hash_1 (void const *key) +{ + unsigned long result = 0; + ADDRESS_HASH_1 (((struct file_link const *) key)->fl_parent, result); + STRING_HASH_1 (((struct file_link const *) key)->fl_name, result); + return result; +} + +unsigned long +file_link_hash_2 (void const *key) +{ + unsigned long result = 0; + ADDRESS_HASH_2 (((struct file_link const *) key)->fl_parent, result); + STRING_HASH_2 (((struct file_link const *) key)->fl_name, result); + return result; +} + +int +file_link_hash_cmp (void const *x, void const *y) +{ + int result; + ADDRESS_CMP (((struct file_link const *) x)->fl_parent, + ((struct file_link const *) y)->fl_parent, result); + if (result) + return result; + STRING_CMP (((struct file_link const *) x)->fl_name, + ((struct file_link const *) y)->fl_name, result); + return result; +} + + int read_idhead (FILE *input_FILE, struct idhead *idh) { @@ -181,14 +227,15 @@ static int io_idhead (FILE *fp, iof_t iof, struct idhead *idh) { unsigned int size = 0; + unsigned char pad = 0; if (fp) fseek (fp, 0L, 0); size += iof (fp, idh->idh_magic, 2, 0); - size += iof (fp, &idh->idh_pad_1, 1, 0); + size += iof (fp, &pad, 1, 0); size += iof (fp, &idh->idh_version, 1, 0); size += iof (fp, &idh->idh_flags, 2, 1); - size += iof (fp, &idh->idh_args, 4, 1); - size += iof (fp, &idh->idh_paths, 4, 1); + size += iof (fp, &idh->idh_links, 4, 1); + size += iof (fp, &idh->idh_files, 4, 1); size += iof (fp, &idh->idh_tokens, 4, 1); size += iof (fp, &idh->idh_buf_size, 4, 1); size += iof (fp, &idh->idh_vec_size, 4, 1); @@ -1,4 +1,4 @@ -/* idfile.h -- defs for mkid database file header & interface to idfile.c +/* idfile.h -- decls for ID file header and constituent file names Copyright (C) 1986, 1995 Greg McGary This program is free software; you can redistribute it and/or modify @@ -21,6 +21,7 @@ #include <sys/types.h> #include <stdio.h> +#include "hash.h" #define IDFILE "ID" @@ -29,24 +30,71 @@ struct idhead unsigned char idh_magic[2]; #define IDH_MAGIC_0 ('I'|0x80) #define IDH_MAGIC_1 ('D'|0x80) - unsigned char idh_pad_1; unsigned char idh_version; #define IDH_VERSION 3 unsigned short idh_flags; -#define IDH_COUNTS 0x0001 /* occurrence counts are included with each token */ - unsigned long idh_args; /* total # of args for mkid update */ - unsigned long idh_paths; /* total # of file names for mkid update */ - unsigned long idh_tokens; /* total # of tokens */ - unsigned long idh_buf_size; /* # of bytes in longest entry (bufsiz for lid) */ - unsigned long idh_vec_size; /* # of hits in longest entry (max vector size for lid) */ - long idh_args_offset; /* file offset of args */ - long idh_tokens_offset; /* file offset of tokens section */ - long idh_end_offset; /* file offset beyond tokens section */ +#define IDH_COUNTS 0x0001 /* include occurrence counts for each token */ +#define IDH_FOLLOW_SL 0x0002 /* follow symlinks to directories */ +#define IDH_COMMENTS 0x0004 /* include tokens found in comments */ +#define IDH_LOCALS 0x0008 /* include names of formal params & local vars */ +#define IDH_DECL_DEFN_USE 0x0100 /* include decl/defn/use info */ +#define IDH_L_R_VALUE 0x0200 /* include lvalue/rvalue info */ +#define IDH_CALL_ER_EE 0x0400 /* include caller/callee relationship info */ + unsigned long idh_links; /* total # of file name components */ + unsigned long idh_files; /* total # of constituent source files */ + unsigned long idh_tokens; /* total # of constituent tokens */ + /* idh_*_size: max buffer-sizes for ID file reading programs */ + unsigned long idh_buf_size; /* # of bytes in longest entry */ + unsigned long idh_vec_size; /* # of hits in longest entry */ + unsigned long idh_path_size; /* # of bytes in longest file name path */ + /* idh_*_offset: ID file offsets for start of various sections */ + long idh_args_offset; /* command-line options section */ + long idh_files_offset; /* constituent file & directory names section */ + long idh_tokens_offset; /* constituent tokens section */ + long idh_end_offset; /* end of tokens section */ + /* */ + struct hash_table ia_link_table; /* all file and dir name name links */ + struct arg_file **ia_file_order; /* sequence in ID file */ + struct arg_file **ia_scan_order; /* sequence in summaries */ }; -struct idarg; +struct file_link +{ + struct file_link *fl_parent; + unsigned char fl_flags; +#define FL_IS_ARG 0x01 /* is an explicit command-line argument */ +#define FL_SYM_LINK 0x02 /* is a symlink (only used for dirs) */ +#define FL_TYPE_MASK 0x10 +# define FL_TYPE_DIR 0x00 +# define FL_TYPE_FILE 0x10 + char fl_name[1]; +}; + +struct arg_file +{ + struct file_link *af_name; + short af_old_index; /* order in extant ID file */ + short af_new_index; /* order in new ID file */ + short af_scan_index; /* order of scanning in summary */ +}; + +#if HAVE_LINK + +/* If the system supports filesystem links (e.g., any UN*X variant), + we should detect file name aliases. */ + +struct dev_ino +{ + dev_t di_dev; + ino_t di_ino; + struct file_link *di_file_link; +}; + +extern struct hash_table dev_ino_table; + +#endif -FILE *init_idfile __P((char const *id_file, struct idhead *idhp, struct idarg **id_args)); +FILE *init_id_file __P((char const *id_file, struct idhead *idh)); int read_idhead __P((FILE *input_FILE, struct idhead *idh)); int write_idhead __P((FILE *input_FILE, struct idhead *idh)); int sizeof_idhead __P((void)); @@ -2,6 +2,12 @@ export LANG; LANG=C +: ${TMP=/tmp} +ID_idx=$TMP/ID.idx +ID_lid=$TMP/ID.lid +tmp_idx=$TMP/$$.idx +tmp_fid=$TMP/$$.fid + case $# in 0) 1>&2 echo Usage: $0 files...; exit 1;; esac @@ -11,29 +17,26 @@ esac errors= -if idx "$@" |sort -u >ID.idx && - lid $idfile_arg |sed -e 's/[ ].*//' |sort -u >ID.lid && - cmp -s ID.idx ID.lid +if idx "$@" |sort -u >$ID_idx && + lid $idfile_arg |sed -e 's/[ ].*//' |sort -u >$ID_lid && + cmp -s $ID_idx $ID_lid then - rm -f ID.idx ID.lid + rm -f $ID_idx $ID_lid echo "Good. idx and lid agree." else - 1>&2 echo "Oops! idx and lid disagree--look in ID.idx and ID.lid" + 1>&2 echo "Oops! idx and lid disagree--look at $ID_idx and $ID_lid" errors=t fi -idx_file=$$.idx -fid_file=$$.fid - for file do case x$file in x-*) scan_args="$scan_args $file" continue;; esac - if fid $idfile_arg $file >$fid_file && - idx $scan_args $file |sort -u >$idx_file && - cmp -s $idx_file $fid_file; + if fid $idfile_arg $file >$tmp_fid && + idx $scan_args $file |sort -u >$tmp_idx && + cmp -s $tmp_idx $tmp_fid; then echo "Good. idx and fid agree for $file" else @@ -41,7 +44,7 @@ do errors=t fi done -rm -f $idx_file $fid_file +rm -f $tmp_idx $tmp_fid case x$errors in xt) echo "Some checks failed." @@ -16,7 +16,13 @@ char const *program_name; static void usage (void) { - fprintf (stderr, "Usage: %s [-u] [+/-a<ccc>] [-c<ccc>] files\n", program_name); + fprintf (stderr, "\ +Usage: %s [(+|-)S<scanarg>] files\n\ + -S<lang>-<arg> Pass arg to <lang> scanner\n\ + -S.<suffix>=<lang> Scan files with .<suffix> as <lang>\n\ + -S<lang>? Print usage documentation for <lang>\n", + program_name); + exit (1); } @@ -71,7 +77,7 @@ idxtract (char *file_name) char const *suffix; char const *filter; char const *lang_name; - char const *(*scanner) (FILE*, int*); + get_token_t scanner; suffix = strrchr (file_name, '.'); lang_name = get_lang_name (suffix); @@ -51,6 +51,13 @@ #include <config.h> #include "strxtra.h" +#include "obstack.h" +#include "xmalloc.h" + +FILE *popen (); + +#define obstack_chunk_alloc xmalloc +#define obstack_chunk_free free #if HAVE_ALLOCA @@ -225,6 +232,8 @@ set_type * * TheSets = NULL ; */ int VerboseQuery ; +char const *program_name ; + int yyerror __P(( char const * s )) ; void ScanInit __P(( char * line )) ; int yylex __P(( void )) ; @@ -252,7 +261,7 @@ set_type * SetInverse __P(( set_type * sp )) ; void RunShell __P(( char * pp , id_list_type * idlp )) ; -#line 231 "./iid.y" +#line 240 "./iid.y" typedef union { set_type * setdef ; id_type * strdef ; @@ -344,9 +353,9 @@ static const short yyrhs[] = { 9, #if YYDEBUG != 0 static const short yyrline[] = { 0, - 257, 265, 266, 272, 278, 284, 290, 294, 301, 310, - 319, 328, 335, 344, 353, 364, 371, 380, 389, 397, - 405, 414, 423, 432, 440, 447, 453, 461, 469 + 266, 274, 275, 281, 287, 293, 299, 303, 310, 319, + 328, 337, 344, 353, 362, 373, 380, 389, 398, 406, + 414, 423, 432, 441, 449, 456, 462, 470, 478 }; static const char * const yytname[] = { "$","error","$illegal.","SET","ID", @@ -972,7 +981,7 @@ yyreduce: switch (yyn) { case 1: -#line 259 "./iid.y" +#line 268 "./iid.y" { /* cd to the directory specified as argument, flush sets */ @@ -981,7 +990,7 @@ case 1: ; break;} case 3: -#line 267 "./iid.y" +#line 276 "./iid.y" { /* print the list of files resulting from Query */ @@ -989,7 +998,7 @@ case 3: ; break;} case 4: -#line 273 "./iid.y" +#line 282 "./iid.y" { /* run PAGER on the list of files in SET */ @@ -997,7 +1006,7 @@ case 4: ; break;} case 5: -#line 279 "./iid.y" +#line 288 "./iid.y" { /* describe sets created so far */ @@ -1005,7 +1014,7 @@ case 5: ; break;} case 6: -#line 285 "./iid.y" +#line 294 "./iid.y" { /* run PAGER on the help file */ @@ -1013,13 +1022,13 @@ case 6: ; break;} case 7: -#line 291 "./iid.y" +#line 300 "./iid.y" { exit(0) ; ; break;} case 8: -#line 295 "./iid.y" +#line 304 "./iid.y" { /* run the shell command and eat the results as a file set */ @@ -1028,7 +1037,7 @@ case 8: ; break;} case 9: -#line 302 "./iid.y" +#line 311 "./iid.y" { /* run the shell command */ @@ -1037,7 +1046,7 @@ case 9: ; break;} case 10: -#line 312 "./iid.y" +#line 321 "./iid.y" { /* Turn on verbose query flag */ @@ -1045,7 +1054,7 @@ case 10: ; break;} case 11: -#line 321 "./iid.y" +#line 330 "./iid.y" { /* Turn off verbose query flag */ @@ -1053,7 +1062,7 @@ case 11: ; break;} case 12: -#line 330 "./iid.y" +#line 339 "./iid.y" { /* value of query is set associated with primitive */ @@ -1061,7 +1070,7 @@ case 12: ; break;} case 13: -#line 336 "./iid.y" +#line 345 "./iid.y" { /* value of query is intersection of the two query sets */ @@ -1072,7 +1081,7 @@ case 13: ; break;} case 14: -#line 345 "./iid.y" +#line 354 "./iid.y" { /* value of query is union of the two query sets */ @@ -1083,7 +1092,7 @@ case 14: ; break;} case 15: -#line 354 "./iid.y" +#line 363 "./iid.y" { /* value of query is inverse of other query */ @@ -1094,7 +1103,7 @@ case 15: ; break;} case 16: -#line 366 "./iid.y" +#line 375 "./iid.y" { /* Value of primitive is value of recorded set */ @@ -1102,7 +1111,7 @@ case 16: ; break;} case 17: -#line 372 "./iid.y" +#line 381 "./iid.y" { /* Value of primitive is obtained by running an lid query */ @@ -1113,7 +1122,7 @@ case 17: ; break;} case 18: -#line 381 "./iid.y" +#line 390 "./iid.y" { /* Value of primitive is obtained by running an aid query */ @@ -1124,7 +1133,7 @@ case 18: ; break;} case 19: -#line 390 "./iid.y" +#line 399 "./iid.y" { /* Match names from database against pattern */ yyval. setdef = RunProg("pid -kmn", yyvsp[0]. listdef ) ; @@ -1134,7 +1143,7 @@ case 19: ; break;} case 20: -#line 398 "./iid.y" +#line 407 "./iid.y" { /* value of primitive is value of query */ @@ -1142,7 +1151,7 @@ case 20: ; break;} case 21: -#line 407 "./iid.y" +#line 416 "./iid.y" { /* make arg list holding single ID */ @@ -1152,7 +1161,7 @@ case 21: ; break;} case 22: -#line 415 "./iid.y" +#line 424 "./iid.y" { /* arg list is Id_list */ @@ -1161,7 +1170,7 @@ case 22: ; break;} case 23: -#line 425 "./iid.y" +#line 434 "./iid.y" { /* arg list is Id_list */ @@ -1169,7 +1178,7 @@ case 23: ; break;} case 24: -#line 434 "./iid.y" +#line 443 "./iid.y" { /* make arg list holding single ID */ @@ -1178,7 +1187,7 @@ case 24: ; break;} case 25: -#line 441 "./iid.y" +#line 450 "./iid.y" { /* make arg list holding names from set */ @@ -1187,7 +1196,7 @@ case 25: ; break;} case 26: -#line 448 "./iid.y" +#line 457 "./iid.y" { /* extend arg list with additional ID */ @@ -1195,7 +1204,7 @@ case 26: ; break;} case 27: -#line 454 "./iid.y" +#line 463 "./iid.y" { /* extend arg list with additional file names */ @@ -1203,7 +1212,7 @@ case 27: ; break;} case 28: -#line 463 "./iid.y" +#line 472 "./iid.y" { /* make arg list holding single ID */ @@ -1212,7 +1221,7 @@ case 28: ; break;} case 29: -#line 470 "./iid.y" +#line 479 "./iid.y" { /* extend arg list with additional ID */ @@ -1443,7 +1452,7 @@ yyerrhandle: yystate = yyn; goto yynewstate; } -#line 477 "./iid.y" +#line 486 "./iid.y" /* ScanLine - a global variable holding a pointer to the current @@ -1605,6 +1614,7 @@ main( int argc , char * argv [ ] ) int DoPrompt ; /* 1 if should write a prompt */ int errors = 0 ; /* error count */ + program_name = argv[0]; DoPrompt = isatty(fileno(stdin)) ; while ((c = getopt(argc, argv, "Hac:")) != EOF) { switch(c) { @@ -2061,7 +2071,7 @@ RunProg( char const * pp , id_list_type * idlp ) int c ; char * cmd ; char * dp ; - char file [ MAXCMD ] ; + struct obstack pipe_output_obstack; int i ; id_type * idep ; id_type * next_id ; @@ -2084,23 +2094,38 @@ RunProg( char const * pp , id_list_type * idlp ) /* run program with popen, reading the output. Assume each * white space terminated string is a file name. */ + prog = popen(cmd, "r") ; - dp = file ; - while ((c = getc(prog)) != EOF) { - if (isspace(c)) { - if (dp != file) { - *dp++ = '\0' ; - InstallFile(file) ; - dp = file ; - } - } else { - *dp++ = c ; - } - } - if (dp != file) { - *dp++ = '\0' ; - InstallFile(file) ; - } + obstack_init (&pipe_output_obstack); + + while (1) + { + c = getc (prog); + if (c == EOF || isspace (c)) + { + int n; + if ((n = obstack_object_size (&pipe_output_obstack)) > 0) + { + char *_file; + + obstack_1grow (&pipe_output_obstack, 0); + ++n; + _file = obstack_finish (&pipe_output_obstack); + InstallFile(_file) ; + if (n != strlen (_file) + 1) + abort (); + obstack_free (&pipe_output_obstack, _file); + } + if (c == EOF) + break; + } + else + { + obstack_1grow (&pipe_output_obstack, c); + } + } + obstack_free (&pipe_output_obstack, NULL); + if (pclose(prog) != 0) { /* if there was an error make an empty set, who knows what * garbage the program printed. @@ -26,6 +26,13 @@ #include <config.h> #include "strxtra.h" +#include "obstack.h" +#include "xmalloc.h" + +FILE *popen (); + +#define obstack_chunk_alloc xmalloc +#define obstack_chunk_free free #if HAVE_ALLOCA @@ -200,6 +207,8 @@ set_type * * TheSets = NULL ; */ int VerboseQuery ; +char const *program_name ; + int yyerror __P(( char const * s )) ; void ScanInit __P(( char * line )) ; int yylex __P(( void )) ; @@ -635,6 +644,7 @@ main( int argc , char * argv [ ] ) int DoPrompt ; /* 1 if should write a prompt */ int errors = 0 ; /* error count */ + program_name = argv[0]; DoPrompt = isatty(fileno(stdin)) ; while ((c = getopt(argc, argv, "Hac:")) != EOF) { switch(c) { @@ -1091,7 +1101,7 @@ RunProg( char const * pp , id_list_type * idlp ) int c ; char * cmd ; char * dp ; - char file [ MAXCMD ] ; + struct obstack pipe_output_obstack; int i ; id_type * idep ; id_type * next_id ; @@ -1114,23 +1124,38 @@ RunProg( char const * pp , id_list_type * idlp ) /* run program with popen, reading the output. Assume each * white space terminated string is a file name. */ + prog = popen(cmd, "r") ; - dp = file ; - while ((c = getc(prog)) != EOF) { - if (isspace(c)) { - if (dp != file) { - *dp++ = '\0' ; - InstallFile(file) ; - dp = file ; - } - } else { - *dp++ = c ; - } - } - if (dp != file) { - *dp++ = '\0' ; - InstallFile(file) ; - } + obstack_init (&pipe_output_obstack); + + while (1) + { + c = getc (prog); + if (c == EOF || isspace (c)) + { + int n; + if ((n = obstack_object_size (&pipe_output_obstack)) > 0) + { + char *_file; + + obstack_1grow (&pipe_output_obstack, 0); + ++n; + _file = obstack_finish (&pipe_output_obstack); + InstallFile(_file) ; + if (n != strlen (_file) + 1) + abort (); + obstack_free (&pipe_output_obstack, _file); + } + if (c == EOF) + break; + } + else + { + obstack_1grow (&pipe_output_obstack, c); + } + } + obstack_free (&pipe_output_obstack, NULL); + if (pclose(prog) != 0) { /* if there was an error make an empty set, who knows what * garbage the program printed. @@ -32,7 +32,6 @@ #include <config.h> #include "alloc.h" #include "idfile.h" -#include "idarg.h" #include "token.h" #include "bitops.h" #include "strxtra.h" @@ -47,6 +46,7 @@ char **tree8_to_argv __P((unsigned char const *hits_tree8)); char **bits_to_argv __P((unsigned char const *bits_vec)); static void usage __P((void)); +int common_prefix_suffix __P((char const *path1, char const *path2)); void look_id __P((char const *name, char **argv)); void grep_id __P((char const *name, char **argv)); void edit_id __P((char const *name, char **argv)); @@ -87,8 +87,8 @@ enum radix { #define TOLOWER(c) (isupper (c) ? tolower (c) : (c)) #define IS_ALNUM(c) (isalnum (c) || (c) == '_') -#ifndef CRUNCH_DEFAULT -#define CRUNCH_DEFAULT 1 +#ifndef BRACE_NOTATION_DEFAULT +#define BRACE_NOTATION_DEFAULT 1 #endif /* Sorry about all the globals, but it's really cleaner this way. */ @@ -96,16 +96,15 @@ FILE *id_FILE; int merging; int radix_arg; int echo_on = 1; -int crunch_on = CRUNCH_DEFAULT; +int brace_notation_on = BRACE_NOTATION_DEFAULT; int file_name_regexp = 0; int match_base = 0; -char id_dir[BUFSIZ]; +char *anchor_dir; int tree8_levels; unsigned int bits_vec_size; -char PWD_name[BUFSIZ]; +char PWD_buf[MAXPATHLEN]; struct idhead idh; -struct idarg *id_args; -int (*find_func) (char const *, doit_t); +int (*find_func) __P((char const *, doit_t)); unsigned short frequency_low = 1; unsigned short frequency_high = USHRT_MAX; char *buf; @@ -117,7 +116,7 @@ char const *program_name; static void usage (void) { - fprintf (stderr, "Usage: %s [-f<file>] [-u<n>] [-r<dir>] [-mewdoxasknc] patterns...\n", program_name); + fprintf (stderr, "Usage: %s [-f<file>] [-u<n>] [-r<dir>] [-mewdoxaskncg] patterns...\n", program_name); exit (1); } @@ -128,11 +127,7 @@ main (int argc, char **argv) doit_t doit = look_id; int force_merge = 0; unsigned int unique_limit = 0; - int use_id_file_name = 1; - int use_pwd_file_name = 0; - int use_relative_file_name = 0; - char const *REL_file_name = NULL; - int (*forced_find_func) (char const *, doit_t) = NULL; + int (*forced_find_func) __P((char const *, doit_t)) = NULL; program_name = basename ((argc--, *argv++)); @@ -184,25 +179,24 @@ main (int argc, char **argv) parse_frequency_arg (arg); goto nextarg; case 'k': - crunch_on = 0; + brace_notation_on = 0; break; case 'g': - crunch_on = 1; + brace_notation_on = 1; break; case 'n': echo_on = 0; break; - case 'c': - use_id_file_name = 0; - use_pwd_file_name = 1; - break; case 'b': match_base = 1; break; + case 'c': + maybe_anchor_usage (); + anchor_dir = PWD_buf; + break; case 'r': - use_id_file_name = 0; - use_relative_file_name = 1; - REL_file_name = arg; + maybe_anchor_usage (); + anchor_dir = arg; goto nextarg; default: usage (); @@ -211,48 +205,17 @@ main (int argc, char **argv) } argsdone: - if (use_pwd_file_name && use_relative_file_name) - { - fprintf (stderr, "%s: please use only one of -c or -r\n", program_name); - usage (); - } - /* Look for the ID database up the tree */ - id_file_name = look_up (id_file_name); - if (id_file_name == NULL) - { - filerr ("open", id_file_name); - exit (1); - } - /* Find out current directory to relate names to */ - if (kshgetwd (PWD_name) == NULL) - { - fprintf (stderr, "%s: cannot determine current directory\n", program_name); - exit (1); - } - strcat (PWD_name, "/"); - /* Determine absolute path name that database files are relative to */ - if (use_id_file_name) - { - strcpy (id_dir, span_file_name (PWD_name, id_file_name)); - *(strrchr (id_dir, '/') + 1) = '\0'; - } - else if (use_pwd_file_name) - { - strcpy (id_dir, PWD_name); - } - else - { - strcpy (id_dir, span_file_name (PWD_name, REL_file_name)); - strcat (id_dir, "/"); - } - id_FILE = init_idfile (id_file_name, &idh, &id_args); - if (id_FILE == NULL) - { - filerr ("open", id_file_name); - exit (1); - } - bits_vec_size = (idh.idh_paths + 7) >> 3; - tree8_levels = tree8_count_levels (idh.idh_paths); + get_PWD (PWD_buf); + id_file_name = find_id_file (id_file_name); + + if (anchor_dir == NULL) + anchor_dir = strdup (span_dir_name (PWD_buf, id_file_name)); + else if (anchor_dir != PWD_buf) + anchor_dir = strdup (span_dir_name (PWD_buf, anchor_dir)); + + id_FILE = init_id_file (id_file_name, &idh); + bits_vec_size = (idh.idh_files + 7) >> 3; + tree8_levels = tree8_count_levels (idh.idh_files); switch (program_name[0]) { @@ -328,21 +291,43 @@ argsdone: exit (0); } +/* common_prefix_suffix returns non-zero if two file names have a + fully common directory prefix and a common suffix (i.e., they're + eligible for coalescing with brace notation. */ + +int +common_prefix_suffix (char const *file_name_1, char const *file_name_2) +{ + char const *slash_1; + char const *slash_2; + + slash_1 = strrchr (file_name_1, '/'); + slash_2 = strrchr (file_name_2, '/'); + + if (slash_1 == NULL && slash_2 == NULL) + return strequ (suff_name (file_name_1), suff_name (file_name_2)); + if ((slash_1 - file_name_1) != (slash_2 - file_name_2)) + return 0; + if (!strnequ (file_name_1, file_name_2, slash_1 - file_name_1)) + return 0; + return strequ (suff_name (slash_1), suff_name (slash_2)); +} + void look_id (char const *name, char **argv) { char const *arg; char const *dir; - int crunching = 0; + int using_braces = 0; if (echo_on) printf ("%-14s ", name); while (*argv) { arg = *argv++; - if (*argv && crunch_on && can_crunch (arg, *argv)) + if (*argv && brace_notation_on && common_prefix_suffix (arg, *argv)) { - if (crunching) + if (using_braces) printf (",%s", root_name (arg)); else { @@ -351,15 +336,15 @@ look_id (char const *name, char **argv) printf ("%s/", dir); printf ("{%s", root_name (arg)); } - crunching = 1; + using_braces = 1; } else { - if (crunching) + if (using_braces) printf (",%s}%s", root_name (arg), suff_name (arg)); else fputs (arg, stdout); - crunching = 0; + using_braces = 0; if (*argv) putchar (' '); } @@ -376,7 +361,7 @@ grep_id (char const *name, char **argv) if (merging) { - re = file_regexp (name, "[^a-zA-Z0-9_À-ÿ]_*", "[^a-zA-Z0-9_À-ÿ]"); + re = file_regexp (name, "[^a-zA-Z0-9_]_*", "[^a-zA-Z0-9_]"); if (re) { char const *regexp_error = re_comp (re); @@ -539,8 +524,8 @@ editit: filerr ("exec", editor); default: { - void (*oldint) (int) = signal (SIGINT, SIG_IGN); - void (*oldquit) (int) = signal (SIGQUIT, SIG_IGN); + void (*oldint) __P((int)) = signal (SIGINT, SIG_IGN); + void (*oldquit) __P((int)) = signal (SIGQUIT, SIG_IGN); while (wait (0) == -1 && errno == EINTR) ; @@ -869,7 +854,7 @@ find_token (char const *token_0) { int c; int incr = 1; - unsigned char const *token = (unsigned char const *) token_0; + char const *token; offset = start + (end - start) / 2; fseek (id_FILE, offset, SEEK_SET); @@ -881,6 +866,7 @@ find_token (char const *token_0) } /* compare the token names */ + token = token_0; while (*token == (c = getc (id_FILE)) && *token && c) { token++; @@ -1022,7 +1008,7 @@ file_name_wildcard (char const *re, char const *fn) int match_file_names (char const *re, doit_t doit) { - char const *absname; + char const *abs_name; struct idarg *ida = id_args; int i; int count = 0; @@ -1038,22 +1024,22 @@ match_file_names (char const *re, doit_t doit) } } - for (i = 0; i < idh.idh_paths; i++, ida++) + for (i = 0; i < idh.idh_files; i++, ida++) { if (*ida->ida_arg == 0) continue; if (match_base) { - absname = strrchr (ida->ida_arg, '/'); - if (absname == NULL) - absname = ida->ida_arg; + abs_name = strrchr (ida->ida_arg, '/'); + if (abs_name == NULL) + abs_name = ida->ida_arg; } else - absname = span_file_name (id_dir, ida->ida_arg); + abs_name = span_file_name (anchor_dir, ida->ida_arg); if (file_name_regexp) - matched = re_exec (absname); + matched = re_exec (abs_name); else - matched = file_name_wildcard (re, absname); + matched = file_name_wildcard (re, abs_name); if (matched) { BITSET (bits_vec, i); @@ -1224,10 +1210,10 @@ bits_to_argv (unsigned char const *bv) static char **argv_0; char **argv; struct idarg *ida = id_args; - struct idarg *end = &id_args[idh.idh_paths]; + struct idarg *end = &id_args[idh.idh_files]; if (argv_0 == NULL) - argv_0 = MALLOC (char *, idh.idh_paths + reserved_argv_slots + 2); + argv_0 = MALLOC (char *, idh.idh_files + reserved_argv_slots + 2); argv = &argv_0[reserved_argv_slots]; for (;;) @@ -1249,8 +1235,8 @@ bits_to_argv (unsigned char const *bv) { if (!(ida->ida_flags & IDA_RELATIVE)) { - char const *abs_name = span_file_name (id_dir, ida->ida_arg); - char const *rel_name = relative_file_name (PWD_name, abs_name); + char const *abs_name = span_file_name (anchor_dir, ida->ida_arg); + char const *rel_name = relative_file_name (PWD_buf, abs_name); char const *short_name = (strlen (rel_name) > strlen (abs_name) ? abs_name : rel_name); if (!strequ (short_name, ida->ida_arg)) @@ -25,7 +25,7 @@ #include "misc.h" #if !HAVE_BASENAME -char const * +char * basename (char const *path) { char *base; @@ -39,7 +39,7 @@ basename (char const *path) #endif #if !HAVE_DIRNAME -char const * +char * dirname (char const *path) { char *base; @@ -19,11 +19,15 @@ #ifndef _misc_h_ #define _misc_h_ -#if !HAVE_BASENAME -char const *basename __P((char const *path)); +#if HAVE_BASENAME +char *basename (); +#else +char *basename __P((char const *path)); #endif -#if !HAVE_DIRNAME -char const *dirname __P((char const *path)); +#if HAVE_DIRNAME +char *dirname (); +#else +char *dirname __P((char const *path)); #endif int fgets0 __P((char *buf0, int size, FILE *in_FILE)); void filerr __P((char const *syscall, char const *file_name)); @@ -19,6 +19,7 @@ #include <sys/types.h> #include <sys/stat.h> #include <stdlib.h> +#include <stddef.h> #include <unistd.h> #include <limits.h> #include <assert.h> @@ -31,13 +32,17 @@ #include "strxtra.h" #include "alloc.h" #include "idfile.h" -#include "idarg.h" #include "token.h" #include "bitops.h" #include "misc.h" #include "filenames.h" +#include "hash.h" #include "scanners.h" +#ifndef offsetof +#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER) +#endif + struct summary { struct token **sum_tokens; @@ -55,7 +60,7 @@ struct summary int sum_level; }; -#define MAX_LEVELS 5 /* log_8 of the max # of files log_8 32768 == 5 */ +#define MAX_LEVELS 5 /* log_8 of the max # of files: log_8(32768) == 5 */ struct token { @@ -65,34 +70,28 @@ struct token char tok_name[1]; }; -struct token **hash_table; /* Vector of token pointers */ - char *bitsset __P((char *s1, char const *s2, int n)); char *bitsclr __P((char *s1, char const *s2, int n)); char *bitsand __P((char *s1, char const *s2, int n)); char *bitsxor __P((char *s1, char const *s2, int n)); int bitstst __P((char const *s1, char const *s2, int n)); int bitsany __P((char const *s, int n)); -int round2 __P((int rough)); struct token *make_token __P((char const *name, int)); void scan_1_file __P((char const *(*get_token) (FILE*, int*), FILE *source_FILE)); struct idarg *parse_idargs __P((int argc, char **argv)); struct idarg *parse_idargs_from_FILE __P((FILE *arg_FILE, struct idarg *idarg)); -void init_hash_table __P((int file_name_count)); void scan_files __P((struct idarg *idarg)); void report_statistics __P((void)); -void init_hash __P((long size)); -struct token **hash_lookup __P((char const *key)); -unsigned int string_hash_1 __P((char const *key)); -unsigned int string_hash_2 __P((char const *key)); -void rehash __P((void)); +unsigned long token_hash_1 __P((void const *key)); +unsigned long token_hash_2 __P((void const *key)); +int token_hash_cmp __P((void const *x, void const *y)); void write_idfile __P((char const *id_file, struct idarg *idargs)); void bump_current_hits_signature __P((void)); void init_hits_signature __P((int i)); int bit_to_index __P((int bit)); -int compare_tokens __P((void const *x, void const *y)); +int token_qsort_cmp __P((void const *x, void const *y)); void free_summary_tokens __P((void)); void summarize __P((void)); void assert_hits __P((struct summary *summary)); @@ -105,6 +104,9 @@ int count_vec_size __P((struct summary *summary, unsigned char const *tail_hits) int count_buf_size __P((struct summary *summary, unsigned char const *tail_hits)); void usage __P((void)); +struct hash_table token_table; +struct hash_table file_table; + /* Miscellaneous statistics */ long input_chars; long name_tokens; @@ -118,14 +120,6 @@ long hits_length = 0; long tokens_length = 0; long output_length = 0; -/* Hash table maintenance */ -unsigned long hash_size; /* # of slots */ -unsigned long hash_capacity; /* # of usable slots */ -unsigned long hash_fill; /* # of keys inserted in table */ -unsigned long hash_probes = 0; -unsigned long hash_lookups = 0; -unsigned int hash_rehashes = 0; - int verbose_flag = 0; int statistics_flag = 1; @@ -139,7 +133,7 @@ unsigned char current_hits_signature[MAX_LEVELS]; struct summary *summary_root; struct summary *summary_leaf; -char PWD_name[BUFSIZ]; /* The current working directory */ +char PWD_buf[BUFSIZ]; /* The current working directory */ char absolute_idfile_name[BUFSIZ]; /* The absolute name of the database */ char const *id_file_name = IDFILE; @@ -149,7 +143,7 @@ void usage (void) { fprintf (stderr, "\ -Usage: %s [-v] [-f<idfile>] [(+|-)l[<lang>]] [(+|-)S<scanarg>] [-a<argfile>] [-] [-u] [files...]\n\ +Usage: %s [-v] [-f<idfile>] [(+|-)l[<lang>]] [(+|-)S<scanarg>] [-a<argfile>] [-] [files...]\n\ -v Verbose: print reports of progress\n\ -a<file> Open file for arguments\n\ - Read newline-separated args from stdin\n\ @@ -157,14 +151,18 @@ Usage: %s [-v] [-f<idfile>] [(+|-)l[<lang>]] [(+|-)S<scanarg>] [-a<argfile>] [-] -S<lang>-<arg> Pass arg to <lang> scanner\n\ -S.<suffix>=<lang> Scan files with .<suffix> as <lang>\n\ -S<lang>? Print usage documentation for <lang>\n\ - -u Update an existing database (unimplemented)\n\ \n\ -Version %s; Made %s %s\n", - program_name, VERSION, __DATE__, __TIME__); - +Version %s", + program_name, VERSION); +#ifdef __DATE__ + fprintf (stderr, "; Made %s %s", __DATE__, __TIME__); +#endif + fputc ('\n', stderr); exit (1); } +void *sbrk (); + int main (int argc, char **argv) { @@ -172,13 +170,6 @@ main (int argc, char **argv) char const *sbrk0; program_name = basename ((argc--, *argv++)); - if (kshgetwd (PWD_name) == NULL) - { - fprintf (stderr, "%s: cannot get current working directory name.\n", program_name); - return 1; - } - strcat (PWD_name, "/"); - init_scanners (); idarg_0 = parse_idargs (argc, argv); @@ -188,10 +179,11 @@ main (int argc, char **argv) return 0; } - sbrk0 = (char const *)sbrk (0); - init_hash (scan_count * 64); + sbrk0 = (char const *) sbrk (0); + hash_init (&token_table, scan_count * 64, token_hash_1, token_hash_2, token_hash_cmp); - strcpy (absolute_idfile_name, span_file_name (PWD_name, id_file_name)); + get_PWD (PWD_buf); + strcpy (absolute_idfile_name, span_file_name (PWD_buf, id_file_name)); if (access (id_file_name, 06) < 0 && (errno != ENOENT || access (dirname (id_file_name), 06) < 0)) { @@ -204,11 +196,11 @@ main (int argc, char **argv) scan_files (idarg_0); - if (hash_fill == 0) + if (token_table.ht_fill == 0) return 0; free_summary_tokens (); - free (hash_table); + free (token_table.ht_vec); write_idfile (id_file_name, idarg_0); heap_size = (char const *) sbrk (0) - sbrk0; @@ -225,7 +217,7 @@ scan_files (struct idarg *idarg) for ( ; idarg->ida_next; idarg = idarg->ida_next) { - char const *(*scanner) (FILE*, int*); + char const *(*scanner) __P((FILE*, int*)); FILE *source_FILE; char *arg = idarg->ida_arg; char const *lang_name = NULL; @@ -320,13 +312,13 @@ report_statistics (void) printf ("Heap=%ld Kb, ", heap_size / 1024); printf ("Output=%ld (%ld tok, %ld hit)\n", output_length, tokens_length, hits_length); - printf ("Load=%ld/%ld=%.2f, ", hash_fill, hash_size, - (double) hash_fill / (double) hash_size); - printf ("Rehash=%d, ", hash_rehashes); - printf ("Probes=%ld/%ld=%.2f, ", hash_probes, hash_lookups, - (double) hash_probes / (double) hash_lookups); - printf ("Freq=%ld/%ld=%.2f\n", occurrences, hash_fill, - (double) occurrences / (double) hash_fill); + printf ("Load=%ld/%ld=%.2f, ", token_table.ht_fill, token_table.ht_size, + (double) token_table.ht_fill / (double) token_table.ht_size); + printf ("Rehash=%d, ", token_table.ht_rehashes); + printf ("Probes=%ld/%ld=%.2f, ", token_table.ht_probes, token_table.ht_lookups, + (double) token_table.ht_probes / (double) token_table.ht_lookups); + printf ("Freq=%ld/%ld=%.2f\n", occurrences, token_table.ht_fill, + (double) occurrences / (double) token_table.ht_fill); } struct idarg * @@ -341,8 +333,7 @@ parse_idargs (int argc, char **argv) enum { AF_CMDLINE = 0x1, /* file args came on command line */ AF_FILE = 0x2, /* file args came from a file (-f<file>) */ - AF_IDFILE = 0x4, /* file args came from an old ID file (-u) */ - AF_QUERY = 0x8 + AF_USAGE = 0x8 }; /* no file args necessary: usage query */ idarg = idarg_0 = CALLOC (struct idarg, 1); @@ -367,12 +358,6 @@ parse_idargs (int argc, char **argv) op = *arg++; switch (*arg++) { - case 'u': -#if 0 - args_from |= AF_IDFILE; - old_idarg (id_file_name, &idarg); - break; -#endif case '\0': args_from |= AF_FILE; idarg = parse_idargs_from_FILE (stdin, idarg); @@ -397,12 +382,10 @@ parse_idargs (int argc, char **argv) if (strchr (&arg[-2], '?')) { set_scan_args (op, arg); - args_from |= AF_QUERY; + args_from |= AF_USAGE; } /*FALLTHROUGH */ case 'l': - case 's': - case 'r': idarg->ida_arg = &arg[-2]; idarg->ida_index = -1; idarg = (idarg->ida_next = CALLOC (struct idarg, 1)); @@ -414,7 +397,7 @@ parse_idargs (int argc, char **argv) } } - if (args_from & AF_QUERY) + if (args_from & AF_USAGE) exit (0); /* File args should only come from one place. Ding the user if arguments came from multiple places, or if none were supplied at @@ -423,7 +406,6 @@ parse_idargs (int argc, char **argv) { case AF_CMDLINE: case AF_FILE: - case AF_IDFILE: if (file_name_count > 0) break; /*FALLTHROUGH */ @@ -468,7 +450,7 @@ parse_idargs_from_FILE (FILE *arg_FILE, struct idarg *idarg) } void -scan_1_file (char const *(*get_token) (FILE*, int*), FILE *source_FILE) +scan_1_file (get_token_t get_token, FILE *source_FILE) { struct stat stat_buf; struct token **slot; @@ -490,8 +472,9 @@ scan_1_file (char const *(*get_token) (FILE*, int*), FILE *source_FILE) { if (*key == '\0') continue; - token = *(slot = hash_lookup (key)); total_tokens++; + slot = (struct token **) hash_lookup (&token_table, key - offsetof (struct token, tok_name)); + token = *slot; if (token) { token->tok_flags |= flags; @@ -507,8 +490,8 @@ scan_1_file (char const *(*get_token) (FILE*, int*), FILE *source_FILE) sign_token (token); distinct_tokens++; new_tokens++; - if (hash_fill++ >= hash_capacity) - rehash (); + if (token_table.ht_fill++ >= token_table.ht_capacity) + rehash (&token_table); } } if (verbose_flag) @@ -546,13 +529,13 @@ write_idfile (char const *file_name, struct idarg *idarg) if (verbose_flag) printf ("Sorting tokens...\n"); - assert (summary_root->sum_hits_count == hash_fill); - tokens = REALLOC (summary_root->sum_tokens, struct token *, hash_fill); - qsort (tokens, hash_fill, sizeof (struct token *), compare_tokens); + assert (summary_root->sum_hits_count == token_table.ht_fill); + tokens = REALLOC (summary_root->sum_tokens, struct token *, token_table.ht_fill); + qsort (tokens, token_table.ht_fill, sizeof (struct token *), token_qsort_cmp); if (verbose_flag) printf ("Writing `%s'...\n", file_name); - lsl = strrchr (relative_file_name (PWD_name, absolute_idfile_name), '/'); + lsl = strrchr (relative_file_name (PWD_buf, absolute_idfile_name), '/'); if (lsl == NULL) { /* The database is in the cwd, don't adjust the names */ @@ -575,23 +558,20 @@ write_idfile (char const *file_name, struct idarg *idarg) idh.idh_magic[0] = IDH_MAGIC_0; idh.idh_magic[1] = IDH_MAGIC_1; idh.idh_version = IDH_VERSION; - idh.idh_pad_1 = 0; idh.idh_flags = IDH_COUNTS; /* write out the list of pathnames */ fseek (id_FILE, sizeof_idhead (), 0); idh.idh_args_offset = ftell (id_FILE); - for (i = 0; idarg->ida_next; idarg = idarg->ida_next) + for ( ; idarg->ida_next; idarg = idarg->ida_next) { if (*idarg->ida_arg != '-' && fixup_names) - fputs (relative_file_name (absolute_idfile_name, span_file_name (PWD_name, idarg->ida_arg)), id_FILE); + fputs (relative_file_name (absolute_idfile_name, span_file_name (PWD_buf, idarg->ida_arg)), id_FILE); else fputs (idarg->ida_arg, id_FILE); - i++; putc ('\0', id_FILE); } - idh.idh_args = i; - idh.idh_paths = file_name_count; + idh.idh_files = file_name_count; /* write out the list of identifiers */ @@ -599,7 +579,7 @@ write_idfile (char const *file_name, struct idarg *idarg) putc ('\0', id_FILE); idh.idh_tokens_offset = ftell (id_FILE); - for (i = 0; i < hash_fill; i++, tokens++) + for (i = 0; i < token_table.ht_fill; i++, tokens++) { struct token *token = *tokens; occurrences += token->tok_count; @@ -639,7 +619,7 @@ write_idfile (char const *file_name, struct idarg *idarg) putc ('\0', id_FILE); } assert_hits (summary_root); - idh.idh_tokens = hash_fill; + idh.idh_tokens = token_table.ht_fill; output_length = ftell (id_FILE); idh.idh_end_offset = output_length - 2; idh.idh_buf_size = max_buf_size; @@ -649,119 +629,30 @@ write_idfile (char const *file_name, struct idarg *idarg) fclose (id_FILE); } -void -init_hash (long size) -{ - hash_size = round2 (size); - if (hash_size < 512) - hash_size = 512; -#if 0 - if (hash_size > 0x8000) - hash_size = 0x8000; -#endif - if (hash_size > (128 * 1024)) - hash_size /= 2; - hash_capacity = hash_size - (hash_size >> 4); /* about 94% */ - hash_table = CALLOC (struct token *, hash_size); - assert (hash_table); -} - -/* Use double hashing with open addressing. - The table size is always a power of two. */ -struct token ** -hash_lookup (char const *key) -{ - unsigned int hash1 = string_hash_1 (key) % hash_size; - unsigned int hash2 = 0; - struct token **slot = &hash_table[hash1]; - - hash_lookups++; - for (;;) - { - hash_probes++; - if (*slot == NULL || strcmp (key, (*slot)->tok_name) == 0) - return slot; - - if (!hash2) - hash2 = string_hash_2 (key); - hash1 = (hash1 + hash2) % hash_size; - slot = &hash_table[hash1]; - } -} - -/* Primary hash function for string keys. */ -unsigned int -string_hash_1 (char const *key) +unsigned long +token_hash_1 (void const *key) { - unsigned int sum = 0; - - key--; - while (*++key) - sum += (*key << (key[1] & 0xf)); - - return sum; + return_STRING_HASH_1 (((struct token const *) key)->tok_name); } -/* Secondary hash function for string keys. The result must be - relatively prime to the table size, which is a power of two, - so any odd number will do. */ -unsigned int -string_hash_2 (char const *key) +unsigned long +token_hash_2 (void const *key) { - unsigned int sum = 0; - - key--; - while (*++key) - sum += (*key << (key[1] & 0x7)); - - return sum | 1; + return_STRING_HASH_2 (((struct token const *) key)->tok_name); } -/* Double the size of the hash table in the event of overflow... */ -void -rehash (void) +int +token_hash_cmp (void const *x, void const *y) { - unsigned long old_hash_size = hash_size; - struct token **old_hash_table = hash_table; - struct token **htp; - struct token **slot; - - hash_size *= 2; - if (verbose_flag) - printf ("\n\tRehashing... (doubling size to %ld)\n", hash_size); - hash_rehashes++; - hash_capacity = hash_size - (hash_size >> 4); - hash_table = CALLOC (struct token *, hash_size); - - for (htp = old_hash_table; htp < &old_hash_table[old_hash_size]; htp++) - { - if (*htp == NULL) - continue; - slot = hash_lookup ((*htp)->tok_name); - - if (*slot) - { - fprintf (stderr, "%s: Duplicate hash entry!\n", (*slot)->tok_name); - exit (1); - } - *slot = *htp; - } - free (old_hash_table); + return_STRING_COMPARE (((struct token const *) x)->tok_name, + ((struct token const *) y)->tok_name); } -/* Round a given number up to the nearest power of 2. */ -int -round2 (int rough) +int +token_qsort_cmp (void const *x, void const *y) { - int round; - - round = 1; - while (rough) - { - round <<= 1; - rough >>= 1; - } - return round; + return_STRING_COMPARE ((*(struct token const *const *) x)->tok_name, + (*(struct token const *const *) y)->tok_name); } struct token * @@ -815,13 +706,6 @@ bit_to_index (int bit) return i; } -int -compare_tokens (void const *x, void const *y) -{ - return strcmp ((*(struct token const *const *) x)->tok_name, - (*(struct token const *const *) y)->tok_name); -} - void free_summary_tokens (void) { @@ -863,7 +747,7 @@ summarize (void) printf (fmt, summary->sum_level, count, init_size); } - qsort (tokens, count, sizeof (struct token *), compare_tokens); + qsort (tokens, count, sizeof (struct token *), token_qsort_cmp); summary->sum_hits = hits; while (count--) { @@ -26,7 +26,9 @@ #define _GNU_SOURCE -#include "config.h" +#if HAVE_CONFIG_H +#include <config.h> +#endif /* We need this for `regex.h', and perhaps for the Emacs include files. */ #include <sys/types.h> @@ -32,29 +32,31 @@ extern char const *program_name; static char const *get_token_VHIL __P((FILE *input_FILE, int *flags)); static char const *get_token_c __P((FILE *input_FILE, int *flags)); static void set_args_c __P((char const *lang_name, int op, char const *arg)); -static void set_ctype_c __P((unsigned char const *chars, int type)); -static void clear_ctype_c __P((unsigned char const *chars, int type)); +static void set_ctype_c __P((char const *chars, int type)); +static void clear_ctype_c __P((char const *chars, int type)); static void usage_c __P((char const *lang_name)); static char const *get_token_asm __P((FILE *input_FILE, int *flags)); -static void set_ctype_asm __P((unsigned char const *chars, int type)); -static void clear_ctype_asm __P((unsigned char const *chars, int type)); +static void set_ctype_asm __P((char const *chars, int type)); +static void clear_ctype_asm __P((char const *chars, int type)); static void usage_asm __P((char const *lang_name)); static void set_args_asm __P((char const *lang_name, int op, char const *arg)); static char const *get_token_text __P((FILE *input_FILE, int *flags)); -static void set_ctype_text __P((unsigned char const *chars, int type)); -static void clear_ctype_text __P((unsigned char const *chars, int type)); +static void set_ctype_text __P((char const *chars, int type)); +static void clear_ctype_text __P((char const *chars, int type)); static void usage_text __P((char const *lang_name)); static void set_args_text __P((char const *lang_name, int op, char const *arg)); /****************************************************************************/ +typedef void (*set_args_t) __P((char const *lang_name, int op, char const *arg)); + struct language { char const *lang_name; - char const *(*lang_get_token) (FILE *input_FILE, int *flags); - void (*lang_set_args) (char const *lang_name, int op, char const *arg); + get_token_t lang_get_token; + set_args_t lang_set_args; char const *lang_filter; struct language *lang_next; }; @@ -380,7 +382,7 @@ usage_scan (void) fprintf (stderr, "Usage: %s [-S<suffix>=<lang>] [+S(+|-)<arg>] [-S<lang>(+|-)<arg>] [-S<lang>/<lang>/<filter>]\n", program_name); exit (1); } - + /*************** C & C++ ****************************************************/ #define I1 0x0001 /* 1st char of an identifier [a-zA-Z_] */ @@ -438,22 +440,6 @@ static unsigned short ctype_c[257] = /*150*/ I1, I1, I1, I1, I1|NM, I1, I1, I1, /*160*/ I1, I1, I1, I1, I1, I1, I1, I1, /*170*/ I1|NM, I1, I1, 0, 0, 0, 0, 0, -/*200*/ 0, 0, 0, 0, 0, 0, 0, 0, -/*210*/ 0, 0, 0, 0, 0, 0, 0, 0, -/*220*/ 0, 0, 0, 0, 0, 0, 0, 0, -/*230*/ 0, 0, 0, 0, 0, 0, 0, 0, -/*240*/ 0, 0, 0, 0, 0, 0, 0, 0, -/*250*/ 0, 0, 0, 0, 0, 0, 0, 0, -/*260*/ 0, 0, 0, 0, 0, 0, 0, 0, -/*270*/ 0, 0, 0, 0, 0, 0, 0, 0, -/*300*/ SK, SK, SK, SK, SK, SK, SK, SK, -/*310*/ SK, SK, SK, SK, SK, SK, SK, SK, -/*320*/ SK, SK, SK, SK, SK, SK, SK, 0, -/*330*/ SK, SK, SK, SK, SK, SK, SK, SK, -/*340*/ SK, SK, SK, SK, SK, SK, SK, SK, -/*350*/ SK, SK, SK, SK, SK, SK, SK, SK, -/*360*/ SK, SK, SK, SK, SK, SK, SK, 0, -/*370*/ SK, SK, SK, SK, SK, SK, SK, SK, }; static int eat_underscore = 1; @@ -705,7 +691,7 @@ next: } static void -set_ctype_c (unsigned char const *chars, int type) +set_ctype_c (char const *chars, int type) { unsigned short *rct = &ctype_c[1]; @@ -714,7 +700,7 @@ set_ctype_c (unsigned char const *chars, int type) } static void -clear_ctype_c (unsigned char const *chars, int type) +clear_ctype_c (char const *chars, int type) { unsigned short *rct = &ctype_c[1]; @@ -751,14 +737,14 @@ set_args_c (char const *lang_name, int op, char const *arg) break; case 's': if (op == '+') - set_ctype_c ((unsigned char *) arg, SK); + set_ctype_c (arg, SK); else - clear_ctype_c ((unsigned char *) arg, SK); + clear_ctype_c (arg, SK); break; case 'v': - set_ctype_c ((unsigned char *) "$", I1); - set_ctype_c ((unsigned char *) "#", VH); - set_ctype_c ((unsigned char *) " \t", WS); + set_ctype_c ("$", I1); + set_ctype_c ("#", VH); + set_ctype_c (" \t", WS); scan_VHIL = 1; break; default: @@ -793,7 +779,7 @@ set_args_c (char const *lang_name, int op, char const *arg) #undef ISVBORING #undef ISQ1BORING #undef ISQ2BORING - + /*************** Assembly ***************************************************/ #define I1 0x01 /* 1st char of an identifier [a-zA-Z_] */ @@ -837,22 +823,7 @@ static unsigned char ctype_asm[257] = /*150*/ I1, I1, I1, I1, I1|NM, I1, I1, I1, /*160*/ I1, I1, I1, I1, I1, I1, I1, I1, /*170*/ I1|NM, I1, I1, 0, 0, 0, 0, 0, -/*200*/ 0, 0, 0, 0, 0, 0, 0, 0, -/*210*/ 0, 0, 0, 0, 0, 0, 0, 0, -/*220*/ 0, 0, 0, 0, 0, 0, 0, 0, -/*230*/ 0, 0, 0, 0, 0, 0, 0, 0, -/*240*/ 0, 0, 0, 0, 0, 0, 0, 0, -/*250*/ 0, 0, 0, 0, 0, 0, 0, 0, -/*260*/ 0, 0, 0, 0, 0, 0, 0, 0, -/*270*/ 0, 0, 0, 0, 0, 0, 0, 0, -/*300*/ 0, 0, 0, 0, 0, 0, 0, 0, -/*310*/ 0, 0, 0, 0, 0, 0, 0, 0, -/*320*/ 0, 0, 0, 0, 0, 0, 0, 0, -/*330*/ 0, 0, 0, 0, 0, 0, 0, 0, -/*340*/ 0, 0, 0, 0, 0, 0, 0, 0, -/*350*/ 0, 0, 0, 0, 0, 0, 0, 0, -/*360*/ 0, 0, 0, 0, 0, 0, 0, 0, -/*370*/ 0, 0, 0, 0, 0, 0, 0, 0, + }; static int cpp_on_asm = 1; @@ -994,7 +965,7 @@ next: } static void -set_ctype_asm (unsigned char const *chars, int type) +set_ctype_asm (char const *chars, int type) { unsigned char *rct = &ctype_asm[1]; @@ -1003,7 +974,7 @@ set_ctype_asm (unsigned char const *chars, int type) } static void -clear_ctype_asm (unsigned char const *chars, int type) +clear_ctype_asm (char const *chars, int type) { unsigned char *rct = &ctype_asm[1]; @@ -1038,10 +1009,10 @@ set_args_asm (char const *lang_name, int op, char const *arg) switch (*arg++) { case 'a': - set_ctype_asm ((unsigned char *) arg, I1 | ((op == '-') ? IG : 0)); + set_ctype_asm (arg, I1 | ((op == '-') ? IG : 0)); break; case 'c': - set_ctype_asm ((unsigned char *) arg, CM); + set_ctype_asm (arg, CM); break; case 'u': eat_underscore = (op == '+'); @@ -1052,13 +1023,13 @@ set_args_asm (char const *lang_name, int op, char const *arg) case 'C': if (op == '+') { - set_ctype_asm ((unsigned char *) "/", C1); - set_ctype_asm ((unsigned char *) "*", C2); + set_ctype_asm ("/", C1); + set_ctype_asm ("*", C2); } else { - clear_ctype_asm ((unsigned char *) "/", C1); - clear_ctype_asm ((unsigned char *) "*", C2); + clear_ctype_asm ("/", C1); + clear_ctype_asm ("*", C2); } break; default: @@ -1085,7 +1056,7 @@ set_args_asm (char const *lang_name, int op, char const *arg) #undef ISCBORING #undef ISCCBORING #undef ISIGNORE - + /*************** Text *******************************************************/ #define I1 0x01 /* 1st char of an identifier [a-zA-Z_] */ @@ -1122,22 +1093,6 @@ static unsigned char ctype_text[257] = /*150*/ I1, I1, I1, I1, I1|NM, I1, I1, I1, /*160*/ I1, I1, I1, I1, I1, I1, I1, I1, /*170*/ I1|NM, I1, I1, 0, 0, 0, 0, 0, -/*200*/ 0, 0, 0, 0, 0, 0, 0, 0, -/*210*/ 0, 0, 0, 0, 0, 0, 0, 0, -/*220*/ 0, 0, 0, 0, 0, 0, 0, 0, -/*230*/ 0, 0, 0, 0, 0, 0, 0, 0, -/*240*/ 0, 0, 0, 0, 0, 0, 0, 0, -/*250*/ 0, 0, 0, 0, 0, 0, 0, 0, -/*260*/ 0, 0, 0, 0, 0, 0, 0, 0, -/*270*/ 0, 0, 0, 0, 0, 0, 0, 0, -/*300*/ I1, I1, I1, I1, I1, I1, I1, I1, -/*310*/ I1, I1, I1, I1, I1, I1, I1, I1, -/*320*/ I1, I1, I1, I1, I1, I1, I1, 0, -/*330*/ I1, I1, I1, I1, I1, I1, I1, I1, -/*340*/ I1, I1, I1, I1, I1, I1, I1, I1, -/*350*/ I1, I1, I1, I1, I1, I1, I1, I1, -/*360*/ I1, I1, I1, I1, I1, I1, I1, 0, -/*370*/ I1, I1, I1, I1, I1, I1, I1, I1, }; /* @@ -1190,7 +1145,7 @@ top: } static void -set_ctype_text (unsigned char const *chars, int type) +set_ctype_text (char const *chars, int type) { unsigned char *rct = &ctype_text[1]; @@ -1199,7 +1154,7 @@ set_ctype_text (unsigned char const *chars, int type) } static void -clear_ctype_text (unsigned char const *chars, int type) +clear_ctype_text (char const *chars, int type) { unsigned char *rct = &ctype_text[1]; @@ -1232,15 +1187,15 @@ set_args_text (char const *lang_name, int op, char const *arg) { case 'a': if (op == '+') - set_ctype_text ((unsigned char *) arg, I1); + set_ctype_text (arg, I1); else - clear_ctype_text ((unsigned char *) arg, I1); + clear_ctype_text (arg, I1); break; case 's': if (op == '+') - set_ctype_text ((unsigned char *) arg, SQ); + set_ctype_text (arg, SQ); else - clear_ctype_text ((unsigned char *) arg, SQ); + clear_ctype_text (arg, SQ); break; default: if (lang_name) @@ -15,7 +15,12 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -char *strerror(int errnum) +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +char * +strerror __P((int errnum)) { extern char *sys_errlist[]; extern int sys_nerr; @@ -33,6 +33,8 @@ #define strncaseequ(s1, s2, n) (strncasecmp ((s1), (s2), (n)) == 0) #ifndef HAVE_STRDUP #define strdup(s) (strcpy (calloc (1, strlen (s) + 1), (s))) +#else +char *strdup (); #endif #define strndup(s, n) (strncpy (calloc (1, (n)+1), (s), (n))) diff --git a/version.texi b/version.texi index 4550c3d..65e414e 100644 --- a/version.texi +++ b/version.texi @@ -1 +1 @@ -@set VERSION 3.0.8 +@set VERSION 3.0.9 |