texinfo-commits
[Top][All Lists]
Advanced

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

[5658] PARSE_NODE_* removed


From: Gavin D. Smith
Subject: [5658] PARSE_NODE_* removed
Date: Wed, 11 Jun 2014 12:41:29 +0000

Revision: 5658
          http://svn.sv.gnu.org/viewvc/?view=rev&root=texinfo&revision=5658
Author:   gavin
Date:     2014-06-11 12:41:26 +0000 (Wed, 11 Jun 2014)
Log Message:
-----------
PARSE_NODE_* removed

Modified Paths:
--------------
    trunk/ChangeLog
    trunk/info/dir.c
    trunk/info/footnotes.c
    trunk/info/indices.c
    trunk/info/info-utils.c
    trunk/info/info-utils.h
    trunk/info/info.c
    trunk/info/infodoc.c
    trunk/info/nodes.c
    trunk/info/nodes.h
    trunk/info/session.c

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog     2014-06-11 11:16:25 UTC (rev 5657)
+++ trunk/ChangeLog     2014-06-11 12:41:26 UTC (rev 5658)
@@ -1,3 +1,16 @@
+2014-06-12  Gavin Smith  <address@hidden>
+
+       * info/info-utils.c (info_parse_node): Don't parse line number part of
+       menus.  Return value and arguments changed.  All callers updated.
+       (info_parsed_line_number): Removed.
+       (scan_reference_target): Parse line number part of menus.
+
+       * info/info-utils.h (PARSE_NODE_DFLT, PARSE_NODE_SKIP_NEWLINES)
+       (PARSE_NODE_VERBATIM, PARSE_NODE_START): Removed.
+       * info/nodes.c (info_get_node, info_get_node_with_defaults)
+       (get_filename_and_nodename): Arguments changed.  All
+       callers updated.
+
 2014-06-11  Gavin Smith  <address@hidden>
 
        * info/info-utils.c (save_conversion_state, reset_conversion): New

Modified: trunk/info/dir.c
===================================================================
--- trunk/info/dir.c    2014-06-11 11:16:25 UTC (rev 5657)
+++ trunk/info/dir.c    2014-06-11 12:41:26 UTC (rev 5658)
@@ -282,7 +282,7 @@
       if (!dir_fullpath)
         continue;
 
-      dir_node = info_get_node (dir_fullpath, "Top", PARSE_NODE_VERBATIM);
+      dir_node = info_get_node (dir_fullpath, "Top");
       free (dir_fullpath);
       entry = info_get_menu_entry_by_label (dir_node, label, 1);
       if (!entry)

Modified: trunk/info/footnotes.c
===================================================================
--- trunk/info/footnotes.c      2014-06-11 11:16:25 UTC (rev 5657)
+++ trunk/info/footnotes.c      2014-06-11 12:41:26 UTC (rev 5658)
@@ -101,8 +101,7 @@
                 if (!filename)
                   filename = node->filename;
 
-                fn_node = info_get_node (filename, refname, PARSE_NODE_DFLT);
-
+                fn_node = info_get_node (filename, refname);
                 if (fn_node)
                   fn_start = 0;
 

Modified: trunk/info/indices.c
===================================================================
--- trunk/info/indices.c        2014-06-11 11:16:25 UTC (rev 5657)
+++ trunk/info/indices.c        2014-06-11 12:41:26 UTC (rev 5658)
@@ -241,8 +241,7 @@
               NODE *node;
 
               node = info_get_node (initial_index_filename,
-                                    initial_index_nodename,
-                                    PARSE_NODE_DFLT);
+                                    initial_index_nodename);
               info_set_node_of_window (window, node);
               window_clear_echo_area ();
               return;
@@ -505,7 +504,7 @@
   REFERENCE **dir_menu = NULL;
   NODE *dir_node;
 
