texinfo-commits
[Top][All Lists]
Advanced

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

[7797] replace_in_documentation simplify code


From: gavinsmith0123
Subject: [7797] replace_in_documentation simplify code
Date: Fri, 19 May 2017 17:11:40 -0400 (EDT)

Revision: 7797
          http://svn.sv.gnu.org/viewvc/?view=rev&root=texinfo&revision=7797
Author:   gavin
Date:     2017-05-19 17:11:40 -0400 (Fri, 19 May 2017)
Log Message:
-----------
replace_in_documentation simplify code

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

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog     2017-05-19 21:07:44 UTC (rev 7796)
+++ trunk/ChangeLog     2017-05-19 21:11:40 UTC (rev 7797)
@@ -1,3 +1,10 @@
+2017-05-19  Gavin Smith  <address@hidden>
+
+       * info/infodoc.c (replace_in_documentation):
+       Remove code to handle numbers before command name, like
+       "\\[6next-line]" meaning "M-6 M-x next-line", as it is not used 
+       anywhere, and this simplifies the code.
+
 2017-05-18  Gavin Smith  <address@hidden>
 
        * info/t/cr-tag-table.sh: Remove test.

Modified: trunk/info/infodoc.c
===================================================================
--- trunk/info/infodoc.c        2017-05-19 21:07:44 UTC (rev 7796)
+++ trunk/info/infodoc.c        2017-05-19 21:11:40 UTC (rev 7797)
@@ -635,22 +635,6 @@
   return text_buffer_base (&rep);
 }
 
-/* Return a pointer to the last character in s that is found in f. */
-static const char *
-strrpbrk (const char *s, const char *f)
-{
-  register const char *e = s + strlen(s);
-  register const char *t;
-
-  while (e-- != s)
-    {
-      for (t = f; *t; t++)
-        if (*e == *t)
-          return e;
-    }
-  return NULL;
-}
-
 /* Replace the names of functions with the key that invokes them. */
 char *
 replace_in_documentation (const char *string, int help_is_only_window_p)
@@ -702,11 +686,8 @@
             }
           if (string[j] == '[')
             {
-              unsigned arg = 0;
-              char *argstr = NULL;
               char *rep_name, *fun_name, *rep;
               InfoCommand *command;
-              char *repstr = NULL;
               unsigned replen;
 
               /* Copy in the old text. */
@@ -714,19 +695,6 @@
               next += (i - start);
               start = j + 1;
 
-              /* Look for an optional numeric arg. */
-              i = start;
-              if (isdigit(string[i])
-                  || (string[i] == '-' && isdigit(string[i + 1])) )
-                {
-                  arg = atoi(string + i);
-                  if (string[i] == '-')
-                    i++;
-                  while (isdigit(string[i]))
-                    i++;
-                }
-              start = i;
-
               /* Move to the end of the function name. */
               for (i = start; string[i] && (string[i] != ']'); i++);
 
@@ -754,35 +722,10 @@
               if (!command)
                 abort ();
 
-              if (arg)
-                {
-                  char *argrep;
-                 const char *p;
-
-                  argrep = where_is (info_keymap, 
InfoCmd(info_add_digit_to_numeric_arg));
-                  p = argrep ? strrpbrk (argrep, "0123456789-") : NULL;
-                  if (p)
-                    {
-                      argstr = xmalloc (p - argrep + 21);
-                      strncpy (argstr, argrep, p - argrep);
-                      sprintf (argstr + (p - argrep), "%d", arg);
-                    }
-                  else
-                    command = NULL;
-                }
-              rep = command ? where_is (info_keymap, command) : NULL;
+              rep = where_is (info_keymap, command);
               if (!rep)
                 rep = "N/A";
-              replen = (argstr ? strlen (argstr) : 0) + strlen (rep) + 1;
-              repstr = xmalloc (replen);
-              repstr[0] = '\0';
-              if (argstr)
-                {
-                  strcat(repstr, argstr);
-                  strcat(repstr, " ");
-                  free (argstr);
-                }
-              strcat(repstr, rep);
+              replen = strlen (rep) + 1;
 
               if (fmt)
                 {
@@ -798,12 +741,11 @@
                 }
 
               if (fmt)
-                  sprintf (result + next, fmt, repstr);
+                  sprintf (result + next, fmt, rep);
               else
-                  strcpy (result + next, repstr);
+                  strcpy (result + next, rep);
 
               next = strlen (result);
-              free (repstr);
 
               start = i;
               if (string[i])




reply via email to

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