summaryrefslogtreecommitdiffstats
path: root/contrib/texinfo/util
diff options
context:
space:
mode:
authorru <ru@FreeBSD.org>2003-05-02 00:48:41 +0000
committerru <ru@FreeBSD.org>2003-05-02 00:48:41 +0000
commit374ada20ea75e5e2d1945e7896180bea1f752477 (patch)
tree58bf7fa721f3333d934a90edf15dd134b60feacf /contrib/texinfo/util
parent4d1fda8c19d6f882c382a685e1c553d80d8f0e11 (diff)
downloadFreeBSD-src-374ada20ea75e5e2d1945e7896180bea1f752477.zip
FreeBSD-src-374ada20ea75e5e2d1945e7896180bea1f752477.tar.gz
Import of stripped down GNU texinfo 4.5
Diffstat (limited to 'contrib/texinfo/util')
-rw-r--r--contrib/texinfo/util/README14
-rw-r--r--contrib/texinfo/util/install-info.c46
-rw-r--r--contrib/texinfo/util/texindex.c82
3 files changed, 106 insertions, 36 deletions
diff --git a/contrib/texinfo/util/README b/contrib/texinfo/util/README
index 20d7bda..d3f8a75 100644
--- a/contrib/texinfo/util/README
+++ b/contrib/texinfo/util/README
@@ -1,10 +1,14 @@
+$Id: README,v 1.4 2002/12/29 17:47:20 karl Exp $
+texinfo/util/README
+
+ Copyright (C) 2002 Free Software Foundation, Inc.
+
+ Copying and distribution of this file, with or without modification,
+ are permitted in any medium without royalty provided the copyright
+ notice and this notice are preserved.
+
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.
-You may also be interested in a2ps, an ASCII->PostScript program which
-has a Texinfo style option. Available from
-http://www.inf.enst.fr/~demaille/a2ps/ and
-ftp://ftp.enst.fr/pub/unix/a2ps/.
-
diff --git a/contrib/texinfo/util/install-info.c b/contrib/texinfo/util/install-info.c
index aec6a79..75fcba9 100644
--- a/contrib/texinfo/util/install-info.c
+++ b/contrib/texinfo/util/install-info.c
@@ -1,7 +1,8 @@
/* install-info -- create Info directory entry(ies) for an Info file.
- $Id: install-info.c,v 1.55 2002/03/11 19:55:23 karl Exp $
+ $Id: install-info.c,v 1.7 2003/01/19 18:46:51 karl Exp $
- Copyright (C) 1996, 97, 98, 99, 2000, 01, 02 Free Software Foundation, Inc.
+ Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003 Free Software
+ Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -119,6 +120,7 @@ struct option longopts[] =
{ "dir-file", required_argument, NULL, 'd' },
{ "entry", required_argument, NULL, 'e' },
{ "help", no_argument, NULL, 'h' },
+ { "infodir", required_argument, NULL, 'D' },
{ "info-dir", required_argument, NULL, 'D' },
{ "info-file", required_argument, NULL, 'i' },
{ "item", required_argument, NULL, 'e' },
@@ -311,6 +313,11 @@ strip_info_suffix (fname)
len -= 3;
ret[len] = 0;
}
+ else if (len > 4 && FILENAME_CMP (ret + len - 4, ".bz2") == 0)
+ {
+ len -= 4;
+ ret[len] = 0;
+ }
if (len > 5 && FILENAME_CMP (ret + len - 5, ".info") == 0)
{
@@ -455,8 +462,10 @@ The first time you invoke Info you start off looking at this node.\n\
In Emacs, you can click mouse button 2 on a menu item or cross reference\n\
to select it.\n\
\n\
-* Menu:\n\
-"), "File: dir,\tNode: Top"); /* This part must not be translated. */
+%s\n\
+"), "File: dir,\tNode: Top", /* These keywords must not be translated. */
+ "* Menu:"
+);
if (fclose (f) < 0)
pfatal_with_name (dirfile);
}
@@ -508,6 +517,13 @@ open_possibly_compressed_file (filename, create_callback,
{
*opened_filename = concat (filename, ".gz", "");
f = fopen (*opened_filename, FOPEN_RBIN);
+ if (!f)
+ {
+ free (*opened_filename);
+ *opened_filename = concat (filename, ".bz2", "");
+ f = fopen (*opened_filename, FOPEN_RBIN);
+ }
+
#ifdef __MSDOS__
if (!f)
{
@@ -563,6 +579,18 @@ open_possibly_compressed_file (filename, create_callback,
#else
*compression_program = "gzip";
#endif
+ else if(data[0] == 'B' && data[1] == 'Z' && data[2] == 'h')
+#ifndef STRIP_DOT_EXE
+ *compression_program = "bzip2.exe";
+#else
+ *compression_program = "bzip2";
+#endif
+ else if(data[0] == 'B' && data[1] == 'Z' && data[2] == '0')
+#ifndef STRIP_DOT_EXE
+ *compression_program = "bzip.exe";
+#else
+ *compression_program = "bzip";
+#endif
else
*compression_program = NULL;
@@ -904,7 +932,7 @@ parse_input (lines, nlines, sections, entries)
}
if (start_of_this_entry != 0)
fatal (_("START-INFO-DIR-ENTRY without matching END-INFO-DIR-ENTRY"),
- 0, 0);
+ 0, 0);
/* If we ignored the INFO-DIR-ENTRY directives, we need now go back
and plug the names of all the sections we found into every
@@ -1221,11 +1249,11 @@ main (argc, argv)
case 'V':
printf ("install-info (GNU %s) %s\n", PACKAGE, VERSION);
puts ("");
- printf (_("Copyright (C) %s Free Software Foundation, Inc.\n\
+ 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.\n"),
- "2002");
+ "2003");
xexit (0);
default:
@@ -1246,7 +1274,7 @@ For more information about these matters, see the files named COPYING.\n"),
if (!infile)
fatal (_("No input file specified; try --help for more information."),
- 0, 0);
+ 0, 0);
if (!dirfile)
fatal (_("No dir file specified; try --help for more information."), 0, 0);
@@ -1313,7 +1341,7 @@ For more information about these matters, see the files named COPYING.\n"),
char *infile_basename = infile + strlen (infile);
if (HAVE_DRIVE (infile))
- infile += 2; /* get past the drive spec X: */
+ infile += 2; /* get past the drive spec X: */
while (infile_basename > infile && !IS_SLASH (infile_basename[-1]))
infile_basename--;
diff --git a/contrib/texinfo/util/texindex.c b/contrib/texinfo/util/texindex.c
index 7f8ff59..c7dc64b 100644
--- a/contrib/texinfo/util/texindex.c
+++ b/contrib/texinfo/util/texindex.c
@@ -1,8 +1,8 @@
-/* Process TeX index dribble output into an actual index.
- $Id: texindex.c,v 1.41 2002/03/11 19:55:46 karl Exp $
+/* texindex -- sort TeX index dribble output into an actual index.
+ $Id: texindex.c,v 1.7 2003/01/19 18:47:15 karl Exp $
- Copyright (C) 1987, 91, 92, 96, 97, 98, 99, 2000, 01, 02
- Free Software Foundation, Inc.
+ Copyright (C) 1987, 1991, 1992, 1996, 1997, 1998, 1999, 2000, 2001,
+ 2002, 2003 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -97,9 +97,6 @@ long nlines;
/* Directory to use for temporary files. On Unix, it ends with a slash. */
char *tempdir;
-/* Start of filename to use for temporary files. */
-char *tempbase;
-
/* Number of last temporary file. */
int tempcount;
@@ -111,6 +108,13 @@ int last_deleted_tempcount;
which contains all the lines of data. */
char *text_base;
+/* Initially 0; changed to 1 if we want initials in this index. */
+int need_initials;
+
+/* Remembers the first initial letter seen in this index, so we can
+ determine whether we need initials in the sorted form. */
+char first_initial;
+
/* Additional command switches .*/
/* Nonzero means do not delete tempfiles -- for debugging. */
@@ -160,6 +164,9 @@ main (argc, argv)
bindtextdomain (PACKAGE, LOCALEDIR);
textdomain (PACKAGE);
+ /* In case we write to a redirected stdout that fails. */
+ /* not ready atexit (close_stdout); */
+
/* Describe the kind of sorting to do. */
/* The first keyfield uses the first braced field and folds case. */
keyfields[0].braced = 1;
@@ -181,8 +188,6 @@ main (argc, argv)
decode_command (argc, argv);
- tempbase = mktemp (concat ("txiXXXXXX", "", ""));
-
/* Process input files completely, one by one. */
for (i = 0; i < num_infiles; i++)
@@ -217,9 +222,12 @@ main (argc, argv)
outfile = concat (infiles[i], "s", "");
}
+ need_initials = 0;
+ first_initial = '\0';
+
if (ptr < MAX_IN_CORE_SORT)
/* Sort a small amount of data. */
- sort_in_core (infiles[i], ptr, outfile);
+ sort_in_core (infiles[i], (int)ptr, outfile);
else
sort_offline (infiles[i], ptr, outfile);
}
@@ -339,7 +347,7 @@ decode_command (argc, argv)
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.\n"),
- "2002");
+ "2003");
xexit (0);
}
else if ((strcmp (arg, "--keep") == 0) ||
@@ -381,17 +389,33 @@ For more information about these matters, see the files named COPYING.\n"),
usage (1);
}
-/* Return a name for a temporary file. */
+/* Return a name for temporary file COUNT. */
static char *
maketempname (count)
int count;
{
+ static char *tempbase = NULL;
char tempsuffix[10];
+
+ if (!tempbase)
+ {
+ int fd;
+ char *tmpdir = getenv ("TEMPDIR");
+ if (!tmpdir)
+ tmpdir = "/tmp";
+ tempbase = concat (tmpdir, "/txidxXXXXXX");
+
+ fd = mkstemp (tempbase);
+ if (fd == -1)
+ pfatal_with_name (tempbase);
+ }
+
sprintf (tempsuffix, ".%d", count);
return concat (tempdir, tempbase, tempsuffix);
}
+
/* Delete all temporary files up to TO_COUNT. */
void
@@ -861,9 +885,8 @@ readline (linebuffer, stream)
/* Sort an input file too big to sort in core. */
void
-sort_offline (infile, nfiles, total, outfile)
+sort_offline (infile, total, outfile)
char *infile;
- int nfiles;
off_t total;
char *outfile;
{
@@ -942,7 +965,7 @@ fail:
for (i = 0; i < ntemps; i++)
{
char *newtemp = maketempname (++tempcount);
- sort_in_core (&tempfiles[i], MAX_IN_CORE_SORT, newtemp);
+ sort_in_core (tempfiles[i], MAX_IN_CORE_SORT, newtemp);
if (!keep_tempfiles)
unlink (tempfiles[i]);
tempfiles[i] = newtemp;
@@ -963,7 +986,7 @@ fail:
void
sort_in_core (infile, total, outfile)
char *infile;
- off_t total;
+ int total;
char *outfile;
{
char **nextline;
@@ -1101,6 +1124,23 @@ parsefile (filename, nextline, data, size)
return 0;
*line = p;
+
+ /* Find the first letter of the first field of this line. If it
+ is different from the first letter of the first field of the
+ first line, we need initial headers in the output index. */
+ while (*p && *p != '{')
+ p++;
+ if (p == end)
+ return 0;
+ p++;
+ if (first_initial)
+ {
+ if (first_initial != toupper (*p))
+ need_initials = 1;
+ }
+ else
+ first_initial = toupper (*p);
+
while (*p && *p != '\n')
p++;
if (p != end)
@@ -1210,12 +1250,9 @@ indexify (line, ostream)
else
{
initial = initial1;
- initial1[0] = *p;
+ initial1[0] = toupper (*p);
initial1[1] = 0;
initiallength = 1;
-
- if (initial1[0] >= 'a' && initial1[0] <= 'z')
- initial1[0] -= 040;
}
pagenumber = find_braced_pos (line, 1, 0, 0);
@@ -1243,8 +1280,9 @@ indexify (line, ostream)
/* If this primary has a different initial, include an entry for
the initial. */
- if (initiallength != lastinitiallength ||
- strncmp (initial, lastinitial, initiallength))
+ if (need_initials &&
+ (initiallength != lastinitiallength ||
+ strncmp (initial, lastinitial, initiallength)))
{
fprintf (ostream, "\\initial {");
fwrite (initial, 1, initiallength, ostream);
OpenPOWER on IntegriCloud