-  dir_node = info_get_node ("dir", "Top", PARSE_NODE_DFLT);
+  dir_node = get_dir_node ();
 
   /* It should be safe to assume that dir nodes do not contain any
      cross-references, i.e., its references list only contains

Modified: trunk/info/info-utils.c
===================================================================
--- trunk/info/info-utils.c     2014-06-11 11:16:25 UTC (rev 5657)
+++ trunk/info/info-utils.c     2014-06-11 12:41:26 UTC (rev 5658)
@@ -46,40 +46,17 @@
    calling info_parse_xxx (). */
 char *info_parsed_nodename = NULL;
 
-/* Variable which holds the most recent line number parsed as a result of
-   calling info_parse_xxx (). */
-int info_parsed_line_number = 0;
-
-/* Parse the filename and nodename out of STRING.  Return length of node
-   specification.  If STRING doesn't contain a filename (i.e., it is NOT
-   (FILENAME)NODENAME) then set INFO_PARSED_FILENAME to NULL.  The
-   second argument is one of the PARSE_NODE_* constants.  It specifies
-   how to parse the node name:
-
-   PARSE_NODE_DFLT             Node name stops at LF, `,', `.', or `TAB'
-   PARSE_NODE_SKIP_NEWLINES    Node name stops at `,', `.', or `TAB'
-   PARSE_NODE_VERBATIM         Don't parse nodename
-*/ 
-   
-int
-info_parse_node (char *string, int flag)
+/* Parse the filename and nodename out of STRING, saving in
+   INFO_PARSED_FILENAME and INFO_PARSED_NODENAME.  These variables should not
+   be freed by calling code.  If either is missing, the relevant variable is
+   set to a null pointer. */ 
+void
+info_parse_node (char *string)
 {
   register int i = 0;
   int nodename_len;
   char *terminator;
-  int length = 0; /* Return value */
 
-  switch (flag)
-    {
-    case PARSE_NODE_DFLT:
-      terminator = "\r\n,.\t"; break;
-    case PARSE_NODE_SKIP_NEWLINES:
-      terminator = ",.\t"; break;
-    case PARSE_NODE_VERBATIM:
-      terminator = ""; break;
-    }
-
-  /* Default the answer. */
   free (info_parsed_filename);
   free (info_parsed_nodename);
   info_parsed_filename = 0;
@@ -87,13 +64,9 @@
 
   /* Special case of nothing passed.  Return nothing. */
   if (!string || !*string)
-    return 0;
+    return;
 
-  if (flag != PARSE_NODE_DFLT)
-    length = skip_whitespace_and_newlines (string);
-  else  
-    length = skip_whitespace (string);
-  string += length;
+  string += skip_whitespace_and_newlines (string);
 
   /* Check for (FILENAME)NODENAME. */
   if (*string == '(')
@@ -104,7 +77,6 @@
       i = 0;
       /* Advance past the opening paren. */
       string++;
-      length++;
 
       /* Find the closing paren. Handle nested parens correctly. */
       for (bcnt = 0, bfirst = -1; string[i]; i++)
@@ -133,67 +105,20 @@
 
       /* Point directly at the nodename. */
       string += i;
-      length += i;
 
       if (*string)
-        {
-          string++;
-          length++;
-        }
+        string++;
     }
 
   /* Parse out nodename. */
-  nodename_len = read_quoted_string (string, terminator, 0,
-                                     &info_parsed_nodename);
+  string += skip_whitespace_and_newlines (string);
+  nodename_len = strlen (string);
 
-  string += nodename_len;
-  length += nodename_len;
-
-  if (nodename_len == 0)
+  if (nodename_len != 0)
     {
-      free (info_parsed_nodename);
-      info_parsed_nodename = 0;
+      info_parsed_nodename = xstrdup (string);
+      canonicalize_whitespace (info_parsed_nodename);
     }
