diff options
Diffstat (limited to 'contrib/texinfo/util')
-rw-r--r-- | contrib/texinfo/util/Makefile.am | 13 | ||||
-rw-r--r-- | contrib/texinfo/util/Makefile.in | 348 | ||||
-rw-r--r-- | contrib/texinfo/util/README | 4 | ||||
-rwxr-xr-x | contrib/texinfo/util/gen-dir-node | 11 | ||||
-rw-r--r-- | contrib/texinfo/util/install-info.c | 275 | ||||
-rwxr-xr-x | contrib/texinfo/util/texi2dvi | 192 | ||||
-rw-r--r-- | contrib/texinfo/util/texindex.c | 710 | ||||
-rwxr-xr-x | contrib/texinfo/util/update-info | 875 |
8 files changed, 1796 insertions, 632 deletions
diff --git a/contrib/texinfo/util/Makefile.am b/contrib/texinfo/util/Makefile.am new file mode 100644 index 000000000000..f16dd034da85 --- /dev/null +++ b/contrib/texinfo/util/Makefile.am @@ -0,0 +1,13 @@ +## Makefile.am for texinfo/util. +## $Id: Makefile.am,v 1.6 1997/07/15 19:15:05 karl Exp $ +## Run automake in .. to produce Makefile.in from this. + +bin_PROGRAMS = install-info texindex +bin_SCRIPTS = texi2dvi + +localedir = $(datadir)/locale +INCLUDES = -I$(top_srcdir)/lib -I../intl -DLOCALEDIR=\"$(localedir)\" +LDADD = ../lib/libtxi.a @INTLLIBS@ + +EXTRA_DIST = README deref.c fixfonts gen-dir-node tex3patch texi2dvi \ + update-info diff --git a/contrib/texinfo/util/Makefile.in b/contrib/texinfo/util/Makefile.in index aa3b85a8bd68..7b04741a6c60 100644 --- a/contrib/texinfo/util/Makefile.in +++ b/contrib/texinfo/util/Makefile.in @@ -1,101 +1,321 @@ -# Makefile for GNU Texindex and other utilities. -# $Id: Makefile.in,v 1.5 1996/09/29 20:07:06 karl Exp $ -# -# Copyright (C) 1990, 91, 92, 96 Free Software Foundation, Inc. +# Makefile.in generated automatically by automake 1.2f from Makefile.am -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2, or (at your option) -# any later version. +# Copyright (C) 1994, 1995, 1996, 1997, 1998 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -#### Start of system configuration section. #### +SHELL = /bin/sh srcdir = @srcdir@ -VPATH = $(srcdir):$(common) +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +prefix = @prefix@ +exec_prefix = @exec_prefix@ -common = $(srcdir)/../libtxi +bindir = @bindir@ +sbindir = @sbindir@ +libexecdir = @libexecdir@ +datadir = @datadir@ +sysconfdir = @sysconfdir@ +sharedstatedir = @sharedstatedir@ +localstatedir = @localstatedir@ +libdir = @libdir@ +infodir = @infodir@ +mandir = @mandir@ +includedir = @includedir@ +oldincludedir = /usr/include + +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ + +top_builddir = .. + +ACLOCAL = @ACLOCAL@ +AUTOCONF = @AUTOCONF@ +AUTOMAKE = @AUTOMAKE@ +AUTOHEADER = @AUTOHEADER@ -CC = @CC@ INSTALL = @INSTALL@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_DATA = @INSTALL_DATA@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +transform = @program_transform_name@ -LN = ln -RM = rm -f -MKDIR = mkdir +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +CATALOGS = @CATALOGS@ +CATOBJEXT = @CATOBJEXT@ +CC = @CC@ +DATADIRNAME = @DATADIRNAME@ +GENCAT = @GENCAT@ +GMOFILES = @GMOFILES@ +GMSGFMT = @GMSGFMT@ +GT_NO = @GT_NO@ +GT_YES = @GT_YES@ +INCLUDE_LOCALE_H = @INCLUDE_LOCALE_H@ +INSTOBJEXT = @INSTOBJEXT@ +INTLDEPS = @INTLDEPS@ +INTLLIBS = @INTLLIBS@ +INTLOBJS = @INTLOBJS@ +MAKEINFO = @MAKEINFO@ +MKINSTALLDIRS = @MKINSTALLDIRS@ +MSGFMT = @MSGFMT@ +PACKAGE = @PACKAGE@ +POFILES = @POFILES@ +POSUB = @POSUB@ +RANLIB = @RANLIB@ +TERMLIBS = @TERMLIBS@ +TEXCONFIG = @TEXCONFIG@ +TEXMF = @TEXMF@ +USE_INCLUDED_LIBINTL = @USE_INCLUDED_LIBINTL@ +USE_NLS = @USE_NLS@ +VERSION = @VERSION@ +l = @l@ -DEFS = @DEFS@ -LIBS = -L../libtxi -ltxi @LIBS@ -LOADLIBES = $(LIBS) +bin_PROGRAMS = install-info texindex +bin_SCRIPTS = texi2dvi -SHELL = /bin/sh +localedir = $(datadir)/locale +INCLUDES = -I$(top_srcdir)/lib -I../intl -DLOCALEDIR=\"$(localedir)\" +LDADD = ../lib/libtxi.a @INTLLIBS@ -CFLAGS = @CFLAGS@ +EXTRA_DIST = README deref.c fixfonts gen-dir-node tex3patch texi2dvi \ + update-info +mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs +CONFIG_HEADER = ../config.h +CONFIG_CLEAN_FILES = +PROGRAMS = $(bin_PROGRAMS) + + +DEFS = @DEFS@ -I. -I$(srcdir) -I.. +CPPFLAGS = @CPPFLAGS@ LDFLAGS = @LDFLAGS@ +LIBS = @LIBS@ +install_info_SOURCES = install-info.c +install_info_OBJECTS = install-info.o +install_info_LDADD = $(LDADD) +install_info_DEPENDENCIES = ../lib/libtxi.a +install_info_LDFLAGS = +texindex_SOURCES = texindex.c +texindex_OBJECTS = texindex.o +texindex_LDADD = $(LDADD) +texindex_DEPENDENCIES = ../lib/libtxi.a +texindex_LDFLAGS = +SCRIPTS = $(bin_SCRIPTS) -prefix = @prefix@ -exec_prefix = @exec_prefix@ -bindir = $(exec_prefix)/bin -# Prefix for each installed program, normally empty or `g'. -binprefix = -# Prefix for each installed man page, normally empty or `g'. -manprefix = -mandir = $(prefix)/man/man1 -manext = 1 -infodir = $(prefix)/info +CFLAGS = @CFLAGS@ +COMPILE = $(CC) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) +LINK = $(CC) $(CFLAGS) $(LDFLAGS) -o $@ +DIST_COMMON = README Makefile.am Makefile.in + + +DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) + +TAR = tar +GZIP = --best +SOURCES = install-info.c texindex.c +OBJECTS = install-info.o texindex.o + +default: all + +.SUFFIXES: +.SUFFIXES: .S .c .o .s +$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) + cd $(top_srcdir) && $(AUTOMAKE) --gnu --include-deps util/Makefile + +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + cd $(top_builddir) \ + && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status + + +mostlyclean-binPROGRAMS: + +clean-binPROGRAMS: + -test -z "$(bin_PROGRAMS)" || rm -f $(bin_PROGRAMS) + +distclean-binPROGRAMS: -#### End of system configuration section. #### +maintainer-clean-binPROGRAMS: -all: texindex install-info -sub-all: all +install-binPROGRAMS: $(bin_PROGRAMS) + @$(NORMAL_INSTALL) + $(mkinstalldirs) $(bindir) + @list='$(bin_PROGRAMS)'; for p in $$list; do \ + if test -f $$p; then \ + echo " $(INSTALL_PROGRAM) $$p $(bindir)/`echo $$p|sed '$(transform)'`"; \ + $(INSTALL_PROGRAM) $$p $(bindir)/`echo $$p|sed '$(transform)'`; \ + else :; fi; \ + done + +uninstall-binPROGRAMS: + @$(NORMAL_UNINSTALL) + list='$(bin_PROGRAMS)'; for p in $$list; do \ + rm -f $(bindir)/`echo $$p|sed '$(transform)'`; \ + done .c.o: - $(CC) -c $(CPPFLAGS) $(DEFS) -I. -I$(srcdir) -I$(common) $(CFLAGS) $< + $(COMPILE) -c $< + +.s.o: + $(COMPILE) -c $< + +.S.o: + $(COMPILE) -c $< + +mostlyclean-compile: + -rm -f *.o core *.core + +clean-compile: + +distclean-compile: + -rm -f *.tab.c + +maintainer-clean-compile: + +install-info: $(install_info_OBJECTS) $(install_info_DEPENDENCIES) + @rm -f install-info + $(LINK) $(install_info_LDFLAGS) $(install_info_OBJECTS) $(install_info_LDADD) $(LIBS) + +texindex: $(texindex_OBJECTS) $(texindex_DEPENDENCIES) + @rm -f texindex + $(LINK) $(texindex_LDFLAGS) $(texindex_OBJECTS) $(texindex_LDADD) $(LIBS) + +install-binSCRIPTS: $(bin_SCRIPTS) + @$(NORMAL_INSTALL) + $(mkinstalldirs) $(bindir) + @list='$(bin_SCRIPTS)'; for p in $$list; do \ + if test -f $$p; then \ + echo " $(INSTALL_SCRIPT) $$p $(bindir)/`echo $$p|sed '$(transform)'`"; \ + $(INSTALL_SCRIPT) $$p $(bindir)/`echo $$p|sed '$(transform)'`; \ + else if test -f $(srcdir)/$$p; then \ + echo " $(INSTALL_SCRIPT) $(srcdir)/$$p $(bindir)/`echo $$p|sed '$(transform)'`"; \ + $(INSTALL_SCRIPT) $(srcdir)/$$p $(bindir)/`echo $$p|sed '$(transform)'`; \ + else :; fi; fi; \ + done + +uninstall-binSCRIPTS: + @$(NORMAL_UNINSTALL) + list='$(bin_SCRIPTS)'; for p in $$list; do \ + rm -f $(bindir)/`echo $$p|sed '$(transform)'`; \ + done + +tags: TAGS + +ID: $(HEADERS) $(SOURCES) $(LISP) + here=`pwd` && cd $(srcdir) \ + && mkid -f$$here/ID $(SOURCES) $(HEADERS) $(LISP) + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS)'; \ + unique=`for i in $$list; do echo $$i; done | \ + awk ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \ + || (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags $$unique $(LISP) -o $$here/TAGS) + +mostlyclean-tags: + +clean-tags: + +distclean-tags: + -rm -f TAGS ID + +maintainer-clean-tags: + +distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir) + +subdir = util + +distdir: $(DISTFILES) + @for file in $(DISTFILES); do \ + d=$(srcdir); \ + test -f $(distdir)/$$file \ + || ln $$d/$$file $(distdir)/$$file 2> /dev/null \ + || cp -p $$d/$$file $(distdir)/$$file; \ + done +install-info.o: install-info.c ../lib/system.h ../config.h \ + ../lib/getopt.h +texindex.o: texindex.c ../lib/system.h ../config.h ../lib/getopt.h + +info: +dvi: +check: all + $(MAKE) +installcheck: +install-exec: install-binPROGRAMS install-binSCRIPTS + @$(NORMAL_INSTALL) + +install-data: + @$(NORMAL_INSTALL) + +install: install-exec install-data all + @: +uninstall: uninstall-binPROGRAMS uninstall-binSCRIPTS -install: all - $(INSTALL_PROGRAM) texindex $(bindir)/texindex - $(INSTALL_PROGRAM) $(srcdir)/texi2dvi $(bindir)/texi2dvi - $(INSTALL_PROGRAM) install-info $(bindir)/install-info +all: Makefile $(PROGRAMS) $(SCRIPTS) -uninstall: - rm -f $(bindir)/texindex $(bindir)/texi2dvi $(bindir)/install-info +install-strip: + $(MAKE) INSTALL_PROGRAM='$(INSTALL_PROGRAM) -s' INSTALL_SCRIPT='$(INSTALL_PROGRAM)' install +installdirs: + $(mkinstalldirs) $(bindir) $(bindir) -Makefile: Makefile.in ../config.status - cd ..; sh config.status -TAGS: - etags *.c *.h $(common)/getopt*.c $(common)/getopt.h +mostlyclean-generic: + -test -z "$(MOSTLYCLEANFILES)" || rm -f $(MOSTLYCLEANFILES) -clean: - rm -f *.o a.out core core.* texindex install-info +clean-generic: + -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) -mostlyclean: clean +distclean-generic: + -rm -f Makefile $(DISTCLEANFILES) + -rm -f config.cache config.log stamp-h stamp-h[0-9]* + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -distclean: clean - rm -f Makefile config.status +maintainer-clean-generic: + -test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES) + -test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES) +mostlyclean: mostlyclean-binPROGRAMS mostlyclean-compile \ + mostlyclean-tags mostlyclean-generic -realclean: distclean - rm -f TAGS +clean: clean-binPROGRAMS clean-compile clean-tags clean-generic \ + mostlyclean -texindex: texindex.o ../libtxi/libtxi.a - $(CC) $(LDFLAGS) -o texindex texindex.o $(LOADLIBES) +distclean: distclean-binPROGRAMS distclean-compile distclean-tags \ + distclean-generic clean + -rm -f config.status -texindex.o: texindex.c $(common)/getopt.h +maintainer-clean: maintainer-clean-binPROGRAMS maintainer-clean-compile \ + maintainer-clean-tags maintainer-clean-generic \ + distclean + @echo "This command is intended for maintainers to use;" + @echo "it deletes files that may require special tools to rebuild." -install-info: install-info.o - $(CC) $(LDFLAGS) -o install-info install-info.o $(LOADLIBES) +.PHONY: default mostlyclean-binPROGRAMS distclean-binPROGRAMS \ +clean-binPROGRAMS maintainer-clean-binPROGRAMS uninstall-binPROGRAMS \ +install-binPROGRAMS mostlyclean-compile distclean-compile clean-compile \ +maintainer-clean-compile uninstall-binSCRIPTS install-binSCRIPTS tags \ +mostlyclean-tags distclean-tags clean-tags maintainer-clean-tags \ +distdir info dvi installcheck install-exec install-data install \ +uninstall all installdirs mostlyclean-generic distclean-generic \ +clean-generic maintainer-clean-generic clean mostlyclean distclean \ +maintainer-clean -install-info.o: install-info.c $(common)/getopt.h -# Prevent GNU make v3 from overflowing arg limit on SysV. +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: diff --git a/contrib/texinfo/util/README b/contrib/texinfo/util/README new file mode 100644 index 000000000000..5385522543b7 --- /dev/null +++ b/contrib/texinfo/util/README @@ -0,0 +1,4 @@ +Assorted Texinfo-related programs and scripts. + +texindex, texi2dvi, and install-info get installed. +The other items here are for your amusement and/or hacking pleasure. diff --git a/contrib/texinfo/util/gen-dir-node b/contrib/texinfo/util/gen-dir-node index 8f13088f920d..c7ef670c5393 100755 --- a/contrib/texinfo/util/gen-dir-node +++ b/contrib/texinfo/util/gen-dir-node @@ -1,5 +1,5 @@ #!/bin/sh -# $Id: gen-dir-node,v 1.2 1996/10/03 18:49:48 karl Exp $ +# $Id: gen-dir-node,v 1.1 1997/05/22 22:02:43 karl Exp $ # Generate the top-level Info node, given a directory of Info files # and (optionally) a skeleton file. The output will be suitable for a # top-level dir file. The skeleton file contains info topic names in the @@ -164,9 +164,14 @@ else fi for file in ${infofiles}; do + case $file in + *.gz) zcat=zcat; file=`echo $file|sed 's/\.gz$//'`; gz=.gz;; + *) zcat=cat; gz=;; + esac infoname=`echo $file | sed 's/\.info$//'` - entry=`sed -e '1,/START-INFO-DIR-ENTRY/d' \ - -e '/END-INFO-DIR-ENTRY/,$d' ${INFODIR}/${file}` + entry=`$zcat ${INFODIR}/${file}$gz \ + |sed -e '1,/START-INFO-DIR-ENTRY/d' \ + -e '/END-INFO-DIR-ENTRY/,$d'` if [ ! -z "${entry}" ] ; then echo "${entry}" diff --git a/contrib/texinfo/util/install-info.c b/contrib/texinfo/util/install-info.c index 53fa4aa11164..03f6937d1d7f 100644 --- a/contrib/texinfo/util/install-info.c +++ b/contrib/texinfo/util/install-info.c @@ -1,37 +1,27 @@ /* install-info -- create Info directory entry(ies) for an Info file. - Copyright (C) 1996 Free Software Foundation, Inc. + $Id: install-info.c,v 1.21 1998/03/01 15:38:45 karl Exp $ -$Id: install-info.c,v 1.12 1996/10/03 23:13:36 karl Exp $ + Copyright (C) 1996, 97, 98 Free Software Foundation, Inc. -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.*/ -#define INSTALL_INFO_VERSION_STRING "GNU install-info (Texinfo 3.9) 1.2" - -#include <stdio.h> -#include <errno.h> +#include "system.h" #include <getopt.h> -#include <sys/types.h> - -/* Get O_RDONLY. */ -#ifdef HAVE_SYS_FCNTL_H -#include <sys/fcntl.h> -#else -#include <fcntl.h> -#endif /* !HAVE_SYS_FCNTL_H */ -#ifdef HAVE_SYS_FILE_H -#include <sys/file.h> + +#ifdef HAVE_LIBZ +#include <zlib.h> #endif /* Name this program was invoked with. */ @@ -39,7 +29,6 @@ char *progname; char *readfile (); struct line_data *findlines (); -char *my_strerror (); void fatal (); void insert_entry_here (); int compare_section_names (); @@ -48,9 +37,8 @@ struct spec_entry; /* Data structures. */ -/* Record info about a single line from a file - as read into core. */ +/* Record info about a single line from a file as read into core. */ struct line_data { /* The start of the line. */ @@ -67,9 +55,9 @@ struct line_data int delete; }; + /* This is used for a list of the specified menu section names in which entries should be added. */ - struct spec_section { struct spec_section *next; @@ -79,16 +67,16 @@ struct spec_section int missing; }; -/* This is used for a list of the entries specified to be added. */ +/* This is used for a list of the entries specified to be added. */ struct spec_entry { struct spec_entry *next; char *text; }; - -/* This is used for a list of nodes found by parsing the dir file. */ + +/* This is used for a list of nodes found by parsing the dir file. */ struct node { struct node *next; @@ -109,9 +97,9 @@ struct node struct menu_section *last_section; }; + /* This is used for a list of sections found in a node's menu. Each struct node has such a list in the sections field. */ - struct menu_section { struct menu_section *next; @@ -125,7 +113,6 @@ struct menu_section /* Memory allocation and string operations. */ /* Like malloc but get fatal error if memory is exhausted. */ - void * xmalloc (size) unsigned int size; @@ -133,12 +120,11 @@ xmalloc (size) extern void *malloc (); void *result = malloc (size); if (result == NULL) - fatal ("virtual memory exhausted", 0); + fatal (_("virtual memory exhausted"), 0); return result; } -/* Like malloc but get fatal error if memory is exhausted. */ - +/* Like realloc but get fatal error if memory is exhausted. */ void * xrealloc (obj, size) void *obj; @@ -147,12 +133,12 @@ xrealloc (obj, size) extern void *realloc (); void *result = realloc (obj, size); if (result == NULL) - fatal ("virtual memory exhausted", 0); + fatal (_("virtual memory exhausted"), 0); return result; } -/* Return a newly-allocated string whose contents concatenate those of s1, s2, s3. */ - +/* Return a newly-allocated string + whose contents concatenate those of S1, S2, S3. */ char * concat (s1, s2, s3) char *s1, *s2, *s3; @@ -186,7 +172,7 @@ copy_string (string, size) /* Error message functions. */ -/* Print error message. `s1' is printf control string, `s2' is arg for it. */ +/* Print error message. S1 is printf control string, S2 and S3 args for it. */ /* VARARGS1 */ void @@ -195,7 +181,7 @@ error (s1, s2, s3) { fprintf (stderr, "%s: ", progname); fprintf (stderr, s1, s2, s3); - fprintf (stderr, "\n"); + putc ('\n', stderr); } /* VARARGS1 */ @@ -203,9 +189,9 @@ void warning (s1, s2, s3) char *s1, *s2, *s3; { - fprintf (stderr, "%s: Warning: ", progname); + fprintf (stderr, _("%s: warning: "), progname); fprintf (stderr, s1, s2, s3); - fprintf (stderr, "\n"); + putc ('\n', stderr); } /* Print error message and exit. */ @@ -224,7 +210,7 @@ void pfatal_with_name (name) char *name; { - char *s = concat ("", my_strerror (errno), " for %s"); + char *s = concat ("", strerror (errno), _(" for %s")); fatal (s, name); } @@ -293,7 +279,7 @@ extract_menu_file_name (item_text) void suggest_asking_for_help () { - fprintf (stderr, "\tTry `%s --help' for a complete list of options.\n", + fprintf (stderr, _("\tTry `%s --help' for a complete list of options.\n"), progname); exit (1); } @@ -301,8 +287,9 @@ suggest_asking_for_help () void print_help () { - printf ("%s [OPTION]... [INFO-FILE [DIR-FILE]]\n\ - Install INFO-FILE in the Info directory file DIR-FILE.\n\ + printf (_("Usage: %s [OPTION]... [INFO-FILE [DIR-FILE]]\n\ +\n\ +Install INFO-FILE in the Info directory file DIR-FILE.\n\ \n\ Options:\n\ --delete Delete existing entries in INFO-FILE;\n\ @@ -330,24 +317,57 @@ Options:\n\ from information in the Info file itself.\n\ --version Display version information and exit.\n\ \n\ -Email bug reports to bug-texinfo@prep.ai.mit.edu.\n\ -", progname); +Email bug reports to bug-texinfo@gnu.org.\n\ +"), progname); } -/* Convert an errno value into a string describing the error. - We define this function here rather than using strerror - because not all systems have strerror. */ + +/* If DIRFILE does not exist, create a minimal one (or abort). If it + already exists, do nothing. */ -char * -my_strerror (errnum) - int errnum; +void +ensure_dirfile_exists (dirfile) + char *dirfile; { - extern char *sys_errlist[]; - extern int sys_nerr; - - if (errnum >= 0 && errnum < sys_nerr) - return sys_errlist[errnum]; - return (char *) "Unknown error"; + int desc = open (dirfile, O_RDONLY); + if (desc < 0 && errno == ENOENT) + { + FILE *f; + char *readerr = strerror (errno); + close (desc); + f = fopen (dirfile, "w"); + if (f) + { + fputs (_("This is the file .../info/dir, which contains the\n\ +topmost node of the Info hierarchy, called (dir)Top.\n\ +The first time you invoke Info you start off looking at this node.\n\ +\n\ +File: dir,\tNode: Top,\tThis is the top of the INFO tree\n\ +\n\ + This (the Directory node) gives a menu of major topics.\n\ + Typing \"q\" exits, \"?\" lists all Info commands, \"d\" returns here,\n\ + \"h\" gives a primer for first-timers,\n\ + \"mEmacs<Return>\" visits the Emacs manual, etc.\n\ +\n\ + In Emacs, you can click mouse button 2 on a menu item or cross reference\n\ + to select it.\n\ +\n\ +* Menu:\n\ +"), f); + if (fclose (f) < 0) + pfatal_with_name (dirfile); + } + else + { + /* Didn't exist, but couldn't open for writing. */ + fprintf (stderr, + _("%s: could not read (%s) and could not create (%s)\n"), + dirfile, readerr, strerror (errno)); + exit (1); + } + } + else + close (desc); /* It already existed, so fine. */ } /* This table defines all the long-named options, says whether they @@ -355,20 +375,22 @@ my_strerror (errnum) struct option longopts[] = { - { "delete", no_argument, NULL, 'r' }, - { "dir-file", required_argument, NULL, 'd' }, - { "entry", required_argument, NULL, 'e' }, - { "help", no_argument, NULL, 'h' }, - { "info-dir", required_argument, NULL, 'D' }, - { "info-file", required_argument, NULL, 'i' }, - { "item", required_argument, NULL, 'e' }, - { "quiet", no_argument, NULL, 'q' }, - { "remove", no_argument, NULL, 'r' }, - { "section", required_argument, NULL, 's' }, - { "version", no_argument, NULL, 'V' }, + { "delete", no_argument, NULL, 'r' }, + { "dir-file", required_argument, NULL, 'd' }, + { "entry", required_argument, NULL, 'e' }, + { "help", no_argument, NULL, 'h' }, + { "info-dir", required_argument, NULL, 'D' }, + { "info-file", required_argument, NULL, 'i' }, + { "item", required_argument, NULL, 'e' }, + { "quiet", no_argument, NULL, 'q' }, + { "remove", no_argument, NULL, 'r' }, + { "section", required_argument, NULL, 's' }, + { "version", no_argument, NULL, 'V' }, { 0 } }; + +int main (argc, argv) int argc; char **argv; @@ -410,6 +432,15 @@ main (argc, argv) progname = argv[0]; +#ifdef HAVE_SETLOCALE + /* Set locale via LC_ALL. */ + setlocale (LC_ALL, ""); +#endif + + /* Set the text message domain. */ + bindtextdomain (PACKAGE, LOCALEDIR); + textdomain (PACKAGE); + while (1) { int opt = getopt_long (argc, argv, "i:d:e:s:hHr", longopts, 0); @@ -430,7 +461,7 @@ main (argc, argv) case 'd': if (dirfile) { - fprintf (stderr, "%s: Specify the Info directory only once.\n", + fprintf (stderr, _("%s: Specify the Info directory only once.\n"), progname); suggest_asking_for_help (); } @@ -440,7 +471,7 @@ main (argc, argv) case 'D': if (dirfile) { - fprintf (stderr, "%s: Specify the Info directory only once.\n", + fprintf (stderr, _("%s: Specify the Info directory only once.\n"), progname); suggest_asking_for_help (); } @@ -468,7 +499,7 @@ main (argc, argv) case 'i': if (infile) { - fprintf (stderr, "%s: Specify the Info file only once.\n", + fprintf (stderr, _("%s: Specify the Info file only once.\n"), progname); suggest_asking_for_help (); } @@ -495,12 +526,13 @@ main (argc, argv) break; case 'V': - puts (INSTALL_INFO_VERSION_STRING); -puts ("Copyright (C) 1996 Free Software Foundation, Inc.\n\ + printf ("install-info (GNU %s) %s\n", PACKAGE, VERSION); + printf (_("Copyright (C) %s Free Software Foundation, Inc.\n\ There is NO warranty. You may redistribute this software\n\ under the terms of the GNU General Public License.\n\ -For more information about these matters, see the files named COPYING."); - exit (0); +For more information about these matters, see the files named COPYING.\n"), + "1998"); + exit (0); default: suggest_asking_for_help (); @@ -515,13 +547,13 @@ For more information about these matters, see the files named COPYING."); else if (dirfile == 0) dirfile = argv[optind]; else - error ("excess command line argument `%s'", argv[optind]); + error (_("excess command line argument `%s'"), argv[optind]); } if (!infile) - fatal ("No input file specified"); + fatal (_("No input file specified; try --help for more information.")); if (!dirfile) - fatal ("No dir file specified"); + fatal (_("No dir file specified; try --help for more information.")); /* Read the Info file and parse it into lines. */ @@ -573,7 +605,7 @@ For more information about these matters, see the files named COPYING."); && sizeof ("START-INFO-DIR-ENTRY") - 1 == input_lines[i].size) { if (start_of_this_entry != 0) - fatal ("START-INFO-DIR-ENTRY without matching END-INFO-DIR-ENTRY"); + fatal (_("START-INFO-DIR-ENTRY without matching END-INFO-DIR-ENTRY")); start_of_this_entry = input_lines[i + 1].start; } if (!strncmp ("END-INFO-DIR-ENTRY", input_lines[i].start, @@ -592,18 +624,26 @@ For more information about these matters, see the files named COPYING."); start_of_this_entry = 0; } else - fatal ("END-INFO-DIR-ENTRY without matching START-INFO-DIR-ENTRY"); + fatal (_("END-INFO-DIR-ENTRY without matching START-INFO-DIR-ENTRY")); } } if (start_of_this_entry != 0) - fatal ("START-INFO-DIR-ENTRY without matching END-INFO-DIR-ENTRY"); + fatal (_("START-INFO-DIR-ENTRY without matching END-INFO-DIR-ENTRY")); } if (!delete_flag) if (entries_to_add == 0) - fatal ("no info dir entry in `%s'", infile); + { /* No need to abort here, the original info file may not have + the requisite Texinfo commands. This is not something an + installer should have to correct (it's a problem for the + maintainer), and there's no need to cause subsequent parts of + `make install' to fail. */ + warning (_("no info dir entry in `%s'"), infile); + exit (0); + } /* Now read in the Info dir file. */ + ensure_dirfile_exists (dirfile); dir_data = readfile (dirfile, &dir_size); dir_lines = findlines (dir_data, dir_size, &dir_nlines); @@ -612,7 +652,6 @@ For more information about these matters, see the files named COPYING."); .info suffix. */ { unsigned basename_len; - extern char *strrchr (); char *infile_basename = strrchr (infile, '/'); if (infile_basename) infile_basename++; @@ -733,8 +772,12 @@ For more information about these matters, see the files named COPYING."); if ((dir_lines[i].size > (p - dir_lines[i].start + infilelen_sans_info)) && !strncmp (p, infile_sans_info, infilelen_sans_info) - && p[infilelen_sans_info] == ')') - dir_lines[i].delete = 1; + && (p[infilelen_sans_info] == ')' + || !strncmp (p + infilelen_sans_info, ".info)", 6))) + { + dir_lines[i].delete = 1; + something_deleted = 1; + } } } /* Treat lines that start with whitespace @@ -806,7 +849,7 @@ For more information about these matters, see the files named COPYING."); dir_lines[i].start, dir_lines[i].size) && !dir_lines[i].delete) - fatal ("menu item `%s' already exists, for file `%s'", + fatal (_("menu item `%s' already exists, for file `%s'"), extract_menu_item_name (entry->text), extract_menu_file_name (dir_lines[i].start)); if (dir_lines[i].start[0] == '*' @@ -829,7 +872,7 @@ For more information about these matters, see the files named COPYING."); } if (delete_flag && !something_deleted && !quiet_flag) - warning ("no entries found for `%s'; nothing deleted", infile); + warning (_("no entries found for `%s'; nothing deleted"), infile); /* Output the old dir file, interpolating the new sections and/or new entries where appropriate. */ @@ -921,19 +964,49 @@ readfile (filename, sizep) char *filename; int *sizep; { + int desc; int data_size = 1024; char *data = (char *) xmalloc (data_size); int filled = 0; int nread = 0; +#ifdef HAVE_LIBZ + int isGZ = 0; + gzFile zdesc; +#endif - int desc = open (filename, O_RDONLY); - + desc = open (filename, O_RDONLY); if (desc < 0) pfatal_with_name (filename); +#ifdef HAVE_LIBZ + /* The file should always be two bytes long. */ + if (read (desc, data, 2) != 2) + pfatal_with_name (filename); + + /* Undo that read. */ + lseek (desc, 0, SEEK_SET); + + /* If we see gzip magic, use gzdopen. */ + if (data[0] == '\x1f' && data[1] == '\x8b') + { + isGZ = 1; + zdesc = gzdopen (desc, "r"); + if (zdesc == NULL) { + close (desc); + pfatal_with_name (filename); + } + } +#endif /* HAVE_LIBZ */ + while (1) { - nread = read (desc, data + filled, data_size - filled); +#ifdef HAVE_LIBZ + if (isGZ) + nread = gzread (zdesc, data + filled, data_size - filled); + else +#endif + nread = read (desc, data + filled, data_size - filled); + if (nread < 0) pfatal_with_name (filename); if (nread == 0) @@ -948,6 +1021,14 @@ readfile (filename, sizep) } *sizep = filled; + +#ifdef HAVE_LIBZ + if (isGZ) + gzclose (zdesc); + else +#endif + close(desc); + return data; } diff --git a/contrib/texinfo/util/texi2dvi b/contrib/texinfo/util/texi2dvi index 9b2e48eefcc4..43f652d00f19 100755 --- a/contrib/texinfo/util/texi2dvi +++ b/contrib/texinfo/util/texi2dvi @@ -1,10 +1,9 @@ #! /bin/sh # texi2dvi --- smartly produce DVI files from texinfo sources - -# Copyright (C) 1992, 93, 94, 95, 96 Free Software Foundation, Inc. - -# $Id: texi2dvi,v 1.10 1996/10/04 18:21:55 karl Exp $ - +# $Id: texi2dvi,v 0.8 1998/02/26 21:13:13 karl Exp $ +# +# Copyright (C) 1992, 93, 94, 95, 96, 97, 98 Free Software Foundation, Inc. +# # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) @@ -19,35 +18,34 @@ # along with this program; if not, you can either send email to this # program's maintainer or write to: The Free Software Foundation, # Inc.; 59 Temple Place, Suite 330; Boston, MA 02111-1307, USA. - +# # Commentary: - -# Author: Noah Friedman <friedman@prep.ai.mit.edu> - -# Please send bug reports, etc. to bug-texinfo@prep.ai.mit.edu +# +# Author: Noah Friedman <friedman@gnu.org> +# +# Please send bug reports, etc. to bug-texinfo@gnu.org. # If possible, please send a copy of the output of the script called with # the `--debug' option when making a bug report. - +# # In the interest of general portability, some common bourne shell # constructs were avoided because they weren't guaranteed to be available # in some earlier implementations. I've tried to make this program as # portable as possible. Welcome to unix, where the lowest common # denominator is rapidly diminishing. # -# Among the more interesting lossages I noticed with some bourne shells -# are: +# Among the more interesting lossages I noticed among Bourne shells: # * No shell functions. # * No `unset' builtin. # * `shift' cannot take a numeric argument, and signals an error if # there are no arguments to shift. - +# # Code: # Name by which this script was invoked. progname=`echo "$0" | sed -e 's/[^\/]*\///g'` # This string is expanded by rcs automatically when this file is checked out. -rcs_revision='$Revision: 1.10 $' +rcs_revision='$Revision: 0.8 $' version=`set - $rcs_revision; echo $2` # To prevent hairy quoting and escaping later. @@ -58,6 +56,8 @@ usage="Usage: $0 [OPTION]... FILE... Run a Texinfo document through TeX. Options: +-b, --batch No interaction (\nonstopmode in TeX). +-c, --clean Remove all auxiliary files. -D, --debug Turn on shell debugging ($bq${bq}set -x$eq$eq). -t, --texinfo CMD Insert CMD after @setfilename before running TeX. --verbose Report on what is done. @@ -67,14 +67,15 @@ Options: The values of the TEX, TEXINDEX, and MAKEINFO environment variables are used to run those commands, if they are set. -Email bug reports to bug-texinfo@prep.ai.mit.edu. -" +Email bug reports to bug-texinfo@gnu.org." # Initialize variables. # Don't use `unset' since old bourne shells don't have this command. # Instead, assign them an empty value. # Some of these, like TEX and TEXINDEX, may be inherited from the environment. backup_extension=.bak # these files get deleted if all goes well. +batch= +clean= debug= orig_pwd="`pwd`" textra= @@ -92,16 +93,19 @@ export TEXINPUTS # It's a good idea to document the full long option name in each case. # Long options which take arguments will need a `*' appended to the # canonical name to match the value appended after the `=' character. -while : ; do - case $# in 0) break ;; esac +while :; do + test $# -eq 0 && break + case "$1" in + -b | --batch | --b* ) batch=t; shift ;; + -c | --clean | --c* ) clean=t; shift ;; -D | --debug | --d* ) debug=t; shift ;; -h | --help | --h* ) echo "$usage"; exit 0 ;; # OK, we should do real option parsing here, but be lazy for now. -t | --texinfo | --t*) shift; textra="$textra $1"; shift ;; -v | --vers* ) - echo "$progname (Texinfo 3.9) $version" - echo "Copyright (C) 1996 Free Software Foundation, Inc. + echo "$progname (GNU Texinfo 3.12) $version" + echo "Copyright (C) 1998 Free Software Foundation, Inc. There is NO warranty. You may redistribute this software under the terms of the GNU General Public License. For more information about these matters, see the files named COPYING." @@ -109,8 +113,7 @@ For more information about these matters, see the files named COPYING." --verb* ) verbose=echo; shift ;; -- ) # Stop option processing shift - break - ;; + break ;; -* ) case "$1" in --*=* ) arg=`echo "$1" | sed -e 's/=.*//'` ;; @@ -119,11 +122,8 @@ For more information about these matters, see the files named COPYING." exec 1>&2 echo "$progname: Unknown or ambiguous option $bq$arg$eq." echo "$progname: Try $bq--help$eq for more information." - exit 1 - ;; - * ) - break - ;; + exit 1 ;; + * ) break ;; esac done @@ -139,14 +139,14 @@ fi test "$debug" = t && set -x # Texify files -for command_line_filename in ${1+"$@"} ; do +for command_line_filename in ${1+"$@"}; do $verbose "Processing $command_line_filename ..." # See if file exists. If it doesn't we're in trouble since, even # though the user may be able to reenter a valid filename at the tex # prompt (assuming they're attending the terminal), this script won't # be able to find the right index files and so forth. - if test ! -r "${command_line_filename}" ; then + if test ! -r "${command_line_filename}"; then echo "$0: Could not read ${command_line_filename}." >&2 continue fi @@ -161,17 +161,22 @@ for command_line_filename in ${1+"$@"} ; do # basename as the manual. Use extension .texi for the temp file so # that TeX will ignore it. Thus, we must use a subdirectory. # - # Output the macro-expanded file to here. - tmp_dir=${TMPDIR-/tmp}/$$ + # Output the macro-expanded file to here. The vastly abbreviated + # temporary directory name is so we don't have collisions on 8.3 or + # 14-character filesystems. + tmp_dir=${TMPDIR-/tmp}/txi2d.$$ filename_tmp=$tmp_dir/$filename_noext.texi # Output the file with the user's extra commands to here. - filename_tmp2=$tmp_dir.2/$filename_noext.texi - mkdir $tmp_dir $tmp_dir.2 + tmp_dir2=${tmp_dir}.2 + filename_tmp2=$tmp_dir2/$filename_noext.texi + mkdir $tmp_dir $tmp_dir2 + # Always remove the temporary directories. + trap "rm -rf $tmp_dir $tmp_dir2" 1 2 15 # If directory and file are the same, then it's probably because there's # no pathname component. Set dirname to `.', the current directory. - if test "z${directory}" = "z${command_line_filename}" ; then - directory=. + if test "z${directory}" = "z${command_line_filename}"; then + directory=. fi # Source file might @include additional texinfo sources. Put `.' and @@ -195,10 +200,10 @@ for command_line_filename in ${1+"$@"} ; do # let's be safe.) if test $? -ne 0 || cmp -s $filename_tmp $command_line_filename; then $verbose "Reverting to $command_line_filename ..." - filename_input=$command_line_filename - else - filename_input=$filename_tmp + cp -p $command_line_filename $filename_tmp fi + filename_input=$filename_tmp + dirname_input=$tmp_dir # Used most commonly for @finalout, @smallbook, etc. if test -n "$textra"; then @@ -206,6 +211,14 @@ for command_line_filename in ${1+"$@"} ; do sed '/^@setfilename/a\ '"$textra" $filename_input >$filename_tmp2 filename_input=$filename_tmp2 + dirname_input=$tmp_dir2 + fi + + # If clean mode was specified, then move to the temporary directory. + if test "$clean" = t; then + $verbose "cd $dirname_input" + cd $dirname_input || exit 1 + filename_input=`basename $filename_input` fi while true; do # will break out of loop below @@ -218,17 +231,17 @@ for command_line_filename in ${1+"$@"} ; do # is actually the cross-references file, but we need to keep track of # that too. possible_index_files="`eval echo ${filename_noext}.?? ${filename_noext}.aux`" - for this_file in ${possible_index_files} ; do - # If file is empty, forget it. - test -s "${this_file}" || continue - - # Examine first character of file. If it's not suitable to be an - # index or xref file, don't process it. - first_character="`sed -n '1s/^\(.\).*$/\1/p;q' ${this_file}`" - if test "x${first_character}" = "x\\" \ - || test "x${first_character}" = "x'"; then - definite_index_files="${definite_index_files} ${this_file}" - fi + for this_file in ${possible_index_files}; do + # If file is empty, forget it. + test -s "${this_file}" || continue + + # Examine first character of file. If it's not suitable to be an + # index or xref file, don't process it. + first_character="`sed -n '1s/^\(.\).*$/\1/p;q' ${this_file}`" + if test "x${first_character}" = "x\\" \ + || test "x${first_character}" = "x'"; then + definite_index_files="${definite_index_files} ${this_file}" + fi done orig_index_files="${definite_index_files}" orig_index_files_sans_aux="`echo ${definite_index_files} \ @@ -238,7 +251,7 @@ for command_line_filename in ${1+"$@"} ; do # Now save copies of original index files so we have some means of # comparison later. $verbose "Backing up current index files: $orig_index_files ..." - for index_file_to_save in ${orig_index_files} ; do + for index_file_to_save in ${orig_index_files}; do cp "${index_file_to_save}" "${index_file_to_save}${backup_extension}" done @@ -246,21 +259,27 @@ for command_line_filename in ${1+"$@"} ; do # after running TeX a first time the index files don't change, then # there's no reason to run TeX again. But we won't know that if the # index files are out of date or nonexistent. - if test -n "${orig_index_files_sans_aux}" ; then - $verbose "Running $texindex $orig_index_files_sans_aux ..." - ${texindex} ${orig_index_files_sans_aux} + if test -n "${orig_index_files_sans_aux}"; then + $verbose "Running $texindex $orig_index_files_sans_aux ..." + ${texindex} ${orig_index_files_sans_aux} fi # Finally, run TeX. + if test "$batch" = t; then + tex_mode='\nonstopmode' + else + tex_mode= + fi $verbose "Running $tex $filename_input ..." - ${tex} "$filename_input" + cmd="$tex $tex_mode \\input $filename_input" + $cmd # Check if index files changed. # definite_index_files= # Get list of new index files. possible_index_files="`eval echo ${filename_noext}.?? ${filename_noext}.aux`" - for this_file in ${possible_index_files} ; do + for this_file in ${possible_index_files}; do # If file is empty, forget it. test -s "${this_file}" || continue @@ -283,17 +302,17 @@ for command_line_filename in ${1+"$@"} ; do # file or another has definitely changed. $verbose "Original index files =$orig_index_files" $verbose "New index files =$new_index_files" - if test "z${orig_index_files}" != "z${new_index_files}" ; then + if test "z${orig_index_files}" != "z${new_index_files}"; then index_files_changed_p=t else # File list is the same. We must compare each file until we find a # difference. index_files_changed_p= - for this_file in ${new_index_files} ; do + for this_file in ${new_index_files}; do $verbose "Comparing index file $this_file ..." # cmp -s will return nonzero exit status if files differ. cmp -s "${this_file}" "${this_file}${backup_extension}" - if test $? -ne 0 ; then + if test $? -ne 0; then # We only need to keep comparing until we find *one* that # differs, because we'll have to run texindex & tex no # matter what. @@ -308,57 +327,36 @@ for command_line_filename in ${1+"$@"} ; do # If index files have changed since TeX has been run, or if the aux # file wasn't present originally, run texindex and TeX again. - if test "${index_files_changed_p}" ; then :; else + if test "${index_files_changed_p}"; then :; else # Nothing changed. We're done with TeX. break fi done + # If we were in clean mode, compilation was in a tmp directory. + # Copy the DVI file into the directory where the compilation + # has been done. (The temp dir is about to get removed anyway.) + # We also return to the original directory so that + # - the next file is processed in correct conditions + # - the temporary file can be removed + if test -n "$clean"; then + $verbose "Copying DVI file from `pwd` to $orig_pwd" + cp -p $filename_noext.dvi $orig_pwd + cd $orig_pwd || exit 1 + fi + # Generate list of files to delete, then call rm once with the entire # list. This is significantly faster than multiple executions of rm. file_list= - for file in ${orig_index_files} ; do + for file in ${orig_index_files}; do file_list="${file_list} ${file}${backup_extension}" done - if test -n "${file_list}" ; then - $verbose "Removing $file_list $tmp_dir $tmp_dir.2 ..." + if test -n "${file_list}"; then + $verbose "Removing $file_list $tmp_dir $tmp_dir2 ..." rm -f ${file_list} - rm -rf $tmp_dir $tmp_dir.2 + rm -rf $tmp_dir $tmp_dir2 fi done $verbose "$0 done." true # exit successfully. - -# texi2dvi ends here -# $Log: texi2dvi,v $ -# Revision 1.10 1996/10/04 18:21:55 karl -# Include only the current year in the copyright message. -# -# Revision 1.9 1996/10/04 11:49:48 karl -# Exit successfully. From arnold. -# -# Revision 1.8 1996/10/03 23:14:26 karl -# Only show diff if verbose. -# Update version number. -# -# Revision 1.7 1996/09/29 22:56:08 karl -# Use $progname instead of $0 for --version. -# -# Revision 1.6 1996/09/28 21:01:23 karl -# Recompute original index files each time through loop. -# Make indentation uniform. -# Use same basename for the temp input files. -# Standardize --version output. -# -# Revision 1.5 1996/09/26 14:46:34 karl -# (texi2dvi): Run TeX until the aux/index files stabilize, instead of just -# twice. From: David Shaw <daves@gsms01.alcatel.com.au>. -# -# Revision 1.4 1996/08/27 18:59:26 karl -# Include bug reporting address. -# -# Revision 1.3 1996/07/26 18:20:56 karl -# Do macro expansion with makeinfo before running TeX. -# Various expansion safety measures added for test; avoid use of -o. -# diff --git a/contrib/texinfo/util/texindex.c b/contrib/texinfo/util/texindex.c index 47a56791611f..7ae607c16948 100644 --- a/contrib/texinfo/util/texindex.c +++ b/contrib/texinfo/util/texindex.c @@ -1,7 +1,7 @@ /* Prepare TeX index dribble output into an actual index. - $Id: texindex.c,v 1.6 1996/10/04 18:21:30 karl Exp $ + $Id: texindex.c,v 1.22 1998/02/22 23:00:09 karl Exp $ - Copyright (C) 1987, 91, 92, 96 Free Software Foundation, Inc. + Copyright (C) 1987, 91, 92, 96, 97, 98 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -17,12 +17,8 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307. */ -#include <stdio.h> -#include <ctype.h> -#include <errno.h> -#include "getopt.h" - -#define TEXINDEX_VERSION_STRING "GNU Texindex (Texinfo 3.9) 2.1" +#include "system.h" +#include <getopt.h> #if defined (emacs) # include "../src/config.h" @@ -33,26 +29,6 @@ # undef open #endif -#if defined (HAVE_STRING_H) -# include <string.h> -#endif /* HAVE_STRING_H */ - -#if !defined (HAVE_STRCHR) -char *strrchr (); -#endif /* !HAVE_STRCHR */ - -#if defined (STDC_HEADERS) -# include <stdlib.h> -#else /* !STDC_HEADERS */ -char *getenv (), *malloc (), *realloc (); -#endif /* !STDC_HEADERS */ - -#if defined (HAVE_UNISTD_H) -# include <unistd.h> -#else /* !HAVE_UNISTD_H */ -off_t lseek (); -#endif /* !HAVE_UNISTD_H */ - #if !defined (HAVE_MEMSET) #undef memset #define memset(ptr, ignore, count) bzero (ptr, count) @@ -67,18 +43,6 @@ char *mktemp (); # define TI_FATAL_ERROR ((1 << 28) | 4) # define unlink delete #else /* !VMS */ -# if defined (HAVE_SYS_FCNTL_H) -# include <sys/types.h> -# include <sys/fcntl.h> -# endif /* HAVE_SYS_FCNTL_H */ - -# if defined (_AIX) || !defined (_POSIX_VERSION) -# include <sys/file.h> -# else /* !AIX && _POSIX_VERSION */ -# if !defined (HAVE_SYS_FCNTL_H) -# include <fcntl.h> -# endif /* !HAVE_FCNTL_H */ -# endif /* !_AIX && _POSIX_VERSION */ # define TI_NO_ERROR 0 # define TI_FATAL_ERROR 1 #endif /* !VMS */ @@ -89,38 +53,31 @@ char *mktemp (); # define SEEK_END 2 #endif /* !SEEK_SET */ -#ifndef errno -extern int errno; -#endif -#ifndef strerror -extern char *strerror (); -#endif - /* When sorting in core, this structure describes one line and the position and length of its first keyfield. */ struct lineinfo { - char *text; /* The actual text of the line. */ + char *text; /* The actual text of the line. */ union { - char *text; /* The start of the key (for textual comparison). */ - long number; /* The numeric value (for numeric comparison). */ + char *text; /* The start of the key (for textual comparison). */ + long number; /* The numeric value (for numeric comparison). */ } key; - long keylen; /* Length of KEY field. */ + long keylen; /* Length of KEY field. */ }; /* This structure describes a field to use as a sort key. */ struct keyfield { - int startwords; /* Number of words to skip. */ - int startchars; /* Number of additional chars to skip. */ - int endwords; /* Number of words to ignore at end. */ - int endchars; /* Ditto for characters of last word. */ - char ignore_blanks; /* Non-zero means ignore spaces and tabs. */ - char fold_case; /* Non-zero means case doesn't matter. */ - char reverse; /* Non-zero means compare in reverse order. */ - char numeric; /* Non-zeros means field is ASCII numeric. */ - char positional; /* Sort according to file position. */ - char braced; /* Count balanced-braced groupings as fields. */ + int startwords; /* Number of words to skip. */ + int startchars; /* Number of additional chars to skip. */ + int endwords; /* Number of words to ignore at end. */ + int endchars; /* Ditto for characters of last word. */ + char ignore_blanks; /* Non-zero means ignore spaces and tabs. */ + char fold_case; /* Non-zero means case doesn't matter. */ + char reverse; /* Non-zero means compare in reverse order. */ + char numeric; /* Non-zeros means field is ASCII numeric. */ + char positional; /* Sort according to file position. */ + char braced; /* Count balanced-braced groupings as fields. */ }; /* Vector of keyfields to use. */ @@ -198,7 +155,7 @@ char *tempcopy (); #define MAX_IN_CORE_SORT 500000 -void +int main (argc, argv) int argc; char **argv; @@ -214,6 +171,15 @@ main (argc, argv) else program_name = argv[0]; +#ifdef HAVE_SETLOCALE + /* Set locale via LC_ALL. */ + setlocale (LC_ALL, ""); +#endif + + /* Set the text message domain. */ + bindtextdomain (PACKAGE, LOCALEDIR); + textdomain (PACKAGE); + /* Describe the kind of sorting to do. */ /* The first keyfield uses the first braced field and folds case. */ keyfields[0].braced = 1; @@ -247,7 +213,7 @@ main (argc, argv) desc = open (infiles[i], O_RDONLY, 0); if (desc < 0) - pfatal_with_name (infiles[i]); + pfatal_with_name (infiles[i]); lseek (desc, (off_t) 0, SEEK_END); ptr = (long) lseek (desc, (off_t) 0, SEEK_CUR); @@ -255,19 +221,21 @@ main (argc, argv) outfile = outfiles[i]; if (!outfile) - { - outfile = concat (infiles[i], "s", ""); - } + { + outfile = concat (infiles[i], "s", ""); + } if (ptr < MAX_IN_CORE_SORT) - /* Sort a small amount of data. */ - sort_in_core (infiles[i], ptr, outfile); + /* Sort a small amount of data. */ + sort_in_core (infiles[i], ptr, outfile); else - sort_offline (infiles[i], ptr, outfile); + sort_offline (infiles[i], ptr, outfile); } flush_tempfiles (tempcount); exit (TI_NO_ERROR); + + return 0; /* Avoid bogus warnings. */ } typedef struct @@ -282,15 +250,15 @@ typedef struct TEXINDEX_OPTION texindex_options[] = { { "--keep", "-k", &keep_tempfiles, 1, (char *)NULL, - "keep temporary files around after processing" }, + N_("keep temporary files around after processing") }, { "--no-keep", 0, &keep_tempfiles, 0, (char *)NULL, - "do not keep temporary files around after processing (default)" }, + N_("do not keep temporary files around after processing (default)") }, { "--output", "-o", (int *)NULL, 0, "FILE", - "send output to FILE" }, + N_("send output to FILE") }, { "--version", (char *)NULL, (int *)NULL, 0, (char *)NULL, - "display version information and exit" }, + N_("display version information and exit") }, { "--help", "-h", (int *)NULL, 0, (char *)NULL, - "display this help and exit" }, + N_("display this help and exit") }, { (char *)NULL, (char *)NULL, (int *)NULL, 0, (char *)NULL } }; @@ -301,25 +269,25 @@ usage (result_value) register int i; FILE *f = result_value ? stderr : stdout; - fprintf (f, "Usage: %s [OPTION]... FILE...\n", program_name); - fprintf (f, "Generate a sorted index for each TeX output FILE.\n"); + fprintf (f, _("Usage: %s [OPTION]... FILE...\n"), program_name); + fprintf (f, _("Generate a sorted index for each TeX output FILE.\n")); /* Avoid trigraph nonsense. */ - fprintf (f, "Usually FILE... is `foo.??\' for a document `foo.texi'.\n"); - fprintf (f, "\nOptions:\n"); + fprintf (f, _("Usually FILE... is `foo.??\' for a document `foo.texi'.\n")); + fprintf (f, _("\nOptions:\n")); for (i = 0; texindex_options[i].long_name; i++) { if (texindex_options[i].short_name) - fprintf (f, "%s, ", texindex_options[i].short_name); + fprintf (f, "%s, ", texindex_options[i].short_name); fprintf (f, "%s %s", - texindex_options[i].long_name, - texindex_options[i].arg_name + texindex_options[i].long_name, + texindex_options[i].arg_name ? texindex_options[i].arg_name : ""); - fprintf (f, "\t%s\n", texindex_options[i].doc_string); + fprintf (f, "\t%s\n", _(texindex_options[i].doc_string)); } - puts ("\nEmail bug reports to bug-texinfo@prep.ai.mit.edu."); + puts (_("\nEmail bug reports to bug-texinfo@gnu.org.")); exit (result_value); } @@ -333,7 +301,6 @@ decode_command (argc, argv) char **argv; { int arg_index = 1; - int optc; char **ip; char **op; @@ -364,46 +331,47 @@ decode_command (argc, argv) char *arg = argv[arg_index++]; if (*arg == '-') - { - if (strcmp (arg, "--version") == 0) - { - puts (TEXINDEX_VERSION_STRING); -puts ("Copyright (C) 1996 Free Software Foundation, Inc.\n\ + { + if (strcmp (arg, "--version") == 0) + { + printf ("texindex (GNU %s) %s\n", PACKAGE, VERSION); + printf (_("Copyright (C) %s Free Software Foundation, Inc.\n\ There is NO warranty. You may redistribute this software\n\ under the terms of the GNU General Public License.\n\ -For more information about these matters, see the files named COPYING."); - exit (0); - } - else if ((strcmp (arg, "--keep") == 0) || - (strcmp (arg, "-k") == 0)) - { - keep_tempfiles = 1; - } - else if ((strcmp (arg, "--help") == 0) || - (strcmp (arg, "-h") == 0)) - { - usage (0); - } - else if ((strcmp (arg, "--output") == 0) || - (strcmp (arg, "-o") == 0)) - { - if (argv[arg_index] != (char *)NULL) - { - arg_index++; - if (op > outfiles) - *(op - 1) = argv[arg_index]; - } - else - usage (1); - } - else - usage (1); - } +For more information about these matters, see the files named COPYING.\n"), + "1998"); + exit (0); + } + else if ((strcmp (arg, "--keep") == 0) || + (strcmp (arg, "-k") == 0)) + { + keep_tempfiles = 1; + } + else if ((strcmp (arg, "--help") == 0) || + (strcmp (arg, "-h") == 0)) + { + usage (0); + } + else if ((strcmp (arg, "--output") == 0) || + (strcmp (arg, "-o") == 0)) + { + if (argv[arg_index] != (char *)NULL) + { + arg_index++; + if (op > outfiles) + *(op - 1) = argv[arg_index]; + } + else + usage (1); + } + else + usage (1); + } else - { - *ip++ = arg; - *op++ = (char *)NULL; - } + { + *ip++ = arg; + *op++ = (char *)NULL; + } } /* Record number of keyfields and terminate list of filenames. */ @@ -459,7 +427,7 @@ tempcopy (idesc) int nread = read (idesc, buffer, BUFSIZE); write (odesc, buffer, nread); if (!nread) - break; + break; } close (odesc); @@ -485,16 +453,16 @@ compare_full (line1, line2) char *start1 = find_field (&keyfields[i], *line1, &length1); char *start2 = find_field (&keyfields[i], *line2, &length2); int tem = compare_field (&keyfields[i], start1, length1, *line1 - text_base, - start2, length2, *line2 - text_base); + start2, length2, *line2 - text_base); if (tem) - { - if (keyfields[i].reverse) - return -tem; - return tem; - } + { + if (keyfields[i].reverse) + return -tem; + return tem; + } } - return 0; /* Lines match exactly. */ + return 0; /* Lines match exactly. */ } /* Compare LINE1 and LINE2, described by structures @@ -514,19 +482,19 @@ compare_prepared (line1, line2) if (keyfields->positional) { if (line1->text - text_base > line2->text - text_base) - tem = 1; + tem = 1; else - tem = -1; + tem = -1; } else if (keyfields->numeric) tem = line1->key.number - line2->key.number; else tem = compare_field (keyfields, line1->key.text, line1->keylen, 0, - line2->key.text, line2->keylen, 0); + line2->key.text, line2->keylen, 0); if (tem) { if (keyfields->reverse) - return -tem; + return -tem; return tem; } @@ -543,16 +511,16 @@ compare_prepared (line1, line2) char *start1 = find_field (&keyfields[i], text1, &length1); char *start2 = find_field (&keyfields[i], text2, &length2); int tem = compare_field (&keyfields[i], start1, length1, text1 - text_base, - start2, length2, text2 - text_base); + start2, length2, text2 - text_base); if (tem) - { - if (keyfields[i].reverse) - return -tem; - return tem; - } + { + if (keyfields[i].reverse) + return -tem; + return tem; + } } - return 0; /* Lines match exactly. */ + return 0; /* Lines match exactly. */ } /* Like compare_full but more general. @@ -578,16 +546,16 @@ compare_general (str1, str2, pos1, pos2, use_keyfields) char *start1 = find_field (&keyfields[i], str1, &length1); char *start2 = find_field (&keyfields[i], str2, &length2); int tem = compare_field (&keyfields[i], start1, length1, pos1, - start2, length2, pos2); + start2, length2, pos2); if (tem) - { - if (keyfields[i].reverse) - return -tem; - return tem; - } + { + if (keyfields[i].reverse) + return -tem; + return tem; + } } - return 0; /* Lines match exactly. */ + return 0; /* Lines match exactly. */ } /* Find the start and length of a field in STR according to KEYFIELD. @@ -610,23 +578,23 @@ find_field (keyfield, str, lengthptr) fun = find_pos; start = (*fun) (str, keyfield->startwords, keyfield->startchars, - keyfield->ignore_blanks); + keyfield->ignore_blanks); if (keyfield->endwords < 0) { if (keyfield->braced) - end = find_braced_end (start); + end = find_braced_end (start); else - { - end = start; - while (*end && *end != '\n') - end++; - } + { + end = start; + while (*end && *end != '\n') + end++; + } } else { end = (*fun) (str, keyfield->endwords, keyfield->endchars, 0); if (end - str < start - str) - end = start; + end = start; } *lengthptr = end - start; return start; @@ -651,11 +619,11 @@ find_pos (str, words, chars, ignore_blanks) char c; /* Find next bunch of nonblanks and skip them. */ while ((c = *p) == ' ' || c == '\t') - p++; + p++; while ((c = *p) && c != '\n' && !(c == ' ' || c == '\t')) - p++; + p++; if (!*p || *p == '\n') - return p; + return p; } while (*p == ' ' || *p == '\t') @@ -664,7 +632,7 @@ find_pos (str, words, chars, ignore_blanks) for (i = 0; i < chars; i++) { if (!*p || *p == '\n') - break; + break; p++; } return p; @@ -688,19 +656,19 @@ find_braced_pos (str, words, chars, ignore_blanks) { bracelevel = 1; while ((c = *p++) != '{' && c != '\n' && c) - /* Do nothing. */ ; + /* Do nothing. */ ; if (c != '{') - return p - 1; + return p - 1; while (bracelevel) - { - c = *p++; - if (c == '{') - bracelevel++; - if (c == '}') - bracelevel--; - if (c == 0 || c == '\n') - return p - 1; - } + { + c = *p++; + if (c == '{') + bracelevel++; + if (c == '}') + bracelevel--; + if (c == 0 || c == '\n') + return p - 1; + } } while ((c = *p++) != '{' && c != '\n' && c) @@ -716,7 +684,7 @@ find_braced_pos (str, words, chars, ignore_blanks) for (i = 0; i < chars; i++) { if (!*p || *p == '\n') - break; + break; p++; } return p; @@ -738,11 +706,11 @@ find_braced_end (str) { c = *p++; if (c == '{') - bracelevel++; + bracelevel++; if (c == '}') - bracelevel--; + bracelevel--; if (c == 0 || c == '\n') - return p - 1; + return p - 1; } return p - 1; } @@ -755,7 +723,7 @@ find_value (start, length) while (length != 0L) { if (isdigit (*start)) - return atol (start); + return atol (start); length--; start++; } @@ -801,17 +769,17 @@ compare_field (keyfield, start1, length1, pos1, start2, length2, pos2) if (keyfields->positional) { if (pos1 > pos2) - return 1; + return 1; else - return -1; + return -1; } if (keyfield->numeric) { long value = find_value (start1, length1) - find_value (start2, length2); if (value > 0) - return 1; + return 1; if (value < 0) - return -1; + return -1; return 0; } else @@ -822,46 +790,46 @@ compare_field (keyfield, start1, length1, pos1, start2, length2, pos2) char *e2 = start2 + length2; while (1) - { - int c1, c2; - - if (p1 == e1) - c1 = 0; - else - c1 = *p1++; - if (p2 == e2) - c2 = 0; - else - c2 = *p2++; - - if (char_order[c1] != char_order[c2]) - return char_order[c1] - char_order[c2]; - if (!c1) - break; - } + { + int c1, c2; + + if (p1 == e1) + c1 = 0; + else + c1 = *p1++; + if (p2 == e2) + c2 = 0; + else + c2 = *p2++; + + if (char_order[c1] != char_order[c2]) + return char_order[c1] - char_order[c2]; + if (!c1) + break; + } /* Strings are equal except possibly for case. */ p1 = start1; p2 = start2; while (1) - { - int c1, c2; - - if (p1 == e1) - c1 = 0; - else - c1 = *p1++; - if (p2 == e2) - c2 = 0; - else - c2 = *p2++; - - if (c1 != c2) - /* Reverse sign here so upper case comes out last. */ - return c2 - c1; - if (!c1) - break; - } + { + int c1, c2; + + if (p1 == e1) + c1 = 0; + else + c1 = *p1++; + if (p2 == e2) + c2 = 0; + else + c2 = *p2++; + + if (c1 != c2) + /* Reverse sign here so upper case comes out last. */ + return c2 - c1; + if (!c1) + break; + } return 0; } @@ -903,17 +871,17 @@ readline (linebuffer, stream) { int c = getc (stream); if (p == end) - { - buffer = (char *) xrealloc (buffer, linebuffer->size *= 2); - p += buffer - linebuffer->buffer; - end += buffer - linebuffer->buffer; - linebuffer->buffer = buffer; - } + { + buffer = (char *) xrealloc (buffer, linebuffer->size *= 2); + p += buffer - linebuffer->buffer; + end += buffer - linebuffer->buffer; + linebuffer->buffer = buffer; + } if (c < 0 || c == '\n') - { - *p = 0; - break; - } + { + *p = 0; + break; + } *p++ = c; } @@ -946,7 +914,7 @@ sort_offline (infile, nfiles, total, outfile) if (lb.buffer[0] != '\\' && lb.buffer[0] != '@') { - error ("%s: not a texinfo index file", infile); + error (_("%s: not a texinfo index file"), infile); return; } @@ -960,34 +928,34 @@ sort_offline (infile, nfiles, total, outfile) long tempsize = 0; if (!ostream) - pfatal_with_name (outname); + pfatal_with_name (outname); tempfiles[i] = outname; /* Copy lines into this temp file as long as it does not make file - "too big" or until there are no more lines. */ + "too big" or until there are no more lines. */ while (tempsize + linelength + 1 <= MAX_IN_CORE_SORT) - { - tempsize += linelength + 1; - fputs (lb.buffer, ostream); - putc ('\n', ostream); - - /* Read another line of input data. */ - - linelength = readline (&lb, istream); - if (!linelength && feof (istream)) - break; - - if (lb.buffer[0] != '\\' && lb.buffer[0] != '@') - { - error ("%s: not a texinfo index file", infile); - failure = 1; - goto fail; - } - } + { + tempsize += linelength + 1; + fputs (lb.buffer, ostream); + putc ('\n', ostream); + + /* Read another line of input data. */ + + linelength = readline (&lb, istream); + if (!linelength && feof (istream)) + break; + + if (lb.buffer[0] != '\\' && lb.buffer[0] != '@') + { + error (_("%s: not a texinfo index file"), infile); + failure = 1; + goto fail; + } + } fclose (ostream); if (feof (istream)) - break; + break; } free (lb.buffer); @@ -1006,7 +974,7 @@ fail: char *newtemp = maketempname (++tempcount); sort_in_core (&tempfiles[i], MAX_IN_CORE_SORT, newtemp); if (!keep_tempfiles) - unlink (tempfiles[i]); + unlink (tempfiles[i]); tempfiles[i] = newtemp; } @@ -1041,12 +1009,12 @@ sort_in_core (infile, total, outfile) int desc = open (infile, O_RDONLY, 0); if (desc < 0) - fatal ("failure reopening %s", infile); + fatal (_("failure reopening %s"), infile); for (file_size = 0;;) { i = read (desc, data + file_size, total - file_size); if (i <= 0) - break; + break; file_size += i; } file_data = data; @@ -1056,7 +1024,7 @@ sort_in_core (infile, total, outfile) if (file_size > 0 && data[0] != '\\' && data[0] != '@') { - error ("%s: not a texinfo index file", infile); + error (_("%s: not a texinfo index file"), infile); return; } @@ -1084,7 +1052,7 @@ sort_in_core (infile, total, outfile) nextline = parsefile (infile, nextline, file_data, file_size); if (nextline == 0) { - error ("%s: not a texinfo index file", infile); + error (_("%s: not a texinfo index file"), infile); return; } @@ -1102,18 +1070,18 @@ sort_in_core (infile, total, outfile) char **p; for (lp = lineinfo, p = linearray; p != nextline; lp++, p++) - { - lp->text = *p; - lp->key.text = find_field (keyfields, *p, &lp->keylen); - if (keyfields->numeric) - lp->key.number = find_value (lp->key.text, lp->keylen); - } + { + lp->text = *p; + lp->key.text = find_field (keyfields, *p, &lp->keylen); + if (keyfields->numeric) + lp->key.number = find_value (lp->key.text, lp->keylen); + } qsort (lineinfo, nextline - linearray, sizeof (struct lineinfo), compare_prepared); for (lp = lineinfo, p = linearray; p != nextline; lp++, p++) - *p = lp->text; + *p = lp->text; free (lineinfo); } @@ -1126,7 +1094,7 @@ sort_in_core (infile, total, outfile) { ostream = fopen (outfile, "w"); if (!ostream) - pfatal_with_name (outfile); + pfatal_with_name (outfile); } writelines (linearray, nextline - linearray, ostream); @@ -1160,21 +1128,21 @@ parsefile (filename, nextline, data, size) while (p != end) { if (p[0] != '\\' && p[0] != '@') - return 0; + return 0; *line = p; while (*p && *p != '\n') - p++; + p++; if (p != end) - p++; + p++; line++; if (line == linearray + nlines) - { - char **old = linearray; - linearray = (char **) xrealloc (linearray, sizeof (char *) * (nlines *= 4)); - line += linearray - old; - } + { + char **old = linearray; + linearray = (char **) xrealloc (linearray, sizeof (char *) * (nlines *= 4)); + line += linearray - old; + } } return line; @@ -1266,7 +1234,7 @@ indexify (line, ostream) { initial = p; /* Get length of inner pair of braces starting at `p', - including that inner pair of braces. */ + including that inner pair of braces. */ initiallength = find_braced_end (p + 1) + 1 - p; } else @@ -1277,7 +1245,7 @@ indexify (line, ostream) initiallength = 1; if (initial1[0] >= 'a' && initial1[0] <= 'z') - initial1[0] -= 040; + initial1[0] -= 040; } pagenumber = find_braced_pos (line, 1, 0, 0); @@ -1298,52 +1266,52 @@ indexify (line, ostream) { /* Close off current secondary entry first, if one is open. */ if (pending) - { - fputs ("}\n", ostream); - pending = 0; - } + { + fputs ("}\n", ostream); + pending = 0; + } /* If this primary has a different initial, include an entry for - the initial. */ + the initial. */ if (initiallength != lastinitiallength || - strncmp (initial, lastinitial, initiallength)) - { - fprintf (ostream, "\\initial {"); - fwrite (initial, 1, initiallength, ostream); - fprintf (ostream, "}\n", initial); - if (initial == initial1) - { - lastinitial = lastinitial1; - *lastinitial1 = *initial1; - } - else - { - lastinitial = initial; - } - lastinitiallength = initiallength; - } + strncmp (initial, lastinitial, initiallength)) + { + fprintf (ostream, "\\initial {"); + fwrite (initial, 1, initiallength, ostream); + fputs ("}\n", ostream); + if (initial == initial1) + { + lastinitial = lastinitial1; + *lastinitial1 = *initial1; + } + else + { + lastinitial = initial; + } + lastinitiallength = initiallength; + } /* Make the entry for the primary. */ if (nosecondary) - fputs ("\\entry {", ostream); + fputs ("\\entry {", ostream); else - fputs ("\\primary {", ostream); + fputs ("\\primary {", ostream); fwrite (primary, primarylength, 1, ostream); if (nosecondary) - { - fputs ("}{", ostream); - pending = 1; - } + { + fputs ("}{", ostream); + pending = 1; + } else - fputs ("}\n", ostream); + fputs ("}\n", ostream); /* Record name of most recent primary. */ if (lastprimarylength < primarylength) - { - lastprimarylength = primarylength + 100; - lastprimary = (char *) xrealloc (lastprimary, - 1 + lastprimarylength); - } + { + lastprimarylength = primarylength + 100; + lastprimary = (char *) xrealloc (lastprimary, + 1 + lastprimarylength); + } strncpy (lastprimary, primary, primarylength); lastprimary[primarylength] = 0; @@ -1354,16 +1322,16 @@ indexify (line, ostream) /* Should not have an entry with no subtopic following one with a subtopic. */ if (nosecondary && *lastsecondary) - error ("entry %s follows an entry with a secondary name", line); + error (_("entry %s follows an entry with a secondary name"), line); /* Start a new secondary entry if necessary. */ if (!nosecondary && strncmp (secondary, lastsecondary, secondarylength)) { if (pending) - { - fputs ("}\n", ostream); - pending = 0; - } + { + fputs ("}\n", ostream); + pending = 0; + } /* Write the entry for the secondary. */ fputs ("\\secondary {", ostream); @@ -1373,18 +1341,18 @@ indexify (line, ostream) /* Record name of most recent secondary. */ if (lastsecondarylength < secondarylength) - { - lastsecondarylength = secondarylength + 100; - lastsecondary = (char *) xrealloc (lastsecondary, - 1 + lastsecondarylength); - } + { + lastsecondarylength = secondarylength + 100; + lastsecondary = (char *) xrealloc (lastsecondary, + 1 + lastsecondarylength); + } strncpy (lastsecondary, secondary, secondarylength); lastsecondary[secondarylength] = 0; } /* Here to add one more page number to the current entry. */ if (pending++ != 1) - fputs (", ", ostream); /* Punctuate first, if this is not the first. */ + fputs (", ", ostream); /* Punctuate first, if this is not the first. */ fwrite (pagenumber, pagelength, 1, ostream); } @@ -1422,16 +1390,16 @@ writelines (linearray, nlines, ostream) if (next_line == linearray /* Compare previous line with this one, using only the explicitly specd keyfields. */ - || compare_general (*(next_line - 1), *next_line, 0L, 0L, num_keyfields - 1)) - { - char *p = *next_line; - char c; - - while ((c = *p++) && c != '\n') - /* Do nothing. */ ; - *(p - 1) = 0; - indexify (*next_line, ostream); - } + || compare_general (*(next_line - 1), *next_line, 0L, 0L, num_keyfields - 1)) + { + char *p = *next_line; + char c; + + while ((c = *p++) && c != '\n') + /* Do nothing. */ ; + *(p - 1) = 0; + indexify (*next_line, ostream); + } } finish_index (ostream); @@ -1470,7 +1438,7 @@ merge_files (infiles, nfiles, outfile) { int nf = MAX_DIRECT_MERGE; if (i + 1 == ntemps) - nf = nfiles - i * MAX_DIRECT_MERGE; + nf = nfiles - i * MAX_DIRECT_MERGE; tempfiles[i] = maketempname (++tempcount); value |= merge_direct (&infiles[i * MAX_DIRECT_MERGE], nf, tempfiles[i]); } @@ -1525,7 +1493,7 @@ merge_direct (infiles, nfiles, outfile) if (nfiles == 0) { if (outfile) - fclose (ostream); + fclose (ostream); return 0; } @@ -1567,7 +1535,7 @@ merge_direct (infiles, nfiles, outfile) file_lossage[i] = 0; streams[i] = fopen (infiles[i], "r"); if (!streams[i]) - pfatal_with_name (infiles[i]); + pfatal_with_name (infiles[i]); readline (thisline[i], streams[i]); } @@ -1585,48 +1553,48 @@ merge_direct (infiles, nfiles, outfile) /* Look at the next avail line of each file; choose the least one. */ for (i = 0; i < nfiles; i++) - { - if (thisline[i] && - (!best || - 0 < compare_general (best->buffer, thisline[i]->buffer, - (long) bestfile, (long) i, num_keyfields))) - { - best = thisline[i]; - bestfile = i; - } - } + { + if (thisline[i] && + (!best || + 0 < compare_general (best->buffer, thisline[i]->buffer, + (long) bestfile, (long) i, num_keyfields))) + { + best = thisline[i]; + bestfile = i; + } + } /* Output that line, unless it matches the previous one and we - don't want duplicates. */ + don't want duplicates. */ if (!(prev_out && - !compare_general (prev_out->buffer, - best->buffer, 0L, 1L, num_keyfields - 1))) - indexify (best->buffer, ostream); + !compare_general (prev_out->buffer, + best->buffer, 0L, 1L, num_keyfields - 1))) + indexify (best->buffer, ostream); prev_out = best; /* Now make the line the previous of its file, and fetch a new - line from that file. */ + line from that file. */ exch = prevline[bestfile]; prevline[bestfile] = thisline[bestfile]; thisline[bestfile] = exch; while (1) - { - /* If the file has no more, mark it empty. */ - - if (feof (streams[bestfile])) - { - thisline[bestfile] = 0; - /* Update the number of files still not empty. */ - nleft--; - break; - } - readline (thisline[bestfile], streams[bestfile]); - if (thisline[bestfile]->buffer[0] || !feof (streams[bestfile])) - break; - } + { + /* If the file has no more, mark it empty. */ + + if (feof (streams[bestfile])) + { + thisline[bestfile] = 0; + /* Update the number of files still not empty. */ + nleft--; + break; + } + readline (thisline[bestfile], streams[bestfile]); + if (thisline[bestfile]->buffer[0] || !feof (streams[bestfile])) + break; + } } finish_index (ostream); @@ -1692,7 +1660,7 @@ pfatal_with_name (name) s = strerror (errno); printf ("%s: ", program_name); - printf ("%s; for file `%s'.\n", s, name); + printf (_("%s; for file `%s'.\n"), s, name); exit (TI_FATAL_ERROR); } @@ -1745,6 +1713,21 @@ strrchr (string, character) } #endif /* HAVE_STRCHR */ +void +memory_error (callers_name, bytes_wanted) + char *callers_name; + int bytes_wanted; +{ + char printable_string[80]; + + sprintf (printable_string, + _("Virtual memory exhausted in %s ()! Needed %d bytes."), + callers_name, bytes_wanted); + + error (printable_string); + abort (); +} + /* Just like malloc, but kills the program in case of fatal error. */ void * xmalloc (nbytes) @@ -1776,18 +1759,3 @@ xrealloc (pointer, nbytes) return (temp); } - -memory_error (callers_name, bytes_wanted) - char *callers_name; - int bytes_wanted; -{ - char printable_string[80]; - - sprintf (printable_string, - "Virtual memory exhausted in %s ()! Needed %d bytes.", - callers_name, bytes_wanted); - - error (printable_string); - abort (); -} - diff --git a/contrib/texinfo/util/update-info b/contrib/texinfo/util/update-info new file mode 100755 index 000000000000..0d31fde4d27b --- /dev/null +++ b/contrib/texinfo/util/update-info @@ -0,0 +1,875 @@ +#!/bin/sh +# update-info -- update dir file from all extant info pages. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, you can either send email to this +# program's maintainer or write to: The Free Software Foundation, +# Inc.; 59 Temple Place, Suite 330; Boston, MA 02111-1307, USA. +# +# Author: rhawes@dmapub.dma.org. Please report bugs to him. +# +# run this program to install update-info +# ###SECTION 0### install script +# These constants set the version numbers for both files: +PROGRAM_VERSION="1.4" +PACKAGE_VERSION="4.0" + +# ENVIRONMENT +if test -z "$TMPDIR"; then + TMPDIR="/usr/tmp" +fi + +TMP_SED="$TMPDIR/uss$$.info" +TMP_F_ADD_SECTION="$TMPDIR/ufa$$.info" +TMP_F_DELETE_INVALID="$TMPDIR/ufd$$.info" +TMP_F_INSERT_MISSING="$TMPDIR/ufi$$.info" +TMP_FILES="$TMP_SED $TMP_F_ADD_SECTION $TMP_F_DELETE_INVALID\ + $TMP_F_INSERT_MISSING" + +trap 'rm -f $TMP_FILES' 0 + +# file boundaries +UPDATE_INFO="/^# _file: 'update-info'_/" +UPDATE_INFO_F="/^# _file: 'update-info.f'_/" + +# @F_ADD_SECTION@ +echo 'Item_Num=`expr "$Item_Num" + "1"` +echo "$1">>"$TMP_SECTIONS" +if test "$Item_Status"; then + Item_Status=`echo "${Item_Status} +X"` +else + Item_Status="X" +fi '>$TMP_F_ADD_SECTION + +# @F_INSERT_MISSING@ +echo 'if test -z "$Create_Node"; then + rm -f ${Info_Node}.old + cp $Info_Node ${Info_Node}.old + echo "$BACKUP_MSG" +fi +echo "/$MENU_BEGIN/ ++,$ d +r $TMP_MENU +w +q"|ed -s $Info_Node>/dev/null'>$TMP_F_INSERT_MISSING + +# @F_DELETE_INVALID@ +echo ' +rm -f ${Info_Node}.old +cp $Info_Node ${Info_Node}.old +echo "$BACKUP_MSG" +echo "/$MENU_BEGIN/ ++,$ d +w +q"|ed -s $Info_Node>/dev/null +sed -f "$TMP_SED" "$TMP_MENU">>"$Info_Node"'>$TMP_F_DELETE_INVALID + +cat<<Sed_Script_EOF>$TMP_SED +s/@UPDATE_INFO_VERSION@/$PROGRAM_VERSION/g +s/@TEXINFO_VERSION@/$PACKAGE_VERSION/g +s/@SET_ITEM@/Item_Status=\`echo "\$Item_Status"|sed -e "\${1}s%^.*%\${2}%"\`/ +/@F_ADD_SECTION@/r $TMP_F_ADD_SECTION +/@F_ADD_SECTION@/d +/@F_DELETE_INVALID@/r $TMP_F_DELETE_INVALID +/@F_DELETE_INVALID@/d +/@F_INSERT_MISSING@/r $TMP_F_INSERT_MISSING +/@F_INSERT_MISSING@/d +Sed_Script_EOF + +sed -e "1,${UPDATE_INFO}d" -e "$UPDATE_INFO_F,\$d" -f $TMP_SED $0>update-info +sed -e "1,${UPDATE_INFO_F}d" -f $TMP_SED $0>update-info.f +chmod +x update-info update-info.f +echo "installed update-info, and update-info.f into `pwd`" +rm -f $TMP_FILES +exit + +# _file: 'update-info'_ +#!/bin/sh +#update-info (GNU texinfo @TEXINFO_VERSION@) @UPDATE_INFO_VERSION@ +#Copyright (C) 1997 Free Software Foundation, Inc. +#update-info comes with NO WARRANTY, to the extent permitted by law. +#You may redistribute copies of update-info +#under the terms of the GNU General Public License. +#For more information about these matters, see the files named COPYING." +#Author: Richard L. Hawes + +# ###SECTION 1### Constants +set -h 2>/dev/null +# ENVIRONMENT +if test -z "$TMPDIR"; then + TMPDIR="/usr/tmp" +fi +if test -z "$LINES"; then + LINES=24 +fi +if test -z "$COLUMNS"; then + COLUMNS=80 +fi +if test -z "$EDITOR"; then + EDITOR=vi +fi +if test -z "$LINENO"; then + LINENO="0" +fi +# constants redefined by update-info.f +PROMPT1="(y=yes, Y=yes to all, n=no, N=No to all):" +FUNCTIONS="" +# +ARGUMENTS="$*" +DISPLAY_NUM=`expr "$LINES" - 4` +CONTROL_D="{Ctrl-D}" +DIR_SECTION="^INFO-DIR-SECTION" +ENTRY_END="^END-INFO-DIR-ENTRY" +ENTRY_START="^START-INFO-DIR-ENTRY" +MENU_BEGIN='^\*\([ ]\)\{1,\}Menu:' +MENU_ITEM='^\* ([^ ]).*:([ ])+\(' +SECTION_TITLE="^[A-Za-z0-9]" +MENU_FILTER1='s/^\*\([ ]\)\{1,\}/* /' +MENU_FILTER2='s/\([ ]\)\{1,\}$//g' +TMP_ITEM="${TMPDIR}/ui${$}.info" +TMP_LIST="${TMPDIR}/ul${$}.info" +TMP_MENU="${TMPDIR}/um${$}.info" +TMP_SECTIONS="${TMPDIR}/us${$}.info" # used only in Detect_Missing +TMP_SED="$TMP_SECTIONS" # used only in Detect_Invalid routines +TMP_FILE1="${TMPDIR}/ux${$}.info" +TMP_FILE2="${TMPDIR}/uy${$}.info" +TMP_COUNT="$TMP_FILE2" +TMP_FILE_LIST="$TMP_LIST $TMP_MENU $TMP_SECTIONS $TMP_FILE1 $TMP_FILE2\ + $TMP_ITEM" +TRY_HELP_MSG="Try --help for more information" +if zcat --version 2>/dev/null>/dev/null; then + CAT_COMMAND="zcat -f" +else + echo "$0:$LINENO: GNU zcat not found">&2 + CAT_COMMAND="cat" +fi + +# ###SECTION 100### main program +#variables set by options +Create_Node="" +Debug=":" +Interactive="" +Load_Functions="y" +Mode="" +# +Inserts="0" +Inserts_Total="0" +Invalid="0" +Invalid_Total="0" +Changed="" + +while test "$*" + do + case "$1" in + -c) Create_Node="y";; + -ci|-ic) Create_Node="y"; Interactive="y";; + -cif|-cfi|-ifc|-icf|-fci|-fic) Create_Node="y" + Interactive="y"; Load_Functions="";; + --debug) set -eux; Debug="set>&2";; + -d|--delete) Mode="Detect_Invalid";; + -f) Load_Functions="";; + -i|--interactive) Interactive="y";; + -fi|-if) Load_Functions=""; Interactive="y";; + -id|-di) Mode="Detect_Invalid"; Interactive="y";; + +i|+d|+f);; + --version) +cat<<VersionEOF +update-info (GNU texinfo @TEXINFO_VERSION@) @UPDATE_INFO_VERSION@ +Copyright (C) 1997 Free Software Foundation, Inc. +update-info comes with NO WARRANTY, to the extent permitted by law. +You may redistribute copies of update-info +under the terms of the GNU General Public License. +For more information about these matters, see the files named COPYING. +Author: Richard L. Hawes +VersionEOF + exit;; + + --help) +cat<<HelpEndOfFile +Usage: update-info [OPTION]... INFO_PATH/INFO_DIR_FILE + +It detects and inserts missing menu items into the info node file. + +Options: +-c create a new info node + --debug print debug information to standard error path +-d, --delete delete invalid menu items (ignore missing menu items) +-f do not load functions (file update-info.f) + --help print this help message and exit +-i, --interactive interactive mode prompts before inserting or removing + menu items + --version print current version and exit +Backup of the info node has a '.old' suffix added. This is a shell script. +Files: update-info.f -- contains functions (optional). +Environment Variables: COLUMNS, EDITOR, LINES, TMPDIR +Email bug reports to bug-texinfo@gnu.org. +HelpEndOfFile + exit;; + + [-+]*) echo "$0:$LINENO: \"$1\" is not a valid option">&2 + echo "$TRY_HELP_MSG">&2 + exit 2;; + *) break;; + esac + shift + done + +if test "$#" -lt "1"; then + echo "$0:$LINENO: Too few parameters">&2 + echo "$TRY_HELP_MSG">&2 + exit 2 +elif test "$#" -gt "1"; then + echo "$0:$LINENO: Too many parameters">&2 + echo "$TRY_HELP_MSG">&2 + exit 2 +fi +Info_Path="$1" +Info_Node=`basename "$Info_Path"` +if echo "$Info_Node"|grep ".*dir$">/dev/null; then + : +else + echo "$0:$LINENO: $Info_Node is not a valid info node name">&2 + exit 2 +fi +Info_Pathname=`dirname "$Info_Path"` +cd "$Info_Pathname"||exit + +BACKUP_MSG="Backed up $Info_Node to ${Info_Node}.old." +HANGUP_MSG="Hang up on \"update-info $ARGUMENTS\"" +INSERT_MSG="menu item(s) were inserted (not counting duplicates)." +INSERT_MSG2="total menu item(s) were inserted into `pwd`/$Info_Node" +DELETE_MSG="invalid menu item(s) were removed (not counting duplicates)." +DELETE_MSG2="total invalid menu item(s) were removed from `pwd`/$Info_Node" + +if test "$Create_Node"; then + if test "$Mode"; then + echo "$0:$LINENO: ERROR: Illogical option combination: -d -c">&2 + echo "$TRY_HELP_MSG">&2 + exit 2 + fi + if test -f "$Info_Node"; then + rm -f ${Info_Node}.old + mv "$Info_Node" "${Info_Node}.old" + echo "$BACKUP_MSG" + fi + echo "Creating new Info Node: `pwd`/$Info_Node" +cat>$Info_Node<<NodeEndOfFile||exit + +This is the file .../info/dir, which contains the topmost node of the +Info hierarchy. The first time you invoke Info you start off +looking at that node, which is (dir)Top. + +File: dir Node: Top This is the top of the INFO tree + This (the Directory node) gives a menu of major topics. + Typing "d" returns here, "q" exits, "?" lists all INFO commands, "h" + gives a primer for first-timers, "mTexinfo<Return>" visits Texinfo topic, + etc. + Or click mouse button 2 on a menu item or cross reference to select it. + --- PLEASE ADD DOCUMENTATION TO THIS TREE. (See INFO topic first.) --- + +* Menu: The list of major topics begins on the next line. + +NodeEndOfFile +else + if test ! -f "$Info_Node"; then + echo "$0:$LINENO: $Info_Node is irregular or nonexistant">&2 + exit 2 + elif test ! -r "$Info_Node"; then + echo "$0:$LINENO: $Info_Node is not readable">&2 + exit 2 + elif test ! -w "$Info_Node"; then + echo "$0:$LINENO: $Info_Node is not writeable">&2 + exit 2 + fi +fi + +if test "$Load_Functions" -a "$Interactive" -a -z "$Mode"; then + if FUNCTIONS_VERSION=`( update-info.f )`; then + if test `echo "$FUNCTIONS_VERSION"\ + |cut -d' ' -f5` = "@UPDATE_INFO_VERSION@"; then + echo "Loading functions..." + . update-info.f + else + echo "$0:$LINENO: wrong version of update-info.f">&2 + echo "(functions were not loaded)">&2 + fi + else + echo "(functions were not loaded)">&2 + fi +fi + + +trap ' eval "$Debug"; rm -f $TMP_FILE_LIST; exit ' 0 +if test "$Interactive"; then + if test ! -t "1"; then + echo "$0:$LINENO: Cannot run in interactive mode "\ + "standard out is redirected">&2 + exit 2 + fi + trap ' ' 2 3 +else + trap ' rm -f $TMP_FILE_LIST + echo "$0:$LINENO: received INT signal. All edits are canceled.">&2 + exit ' 2 + trap ' rm -f $TMP_FILE_LIST + echo "$0:$LINENO: received QUIT signal. All edits are canceled.">&2 + exit ' 3 +fi +if test -z "$Mode"; then + trap ' + if test "$Changed"; then + { + echo $HANGUP_MSG + @F_INSERT_MISSING@ + Inserts_Total=`wc -c<"$TMP_COUNT"` + echo $Inserts_Total $INSERT_MSG2 + }|mail "$LOGNAME" + fi + rm -f $TMP_FILE_LIST + exit ' 1 +else + trap ' + if test "$Changed"; then + { + echo $HANGUP_MSG + @F_DELETE_INVALID@ + Invalid_Total=`wc -l<"$TMP_SED"` + echo $Invalid_Total $DELETE_MSG2 + }|mail $LOGNAME + fi + rm -f $TMP_FILE_LIST + exit ' 1 +fi + +sed -e "1,/$MENU_BEGIN/d" -e "$MENU_FILTER1" -e "$MENU_FILTER2"<$Info_Node\ +|tee $TMP_MENU\ +|sed -n -e '/\* /{ +s/).*$//g +s/\.gz$// +s/\.info$// +s/^.*(//p +}'|sort -u>$TMP_FILE1 +ls -F|sed -e '/\/$/d' -e '/[-.][0-9]/d'\ + -e '/:$/d' -e '/^$/d' -e "/^${Info_Node}~\$/d"\ + -e "/^${Info_Node}\$/d" -e "/^${Info_Node}.old\$/d"\ + -e 's/\.gz$//' -e 's/\.info$//'|sort>$TMP_FILE2 + +if test -z "$Mode"; then + #Detect Missing + comm -13 $TMP_FILE1 $TMP_FILE2>$TMP_LIST + cat</dev/null>$TMP_COUNT + #get sections, initialize variables + sed -n -e "/$SECTION_TITLE/p" "$TMP_MENU">"$TMP_SECTIONS" + Item_Num=`wc -l<"$TMP_SECTIONS"|tr -d ' '` + Item_Status=`echo\ + |awk "BEGIN{for(i=1;i<=${Item_Num};i++)printf(\"_\n\")}"` + Item_Dir="$Item_Num" + for Info_Name in `cat $TMP_LIST` + do + if test -r "$Info_Name"; then + Info_File="$Info_Name" + elif test -r "${Info_Name}.info"; then + Info_File="${Info_Name}.info" + elif test -r "${Info_Name}.gz"; then + Info_File="${Info_Name}.gz" + elif test -r "${Info_Name}.info.gz"; then + Info_File="${Info_Name}.info.gz" + else + echo "$0:$LINENO: can't find info file for ${Info_Name}?">&2 + fi + #generate menu item + echo|tr -d '\012'>$TMP_FILE1 + eval $CAT_COMMAND "$Info_File"\ + |sed -n -e "/$DIR_SECTION/w $TMP_FILE1"\ + -e "/$ENTRY_START/,/$ENTRY_END/{ + $MENU_FILTER1 + p + }"|awk "BEGIN{Mode=0} + /^$/{if(Mode==1)exit} + /^([ ])+([^ ])+/{if(Mode==1)print} + /^[^ ]/{if(Mode==1)exit} + /${MENU_ITEM}${Info_Name}\)\./{if(Mode==0){Mode++ + print} + else + exit}">"$TMP_ITEM" + if test ! -s "$TMP_ITEM"; then + echo "* $Info_Name: ($Info_Name).">"$TMP_ITEM" + fi + Item_Status=`echo "$Item_Status"|sed -e '1,$s/^./_/'` + if test -s "$TMP_FILE1"; then + Item_Section=`sed -e "s/$DIR_SECTION[ ]*//"\ + <$TMP_FILE1` + else + Item_Section=`echo "Miscellaneous"` + fi + Size=`echo "$Item_Section"|wc -l|tr -d ' '` + # initialize variables, check for new sections + Num1=1 + while test "$Num1" -le "$Size" + do + Item=`echo "$Item_Section"|sed -n -e "${Num1}p"` + if Num=`grep -in "^$Item$" "$TMP_SECTIONS"`; then + Num=`echo "$Num"|sed -e 's/:.*$//g'` + ##F#Set_Item + set "$Num" "X" + @SET_ITEM@ + else + set "$Item" + @F_ADD_SECTION@ + fi + Num1=`expr "$Num1" + "1"` + done + if test "$Interactive"; then + echo "$Item_Section" + cat "$TMP_ITEM" + echo "add menu item for $Info_File? " + while true + do + echo "$PROMPT1"|tr -d '\012' + read Answer + case $Answer in + y) break;; + e) + if test "$FUNCTIONS"; then + Select_Sections + break + else + echo "Can't edit. "\ + "Functions are not loaded.">&2 + fi;; + Y) Interactive=""; break;; + n) continue 2;; + N) break 2;; + *) echo "\"$Answer\" "\ + "is an invalid response">&2;; + esac + done + fi + if echo "$Item_Status"|grep '^X'>/dev/null; then + # edit $TMP_MENU + + Changed="y" + ( + trap ' ' 1 2 3 + Tmp_Var=`echo "$Item_Status"|tr -d '\012'` + Key=`awk -F':' ' FNR==1{ print $1}' $TMP_ITEM` + # add new sections to 'dir' file + if test "$Item_Num" -gt "$Item_Dir"; then + if test "$Item_Dir" -ne "0"; then + sed -e "1,${Item_Dir}d" -e 'i\ + +' "$TMP_SECTIONS">>"$TMP_MENU" + else + sed -e 'i\ + +' "$TMP_SECTIONS">>"$TMP_MENU" + fi + fi + # awk determines the insertion points for each section + awk -F":" "function Insert(Line){ + if(Mode==2){ + Mode=1;if(substr(\"$Tmp_Var\",Item++,1)==\"X\") + print Line + } + } + BEGIN{Mode=1;Item=1} + /$SECTION_TITLE/{Insert(FNR-1);if(Mode>=1)Mode=2} + /${MENU_ITEM}.*\)\./{if(\$1>Item_Name)Insert(FNR-1)} + /^$/{Insert(FNR-1)} + END{Insert(FNR)}" Item_Name="$Key" "$TMP_MENU"\ + |sort -nr|sed -e "s%\$% r $TMP_ITEM%"|sed -e '$a\ +w +' -e '$a\ +q +'|ed -s "$TMP_MENU" + echo "$Item_Status"|tr -cd "X">>$TMP_COUNT + ) + + Inserts=`expr "$Inserts" + "1"` + echo "$Info_File installed into section(s):"\ + |tr -d '\012' + echo "$Item_Status"|awk '/X/{printf(" %d", FNR)}' + echo + Item_Dir="$Item_Num" + else + echo "$Info_File not installed (no section selected)" + fi + done + # print summary + trap ' ' 1 2 3 + if test "$Changed"; then + @F_INSERT_MISSING@ + Inserts_Total=`wc -c<"$TMP_COUNT"|tr -d " "` + if test "$Inserts" -ne "$Inserts_Total"; then + echo "$Inserts $INSERT_MSG" + fi + echo "$Inserts_Total $INSERT_MSG2" + fi +else + # Detect Invalid + cat</dev/null>"$TMP_SED" + comm -23 $TMP_FILE1 $TMP_FILE2>$TMP_LIST + for Info_Name in `cat $TMP_LIST` + do + if test "$Interactive"; then + # display invalid menu item(s) + awk "BEGIN{Mode=1} + /^([ ])+([^ ])+/{if(Mode==2)print} + /^$/{if(Mode==2)Mode=1} + /$SECTION_TITLE/{Section=\$0} + /^[^ ]/{if(Mode==2)Mode=1} + /${MENU_ITEM}${Info_Name}\)\./{if(Mode==1){Mode++ + print Section + print}}" $TMP_MENU + echo "delete menu item for $Info_Name? " + while true + do + echo\ + "(y=yes, n=no, Y=yes to all, N=No to all):"\ + |tr -d '\012' + read Answer + case "$Answer" in + y) break;; + Y) Interactive=""; break;; + n) continue 2;; + N) break 2;; + *) echo "\"$Answer\" "\ + "is an invalid reponse">&2;; + esac + done + fi + # remove menu item from $TMP_MENU + Invalid=`expr "$Invalid" + "1"` + Changed="y" + ( + trap ' ' 1 2 3 + echo\ + "invalid menu item for $Info_Name removed from section(s):"\ + |tr -d '\012' + awk "function Delete(Last){ + printf(\"%d,%dd\n\",First,Last-1)>>\"$TMP_SED\"} + BEGIN{Mode=1;Section=0} + /^$/{if(Mode==2){Delete(FNR);Mode=1}} + /$SECTION_TITLE/{Section++} + /^[^ ]/{if(Mode==2){Delete(FNR);Mode=1}} + /${MENU_ITEM}${Info_Name}\)\./{if(Mode==1){ + First=FNR;printf(\" %d\",Section);Mode=2}} + END{if(Mode==2)Delete(FNR+1)}" $TMP_MENU + echo + ) + done + + # display a summary + trap ' ' 1 2 3 + if test "$Changed"; then + Invalid_Total=`wc -l<"$TMP_SED"|tr -d ' '` + @F_DELETE_INVALID@ + if test "$Invalid" -ne "$Invalid_Total"; then + echo "$Invalid $DELETE_MSG" + fi + echo "$Invalid_Total $DELETE_MSG2" + fi +fi +if test -z "$Changed"; then + echo "Nothing to do" +fi +rm -f $TMP_FILE_LIST +eval "$Debug" +exit 0 +# _file: 'update-info.f'_ +#update-info.f (GNU texinfo @TEXINFO_VERSION@) @UPDATE_INFO_VERSION@ +#Copyright (C) 1997 Free Software Foundation, Inc. +#update-info comes with NO WARRANTY, to the extent permitted by law. +#You may redistribute copies of update-info +#under the terms of the GNU General Public License. +#For more information about these matters, see the files named COPYING." +#Author: Richard L. Hawes + +# update-info.f functions for update-info + +# ###SECTION 1### functions used to insert missing menu items + +Set_Item (){ +# set item status +@SET_ITEM@ +} + +Add_Section (){ +# add a section +@F_ADD_SECTION@ +} + +# ###SECTION 2### functions for menu selection of sections + +Print (){ +# print a line without a linefeed +echo "$*"|tr -d '\012' +} + +Get_Answer (){ +# get an answer to question +_gs_Valid="$1" +_gs_Prompt="$2" +set -f +Answer="" +while test -z "$Answer" + do + Print "$_gs_Prompt" + if read Answer; then + : + else + Answer="$CONTROL_D" + echo + fi + if expr "$Answer" : "[$_gs_Valid]$">/dev/null; then + : + else + Print "\"$Answer\" is not a valid response! --">&2 + Answer="" + fi + done +set +f +} + +Do_Previous (){ +# go to previous screen +if test "$Previous"; then + Next="$Top_Item" + Top_Item="$Previous" + if Previous=`expr "$Top_Item" - "$DISPLAY_NUM"`; then + if test "$Previous" -le "0"; then + Previous="" + fi + else + Previous="" + fi +elif test "$Next"; then + Last_Page +else + Print "There is no previous page. ">&2 +fi +} + +Do_Next (){ +# process go to next +if test "$Next"; then + Previous="$Top_Item" + Top_Item="$Next" + Set_Next +elif test "$Previous"; then + Top_Item="1" + Previous="" + Set_Next +else + Print "There is no next page. ">&2 +fi +} + +Do_Add_Section (){ +# process add section command +echo +echo "Please enter the name of the new section:" +if read Answer; then + Answer=`echo "$Answer"\ + |sed -e 's/^\([ ]\)\{1,\}//g' -e "$MENU_FILTER2"` + if test "$Answer"; then + Add_Section "$Answer" + Last_Page + clear + fi +else + Answer="" +fi +if test -z "$Answer"; then + clear + Print "no section added. " +fi +} + +Do_Edit (){ +# process edit item command +if test -t "2"; then + _de_Done="" + cp "$TMP_ITEM" "$TMP_FILE1" + while test -z "$_de_Done" + do + eval $EDITOR "$TMP_FILE1" + clear + _de_Done="t" + if sed -n -e "$MENU_FILTER1" -e '1p' "$TMP_FILE1"\ + |egrep "${MENU_ITEM}${Info_Name}\)\.">/dev/null; then + : + else + sed -n -e '1p' "$TMP_FILE1" + echo "Pattern mismatch: `echo\ + "/${MENU_ITEM}${Info_Name}\)\./"\ + |tr -d "\011"`">&2 + echo + _de_Done="" + fi + if sed -n -e '2,$p' "$TMP_FILE1"|grep '^[^ ]'>&2; then + echo "These lines must have leading spaces">&2 + echo + _de_Done="" + fi + if test -z "$_de_Done"; then + Get_Answer "yn" "Invalid entry, cancel edits? (y or n):" + if test "y" = "$Answer"; then + clear + Print "Canceling edits -- invalid entry ">&2 + _de_Done="t" + fi + else + sed -e "$MENU_FILTER1" -e "$MENU_FILTER2" -e '/^$/d'\ + <"$TMP_FILE1">"$TMP_ITEM" + fi + done +else + Print "editor cannot run with error path redirected " +fi +} + +Do_Number (){ +# process number +_dn_Num="$1" +if test "$_dn_Num" -ge 1 -a "$_dn_Num" -le "$Item_Num"; then + if test `echo "$Item_Status"|sed -n -e "${_dn_Num}p"` = "_"; then + Set_Item "$_dn_Num" "X" + else + Set_Item "$_dn_Num" "_" + fi +else + Print "\"$_dn_Num\" is an invalid section number. ">&2 +fi +} + +Do_Help (){ +# process menu help +echo +echo "\ +Enter the following commands seperated +by spaces and terminated by<ENTER>: +# : (section number) toggle section +a : add a new section +e : edit item -- changes will not be + accepted if you change the + '(info_file_name).' or delete + the key parts: '*' 'Menu Name' ':' +h : get this help screen +n : next page +p : previous page +q : quit and do not put into menu +s : save and put into menu" +Print "Press enter to continue:" +read junk +clear +} + +Set_Next (){ +# determine value of Next +Next=`expr "$DISPLAY_NUM" + "$Top_Item"` +if test "$Next" -gt "$Item_Num"; then + Next="" +fi +} + +Last_Page (){ +# go to last page of menu +Top_Item=`echo|awk "BEGIN{printf(\"%d\", +int((${Item_Num}-1)/${DISPLAY_NUM})*${DISPLAY_NUM}+1)}"` +if test "$Top_Item" -gt "$DISPLAY_NUM"; then + Previous=`expr "$Top_Item" '-' "$DISPLAY_NUM"` +else + Previous="" +fi +Set_Next +} + +Select_Sections (){ +# prompt user for which sections +set -f +Top_Item="1" +Previous="" +Set_Next +clear +echo "Default sections are selected." +Done="" +while test -z "$Done" + do + awk "FNR==1{printf(\"%s\n\", substr(\$0,1,${COLUMNS}))}" $TMP_ITEM + Tmp_Var=`echo "$Item_Status"|tr -d '\012'` + awk "BEGIN{Max=$Top_Item+$DISPLAY_NUM} + FNR>=$Top_Item{if(FNR>=Max)exit + printf(\"%2d:%s %s\n\",FNR,substr(\"$Tmp_Var\",FNR,1), + substr(\$0,1,${COLUMNS}-5))}" "$TMP_SECTIONS" + echo "Enter 1-${Item_Num}, add, edit, help," + if test "$Previous" -o "$Next"; then + Print "next, previous, " + fi + Print "quit, save :" + read Command_List||Command_List="$CONTROL_D" + Command_List=`echo "$Command_List"\ + |tr '\011' ' '|tr ' ' '\012'|sed -e "/^$/d"` + clear + if test -z "$Command_List"; then + Help="y" + else + Help="" + fi + while test "$Command_List" + do + Command=`echo "$Command_List"|sed -n -e '1p'` + Command_List=`echo "$Command_List"|sed -e '1d'` + case "$Command" in + [0-9]|[0-9][0-9]) Do_Number "$Command";; + n*) Do_Next;; + p*) Do_Previous;; + a*) Do_Add_Section;; + e*) Do_Edit; break;; + h*) Help="y";; + s*) Done="s"; break;; + q*) Done="q" + Item_Status=`echo "$Item_Status"|sed -e '1,$s/^./_/'` + break;; + *) Print "$Command is not a valid command. ">&2 + Help="y";; + esac + done + if test "$Help"; then + Do_Help + fi + echo + done +set +f +# if new sections added, remove unused ones +if test "$Item_Num" -gt "$Item_Dir"; then + Tmp_Var=`echo "$Item_Status"|awk "FNR>$Item_Dir{ + if(\\$0==\"_\")printf(\"%d\n\", FNR)}"` + if test "$Tmp_Var"; then + Tmp_Var1=`echo "$Tmp_Var"|sed -e 's/$/d/'` + sed -e "$Tmp_Var1" "$TMP_SECTIONS">$TMP_FILE1 + cp $TMP_FILE1 "$TMP_SECTIONS" + Item_Status=`echo "$Item_Status"|sed -e "$Tmp_Var1"` + Tmp_Var="" + Tmp_Var1="" + Item_Num=`wc -l<"$TMP_SECTIONS"|tr -d ' '` + fi +fi +} + +# ###SECTION 100### Constants that redefine +PROMPT1="(y=yes, e=edit, Y=yes to all, n=no, N=No to all):" +FUNCTIONS="y" +# +echo "update-info.f (GNU texinfo @TEXINFO_VERSION@) @UPDATE_INFO_VERSION@" |