texinfo-commits
[Top][All Lists]
Advanced

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

branch master updated: Unify @multitable block line arg ending


From: Gavin D. Smith
Subject: branch master updated: Unify @multitable block line arg ending
Date: Wed, 08 Feb 2023 16:23:50 -0500

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

gavin pushed a commit to branch master
in repository texinfo.

The following commit(s) were added to refs/heads/master by this push:
     new 6884d33bc2 Unify @multitable block line arg ending
6884d33bc2 is described below

commit 6884d33bc2d8613976ea2ded061de5dddaad3fcb
Author: Gavin Smith <gavinsmith0123@gmail.com>
AuthorDate: Wed Feb 8 21:23:42 2023 +0000

    Unify @multitable block line arg ending
    
    * tp/Texinfo/ParserNonXS.pm (_end_line_misc_line) <@columnfractions>:
    Do not close the @multitable block line element, so that
    _end_line_starting_block will be called afterwards.  Only record
    the @columnfractions command in the 'extra' hash.
    (_end_line_starting_block): Check if columnfractions has been
    set so to avoid reading line as prototype list.
---
 ChangeLog                          | 11 ++++++++++
 tp/Texinfo/ParserNonXS.pm          | 35 ++++++++++++++---------------
 tp/Texinfo/XS/parsetexi/end_line.c | 45 ++++++++++++++++++--------------------
 3 files changed, 48 insertions(+), 43 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index fcd7618be1..16fd9a7d71 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2023-02-08  Gavin Smith <gavinsmith0123@gmail.com>
+
+       Unify @multitable block line arg ending
+
+       * tp/Texinfo/ParserNonXS.pm (_end_line_misc_line) <@columnfractions>:
+       Do not close the @multitable block line element, so that
+       _end_line_starting_block will be called afterwards.  Only record
+       the @columnfractions command in the 'extra' hash.
+       (_end_line_starting_block): Check if columnfractions has been
+       set so to avoid reading line as prototype list.
+
 2023-02-08  Patrice Dumas  <pertusus@free.fr>
 
        * tp/Texinfo/ParserNonXS.pm (_relocate_source_marks),