-  else
-    canonicalize_whitespace (info_parsed_nodename);
-
-  if (info_parsed_nodename && !*info_parsed_nodename)
-    {
-      free (info_parsed_nodename);
-      info_parsed_nodename = NULL;
-    }
-
-  /* Parse ``(line ...)'' part of menus, if any.  */
-  {
-    char *rest = string;
-
-    /* Advance only if it's not already at end of string.  */
-    if (*rest)
-      rest++;
-
-    /* Skip any whitespace first, and then a newline in case the item
-       was so long to contain the ``(line ...)'' string in the same
-       physical line.  */
-    while (whitespace(*rest))
-      rest++;
-    if (*rest == '\n')
-      {
-        rest++;
-        while (whitespace(*rest))
-          rest++;
-      }
-
-    /* Are we looking at an opening parenthesis?  That can only mean
-       we have a winner. :)  */
-    if (strncmp (rest, "(line ", strlen ("(line ")) == 0)
-      {
-        rest += strlen ("(line ");
-        info_parsed_line_number = strtol (rest, NULL, 0);
-      }
-    else
-      info_parsed_line_number = 0;
-  }
-  return length;
 }
 
 /* Set *OUTPUT to a copy of the string starting at START and finishing at
@@ -1385,6 +1310,8 @@
 {
   char *target;
 
+  int info_parsed_line_number = 0;
+
   int length; /* Length of specification */
   int i;
 
@@ -1410,7 +1337,8 @@
   else
     skip_input (skip_whitespace (inptr));
 
-  if (!read_quoted_string (inptr, ",.", 2, &target))
+  length = read_quoted_string (inptr, ",.", 2, &target);
+  if (!length)
     return 0;
 
   if (entry->type == REFERENCE_XREF)
@@ -1418,7 +1346,7 @@
       char *nl_off;
       int space_at_start_of_line = 0;
 
-      length = info_parse_node (target, PARSE_NODE_VERBATIM);
+      info_parse_node (target);
 
       /* Check if there is a newline in the target. */
       nl_off = strchr (target, '\n');
@@ -1451,10 +1379,9 @@
 
       /* Output terminating punctuation, unless we are in a reference
          like "(*note Label:(file)node.)". */
-      if (!in_parentheses)
-        skip_input (length);
-      else
-        skip_input (length + 1);
+      skip_input (length);
+      if (in_parentheses && (inptr[0] == '.' || inptr[0] == ','))
+        skip_input (1);
 
       /* Copy any terminating punctuation before the optional newline. */
       copy_input_to_output (strspn (inptr, ".),"));
@@ -1488,7 +1415,8 @@
           line_len = inptr - linestart;
         }
 
-      length = info_parse_node (inptr, PARSE_NODE_DFLT);
+      info_parse_node (target);
+
       if (inptr[length] == '.') /* Include a '.' terminating the entry. */
         length++;
 
@@ -1509,6 +1437,24 @@
             }
         }
 
