diff -rauN ../orig/texinfo-4.8.dfsg.1/util/install-info.c ./texinfo-4.8.dfsg.1/util/install-info.c --- ../orig/texinfo-4.8.dfsg.1/util/install-info.c 2006-05-29 05:54:40.000000000 +0200 +++ ./texinfo-4.8.dfsg.1/util/install-info.c 2006-06-17 16:50:02.000000000 +0200 @@ -20,6 +20,7 @@ #include "system.h" #include +#include static char *progname = "install-info"; @@ -129,11 +130,19 @@ { "item", required_argument, NULL, 'e' }, { "quiet", no_argument, NULL, 'q' }, { "remove", no_argument, NULL, 'r' }, + { "remove-exactly", no_argument, NULL, 'x' }, + { "section-regex", required_argument, NULL, 'R' }, { "section", required_argument, NULL, 's' }, { "version", no_argument, NULL, 'V' }, { 0 } }; +regex_t *psecreg = NULL; + /* Nonzero means that the name specified for the info file will be used + * (without removing .gz, .info extension or leading path) to match the + * entries that must be removed. */ + int remove_exactly = 0; + /* Error message functions. */ /* Print error message. S1 is printf control string, S2 and S3 args for it. */ @@ -383,6 +392,7 @@ filename from the new dir entries, not the filename on the command line. Not worrying about those things right now, though. --karl, 26mar04. */ + if (!remove_exactly) { while (*item_basename && !IS_SLASH (*item_basename) && *item_basename != term_char) item_basename++; @@ -390,6 +400,7 @@ item_basename = item; /* no /, use original */ else item_basename++; /* have /, move past it */ + } /* First, ITEM must actually match NAME (usually it won't). */ ret = strncasecmp (item_basename, name, name_len) == 0; @@ -455,6 +466,10 @@ An Info directory entry is actually a menu item.\n\ --quiet suppress warnings.\n\ --remove same as --delete.\n\ + --section-regex=REGEX\n\ + if an entry is added to a section that does not alredy\n\ + exist, try to find a section that matches this\n\ + regular expression before starting a new section.\n\ --section=SEC put this file's entries in section SEC of the directory.\n\ If you specify more than one section, all the entries\n\ are added in each of the sections.\n\ @@ -1248,6 +1263,27 @@ delete_flag = 1; break; + case 'R': + { + int error; + if (psecreg) + warning(_("Only one regular expression can be specified `%s'"), + optarg, 0); + else + psecreg = (regex_t *) xmalloc(sizeof (regex_t)); + + if ((error = regcomp(psecreg, optarg, REG_ICASE|REG_NOSUB)) != 0) + { + int errbuf_size = regerror(error, psecreg, NULL, 0); + char *errbuf = (char *) xmalloc(errbuf_size); + regerror(error, psecreg, errbuf, errbuf_size); + fatal (_("Error in regular expression `%s': %s"), + optarg, + errbuf); + }; + } + break; + case 's': { struct spec_section *next @@ -1268,6 +1304,11 @@ For more information about these matters, see the files named COPYING.\n")); xexit (0); + case 'x': + delete_flag = 1; + remove_exactly = 1; + break; + default: suggest_asking_for_help (); } @@ -1349,7 +1390,7 @@ /* We will be comparing the entries in the dir file against the current filename, so need to strip off any directory prefix and/or [.info][.gz] suffix. */ - { + if (!remove_exactly) { char *infile_basename = infile + strlen (infile); if (HAVE_DRIVE (infile)) @@ -1359,7 +1400,8 @@ infile_basename--; infile_sans_info = strip_info_suffix (infile_basename); - } + } else + infile_sans_info = xstrdup(infile); something_deleted = parse_dir_file (dir_lines, dir_nlines, &dir_nodes, infile_sans_info); @@ -1374,6 +1416,32 @@ struct menu_section *section; struct spec_section *spec; + for (spec = input_sections; spec; spec = spec->next) + { + int found = 0; + /* Check if the section specified (e.g. in the info file) exists */ + for (node = dir_nodes; node && found == 0; node = node->next) + for (section = node->sections; + section && found == 0; + section = section->next) + if (!strcmp (spec->name, section->name)) + found = 1; + + /* If it does not exist, but the user specified a regular expression, + * try to find a section that matches this regex. + */ + if (!found && psecreg) + for (node = dir_nodes; node && found == 0; node = node->next) + for (section = node->sections; + section && found == 0; + section = section->next) + if (regexec(psecreg, section->name, 0, NULL, 0) == 0) + { + spec->name = section->name; + spec->missing = 0; + found = 1; + } + } for (node = dir_nodes; node; node = node->next) for (section = node->sections; section; section = section->next) {