texinfo-commits
[Top][All Lists]
Advanced

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

branch master updated: * tp/Texinfo/Common.pm (%block_commands, %block_c


From: Patrice Dumas
Subject: branch master updated: * tp/Texinfo/Common.pm (%block_commands, %block_commands_args_number), tp/Texinfo/ParserNonXS.pm (_process_remaining_on_line), tp/Texinfo/XS/parsetexi/command_data.txt, tp/Texinfo/XS/parsetexi/commands.h, tp/Texinfo/XS/parsetexi/handle_commands.c (handle_block_command): separate type of block command from number of arguments for perl too. Set variadic to be a flag in the XS parser.
Date: Sun, 25 Sep 2022 17:28:56 -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 f085456d22 * tp/Texinfo/Common.pm (%block_commands, 
%block_commands_args_number), tp/Texinfo/ParserNonXS.pm 
(_process_remaining_on_line), tp/Texinfo/XS/parsetexi/command_data.txt, 
tp/Texinfo/XS/parsetexi/commands.h, tp/Texinfo/XS/parsetexi/handle_commands.c 
(handle_block_command): separate type of block command from number of arguments 
for perl too.  Set variadic to be a flag in the XS parser.
f085456d22 is described below

commit f085456d22e770df17befc9ae92d40c8ecc9b7dd
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sun Sep 25 23:28:45 2022 +0200

    * tp/Texinfo/Common.pm (%block_commands, %block_commands_args_number),
    tp/Texinfo/ParserNonXS.pm (_process_remaining_on_line),
    tp/Texinfo/XS/parsetexi/command_data.txt,
    tp/Texinfo/XS/parsetexi/commands.h,
    tp/Texinfo/XS/parsetexi/handle_commands.c (handle_block_command):
    separate type of block command from number of arguments for
    perl too.  Set variadic to be a flag in the XS parser.
---
 ChangeLog                                 | 10 +++++
 tp/Texinfo/Common.pm                      | 63 +++++++++++++++++++------------
 tp/Texinfo/ParserNonXS.pm                 | 17 ++++++---
 tp/Texinfo/XS/parsetexi/command_data.txt  | 24 ++++++------
 tp/Texinfo/XS/parsetexi/commands.h        |  8 ++--
 tp/Texinfo/XS/parsetexi/handle_commands.c |  2 +-
 6 files changed, 77 insertions(+), 47 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index f597dc84dd..158dd9bee3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2022-09-25  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/Texinfo/Common.pm (%block_commands, %block_commands_args_number),
+       tp/Texinfo/ParserNonXS.pm (_process_remaining_on_line),
+       tp/Texinfo/XS/parsetexi/command_data.txt,
+       tp/Texinfo/XS/parsetexi/commands.h,
+       tp/Texinfo/XS/parsetexi/handle_commands.c (handle_block_command):
+       separate type of block command from number of arguments for
+       perl too.  Set variadic to be a flag in the XS parser.
+
 2022-09-25  Gavin Smith  <gavinsmith0123@gmail.com>
 
        * doc/texinfo.texi (Microtypography), NEWS: Document @microtype.
diff --git a/tp/Texinfo/Common.pm b/tp/Texinfo/Common.pm
index 4792de12ca..a6162aec70 100644
--- a/tp/Texinfo/Common.pm
+++ b/tp/Texinfo/Common.pm
@@ -844,10 +844,10 @@ foreach my $unformatted_brace_command ('anchor', 
'shortcaption',
 }
 
 # commands delimiting blocks, with an @end.
-# Value is either the number of arguments on the line separated by
-# commas or the type of command, 'raw', 'def', 'conditional',
-# or 'multitable'.
+# Type of command, 'raw', 'def', 'conditional', 'multitable'...
 our %block_commands;
+# Number of arguments on the line separated by commas
+our %block_commands_args_number;
 
 # commands that have a possible content before an item
 our %block_item_commands;
@@ -925,24 +925,27 @@ $block_item_commands{'multitable'} = 1;
 our %menu_commands;
 foreach my $menu_command ('menu', 'detailmenu', 'direntry') {
   $menu_commands{$menu_command} = 1;
-  $block_commands{$menu_command} = 0;
+  $block_commands{$menu_command} = 'menu';
 };
 
 our %align_commands;
 foreach my $align_command('raggedright', 'flushleft', 'flushright') {
-  $block_commands{$align_command} = 0;
+  $block_commands{$align_command} = 'align';
   $align_commands{$align_command} = 1;
 }
 $align_commands{'center'} = 1;
 
-foreach my $block_command(
-    'cartouche', 'group', 'indentedblock', 'smallindentedblock') {
-  $block_commands{$block_command} = 0;
+foreach my $block_command('indentedblock', 'smallindentedblock') {
+  $block_commands{$block_command} = 'align';
+}
+
+foreach my $block_command('cartouche', 'group') {
+  $block_commands{$block_command} = 'other';
 }
 
 our %region_commands;
 foreach my $block_command('titlepage', 'copying', 'documentdescription') {
-  $block_commands{$block_command} = 0;
+  $block_commands{$block_command} = 'region';
   $region_commands{$block_command} = 1;
 }
 
@@ -950,26 +953,26 @@ our %preformatted_commands;
 our %preformatted_code_commands;
 foreach my $preformatted_command(
     'example', 'smallexample', 'lisp', 'smalllisp') {
-  $block_commands{$preformatted_command} = 0;
+  $block_commands{$preformatted_command} = 'preformatted';
   $preformatted_commands{$preformatted_command} = 1;
   $preformatted_code_commands{$preformatted_command} = 1;
 }
-$block_commands{'example'} = 'variadic'; # unlimited arguments
+$block_commands_args_number{'example'} = 'variadic'; # unlimited arguments
 
 foreach my $preformatted_command(
     'display', 'smalldisplay', 'format', 'smallformat') {
-  $block_commands{$preformatted_command} = 0;
+  $block_commands{$preformatted_command} = 'preformatted';
   $preformatted_commands{$preformatted_command} = 1;
 }
 
 foreach my $block_math_command('displaymath') {
-  $block_commands{$block_math_command} = 0;
+  $block_commands{$block_math_command} = 'math';
   $math_commands{$block_math_command} = 1;
 }
 
 our %format_raw_commands;
 foreach my $format_raw_command('html', 'tex', 'xml', 'docbook', 'latex') {
-  $block_commands{$format_raw_command} = 0;
+  $block_commands{$format_raw_command} = 'format';
   $format_raw_commands{$format_raw_command} = 1;
 }
 
@@ -994,15 +997,20 @@ $block_commands{'ifclear'} = 'conditional';
 $block_commands{'ifcommanddefined'} = 'conditional';
 $block_commands{'ifcommandnotdefined'} = 'conditional';
 
-# 'macro' ?
 foreach my $block_command_one_arg('table', 'ftable', 'vtable',
-  'itemize', 'enumerate', 'quotation', 'smallquotation') {
-  $block_commands{$block_command_one_arg} = 1;
-  $block_item_commands{$block_command_one_arg} = 1
-    unless ($block_command_one_arg =~ /quotation/);
+  'itemize', 'enumerate') {
+  $block_commands{$block_command_one_arg} = 'blockitem';
+  $block_commands_args_number{$block_command_one_arg} = 1;
+  $block_item_commands{$block_command_one_arg} = 1;
+}
+
+foreach my $block_command_one_arg('quotation', 'smallquotation') {
+  $block_commands{$block_command_one_arg} = 'quotation';
+  $block_commands_args_number{$block_command_one_arg} = 1;
 }
 
-$block_commands{'float'} = 2;
+$block_commands{'float'} = 'float';
+$block_commands_args_number{'float'} = 2;
 
 # commands that forces closing an opened paragraph.
 our %close_paragraph_commands;
@@ -2953,11 +2961,16 @@ Commands delimiting a block with a closing C<@end>.  
The value
 is I<conditional> for C<@if> commands, I<def> for definition
 commands like C<@deffn>, I<raw> for @-commands that have no expansion
 of @-commands in their bodies (C<@macro>, C<@verbatim> and C<@ignore>),
-and I<multitable> for C<@multitable>.
-Otherwise it is set to the number of arguments separated by commas
-that may appear on the @-command line, or to I<variadic> if there is
-an unlimited number of arguments. That means 0 in most cases,
-1 for C<@quotation>, 2 for C<@float> and C<variadic> for C<@example>.
+I<multitable> for C<@multitable> and other values for other block line
+commands.
+
+=item %block_commands_args_number
+X<C<%block_commands_args_number>>
+
+Set to the number of arguments separated by commas that may appear on the
+@-command line, or to I<variadic> if there is an unlimited number of arguments.
+That means 0 or unset in most cases, 1 for C<@quotation>, 2 for C<@float> and
+C<variadic> for C<@example>.
 
 =item %brace_commands
 X<C<%brace_commands>>
diff --git a/tp/Texinfo/ParserNonXS.pm b/tp/Texinfo/ParserNonXS.pm
index c5a03210c1..9519d18b24 100644
--- a/tp/Texinfo/ParserNonXS.pm
+++ b/tp/Texinfo/ParserNonXS.pm
@@ -265,6 +265,7 @@ my %brace_commands_args_number = 
%Texinfo::Common::brace_commands_args_number;
 my %accent_commands           = %Texinfo::Common::accent_commands;
 my %context_brace_commands    = %Texinfo::Common::context_brace_commands;
 my %block_commands            = %Texinfo::Common::block_commands;
+my %block_commands_args_number = %Texinfo::Common::block_commands_args_number;
 my %block_item_commands       = %Texinfo::Common::block_item_commands;
 my %close_paragraph_commands  = %Texinfo::Common::close_paragraph_commands;
 my %def_map                   = %Texinfo::Common::def_map;
@@ -3801,7 +3802,7 @@ sub _check_valid_nesting {
                    and $current->{'type'} eq 'line_arg'))
           # we make sure that we are on a block @-command line and
           # not in contents
-          and (!($block_commands{$current->{'parent'}->{'cmdname'}})
+          and (!defined($block_commands{$current->{'parent'}->{'cmdname'}})
                or ($current->{'type'}
                    and $current->{'type'} eq 'block_line_arg'))
           # we make sure that we are on an @item/@itemx line and
@@ -5078,11 +5079,15 @@ sub _process_remaining_on_line($$$$)
            'contents' => [],
            'parent' => $current } ];
 
