There's another bug that relates to this.
Using texi2any_internals.info again as the example, the proper index node is
fine and works as expected but in a virtual index this same kind of entry is
parsed incorrectly:
info texi2any_internals -n Index
vs.
info texi2any_internals --index-search xml_accent --all
It happens because when the virtual index is being created, the DEL characters
have already been stripped from the node name, which is printed as-is, so there
isn't a quote character there for `scan_reference_label()` to stop scanning at.
This is at info/indices.c:903.
Two diffs again--one makes `format_reference()` at that location enclose node
names that have at least one colon in them in DEL characters. In order to use
INFO_QUOTE_STR I moved it and INFO_QUOTE (seemed sensible to keep them
together) from
info/scan.c to info/scan.h.
The other diff updates the test I wrote previously to work with the now quoted
index entry.
diff --git a/info/t/quoted-index-target.sh b/info/t/quoted-index-target.sh
index a364cce357..25fcf3101c 100755
--- a/info/t/quoted-index-target.sh
+++ b/info/t/quoted-index-target.sh
@@ -23,7 +23,7 @@ $ginfo --file quoting --index-search "Colon::in, name" --all >$ginfo_output
# Test that the found index entry has the correct node name. An index entry
# split in the wrong place should not match this RE, rather be shaped something
# like "* Colon::in, name: ^?Colon:: in. (line 0)"
-grep '\* Colon::in, name:[[:blank:]]\{1,\}Colon::in, name' $ginfo_output
+grep '\* Colon::in, name:[[:blank:]]\{1,\}[[:cntrl:]]Colon::in, name[[:cntrl:]]' $ginfo_output
retval=$?
diff --git a/info/indices.c b/info/indices.c
index 95a80636d9..3941481b04 100644
--- a/info/indices.c
+++ b/info/indices.c
@@ -900,7 +900,11 @@ format_reference (REFERENCE *ref, const char *filename, struct text_buffer *buf)
if (ref->filename && strcmp (ref->filename, filename))
n += text_buffer_printf (buf, "(%s)", ref->filename);
- n += text_buffer_printf (buf, "%s. ", ref->nodename);
+
+ if (strchr(ref->nodename, ':'))
+ n += text_buffer_printf (buf, INFO_QUOTE_STR "%s" INFO_QUOTE_STR ". ", ref->nodename);
+ else
+ n += text_buffer_printf (buf, "%s. ", ref->nodename);
if (n < LINECOL)
n += text_buffer_fill (buf, ' ', LINECOL - n);
diff --git a/info/scan.c b/info/scan.c
index 6121f992dd..aa305af20a 100644
--- a/info/scan.c
+++ b/info/scan.c
@@ -127,9 +127,6 @@ info_parse_node (char *string)
}
}
-#define INFO_QUOTE '\177'
-#define INFO_QUOTE_STR "\177"
-
/* Set *OUTPUT to a copy of the string starting at START and finishing at
a character in TERMINATOR, unless START[0] == INFO_QUOTE, in which case
copy string from START+1 until the next occurence of INFO_QUOTE. If
diff --git a/info/scan.h b/info/scan.h
index 8e9afc1730..27fcb257b4 100644
--- a/info/scan.h
+++ b/info/scan.h
@@ -23,6 +23,9 @@
#include "nodes.h"
#include "window.h"
+#define INFO_QUOTE '\177'
+#define INFO_QUOTE_STR "\177"
+
/* Variable which holds the most recent filename parsed as a result of
calling info_parse_xxx (). */
extern char *info_parsed_filename;