aboutsummaryrefslogtreecommitdiff
path: root/texinfo/util
diff options
context:
space:
mode:
authorJeff Law <law@gcc.gnu.org>1998-03-22 14:47:59 -0700
committerJeff Law <law@gcc.gnu.org>1998-03-22 14:47:59 -0700
commitf8b2ac1ece6a3f082b68d854059648e2a6cb3e43 (patch)
tree87e2b2b74f7d097a6b65a3f5d90b032f669ab723 /texinfo/util
parent8491377bd19a528b1249b3a6ad67277d813720fc (diff)
downloadgcc-f8b2ac1ece6a3f082b68d854059648e2a6cb3e43.zip
gcc-f8b2ac1ece6a3f082b68d854059648e2a6cb3e43.tar.gz
gcc-f8b2ac1ece6a3f082b68d854059648e2a6cb3e43.tar.bz2
Merge in texinfo-3.11.
From-SVN: r18767
Diffstat (limited to 'texinfo/util')
-rw-r--r--texinfo/util/install-info.c217
1 files changed, 118 insertions, 99 deletions
diff --git a/texinfo/util/install-info.c b/texinfo/util/install-info.c
index e0289a7..6007a3c 100644
--- a/texinfo/util/install-info.c
+++ b/texinfo/util/install-info.c
@@ -1,56 +1,30 @@
/* install-info -- create Info directory entry(ies) for an Info file.
- Copyright (C) 1996 Free Software Foundation, Inc.
+ $Id: install-info.c,v 1.5 1998/03/24 18:08:44 law Exp $
-$Id: install-info.c,v 1.3 1997/09/18 05:54:18 law Exp $
+ Copyright (C) 1996, 97 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>
-
-#if defined (HAVE_STRING_H)
-#include <string.h>
-#else
-#include <strings.h>
-#endif /* !HAVE_STRING_H */
-
-#if !defined (HAVE_STRCHR)
-char *strrchr ();
-#endif /* !HAVE_STRCHR */
-
-
-/* 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>
-#endif
/* Name this program was invoked with. */
char *progname;
char *readfile ();
struct line_data *findlines ();
-char *my_strerror ();
void fatal ();
void insert_entry_here ();
int compare_section_names ();
@@ -59,9 +33,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. */
@@ -78,9 +51,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;
@@ -90,16 +63,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;
@@ -120,9 +93,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;
@@ -136,7 +109,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;
@@ -144,12 +116,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;
@@ -158,12 +129,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;
@@ -197,7 +168,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
@@ -206,7 +177,7 @@ error (s1, s2, s3)
{
fprintf (stderr, "%s: ", progname);
fprintf (stderr, s1, s2, s3);
- fprintf (stderr, "\n");
+ putc ('\n', stderr);
}
/* VARARGS1 */
@@ -214,9 +185,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. */
@@ -235,7 +206,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);
}
@@ -304,7 +275,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);
}
@@ -312,7 +283,7 @@ suggest_asking_for_help ()
void
print_help ()
{
- printf ("%s [OPTION]... [INFO-FILE [DIR-FILE]]\n\
+ printf (_("%s [OPTION]... [INFO-FILE [DIR-FILE]]\n\
Install INFO-FILE in the Info directory file DIR-FILE.\n\
\n\
Options:\n\
@@ -342,27 +313,54 @@ Options:\n\
--version Display version information and exit.\n\
\n\
Email bug reports to bug-texinfo@prep.ai.mit.edu.\n\
-", progname);
+"), 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. */
-
-char *
-my_strerror (errnum)
- int errnum;
+
+/* If DIRFILE does not exist, create a minimal one (or abort). If it
+ already exists, do nothing. */
+void
+ensure_dirfile_exists (dirfile)
+ char *dirfile;
{
-#ifdef HAVE_STRERROR
- return strerror(errnum);
-#else
- extern char *sys_errlist[];
- extern int sys_nerr;
-
- if (errnum >= 0 && errnum < sys_nerr)
- return sys_errlist[errnum];
- return (char *) "Unknown error";
-#endif
+ 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 Node: Top This 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
@@ -384,6 +382,7 @@ struct option longopts[] =
{ 0 }
};
+int
main (argc, argv)
int argc;
char **argv;
@@ -425,6 +424,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);
@@ -445,7 +453,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 ();
}
@@ -455,7 +463,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 ();
}
@@ -483,7 +491,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 ();
}
@@ -510,12 +518,12 @@ 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);
+puts (_("Copyright (C) 1996 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."));
+ exit (0);
default:
suggest_asking_for_help ();
@@ -530,13 +538,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. */
@@ -588,7 +596,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,
@@ -607,18 +615,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);
@@ -747,8 +763,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
@@ -820,7 +840,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] == '*'
@@ -843,7 +863,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. */
@@ -941,7 +961,6 @@ readfile (filename, sizep)
int nread = 0;
int desc = open (filename, O_RDONLY);
-
if (desc < 0)
pfatal_with_name (filename);