texinfo-commits
[Top][All Lists]
Advanced

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

[8378] parsetexi avoid literal return values


From: gavinsmith0123
Subject: [8378] parsetexi avoid literal return values
Date: Mon, 22 Oct 2018 17:26:32 -0400 (EDT)

Revision: 8378
          http://svn.sv.gnu.org/viewvc/?view=rev&root=texinfo&revision=8378
Author:   gavin
Date:     2018-10-22 17:26:32 -0400 (Mon, 22 Oct 2018)
Log Message:
-----------
parsetexi avoid literal return values

Modified Paths:
--------------
    trunk/tp/Texinfo/XS/parsetexi/handle_commands.c
    trunk/tp/Texinfo/XS/parsetexi/parser.c
    trunk/tp/Texinfo/XS/parsetexi/parser.h

Modified: trunk/tp/Texinfo/XS/parsetexi/handle_commands.c
===================================================================
--- trunk/tp/Texinfo/XS/parsetexi/handle_commands.c     2018-10-22 20:53:31 UTC 
(rev 8377)
+++ trunk/tp/Texinfo/XS/parsetexi/handle_commands.c     2018-10-22 21:26:32 UTC 
(rev 8378)
@@ -89,7 +89,8 @@
   char *line = *line_inout;
   int arg_spec;
 
-  *status = 0;
+  *status = STILL_MORE_TO_PROCESS;
+
   arg_spec = command_data(cmd).data;
   if (arg_spec == OTHER_noarg)
     {
@@ -299,7 +300,7 @@
             current = paragraph;
           if (!*line)
             {
-              *status = 1; /* Get a new line. */
+              *status = GET_A_NEW_LINE;
               goto funexit;
             }
         }
@@ -310,8 +311,8 @@
   return current;
 }
 
-/* STATUS is set to 1 if we should get a new line after this,
-   2 if we should stop processing completely. */
+/* STATUS is set to GET_A_NEW_LINE if we should get a new line after this,
+   to FINISHED_TOTALLY if we should stop processing completely. */
 ELEMENT *
 handle_line_command (ELEMENT *current, char **line_inout,
                      enum command_id cmd, int *status)
@@ -320,7 +321,8 @@
   char *line = *line_inout;
   int arg_spec;
 
-  *status = 0;
+  *status = STILL_MORE_TO_PROCESS;
+
   /* Root commands (like @node) and @bye 4290 */
   if (command_data(cmd).flags & CF_root || cmd == CM_bye)
     {
@@ -506,6 +508,7 @@
         }
       else if (cmd == CM_novalidate)
         {
+          // FIXME - what goes in here?
         }
 
       register_global_command (misc); // 4423
@@ -516,7 +519,7 @@
       // 4429
       if (cmd == CM_bye)
         {
-          *status = 2; /* Finish processing completely. */
+          *status = FINISHED_TOTALLY;
           goto funexit;
         }
 
@@ -523,7 +526,7 @@
       if (close_preformatted_command(cmd))
         current = begin_preformatted (current);
 
-      *status = 1; /* Get a new line */
+      *status = GET_A_NEW_LINE;
       goto funexit;
     }
   else

Modified: trunk/tp/Texinfo/XS/parsetexi/parser.c
===================================================================
--- trunk/tp/Texinfo/XS/parsetexi/parser.c      2018-10-22 20:53:31 UTC (rev 
8377)
+++ trunk/tp/Texinfo/XS/parsetexi/parser.c      2018-10-22 21:26:32 UTC (rev 
8378)
@@ -560,7 +560,8 @@
   return current;
 }
 
-/* 2106 */
+/* If last contents child of CURRENT is an empty line element, remove
+   or merge text, and return true. */
 int
 abort_empty_line (ELEMENT **current_inout, char *additional_spaces)
 {
@@ -581,6 +582,8 @@
       ELEMENT *owning_element = 0, *e;
       KEY_PAIR *k;
 
+      retval = 1;
+
       k = lookup_extra (last_child, "command");
       if (k)
         {
@@ -622,7 +625,6 @@
               last_child->type = ET_empty_spaces_after_command;
             }
         }
-      retval = 1;
     }
   else
     retval = 0;
@@ -826,10 +828,6 @@
   return 1;
 }
 
-#define GET_A_NEW_LINE 0
-#define STILL_MORE_TO_PROCESS 1
-#define FINISHED_TOTALLY 2
-
 /* line 3725 */
 /* *LINEP is a pointer into the line being processed.  It is advanced past any
    bytes processed.  Return 0 when we need to read a new line. */
@@ -839,7 +837,7 @@
   ELEMENT *current = *current_inout;
   char *line = *line_inout;
   char *line_after_command;
-  int retval = 1; /* Return value of function */
+  int retval = STILL_MORE_TO_PROCESS;
   enum command_id end_cmd;
   char *p;
 
@@ -1702,31 +1700,21 @@
         {
           int status;
           current = handle_other_command (current, &line, cmd, &status);
-          if (status == 1)
+          if (status == GET_A_NEW_LINE || status == FINISHED_TOTALLY)
             {
-              retval = GET_A_NEW_LINE;
+              retval = status;
               goto funexit;
             }
-          else if (status == 2)
-            {
-              retval = FINISHED_TOTALLY;
-              goto funexit;
-            }
         }
       else if (command_data(cmd).flags & CF_line)
         {
           int status;
           current = handle_line_command (current, &line, cmd, &status);
-          if (status == 1)
+          if (status == GET_A_NEW_LINE || status == FINISHED_TOTALLY)
             {
-              retval = GET_A_NEW_LINE;
+              retval = status;
               goto funexit;
             }
-          else if (status == 2)
-            {
-              retval = FINISHED_TOTALLY;
-              goto funexit;
-            }
         }
       else if (command_data(cmd).flags & CF_block)
         {
@@ -1736,7 +1724,8 @@
             {
               /* For @macro, to get a new line.  This is done instead of
                  doing the EMPTY TEXT (3879) code on the next time round. */
-              retval = GET_A_NEW_LINE; goto funexit;
+              retval = GET_A_NEW_LINE;
+              goto funexit;
             }
         }
       else if (command_data(cmd).flags & CF_brace
@@ -1791,7 +1780,7 @@
         *line = saved;
       }
 
-      retval = 1;
+      retval = STILL_MORE_TO_PROCESS;
       goto funexit;
     }
   else /* 5331 End of line */

Modified: trunk/tp/Texinfo/XS/parsetexi/parser.h
===================================================================
--- trunk/tp/Texinfo/XS/parsetexi/parser.h      2018-10-22 20:53:31 UTC (rev 
8377)
+++ trunk/tp/Texinfo/XS/parsetexi/parser.h      2018-10-22 21:26:32 UTC (rev 
8378)
@@ -69,6 +69,12 @@
 ELEMENT *begin_paragraph (ELEMENT *current);
 int format_expanded_p (char *format);
 
+/* Return values */
+#define GET_A_NEW_LINE 0
+#define STILL_MORE_TO_PROCESS 1
+#define FINISHED_TOTALLY 2
+
+
 extern const char *whitespace_chars, *whitespace_chars_except_newline;
 extern const char *digit_chars;
 




reply via email to

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