+      /* Parse "(line ...)" part of menus, if any.  */
+      {
+        /* Skip any whitespace first, and then a newline in case the item
+           was so long to contain the ``(line ...)'' string in the same
+           physical line.  */
+        copy_input_to_output (skip_whitespace (inptr));
+        if (*inptr == '\n')
+          copy_input_to_output (skip_whitespace (inptr));
+
+        if (!strncmp (inptr, "(line ", strlen ("(line ")))
+          {
+            copy_input_to_output (strlen ("(line "));
+            info_parsed_line_number = strtol (inptr, 0, 0);
+          }
+        else
+          info_parsed_line_number = 0;
+      }
+
       if (node->flags & N_IsDir) 
         {
           if (inptr[strspn (inptr, " ")] != '\n')

Modified: trunk/info/info-utils.h
===================================================================
--- trunk/info/info-utils.h     2014-06-11 11:16:25 UTC (rev 5657)
+++ trunk/info/info-utils.h     2014-06-11 12:41:26 UTC (rev 5658)
@@ -42,24 +42,9 @@
    calling info_parse_xxx (). */
 extern char *info_parsed_nodename;
 
-#define PARSE_NODE_DFLT          0
-#define PARSE_NODE_SKIP_NEWLINES 1
-#define PARSE_NODE_VERBATIM      2
-#define PARSE_NODE_START         3
+/* Parse the filename and nodename out of STRING. */ 
+void info_parse_node (char *string);
 
-/* Parse the filename and nodename out of STRING.  If STRING doesn't
-   contain a filename (i.e., it is NOT (FILENAME)NODENAME) then set
-   INFO_PARSED_FILENAME to NULL.  The second argument is one of
-   the PARSE_NODE_* constants.  It specifies how to parse the node name:
-   
-   PARSE_NODE_DFLT             Node name stops at LF, `,', `.', or `TAB'
-   PARSE_NODE_SKIP_NEWLINES    Node name stops at `,', `.', or `TAB'
-   PARSE_NODE_VERBATIM         Don't parse nodename
-   PARSE_NODE_START            The STRING argument is retrieved from a node
-                               start line, and therefore ends in `,' only.
-*/ 
-int info_parse_node (char *string, int flag);
-
 long read_quoted_string (char *start, char *terminator, int lines,
                          char **output);
 

Modified: trunk/info/info.c
===================================================================
--- trunk/info/info.c   2014-06-11 11:16:25 UTC (rev 5657)
+++ trunk/info/info.c   2014-06-11 12:41:26 UTC (rev 5658)
@@ -298,7 +298,7 @@
 
           /* Parse node spec to support invoking
              like info --node "(emacs)Buffers". */
-          info_parse_node (user_nodenames[i], PARSE_NODE_VERBATIM);
+          info_parse_node (user_nodenames[i]);
           if (info_parsed_filename)
             node_filename = xstrdup (info_parsed_filename);
           else
@@ -370,8 +370,7 @@
            ref_index, ref_list, ref_slots, 2);
 
       initial_node = info_get_node_with_defaults (ref_list[0]->filename,
-                                                  ref_list[0]->nodename,
-                                                  PARSE_NODE_DFLT, 0);
+                                                  ref_list[0]->nodename, 0);
       if (!initial_node)
         return;
 
