Files
texinfo/install-info.diff

124 lines
5.1 KiB
Diff

Index: install-info/install-info.c
===================================================================
RCS file: /sources/texinfo/texinfo/install-info/install-info.c,v
retrieving revision 1.10
retrieving revision 1.13
diff -u -a -p -u -p -a -r1.10 -r1.13
--- install-info/install-info.c 19 Apr 2008 17:03:14 -0000 1.10
+++ install-info/install-info.c 18 May 2008 16:54:02 -0000 1.13
@@ -1,5 +1,5 @@
/* install-info -- create Info directory entry(ies) for an Info file.
- $Id: install-info.c,v 1.10 2008/04/19 17:03:14 karl Exp $
+ $Id: install-info.c,v 1.13 2008/05/18 16:54:02 karl Exp $
Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
2005, 2007, 2008 Free Software Foundation, Inc.
@@ -1445,19 +1445,27 @@ format_entry (char *name, size_t name_le
free'd.
*/
static void
-split_entry (char *entry, char **name, size_t *name_len, char **description, size_t *description_len)
+split_entry (const char *entry, char **name, size_t *name_len,
+ char **description, size_t *description_len)
{
char *endptr;
- /* on the first line, the description starts after the first period. */
+ /* on the first line, the description starts after the first ". ";
+ that's a period and space -- our heuristic to handle item names like
+ "config.status", and node names like "config.status Invocation".
+ Also accept period-tab and period-newline. */
char *ptr = strchr (entry, '.');
+ while (ptr && ptr[1] != ' ' && ptr[1] != '\t' && ptr[1] != '\n') {
+ ptr = strchr (ptr + 1, '.');
+ }
+
/* Maybe there's no period, and no description */
if (!ptr)
{
size_t length = strlen (entry);
if (length == 0)
return;
- *name = strdup (ptr);
+ *name = strdup (entry);
*name_len = length + 1;
return;
}
@@ -1474,7 +1482,6 @@ split_entry (char *entry, char **name, s
while (ptr[0] != '\0')
{
-
/* Eat up the whitespace after the name, and at the start of a line. */
while (isspace(ptr[0]))
ptr++;
@@ -1598,14 +1605,14 @@ add_missing_basenames (struct spec_entry
/* Insert NAME into the right place in ENTRY->TEXT. */
char *info, *rest, *text;
size_t name_len = strlen (name);
- char *ptr = strstr (entry->text, ": ().");
+ char *ptr = strstr (entry->text, ": (). ");
if (!ptr)
return;
ptr[0] = '\0';
- rest = ptr += sizeof (": ().");
+ rest = ptr += strlen (": (). ");
- info = xmalloc (name_len + 6);
- snprintf (info, name_len + 6, ": (%s).", name);
+ info = xmalloc (name_len + 7);
+ snprintf (info, name_len + 7, ": (%s). ", name);
text = concat (entry->text, info, rest);
free (info);
if (entry->text)
@@ -1672,8 +1679,8 @@ add_missing_descriptions (struct spec_en
{
char *text;
int add_nl = 1;
- if (entry->text)
- if (entry->text[entry->text_len - 1] == '\n')
+ if (strlen (desc) > 1)
+ if (desc[strlen (desc) - 1] == '\n')
add_nl = 0;
/* Append DESC onto ENTRY->TEXT. */
text = concat (entry->text == NULL ? "" : entry->text, desc,
@@ -1910,8 +1917,11 @@ main (int argc, char *argv[])
nl[0] = '\0';
}
/* Concat the description onto the current entry, adding a
- newline if we need one. */
- next->text = concat (next->text == NULL ? "" : next->text, optarg,
+ newline if we need one. Prepend a space if we have no
+ previous text, since eventually we will be adding the
+ "* foo ()." and we want to end up with a ". " for parsing. */
+ next->text = concat (next->text ? next->text : " ",
+ optarg,
optarg[length - 1] == '\n' ? "" : "\n");
next->text_len = strlen (next->text);
}
@@ -1958,20 +1968,20 @@ main (int argc, char *argv[])
size_t length;
if (optarg[0] != '*')
{
- /* Make enough space for "* foo: ().\n". */
+ /* Make enough space for "* foo: (). ". */
length = strlen (optarg) + 9;
next->text = xmalloc (length);
- snprintf (next->text, length, "* %s: ().\n", optarg);
+ snprintf (next->text, length, "* %s: (). ", optarg);
next->missing_basename = 1;
/* The basename will be inserted in between the parentheses
at a later time. See add_missing_basenames. */
}
else
{
- /* Make enough space for "foo\n". */
+ /* Make enough space for "foo ". */
length = strlen (optarg) + 2;
next->text = xmalloc (length);
- snprintf (next->text, length, "%s\n", optarg);
+ snprintf (next->text, length, "%s ", optarg);
next->missing_basename = 0;
/* FIXME: check for info entry correctness in TEXT.
e.g. `* Aaa: (bbb).' */