texinfo-commits
[Top][All Lists]
Advanced

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

[5489] remove save_string etc.


From: Gavin D. Smith
Subject: [5489] remove save_string etc.
Date: Wed, 23 Apr 2014 22:44:02 +0000

Revision: 5489
          http://svn.sv.gnu.org/viewvc/?view=rev&root=texinfo&revision=5489
Author:   gavin
Date:     2014-04-23 22:44:01 +0000 (Wed, 23 Apr 2014)
Log Message:
-----------
remove save_string etc.

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

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog     2014-04-23 21:45:21 UTC (rev 5488)
+++ trunk/ChangeLog     2014-04-23 22:44:01 UTC (rev 5489)
@@ -1,5 +1,20 @@
 2014-04-23  Gavin Smith  <address@hidden>
 
+       * info/info-utils.c (info_parse_node): Don't use saven_filename
+       or saven_nodename.
+       (parsed_filename_size, parsed_nodename_size)
+       (save_filename, saven_filename, save_nodename, saven_nodename)
+       (save_string, saven_string): Functions and variables deleted.
+
+       * info/info-utils.c (scan_reference_target): Better
+       output for target specifications.
+
+       * info/nodes.c (info_get_node_with_defaults): Always free data
+       on exit.  Eliminate extra check for if we were looking for a man
+       page.
+
+2014-04-23  Gavin Smith  <address@hidden>
+
        * info/man.c: (get_manpage_node): Arguments changed.  Do not
        keep all the man page contents in one long buffer.
        (manpage_file_buffer): New variable.

Modified: trunk/info/info-utils.c
===================================================================
--- trunk/info/info-utils.c     2014-04-23 21:45:21 UTC (rev 5488)
+++ trunk/info/info-utils.c     2014-04-23 22:44:01 UTC (rev 5489)
@@ -53,15 +53,6 @@
    calling info_parse_xxx (). */
 int info_parsed_line_number = 0;
 
-static void save_string (char *string, char **string_p, int *string_size_p);
-static void saven_string (char *string, int len, char **string_p,
-    int *string_size_p);
-/* Functions to remember a filename or nodename for later return. */
-static void save_filename (char *filename);
-static void saven_filename (char *filename, int len);
-static void save_nodename (char *nodename);
-static void saven_nodename (char *nodename, int len);
-
 /* 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
@@ -80,8 +71,10 @@
   int length = 0; /* Return value */
 
   /* Default the answer. */
-  save_filename (NULL);
-  save_nodename (NULL);
+  free (info_parsed_filename);
+  free (info_parsed_nodename);
+  info_parsed_filename = 0;
+  info_parsed_nodename = 0;
 
   /* Special case of nothing passed.  Return nothing. */
   if (!string || !*string)
@@ -126,7 +119,8 @@
        i = bfirst;
       
       /* Remember parsed filename. */
-      saven_filename (string, i);
+      info_parsed_filename = xcalloc (1, i+1);
+      memcpy (info_parsed_filename, string, i);
 
       /* Point directly at the nodename. */
       string += i;
@@ -143,7 +137,10 @@
   i = skip_node_characters (string, flag);
   length += i;
   length++; /* skip_node_characters() stops on terminating character */