-        if ($block_commands{$command} =~ /^\d+$/
-            and $block_commands{$command} - 1 > 0) {
-          $current->{'remaining_args'} = $block_commands{$command} - 1;
-        } elsif ($block_commands{$command} eq 'variadic') {
-          $current->{'remaining_args'} = -1; # unlimited args
+        if ($block_commands_args_number{$command}) {
+          if ($block_commands_args_number{$command} =~ /^\d+$/) {
+            if ($block_commands_args_number{$command} - 1 > 0) {
+              $current->{'remaining_args'}
+                = $block_commands_args_number{$command} - 1;
+            }
+          } elsif ($block_commands_args_number{$command} eq 'variadic') {
+            $current->{'remaining_args'} = -1; # unlimited args
+          }
         }
         $current = $current->{'args'}->[-1];
         $self->_push_context('ct_line', $command)
diff --git a/tp/Texinfo/XS/parsetexi/command_data.txt 
b/tp/Texinfo/XS/parsetexi/command_data.txt
index b186abacb5..7f7700ec14 100644
--- a/tp/Texinfo/XS/parsetexi/command_data.txt
+++ b/tp/Texinfo/XS/parsetexi/command_data.txt
@@ -405,11 +405,11 @@ direntry                block,menu
 raggedright             block
 flushleft               block
 flushright              block
+indentedblock           block
+smallindentedblock      block
 
 cartouche               block
 group                   block
-indentedblock           block
-smallindentedblock      block
 
 # region commands
 titlepage               block,global_unique             BLOCK_region
@@ -417,7 +417,7 @@ copying                 block,global_unique             
BLOCK_region
 documentdescription     block,global_unique             BLOCK_region
 
 # preformatted commands
-example                 block,preformatted,preformatted_code    BLOCK_variadic
+example                 block,preformatted,preformatted_code,variadic
 smallexample            block,preformatted,preformatted_code
 lisp                    block,preformatted,preformatted_code
 smalllisp               block,preformatted,preformatted_code
@@ -439,16 +439,16 @@ ignore                  block                           
BLOCK_raw
 macro                   block                           BLOCK_raw
 rmacro                  block                           BLOCK_raw
 
-table                   block,blockitem                 1
-ftable                  block,blockitem                 1
-vtable                  block,blockitem                 1
-itemize                 block,blockitem                 1
-enumerate               block,blockitem                 1
-quotation               block                           1
-smallquotation          block                           1
+table                   block,blockitem                 BLOCK_blockitem    1
+ftable                  block,blockitem                 BLOCK_blockitem    1
+vtable                  block,blockitem                 BLOCK_blockitem    1
+itemize                 block,blockitem                 BLOCK_blockitem    1
+enumerate               block,blockitem                 BLOCK_blockitem    1
+quotation               block                           BLOCK_quotation    1
+smallquotation          block                           BLOCK_quotation    1
 
-float                   block                           2
-displaymath             block                           0
+float                   block                           BLOCK_float        2
+displaymath             block
 
 ##################################################################
 # Conditional commands
diff --git a/tp/Texinfo/XS/parsetexi/commands.h 
b/tp/Texinfo/XS/parsetexi/commands.h
index 58f2210c4b..c4c343b5b5 100644
--- a/tp/Texinfo/XS/parsetexi/commands.h
+++ b/tp/Texinfo/XS/parsetexi/commands.h
@@ -55,9 +55,9 @@ void wipe_user_commands (void);
 #define CF_brace                       0x0010
 #define CF_letter_no_arg               0x0020
 #define CF_accent                      0x0040
-/* CF_style and CF_code_style are not used */
+/* CF_style is not used */
 #define CF_style                       0x0080
-#define CF_code_style                  0x0100
+#define CF_variadic                    0x0100
 #define CF_INFOENCLOSE                 0x0200
 #define CF_in_heading                  0x0400
 #define CF_ref                         0x0800
@@ -113,7 +113,9 @@ void wipe_user_commands (void);
 #define BLOCK_raw -2
 #define BLOCK_multitable -3
 #define BLOCK_region -4
-#define BLOCK_variadic -5
+#define BLOCK_blockitem -6
+#define BLOCK_quotation -7
+#define BLOCK_float -8
 
 /* Types of brace command (CF_brace). */
 #define BRACE_arguments 1
diff --git a/tp/Texinfo/XS/parsetexi/handle_commands.c 
b/tp/Texinfo/XS/parsetexi/handle_commands.c
index a23b1698f4..83944e7e5e 100644
--- a/tp/Texinfo/XS/parsetexi/handle_commands.c
+++ b/tp/Texinfo/XS/parsetexi/handle_commands.c
@@ -943,7 +943,7 @@ handle_block_command (ELEMENT *current, char **line_inout,
                         current,
                         command_data (current->cmd).args_number - 1);
         }
-      else if (command_data (current->cmd).data == BLOCK_variadic)
+      else if (command_data (current->cmd).flags & CF_variadic)
         {
           /* Unlimited args */
           counter_push (&count_remaining_args, current,



reply via email to

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