texinfo-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[7708] index entries scan to last colon on line


From: gavinsmith0123
Subject: [7708] index entries scan to last colon on line
Date: Sat, 8 Apr 2017 17:39:32 -0400 (EDT)

Revision: 7708
          http://svn.sv.gnu.org/viewvc/?view=rev&root=texinfo&revision=7708
Author:   gavin
Date:     2017-04-08 17:39:32 -0400 (Sat, 08 Apr 2017)
Log Message:
-----------
index entries scan to last colon on line

Modified Paths:
--------------
    trunk/ChangeLog
    trunk/info/info-utils.c

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog     2017-04-01 20:47:55 UTC (rev 7707)
+++ trunk/ChangeLog     2017-04-08 21:39:32 UTC (rev 7708)
@@ -1,3 +1,9 @@
+2017-04-08  Gavin Smith  <address@hidden>
+
+       * info/info-utils.c (scan_reference_label): If inside an index 
+       node, scan forward to the last colon on the line to get the
+       index entry, instead of the first colon.
+
 2017-04-01  Gavin Smith  <address@hidden>
 
        * tp/Texinfo/Structuring.pm (do_index_keys): Strip '-', '\',

Modified: trunk/info/info-utils.c
===================================================================
--- trunk/info/info-utils.c     2017-04-01 20:47:55 UTC (rev 7707)
+++ trunk/info/info-utils.c     2017-04-08 21:39:32 UTC (rev 7708)
@@ -1259,7 +1259,7 @@
    at the first character after the colon terminating the label.  Return 0 if
    invalid syntax is encountered. */
 static int
-scan_reference_label (REFERENCE *entry)
+scan_reference_label (REFERENCE *entry, int in_index)
 {
   char *dummy;
   int max_lines;
@@ -1275,12 +1275,41 @@
     max_lines = 1;
   else
     max_lines = 2;
-  len = read_quoted_string (inptr + label_len, ":", max_lines, &dummy);
-  free (dummy);
-  if (!len)
-    return 0; /* Input invalid. */
-  label_len += len;
+  if (!in_index || inptr[label_len] == '\177')
+    {
+      len = read_quoted_string (inptr + label_len, ":", max_lines, &dummy);
+      free (dummy);
+      if (!len)
+        return 0; /* Input invalid. */
+      label_len += len;
+    }
+  else
+    {
+      /* If in an index node, go forward to the last colon on the line
+         (not preceded by a newline, NUL or DEL).  This is in order to
+         support index entries containing colons.  This should work fine
+         as long as the node name does not contain a colon as well. */
 
+      char *p;
+      int n, m = 0;
+      p = inptr + label_len;
+
+      while (1)
+        {
+          n = strcspn (p, ":\n\177");
+          if (p[n] == ':')
+            {
+              m += n + 1;
+              p += n + 1;
+              continue;
+            }
+          break;
+        }
+      if (m == 0)
+        return 0; /* no : found */
+      label_len += m - 1;
+    }
+
   entry->label = xmalloc (label_len + 1);
   memcpy (entry->label, inptr, label_len);
   entry->label[label_len] = '\0';
@@ -1677,7 +1706,7 @@
           save_conversion_state ();
           
           if (!scan_reference_marker (entry, in_parentheses)
-              || !scan_reference_label (entry)
+              || !scan_reference_label (entry, in_index)
               || !scan_reference_target (entry, node, in_parentheses))
             {
               /* This is not a menu entry or reference.  Do not add to our 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]