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 (_parse_texi): set $c


From: Patrice Dumas
Subject: branch master updated: * tp/Texinfo/ParserNonXS.pm (_parse_texi): set $command based on $at_command and $single_letter_command earlier, apply alias earlier, to avoid code duplication and be more similar to the XS parser.
Date: Sat, 27 Aug 2022 02:32:39 -0400

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 11cc48e265 * tp/Texinfo/ParserNonXS.pm (_parse_texi): set $command 
based on $at_command and $single_letter_command earlier, apply alias earlier, 
to avoid code duplication and be more similar to the XS parser.
11cc48e265 is described below

commit 11cc48e26539936164cf626905b6da42a3a2fd5e
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sat Aug 27 08:32:23 2022 +0200

    * tp/Texinfo/ParserNonXS.pm (_parse_texi): set $command based on
    $at_command and $single_letter_command earlier, apply alias earlier,
    to avoid code duplication and be more similar to the XS parser.
---
 ChangeLog                 |  6 ++++++
 tp/Texinfo/ParserNonXS.pm | 50 ++++++++++++++++++++++-------------------------
 2 files changed, 29 insertions(+), 27 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index d0f370ab6f..b346f8dace 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2022-08-27  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/Texinfo/ParserNonXS.pm (_parse_texi): set $command based on
+       $at_command and $single_letter_command earlier, apply alias earlier,
+       to avoid code duplication and be more similar to the XS parser.
+
 2022-08-27  Patrice Dumas  <pertusus@free.fr>
 
        Add spaces information for @-commands with braces followed by spaces
diff --git a/tp/Texinfo/ParserNonXS.pm b/tp/Texinfo/ParserNonXS.pm
index 06132c8728..61b469cd66 100644
--- a/tp/Texinfo/ParserNonXS.pm
+++ b/tp/Texinfo/ParserNonXS.pm
@@ -4086,20 +4086,24 @@ sub _parse_texi($$$)
       print STDERR "PARSED: ".join(', ', map {!defined($_) ? 'UNDEF' : $_} 
@line_parsing)."\n"
         if ($self->{'DEBUG'});
 
-      if ($at_command) {
+      my $command;
+      if ($single_letter_command) {
+        $command = $single_letter_command;
+      } elsif ($at_command) {
         $at_command_length = length($at_command) + 1;
+        $command = $at_command;
 
         # handle unknown @-command
-        if (!$all_commands{$at_command}
-            and !$self->{'macros'}->{$at_command}
-            and !$self->{'definfoenclose'}->{$at_command}
-            and !$self->{'aliases'}->{$at_command}
-            and !$self->{'command_index'}->{$at_command}
+        if (!$all_commands{$command}
+            and !$self->{'macros'}->{$command}
+            and !$self->{'definfoenclose'}->{$command}
+            and !$self->{'aliases'}->{$command}
+            and !$self->{'command_index'}->{$command}
             # @txiinternalvalue is invalid unless accept_internalvalue is set
-            and !($at_command eq 'txiinternalvalue'
+            and !($command eq 'txiinternalvalue'
                   and $self->{'accept_internalvalue'})) {
           $self->_line_error(sprintf(__("unknown command `%s'"),
-                                      $at_command), $source_info);
+                                      $command), $source_info);
           substr($line, 0, $at_command_length) = '';
           _abort_empty_line($self, $current);
           my $paragraph = _begin_paragraph($self, $current, $source_info);
@@ -4107,18 +4111,17 @@ sub _parse_texi($$$)
           next;
         }
 
+        my $alias_command;
+        if (exists($self->{'aliases'}->{$command})) {
+          $alias_command = $command;
+          $command = $self->{'aliases'}->{$command};
+        }
+
+
         # handle user defined macros before anything else since
         # their expansion may lead to changes in the line
-        if ($self->{'macros'}->{$at_command}
-                 or (exists $self->{'aliases'}->{$at_command}
-                     and 
$self->{'macros'}->{$self->{'aliases'}->{$at_command}})) {
+        if ($self->{'macros'}->{$command}) {
           substr($line, 0, $at_command_length) = '';
-          my $command = $at_command;
-          my $alias_command;
-          if (exists($self->{'aliases'}->{$command})) {
-            $alias_command = $command;
-            $command = $self->{'aliases'}->{$command};
-          }
 
           my $expanded_macro = $self->{'macros'}->{$command}->{'element'};
           my $args_number = scalar(@{$expanded_macro->{'args'}}) -1;
@@ -4284,6 +4287,8 @@ sub _parse_texi($$$)
             $current->{'extra'}->{'spaces'} = ''
               if (!defined($current->{'extra'}->{'spaces'}));
             $current->{'extra'}->{'spaces'} .= $1;
+            # FIXME temporary hack to get the same output as XS parser
+            #$current->{'extra'}->{'spaces'} =~ s/\n\n/\n/;
             next;
           }
           $self->_line_error(sprintf(__("\@%s expected braces"),
@@ -4394,24 +4399,15 @@ sub _parse_texi($$$)
           $current = _enter_menu_entry_node($self, $current, $source_info);
         }
       # Any other @-command.
-      } elsif ($at_command or $single_letter_command) {
-        my $command;
+      } elsif ($command) {
         if (!$at_command) {
-          $command = $single_letter_command;
           substr($line, 0, 2) = '';
         } else {
-          $command = $at_command;
           substr($line, 0, $at_command_length) = '';
         }
 
         print STDERR "COMMAND $command\n" if ($self->{'DEBUG'});
 
-        my $alias_command;
-        if (exists($self->{'aliases'}->{$command})) {
-          $alias_command = $command;
-          $command = $self->{'aliases'}->{$command};
-        }
-
         if ($command eq 'value' or $command eq 'txiinternalvalue') {
           $line =~ s/^\s*//
              if ($self->{'IGNORE_SPACE_AFTER_BRACED_COMMAND_NAME'});



reply via email to

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