diff --git a/tp/Texinfo/ParserNonXS.pm b/tp/Texinfo/ParserNonXS.pm
index d9a44e0ca1..99249a9415 100644
--- a/tp/Texinfo/ParserNonXS.pm
+++ b/tp/Texinfo/ParserNonXS.pm
@@ -3625,24 +3625,7 @@ sub _end_line_misc_line($$$)
              __("\@%s only meaningful on a \@multitable line"),
              $command);
     } else {
-      # This is the multitable block_line_arg line context
-      $self->_pop_context(['ct_line'], $source_info, $current, 'for 
multitable');
-      pop @{$self->{'nesting_context'}->{'basic_inline_stack_block'}};
-      # FIXME much better to pop contexts in exactly one place in the
-      # source code.
-
-      $current = $current->{'parent'};
-      $current->{'extra'} = {} if (!defined($current->{'extra'}));
-      $current->{'extra'}->{'max_columns'} = 0;
-      if ($misc_cmd->{'extra'}
-          and defined($misc_cmd->{'extra'}->{'misc_args'})) {
-        $current->{'extra'}->{'max_columns'}
-            = scalar(@{$misc_cmd->{'extra'}->{'misc_args'}});
-        $current->{'extra'}->{'columnfractions'} = $misc_cmd;
-      }
-      push @{$current->{'contents'}}, { 'type' => 'before_item',
-                                        'parent', $current };
-      $current = $current->{'contents'}->[-1];
+      $current->{'parent'}->{'extra'}->{'columnfractions'} = $misc_cmd;
     }
   } elsif ($root_commands{$command}) {
     $current = $current->{'contents'}->[-1];
@@ -3789,7 +3772,21 @@ sub _end_line_starting_block($$$)
        if ($self->{'DEBUG'});
 
   # @multitable args
-  if ($command eq 'multitable') {
+  if ($command eq 'multitable'
+        and defined($current->{'parent'}->{'extra'}->{'columnfractions'})) {
+    my $multitable = $current->{'parent'};
+    my $misc_cmd = $current->{'parent'}->{'extra'}->{'columnfractions'};
+
+    $multitable->{'extra'} = {} if (!defined($multitable->{'extra'}));
+    if ($misc_cmd->{'extra'}
+        and defined($misc_cmd->{'extra'}->{'misc_args'})) {
+      $multitable->{'extra'}->{'max_columns'}
+          = scalar(@{$misc_cmd->{'extra'}->{'misc_args'}});
+    } else {
+      $multitable->{'extra'}->{'max_columns'} = 0;
+      delete $multitable->{'extra'}->{'columnfractions'};
+    }
+  } elsif ($command eq 'multitable') {
     # parse the prototypes and put them in a special arg
     my @prototype_row;
     if ($current->{'contents'}) {
diff --git a/tp/Texinfo/XS/parsetexi/end_line.c 
b/tp/Texinfo/XS/parsetexi/end_line.c
index 0beb0f38a2..9a8b7b06c3 100644
--- a/tp/Texinfo/XS/parsetexi/end_line.c
+++ b/tp/Texinfo/XS/parsetexi/end_line.c
@@ -1009,13 +1009,32 @@ parse_float_type (ELEMENT *current)
 ELEMENT *
 end_line_starting_block (ELEMENT *current)
 {
+  KEY_PAIR *k;
   if (pop_context () != ct_line)
     fatal ("line context expected");
 
   if (command_flags(current->parent) & CF_contain_basic_inline)
       (void) pop_command (&nesting_context.basic_inline_stack_block);
 
-  if (current->parent->cmd == CM_multitable)
+  if (current->parent->cmd == CM_multitable
+      && (k = lookup_extra (current->parent, "columnfractions")))
+    {
+      ELEMENT *misc_cmd = k->value;
+      KEY_PAIR *misc_args;
+
+      if ((misc_args = lookup_extra (misc_cmd, "misc_args")))
+        {
+          add_extra_integer (current->parent, "max_columns",
+                             misc_args->value->contents.number);
+        }
+      else
+        {
+          add_extra_integer (current->parent, "max_columns", 0);
+          k->key = "";
+          k->type = extra_deleted;
+        }
+    }
+  else if (current->parent->cmd == CM_multitable)
     {
       /* Parse prototype row for a @multitable.  Handling
          of @columnfractions is done elsewhere. */
@@ -1907,9 +1926,6 @@ end_line_misc_line (ELEMENT *current)
     command_warn (misc_cmd, "@setfilename after the first element");
   else if (cmd == CM_columnfractions)
     {
-      ELEMENT *before_item;
-      KEY_PAIR *misc_args;
-
       /* Check if in multitable. */
       if (!current->parent || current->parent->cmd != CM_multitable)
         {
@@ -1918,26 +1934,7 @@ end_line_misc_line (ELEMENT *current)
         }
       else
         {
-          if (pop_context () != ct_line)
-            fatal ("line context expected");
-          (void) pop_command (&nesting_context.basic_inline_stack_block);
-          /* FIXME much better to pop contexts in only one place in the
-             source code. */
-
-          current = current->parent;
-
-          if ((misc_args = lookup_extra (misc_cmd, "misc_args")))
-            {
-              add_extra_element (current, "columnfractions", misc_cmd);
-              add_extra_integer (current, "max_columns",
-                                 misc_args->value->contents.number);
-            }
-          else
-            add_extra_integer (current, "max_columns", 0);
-
-          before_item = new_element (ET_before_item);
-          add_to_element_contents (current, before_item);
-          current = before_item;
+          add_extra_element (current->parent, "columnfractions", misc_cmd);
         }
     }
   else if (command_data(cmd).flags & CF_root)



reply via email to

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