-  saven_nodename (string, i);
+
+  info_parsed_nodename = xcalloc (1, i+1);
+  memcpy (info_parsed_nodename, string, i);
+
   canonicalize_whitespace (info_parsed_nodename);
   if (info_parsed_nodename && !*info_parsed_nodename)
     {
@@ -1155,17 +1152,17 @@
           else
             skip_input (length);
 
-          /* We often have a closing bracket or a full stop after a
-             cross reference, so output these before the optional newline. */
-          if (inptr[0] == '.' && inptr[1] == ')')
-            copy_input_to_output (2);
-          else if (*inptr == ')' || *inptr == '.')
-            copy_input_to_output (1);
+          /* Copy any terminating punctuation before the optional newline. */
+          copy_input_to_output (strspn (inptr, ".),"));
 
           if (nl_off)
             { 
               int i, j = skip_whitespace (nl_off + 1);
               write_extra_bytes_to_output ("\n", 1);
+
+              /* Don't allow any spaces in the input to mess up
+                 the margin. */
+              skip_input (strspn (inptr, " "));
               for (i = 0; i < j; i++)
                 write_extra_bytes_to_output (" ", 1);
             }
@@ -1472,102 +1469,6 @@
 /*                                                                  */
 /* **************************************************************** */
 
-/* Amount of space allocated to INFO_PARSED_FILENAME via xmalloc (). */
-static int parsed_filename_size = 0;
-
-/* Amount of space allocated to INFO_PARSED_NODENAME via xmalloc (). */
-static int parsed_nodename_size = 0;
-
-/* Remember FILENAME in PARSED_FILENAME.  An empty FILENAME is translated
-   to a NULL pointer in PARSED_FILENAME. */
-static void
-save_filename (char *filename)
-{
-  save_string (filename, &info_parsed_filename, &parsed_filename_size);
-}
-
-/* Just like save_filename (), but you pass the length of the string. */
-static void
-saven_filename (char *filename, int len)
-{
-  saven_string (filename, len,
-                &info_parsed_filename, &parsed_filename_size);
-}
-
-/* Remember NODENAME in PARSED_NODENAME.  An empty NODENAME is translated
-   to a NULL pointer in PARSED_NODENAME. */
-static void
-save_nodename (char *nodename)
-{
-  save_string (nodename, &info_parsed_nodename, &parsed_nodename_size);
-}
-
-/* Just like save_nodename (), but you pass the length of the string. */
-static void
-saven_nodename (char *nodename, int len)
-{
-  saven_string (nodename, len,
-                &info_parsed_nodename, &parsed_nodename_size);
-}
-
-/* Remember STRING in STRING_P.  STRING_P should currently have STRING_SIZE_P
-   bytes allocated to it.  An empty STRING is translated to a NULL pointer
-   in STRING_P. */
-static void
-save_string (char *string, char **string_p, int *string_size_p)
-{
-  if (!string || !*string)
-    {
-      if (*string_p)
-        free (*string_p);
-
-      *string_p = NULL;
-      *string_size_p = 0;
-    }
-  else if (string_size_p)
-    {
-      if (strlen (string) >= (unsigned int) *string_size_p)
-        *string_p = xrealloc (*string_p,
-                             (*string_size_p = 1 + strlen (string)));
-
-      strcpy (*string_p, string);
-    }
-  else
-    {
-      free (*string_p);
-      *string_p = xstrdup (string);
-    }
-}
-
-/* Just like save_string (), but you also pass the length of STRING. */
-static void
-saven_string (char *string, int len, char **string_p, int *string_size_p)
-{
-  if (!string)
-    {
-      if (*string_p)
-        free (*string_p);
-
-      *string_p = NULL;
-      *string_size_p = 0;
-    }
-  else 
-    {
-      if (string_size_p)
-       {
-         if (len >= *string_size_p)
-           *string_p = xrealloc (*string_p, (*string_size_p = 1 + len));
-       }
-      else
-       {
-         free (*string_p);
-         *string_p = xmalloc (1 + len);
-       }
-      strncpy (*string_p, string, len);
-      (*string_p)[len] = '\0';
-    }
-}
-
 /* Return a pointer to the part of PATHNAME that simply defines the file. */
 char *
 filename_non_directory (char *pathname)

Modified: trunk/info/nodes.c
===================================================================
--- trunk/info/nodes.c  2014-04-23 21:45:21 UTC (rev 5488)
+++ trunk/info/nodes.c  2014-04-23 22:44:01 UTC (rev 5489)
@@ -974,7 +974,8 @@
 #ifdef HANDLE_MAN_PAGES
   if (mbscasecmp (filename, MANPAGE_FILE_BUFFER_NAME) == 0)
     {
-      return get_manpage_node (nodename);
+      node = get_manpage_node (nodename);
+      goto cleanup_and_exit;
     }
 #endif
 
@@ -1000,11 +1001,8 @@
     }
 #endif
 
-  /* If the node not found was "Top", try again with different case,
-     unless this was a man page.  */
-  if (!node
-      && mbscasecmp (filename, MANPAGE_FILE_BUFFER_NAME) != 0
-      && (nodename == NULL || mbscasecmp (nodename, "Top") == 0))
+  /* If the node not found was "Top", try again with different case. */
+  if (!node && (nodename && mbscasecmp (nodename, "Top") == 0))
     {
       node = info_get_node_of_file_buffer ("Top", file_buffer);
       if (!node)
@@ -1013,6 +1011,7 @@
         node = info_get_node_of_file_buffer ("TOP", file_buffer);
     }
 
+cleanup_and_exit:
   free (filename); free (nodename);
   return node;
 }




reply via email to

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