texinfo-commits
[Top][All Lists]
Advanced

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

[5492] dir text, man page SGR


From: Gavin D. Smith
Subject: [5492] dir text, man page SGR
Date: Thu, 24 Apr 2014 20:01:32 +0000

Revision: 5492
          http://svn.sv.gnu.org/viewvc/?view=rev&root=texinfo&revision=5492
Author:   gavin
Date:     2014-04-24 20:01:30 +0000 (Thu, 24 Apr 2014)
Log Message:
-----------
dir text, man page SGR

Modified Paths:
--------------
    trunk/ChangeLog
    trunk/info/dir.c
    trunk/info/man.c

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog     2014-04-24 13:42:03 UTC (rev 5491)
+++ trunk/ChangeLog     2014-04-24 20:01:30 UTC (rev 5492)
@@ -1,5 +1,16 @@
 2014-04-24  Gavin Smith  <address@hidden>
 
+       * info/dir.c (build_dir_node): Use header text from
+       util/dir-example.
+
+       * info/man.c (reference_section_starters, frs_binding)
+       (find_reference_section): Disable with preprocessor.
+       (xrefs_of_manpage): Look in whole man page for possible xrefs.
+       Work even if name of reference is surrounded by ECMA-48 SGR
+       sequences.
+
+2014-04-24  Gavin Smith  <address@hidden>
+
        * info/info.h [HANDLE_MAN_PAGES]: #define removed.  All
        usages updated.
 

Modified: trunk/info/dir.c
===================================================================
--- trunk/info/dir.c    2014-04-24 13:42:03 UTC (rev 5491)
+++ trunk/info/dir.c    2014-04-24 20:01:30 UTC (rev 5492)
@@ -127,15 +127,17 @@
   node->nodename = xstrdup ("dir");
   node->filename = xstrdup ("dir");
   node->contents = xstrdup (
-  " File: dir,      Node: Top       This is the top of the INFO tree\n"
-  "\n"
-  "This (the Directory node) gives a menu of major topics.\n"
-  "Typing \"q\" exits, \"?\" lists all Info commands, \"d\" returns here,\n"
-  "\"h\" gives a primer for first-timers,\n"
-  "\"mEmacs<Return>\" visits the Emacs manual, etc.\n"
-  "\n"
-  "In Emacs, you can click mouse button 2 on a menu item or cross reference\n"
-  "to select it.\n"
+
+"File: dir,    Node: Top,      This is the top of the INFO tree.\n"
+"\n"
+"This is the Info main menu (aka directory node).\n"
+"A few useful Info commands:\n"
+"\n"
+"  `q' quits;\n"
+"  `?' lists all Info commands;\n"
+"  `h' starts the Info tutorial;\n"
+"  `mTexinfo RET' visits the Texinfo manual, etc.\n"
+
   );
 
   node->nodelen = strlen (node->contents);

Modified: trunk/info/man.c
===================================================================
--- trunk/info/man.c    2014-04-24 13:42:03 UTC (rev 5491)
+++ trunk/info/man.c    2014-04-24 20:01:30 UTC (rev 5492)
@@ -441,6 +441,8 @@
   return buffer;
 }
 
+/* Search in the whole man page for references now. */
+#if 0
 static char *reference_section_starters[] =
 {
   "\nRELATED INFORMATION",
@@ -495,10 +497,13 @@
   return &frs_binding;
 }
 
+#endif
+
 static REFERENCE **
 xrefs_of_manpage (NODE *node)
 {
-  SEARCH_BINDING *reference_section;
+  SEARCH_BINDING s;
+
   REFERENCE **refs = NULL;
   size_t refs_index = 0;
   size_t refs_slots = 0;
@@ -508,60 +513,88 @@
   refs = calloc(1, sizeof (REFERENCE *));
   refs_slots = 1;
 
-  reference_section = find_reference_section (node);
+  s.buffer = node->contents;
+  s.start = 0;
+  s.flags = 0;
+  s.end = node->nodelen;
 
-  if (reference_section == NULL)
-    return refs;
+  /* Build a list of references.  A reference is alphabetic characters
+     followed by non-whitespace text within parenthesis leading with a digit. 
*/
+  while (search_forward ("(", &s, &position) == search_success)
+    {
+      register int name, name_end;
+      int section, section_end;
+      int name_len, section_len;
 
-  /* Grovel the reference section building a list of references found there.
-     A reference is alphabetic characters followed by non-whitespace text
-     within parenthesis. */
-  reference_section->flags = 0;
+      for (name = position; name > 0; name--)
+        if (whitespace (s.buffer[name]))
+          break;
 
-  while (search_forward ("(", reference_section, &position) == search_success)
-    {
-      register int start, end;
+      if (name != 0)
+        name++;
 
-      for (start = position; start > reference_section->start; start--)
-        if (whitespace (reference_section->buffer[start]))
+      if (name == position)
+        goto skip; /* Whitespace immediately before '('. */
+
+      /* If we are on an ECMA-48 SGR escape sequence, skip past it. */
+      if (s.buffer[name] == '\033' && s.buffer[name + 1] == '[')
+        {
+          name += 2;
+          name += strspn (s.buffer + name, "0123456789;");
+          if (s.buffer[name] == 'm')
+            name++;
+          else
+            goto skip;
+        }
+
+      for (name_end = name; name_end < position; name_end++)
+        if (!isalnum (s.buffer[name_end])
+            && s.buffer[name_end] != '_'
+            && s.buffer[name_end] != '.'
+            && s.buffer[name_end] != '-')
           break;
 
-      start++;
+      section = position;
+      if (!isdigit (s.buffer[section + 1]))
+        goto skip; /* Could be ordinary text in parentheses. */
 
-      for (end = position; end < reference_section->end; end++)
+      for (section_end = section + 1; section_end < s.end; section_end++)
         {
-          if (whitespace (reference_section->buffer[end]))
+          if (whitespace (s.buffer[section_end]))
             {
-              end = start;
+              continue;
               break;
             }
 
-          if (reference_section->buffer[end] == ')')
+          if (s.buffer[section_end] == ')')
             {
-              end++;
+              section_end++;
               break;
             }
         }
 
-      if (end != start)
-        {
-          REFERENCE *entry;
-          int len = end - start;
+      {
+        REFERENCE *entry;
+        int len = name_end - name + section_end - section;
 
-          entry = xmalloc (sizeof (REFERENCE));
-          entry->label = xmalloc (1 + len);
-          strncpy (entry->label, (reference_section->buffer) + start, len);
-          entry->label[len] = '\0';
-          entry->filename = xstrdup (node->filename);
-          entry->nodename = xstrdup (entry->label);
-          entry->start = start;
-          entry->end = end;
-          entry->type = REFERENCE_XREF;
+        entry = xmalloc (sizeof (REFERENCE));
+        entry->label = xcalloc (1, 1 + len);
+        strncpy (entry->label, s.buffer + name, name_end - name);
+        strncpy (entry->label + strlen (entry->label),
+                 s.buffer + section,
+                 section_end - section);
 
-          add_pointer_to_array (entry, refs_index, refs, refs_slots, 10);
-        }
+        entry->filename = MANPAGE_FILE_BUFFER_NAME;
+        entry->nodename = xstrdup (entry->label);
+        entry->start = name;
+        entry->end = section_end;
+        entry->type = REFERENCE_XREF;
 
-      reference_section->start = position + 1;
+        add_pointer_to_array (entry, refs_index, refs, refs_slots, 10);
+      }
+
+skip:
+      s.start = position + 1;
     }
 
   return refs;




reply via email to

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