@@ -426,7 +425,7 @@
         {
           initial_node = info_get_node_with_defaults (ref_list[0]->filename,
                                                       ref_list[0]->nodename,
-                                                      PARSE_NODE_DFLT, 0);
+                                                      0);
           node_via_menus = info_follow_menus (initial_node, argv, error, 0);
           if (node_via_menus)
             {

Modified: trunk/info/infodoc.c
===================================================================
--- trunk/info/infodoc.c        2014-06-11 11:16:25 UTC (rev 5657)
+++ trunk/info/infodoc.c        2014-06-11 12:41:26 UTC (rev 5658)
@@ -540,7 +540,7 @@
     nodename = "Help";
 
   /* Try to get the info file for Info. */
-  node = info_get_node ("Info", nodename, PARSE_NODE_DFLT);
+  node = info_get_node ("Info", nodename);
 
   if (!node)
     {

Modified: trunk/info/nodes.c
===================================================================
--- trunk/info/nodes.c  2014-06-11 11:16:25 UTC (rev 5657)
+++ trunk/info/nodes.c  2014-06-11 12:41:26 UTC (rev 5658)
@@ -880,7 +880,7 @@
 /* Functions for node creation and retrieval. */
 
 static long get_node_length (SEARCH_BINDING *binding);
-static void get_filename_and_nodename (int flag, WINDOW *window,
+static void get_filename_and_nodename (WINDOW *window,
                                       char **filename, char **nodename,
                                       char *filename_in, char *nodename_in);
 static void node_set_body_start (NODE *node);
@@ -929,13 +929,11 @@
    using WINDOW for defaults.  If WINDOW is null, the defaults are:
    - If FILENAME is NULL, `dir' is used.
    - If NODENAME is NULL, `Top' is used.
-   The FLAG argument (one of the PARSE_NODE_* constants) instructs how to
-   parse NODENAME.
    
    If the node cannot be found, return NULL. */
 NODE *
 info_get_node_with_defaults (char *filename_in, char *nodename_in,
-                             int flag, WINDOW *window)
+                             WINDOW *window)
 {
   NODE *node = 0;
   FILE_BUFFER *file_buffer = NULL;
@@ -943,8 +941,8 @@
 
   info_recent_file_error = NULL;
 
-  get_filename_and_nodename (flag, window,
-       &filename, &nodename, filename_in, nodename_in);
+  get_filename_and_nodename (window, &filename, &nodename,
+                             filename_in, nodename_in);
 
   /* If the file to be looked up is "dir", build the contents from all of
      the "dir"s and "localdir"s found in INFOPATH. */
@@ -997,19 +995,19 @@
 }
 
 NODE *
-info_get_node (char *filename_in, char *nodename_in, int flag)
+info_get_node (char *filename_in, char *nodename_in)
 {
-  return info_get_node_with_defaults (filename_in, nodename_in, flag, 0);
+  return info_get_node_with_defaults (filename_in, nodename_in, 0);
 }
 
 /* Set default values.  Output values should be freed by caller. */
 static void
-get_filename_and_nodename (int flag, WINDOW *window,
+get_filename_and_nodename (WINDOW *window,
                            char **filename, char **nodename,
                            char *filename_in, char *nodename_in)
 {
   /* Get file name, nodename */
-  info_parse_node (nodename_in, flag);
+  info_parse_node (nodename_in);
 
   if (info_parsed_filename)
     *filename = info_parsed_filename;

Modified: trunk/info/nodes.h
===================================================================
--- trunk/info/nodes.h  2014-06-11 11:16:25 UTC (rev 5657)
+++ trunk/info/nodes.h  2014-06-11 12:41:26 UTC (rev 5658)
@@ -148,20 +148,15 @@
 /* Return a pointer to a NODE structure for the Info node (FILENAME)NODENAME.
    FILENAME can be passed as NULL, in which case the filename of "dir" is used.
    NODENAME can be passed as NULL, in which case the nodename of "Top" is used.
-
-   The FLAG argument (one of the PARSE_NODE_* constants) instructs how to
-   parse NODENAME.
    
    If the node cannot be found, return a NULL pointer. */
-extern NODE *info_get_node (char *filename, char *nodename, int flag);
+extern NODE *info_get_node (char *filename, char *nodename);
 
 /* struct window_struct is typedef as WINDOW in window.h, but we cannot
    include window.h in this file (nodes.h), because window.h includes
    nodes.h. */
 struct window_struct;
-
 extern NODE *info_get_node_with_defaults (char *filename, char *nodename,
-                                          int flag,
                                           struct window_struct *window);
 
 extern NODE *info_node_of_tag (FILE_BUFFER *fb, NODE **tag_ptr);

Modified: trunk/info/session.c
===================================================================
--- trunk/info/session.c        2014-06-11 11:16:25 UTC (rev 5657)
+++ trunk/info/session.c        2014-06-11 12:41:26 UTC (rev 5658)
@@ -1338,9 +1338,7 @@
       return;
     }
 
-  node = info_get_node_with_defaults (0, description,
-              PARSE_NODE_VERBATIM, window);
-
+  node = info_get_node_with_defaults (0, description, window);
   if (!node)
     {
       if (info_recent_file_error)
@@ -1417,8 +1415,7 @@
       if (count > 0)
         i = last_node_tag_idx + 1;
       if (i > 0)
-        node = info_get_node (fb->filename, fb->tags[i - 1]->nodename,
-                              PARSE_NODE_DFLT);
+        node = info_get_node (fb->filename, fb->tags[i - 1]->nodename);
     }
 
   if (!node)
@@ -1451,8 +1448,7 @@
       if (count > 0)
         i = last_node_tag_idx + 1;
       if (i > 0)
-        node = info_get_node (fb->filename, fb->tags[i - 1]->nodename,
-                              PARSE_NODE_DFLT);
+        node = info_get_node (fb->filename, fb->tags[i - 1]->nodename);
     }
 
   if (!node)
@@ -1726,7 +1722,7 @@
   file_system_error = NULL;
 
   node = info_get_node_with_defaults (entry->filename, entry->nodename,
-             PARSE_NODE_VERBATIM, window);
+                                      window);
 
   /* Try something a little weird.  If the node couldn't be found, and the
      reference was of the form "foo::", see if the entry->label can be found
@@ -1739,7 +1735,7 @@
       if (entry->nodename
           && entry->label && (strcmp (entry->nodename, entry->label) == 0))
         {
-          node = info_get_node (entry->label, "Top", PARSE_NODE_DFLT);
+          node = info_get_node (entry->label, "Top");
           if (!node && info_recent_file_error)
             {
               free (file_system_error);
@@ -2315,11 +2311,9 @@
       
       /* Try to find this node.  */
       if (initial_node->parent)
-        node = info_get_node (initial_node->parent, entry->nodename,
-                              PARSE_NODE_VERBATIM);
+        node = info_get_node (initial_node->parent, entry->nodename);
       else
-        node = info_get_node (initial_node->filename, entry->nodename,
-                              PARSE_NODE_VERBATIM);
+        node = info_get_node (initial_node->filename, entry->nodename);
       if (!node)
         {
          debug (3, ("no matching node found"));
@@ -2392,7 +2386,7 @@
   if (*line)
     {
       char *error = 0;
-      NODE *dir_node = info_get_node (NULL, NULL, PARSE_NODE_DFLT);
+      NODE *dir_node = get_dir_node ();
       char **nodes = split_list_of_nodenames (line);
       char *node = NULL;
 
@@ -2404,7 +2398,7 @@
 
           if (!file_name)
             file_name = window->node->filename;
-          dir_node = info_get_node (file_name, NULL, PARSE_NODE_DFLT);
+          dir_node = info_get_node (file_name, 0);
         }
 
       /* If we still cannot find the starting point, give up.
@@ -2420,7 +2414,7 @@
       else
         {
           NODE *n;
-          n = info_get_node_with_defaults (0, node, PARSE_NODE_DFLT, window);
+          n = info_get_node_with_defaults (0, node, window);
           info_set_node_of_window (window, n);
         }
     }
@@ -2612,8 +2606,7 @@
         entry->filename = xstrdup (initial_node->parent ? initial_node->parent
                                    : initial_node->filename);
       /* Try to find this node.  */
-      node = info_get_node (entry->filename, entry->nodename, 
-                            PARSE_NODE_VERBATIM);
+      node = info_get_node (entry->filename, entry->nodename);
       if (!node)
         break;
     }
@@ -2676,7 +2669,7 @@
 
   /* In interactive usage they'd probably expect us to begin looking
      from the Top node.  */
-  top_node = info_get_node (file_name, NULL, PARSE_NODE_DFLT);
+  top_node = info_get_node (file_name, 0);
   if (!top_node)
     info_error (msg_cant_find_node, "Top");
 
@@ -2708,7 +2701,7 @@
 
   if (*line)
     {
-      NODE *manpage = info_get_node (MANPAGE_FILE_BUFFER_NAME, line, 0);
+      NODE *manpage = info_get_node (MANPAGE_FILE_BUFFER_NAME, line);
       if (manpage)
         info_set_node_of_window (window, manpage);
     }
@@ -2769,7 +2762,7 @@
     {
       NODE *node;
 
-      node = info_get_node (line, "*", PARSE_NODE_DFLT);
+      node = info_get_node (line, "*");
       if (!node)
         {
           if (info_recent_file_error)
@@ -2873,7 +2866,7 @@
   register int i;
   NODE *node;
 
-  node = info_get_node (filename, nodename, PARSE_NODE_VERBATIM);
+  node = info_get_node (filename, nodename);
 
   if (!node)
     {
@@ -3306,9 +3299,7 @@
               last_subfile = tag->filename;
             }
 
-          node = info_get_node (file_buffer->filename, tag->nodename,
-                                PARSE_NODE_VERBATIM);
-
+          node = info_get_node (file_buffer->filename, tag->nodename);
           if (!node)
             {
               /* If not doing i-search... */




reply via email to

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