From 2d99258bc3b166458f6caa6ca80dcdc45b926f3c Mon Sep 17 00:00:00 2001 From: peter Date: Thu, 4 Feb 1999 03:57:15 +0000 Subject: [PATCH] Restore rev 1.2 and 1.3 after they got spammed and backed out in rev 1.7 and 1.8 as those features are used by the ports tree. (RELENG_3 candidate) --- contrib/texinfo/util/install-info.c | 49 +++++++++++++++++++++++++++-- 1 file changed, 47 insertions(+), 2 deletions(-) diff --git a/contrib/texinfo/util/install-info.c b/contrib/texinfo/util/install-info.c index 03f6937d1d7f..32f3fd618ef6 100644 --- a/contrib/texinfo/util/install-info.c +++ b/contrib/texinfo/util/install-info.c @@ -294,6 +294,10 @@ Install INFO-FILE in the Info directory file DIR-FILE.\n\ Options:\n\ --delete Delete existing entries in INFO-FILE;\n\ don't insert any new entries.\n\ +--defentry=TEXT Like --entry, but only use TEXT if an entry\n\ + is not present in INFO-FILE.\n\ +--defsection=TEXT Like --section, but only use TEXT if a section\n\ + is not present in INFO-FILE.\n\ --dir-file=NAME Specify file name of Info directory file.\n\ This is equivalent to using the DIR-FILE argument.\n\ --entry=TEXT Insert TEXT as an Info directory entry.\n\ @@ -302,6 +306,7 @@ Options:\n\ If you specify more than one entry, they are all added.\n\ If you don't specify any entries, they are determined\n\ from information in the Info file itself.\n\ +--forceentry=TEXT Like --entry, but ignore any entry in INFO-FILE.\n\ --help Display this help and exit.\n\ --info-file=FILE Specify Info file to install in the directory.\n\ This is equivalent to using the INFO-FILE argument.\n\ @@ -376,8 +381,11 @@ File: dir,\tNode: Top,\tThis is the top of the INFO tree\n\ struct option longopts[] = { { "delete", no_argument, NULL, 'r' }, + { "defentry", required_argument, NULL, 'E' }, + { "defsection", required_argument, NULL, 'S' }, { "dir-file", required_argument, NULL, 'd' }, { "entry", required_argument, NULL, 'e' }, + { "forceentry", required_argument, NULL, 'f' }, { "help", no_argument, NULL, 'h' }, { "info-dir", required_argument, NULL, 'D' }, { "info-file", required_argument, NULL, 'i' }, @@ -430,6 +438,11 @@ main (argc, argv) int prefix_length; int i; + /* Nonzero means only use if not present in info file. */ + int entry_default = 0; + int entry_force = 0; + int section_default = 0; + progname = argv[0]; #ifdef HAVE_SETLOCALE @@ -478,6 +491,17 @@ main (argc, argv) dirfile = concat (optarg, "", "/dir"); break; + case 'f': + entry_force = 1; + if (!optarg[0]) + { + fprintf (stderr, "%s: Must provide entry name.\n", progname); + suggest_asking_for_help (); + } + case 'E': + entry_default = 1; + if (!optarg[0]) + break; case 'e': { struct spec_entry *next @@ -514,6 +538,10 @@ main (argc, argv) delete_flag = 1; break; + case 'S': + section_default = 1; + if (!optarg[0]) + break; case 's': { struct spec_section *next @@ -539,6 +567,9 @@ For more information about these matters, see the files named COPYING.\n"), } } + if (entry_force) + entry_default = 0; + /* Interpret the non-option arguments as file names. */ for (; optind < argc; ++optind) { @@ -562,7 +593,7 @@ For more information about these matters, see the files named COPYING.\n"), /* Parse the input file to find the section names it specifies. */ - if (input_sections == 0) + if (input_sections == 0 || section_default) { prefix_length = strlen ("INFO-DIR-SECTION "); for (i = 0; i < input_nlines; i++) @@ -572,6 +603,13 @@ For more information about these matters, see the files named COPYING.\n"), { struct spec_section *next = (struct spec_section *) xmalloc (sizeof (struct spec_section)); + + if (section_default) + { + input_sections = NULL; /* This leaks. */ + section_default = 0; + } + next->name = copy_string (input_lines[i].start + prefix_length, input_lines[i].size - prefix_length); next->next = input_sections; @@ -595,7 +633,7 @@ For more information about these matters, see the files named COPYING.\n"), and put them on entries_to_add. But not if entries were specified explicitly with command options. */ - if (entries_to_add == 0) + if ( !entry_force && (entries_to_add == 0 || entry_default) ) { char *start_of_this_entry = 0; for (i = 0; i < input_nlines; i++) @@ -616,6 +654,13 @@ For more information about these matters, see the files named COPYING.\n"), { struct spec_entry *next = (struct spec_entry *) xmalloc (sizeof (struct spec_entry)); + + if (entry_default) + { + entries_to_add = NULL; + entry_default = 0; + } + next->text = copy_string (start_of_this_entry, input_lines[i].start - start_of_this_entry); next->next = entries_to_add;