texinfo-commits
[Top][All Lists]
Advanced

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

branch master updated: * tp/Texinfo/ParserNonXS.pm (_process_remaining_o


From: Patrice Dumas
Subject: branch master updated: * tp/Texinfo/ParserNonXS.pm (_process_remaining_on_line), tp/Texinfo/XS/parsetexi/parser.c (process_remaining_on_line): use only one place in code to add the raw line in nested raw blocks.
Date: Sun, 01 Jan 2023 12:01:02 -0500

This is an automated email from the git hooks/post-receive script.

pertusus pushed a commit to branch master
in repository texinfo.

The following commit(s) were added to refs/heads/master by this push:
     new 831b948e16 * tp/Texinfo/ParserNonXS.pm (_process_remaining_on_line), 
tp/Texinfo/XS/parsetexi/parser.c (process_remaining_on_line): use only one 
place in code to add the raw line in nested raw blocks.
831b948e16 is described below

commit 831b948e16bc1599b3ebb49d7872d3373899c9e7
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sun Jan 1 18:00:29 2023 +0100

    * tp/Texinfo/ParserNonXS.pm (_process_remaining_on_line),
    tp/Texinfo/XS/parsetexi/parser.c (process_remaining_on_line): use only
    one place in code to add the raw line in nested raw blocks.
---
 ChangeLog                        |  6 +++++
 tp/Texinfo/ParserNonXS.pm        | 35 ++++++++++++----------------
 tp/Texinfo/XS/parsetexi/parser.c | 49 ++++++++++++++--------------------------
 3 files changed, 38 insertions(+), 52 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 312c7101c4..ac385be46b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2023-01-01  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/Texinfo/ParserNonXS.pm (_process_remaining_on_line),
+       tp/Texinfo/XS/parsetexi/parser.c (process_remaining_on_line): use only
+       one place in code to add the raw line in nested raw blocks.
+
 2023-01-01  Patrice Dumas  <pertusus@free.fr>
 
        * tp/Texinfo/ParserNonXS.pm (%parser_state_initialization),
diff --git a/tp/Texinfo/ParserNonXS.pm b/tp/Texinfo/ParserNonXS.pm
index c31769a416..153e1254bc 100644
--- a/tp/Texinfo/ParserNonXS.pm
+++ b/tp/Texinfo/ParserNonXS.pm
@@ -4133,6 +4133,7 @@ sub _process_remaining_on_line($$$$)
   if ($current->{'cmdname'}
       and $block_commands{$current->{'cmdname'}}
       and ($block_commands{$current->{'cmdname'}} eq 'raw')) {
+    my $closed_nested_raw;
     # r?macro may be nested
     if ((($current->{'cmdname'} eq 'macro'
           or $current->{'cmdname'} eq 'rmacro')
@@ -4142,10 +4143,6 @@ sub _process_remaining_on_line($$$$)
       push @{$self->{'raw_block_stack'}}, $1;
       print STDERR "RAW SECOND LEVEL \@$current->{'cmdname'}\n"
         if ($self->{'DEBUG'});
-      push @{$current->{'contents'}},
-        { 'text' => $line, 'type' => 'raw', 'parent' => $current };
-      $retval = $GET_A_NEW_LINE;
-      goto funexit;
     } elsif ($line =~ /^(\s*?)\@end\s+([a-zA-Z][\w-]*)/
              and ($2 eq $current->{'cmdname'})) {
       if (scalar(@{$self->{'raw_block_stack'}}) == 0) {
@@ -4188,25 +4185,23 @@ sub _process_remaining_on_line($$$$)
             }
           }
         }
+        print STDERR "CLOSED raw $current->{'cmdname'}\n" if 
($self->{'DEBUG'});
+        # start a new line for the @end line (without the first spaces on
+        # the line that have already been put in a raw container).
+        # This is normally done at the beginning of a line, but not here,
+        # as we directly got the line.  As the @end is processed just below,
+        # an empty line will not appear in the output, but it is needed to
+        # avoid a duplicate warning on @end not appearing at the beginning
+        # of the line
+        push @{$current->{'contents'}}, { 'type' => 'empty_line',
+                                          'text' => '',
+                                          'parent' => $current };
+        $closed_nested_raw = 1;
       } else {
         my $closed_cmdname = pop @{$self->{'raw_block_stack'}};
-        push @{$current->{'contents'}},
-          { 'text' => $line, 'type' => 'raw', 'parent' => $current };
-        $retval = $GET_A_NEW_LINE;
-        goto funexit;
       }
-      print STDERR "CLOSED raw $current->{'cmdname'}\n" if ($self->{'DEBUG'});
-      # start a new line for the @end line (without the first spaces on
-      # the line that have already been put in a raw container).
-      # This is normally done at the beginning of a line, but not here,
-      # as we directly got the line.  As the @end is processed just below,
-      # an empty line will not appear in the output, but it is needed to
-      # avoid a duplicate warning on @end not appearing at the beginning
-      # of the line
-      push @{$current->{'contents'}}, { 'type' => 'empty_line',
-                                        'text' => '',
-                                        'parent' => $current };
-    } else {
+    }
+    if (not $closed_nested_raw) {
       push @{$current->{'contents'}},
         { 'text' => $line, 'type' => 'raw', 'parent' => $current };
       $retval = $GET_A_NEW_LINE;
diff --git a/tp/Texinfo/XS/parsetexi/parser.c b/tp/Texinfo/XS/parsetexi/parser.c
index 4a07c1690e..b69b958e45 100644
--- a/tp/Texinfo/XS/parsetexi/parser.c
+++ b/tp/Texinfo/XS/parsetexi/parser.c
@@ -1153,6 +1153,7 @@ process_remaining_on_line (ELEMENT **current_inout, char 
**line_inout)
     {
       char *p = line;
       enum command_id cmd = 0;
+      int closed_nested_raw = 0;
       /* Check if we are using a macro within a macro. */
       if (current->cmd == CM_macro || current->cmd == CM_rmacro)
         {
@@ -1182,20 +1183,11 @@ process_remaining_on_line (ELEMENT **current_inout, 
char **line_inout)
         }
       if (cmd)
         {
-          ELEMENT *e;
-          e = new_element (ET_raw);
-          text_append (&e->text, line);
-          add_to_element_contents (current, e);
-
           push_raw_block_stack (cmd);
-
-          retval = GET_A_NEW_LINE;
-          goto funexit;
         }
       /* Else check if line is "@end ..." for current command. */
-      if (is_end_current_command (current, &p, &end_cmd))
+      else if (is_end_current_command (current, &p, &end_cmd))
         {
-          ELEMENT *e;
           if (raw_block_number == 0)
             {
               ELEMENT *e;
@@ -1246,32 +1238,25 @@ process_remaining_on_line (ELEMENT **current_inout, 
char **line_inout)
                         }
                     }
                 }
-            }
-          else
-            {
-              ELEMENT *e;
-              e = new_element (ET_raw);
-              text_append (&e->text, line);
+              debug ("CLOSED raw %s", command_name(end_cmd));
+             /* start a new line for the @end line (without the first spaces on
+                the line that have already been put in a raw container).
+                This is normally done at the beginning of a line, but not here,
+                as we directly got the line.  As the @end is processed just 
below,
+                an empty line will not appear in the output, but it is needed 
to
+                avoid a duplicate warning on @end not appearing at the 
beginning
+                of the line */
+              e = new_element (ET_empty_line);
               add_to_element_contents (current, e);
 
-              pop_raw_block_stack();
-
-              retval = GET_A_NEW_LINE;
-              goto funexit;
+              closed_nested_raw = 1;
             }
-
-          debug ("CLOSED raw %s", command_name(end_cmd));
-         /* start a new line for the @end line (without the first spaces on
-            the line that have already been put in a raw container).
-            This is normally done at the beginning of a line, but not here,
-            as we directly got the line.  As the @end is processed just below,
-            an empty line will not appear in the output, but it is needed to
-            avoid a duplicate warning on @end not appearing at the beginning
-            of the line */
-          e = new_element (ET_empty_line);
-          add_to_element_contents (current, e);
+          else
+            pop_raw_block_stack();
         }
-      else /* save the line verbatim */
+
+      /* save the line verbatim */
+      if (! closed_nested_raw)
         {
           ELEMENT *e;
           e = new_element (ET_raw);



reply via email to

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