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 (%brace_commands, %brace_c


From: Patrice Dumas
Subject: branch master updated: * tp/Texinfo/Common.pm (%brace_commands, %brace_commands_args_number), tp/Texinfo/Convert/LaTeX.pm, tp/Texinfo/Convert/Plaintext.pm, tp/Texinfo/ParserNonXS.pm (_end_line, _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_open_brace) (handle_close_brace): separate number of brace arguments in %brace_commands_args_number and %brace_commands types in perl too. Use 'arguments'/BRACE_argu [...]
Date: Sun, 25 Sep 2022 15:51:11 -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 9c549dbc95 * tp/Texinfo/Common.pm (%brace_commands, 
%brace_commands_args_number), tp/Texinfo/Convert/LaTeX.pm, 
tp/Texinfo/Convert/Plaintext.pm, tp/Texinfo/ParserNonXS.pm (_end_line, 
_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_open_brace) (handle_close_brace): separate number of brace arguments in 
%brace_commands_args_number and %brace_commands types in perl too.  Use ' [...]
9c549dbc95 is described below

commit 9c549dbc954947d55a2745907dcf163e8f79b125
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sun Sep 25 21:50:37 2022 +0200

    * tp/Texinfo/Common.pm (%brace_commands, %brace_commands_args_number),
    tp/Texinfo/Convert/LaTeX.pm, tp/Texinfo/Convert/Plaintext.pm,
    tp/Texinfo/ParserNonXS.pm (_end_line, _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_open_brace)
    (handle_close_brace):
    separate number of brace arguments in %brace_commands_args_number and
    %brace_commands types in perl too.  Use 'arguments'/BRACE_arguments
    for the brace commands types that were selected by a positive number
    of arguments previously.  Use noarg/BRACE_noarg.
---
 ChangeLog                                 | 14 +++++++++
 tp/Texinfo/Common.pm                      | 35 ++++++++++++---------
 tp/Texinfo/Convert/LaTeX.pm               |  2 +-
 tp/Texinfo/Convert/Plaintext.pm           |  2 +-
 tp/Texinfo/ParserNonXS.pm                 | 30 +++++++++---------
 tp/Texinfo/XS/parsetexi/command_data.txt  | 52 +++++++++++++++----------------
 tp/Texinfo/XS/parsetexi/commands.h        |  1 +
 tp/Texinfo/XS/parsetexi/handle_commands.c |  2 +-
 tp/Texinfo/XS/parsetexi/separator.c       | 12 +++----
 9 files changed, 85 insertions(+), 65 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 371c6a168b..f597dc84dd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,20 @@
 
        * doc/texinfo.texi (Microtypography), NEWS: Document @microtype.
 
+2022-09-25  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/Texinfo/Common.pm (%brace_commands, %brace_commands_args_number),
+       tp/Texinfo/Convert/LaTeX.pm, tp/Texinfo/Convert/Plaintext.pm,
+       tp/Texinfo/ParserNonXS.pm (_end_line, _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_open_brace)
+       (handle_close_brace):
+       separate number of brace arguments in %brace_commands_args_number and
+       %brace_commands types in perl too.  Use 'arguments'/BRACE_arguments
+       for the brace commands types that were selected by a positive number
+       of arguments previously.  Use noarg/BRACE_noarg.
+
 2022-09-25  Patrice Dumas  <pertusus@free.fr>
 
        * tp/Texinfo/Common.pm (%line_commands), tp/Texinfo/Convert/DocBook.pm
diff --git a/tp/Texinfo/Common.pm b/tp/Texinfo/Common.pm
index ea57ca872e..4792de12ca 100644
--- a/tp/Texinfo/Common.pm
+++ b/tp/Texinfo/Common.pm
@@ -681,15 +681,16 @@ foreach my $index_name (keys (%index_names)) {
   }
 }
 
-# command with braces. Value is the max number of arguments or
-# a string.
+# commands with braces.
 our %brace_commands;
+# max number of arguments
+our %brace_commands_args_number;
 
 our %letter_no_arg_commands;
 foreach my $letter_no_arg_command ('aa','AA','ae','oe','AE','OE','o','O',
                                    'ss','l','L','DH','dh','TH','th') {
   $letter_no_arg_commands{$letter_no_arg_command} = 1;
-  $brace_commands{$letter_no_arg_command} = 0;
+  $brace_commands{$letter_no_arg_command} = 'noarg';
 }
 
 foreach my $no_arg_command ('TeX','LaTeX','bullet','copyright',
@@ -702,7 +703,7 @@ foreach my $no_arg_command 
('TeX','LaTeX','bullet','copyright',
   'quotedblleft','quotedblright','quoteleft','quoteright','quotedblbase',
   'quotesinglbase','guillemetleft','guillemetright','guillemotleft',
   'guillemotright','guilsinglleft','guilsinglright') {
-  $brace_commands{$no_arg_command} = 0;
+  $brace_commands{$no_arg_command} = 'noarg';
 }
 
 # accent commands. They may be called with and without braces.
@@ -751,7 +752,8 @@ foreach my $command ('code', 'command', 'env', 'file', 
'kbd', 'option',
 # text with type, but commas do not delimitate arguments
 foreach my $one_arg_command ('U', 'dmn', 'key', 'hyphenation', 'indicateurl',
     'titlefont', 'anchor', 'errormsg', 'sortas', 'seeentry', 'seealso') {
-  $brace_commands{$one_arg_command} = 1;
+  $brace_commands{$one_arg_command} = 'arguments';
+  $brace_commands_args_number{$one_arg_command} = 1;
 }
 
 # commands in other keep their leading and trailing spaces in main text
@@ -788,7 +790,8 @@ foreach my $math_brace_command ('math') {
 our %explained_commands;
 foreach my $explained_command ('abbr', 'acronym') {
   $explained_commands{$explained_command} = 1;
-  $brace_commands{$explained_command} = 2;
+  $brace_commands{$explained_command} = 'arguments';
+  $brace_commands_args_number{$explained_command} = 2;
 }
 
 our %inline_format_commands;
@@ -796,29 +799,34 @@ our %inline_commands;
 foreach my $inline_format_command ('inlineraw', 'inlinefmt',
         'inlinefmtifelse') {
   $inline_format_commands{$inline_format_command} = 1;
-  $brace_commands{$inline_format_command} = 2;
+  $brace_commands_args_number{$inline_format_command} = 2;
+  $brace_commands{$inline_format_command} = 'arguments';
   $inline_commands{$inline_format_command} = 1;
 }
 
-$brace_commands{'inlinefmtifelse'} = 3;
+$brace_commands_args_number{'inlinefmtifelse'} = 3;
 
 our %inline_conditional_commands;
 foreach my $inline_conditional_command ('inlineifclear', 'inlineifset') {
   $inline_conditional_commands{$inline_conditional_command} = 1;
-  $brace_commands{$inline_conditional_command} = 2;
+  $brace_commands_args_number{$inline_conditional_command} = 2;
+  $brace_commands{$inline_conditional_command} = 'arguments';
   $inline_commands{$inline_conditional_command} = 1;
 }
 
 foreach my $two_arg_command('email') {
-  $brace_commands{$two_arg_command} = 2;
+  $brace_commands_args_number{$two_arg_command} = 2;
+  $brace_commands{$two_arg_command} = 'arguments';
 }
 
 foreach my $three_arg_command('uref','url','inforef') {
-  $brace_commands{$three_arg_command} = 3;
+  $brace_commands_args_number{$three_arg_command} = 3;
+  $brace_commands{$three_arg_command} = 'arguments';
 }
 
 foreach my $five_arg_command('xref','ref','pxref','image') {
-  $brace_commands{$five_arg_command} = 5;
+  $brace_commands_args_number{$five_arg_command} = 5;
+  $brace_commands{$five_arg_command} = 'arguments';
 }
 
 
@@ -2954,8 +2962,7 @@ an unlimited number of arguments. That means 0 in most 
cases,
 =item %brace_commands
 X<C<%brace_commands>>
 
-The commands that take braces.  The associated value is the maximum
-number of arguments.
+The commands that take braces.
 
 =item %code_style_commands
 X<C<%code_style_commands>>
diff --git a/tp/Texinfo/Convert/LaTeX.pm b/tp/Texinfo/Convert/LaTeX.pm
index 5d28622b2c..f3a07b6aa9 100644
--- a/tp/Texinfo/Convert/LaTeX.pm
+++ b/tp/Texinfo/Convert/LaTeX.pm
@@ -215,7 +215,7 @@ my %no_brace_commands = %Texinfo::Common::no_brace_commands;
 my %brace_no_arg_commands;
 foreach my $command (keys (%Texinfo::Common::brace_commands)) {
   $brace_no_arg_commands{$command} = 1
-    if ($Texinfo::Common::brace_commands{$command} eq '0');
+    if ($Texinfo::Common::brace_commands{$command} eq 'noarg');
 }
 my %accent_commands = %Texinfo::Common::accent_commands;
 my %misc_commands = %Texinfo::Common::misc_commands;
diff --git a/tp/Texinfo/Convert/Plaintext.pm b/tp/Texinfo/Convert/Plaintext.pm
index 786d9a6fba..2967fbbe13 100644
--- a/tp/Texinfo/Convert/Plaintext.pm
+++ b/tp/Texinfo/Convert/Plaintext.pm
@@ -86,7 +86,7 @@ my %no_brace_commands = %Texinfo::Common::no_brace_commands;
 my %brace_no_arg_commands;
 foreach my $command (keys (%Texinfo::Common::brace_commands)) {
   $brace_no_arg_commands{$command} = 1 
-    if ($Texinfo::Common::brace_commands{$command} eq '0');
+    if ($Texinfo::Common::brace_commands{$command} eq 'noarg');
 }
 my %accent_commands = %Texinfo::Common::accent_commands;
 my %misc_commands = %Texinfo::Common::misc_commands;
diff --git a/tp/Texinfo/ParserNonXS.pm b/tp/Texinfo/ParserNonXS.pm
index e31ec43fbb..c5a03210c1 100644
--- a/tp/Texinfo/ParserNonXS.pm
+++ b/tp/Texinfo/ParserNonXS.pm
@@ -261,6 +261,7 @@ my %no_brace_commands         = 
%Texinfo::Common::no_brace_commands;
 my %line_commands             = %Texinfo::Common::line_commands;
 my %other_commands            = %Texinfo::Common::other_commands;
 my %brace_commands            = %Texinfo::Common::brace_commands;
+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;
@@ -381,7 +382,8 @@ foreach my $no_close_preformatted('sp') {
 # commands that may appear in accents
 my %in_accent_commands = %accent_commands;
 foreach my $brace_command(keys(%brace_commands)) {
-  $in_accent_commands{$brace_command} = 1 if 
(!$brace_commands{$brace_command});
+  $in_accent_commands{$brace_command} = 1
+     if ($brace_commands{$brace_command} eq 'noarg');
 }
 foreach my $no_brace_command (keys(%no_brace_commands)) {
   $in_accent_commands{$no_brace_command} = 1;
@@ -457,8 +459,7 @@ delete $simple_text_commands{'center'};
 delete $simple_text_commands{'exdent'};
 
 foreach my $command (keys (%brace_commands)) {
-  if ($brace_commands{$command} =~ /\d/
-      and $brace_commands{$command} > 0
+  if ($brace_commands{$command} eq 'arguments'
       and !$inline_commands{$command}) {
     $simple_text_commands{$command} = 1;
   }
@@ -3110,8 +3111,8 @@ sub _end_line($$$)
           $self->_command_error($current, $source_info,
               __("%s requires an argument: the formatter for %citem"),
               $current->{'cmdname'}, ord('@'));
-        } elsif (!$self->{'brace_commands'}->{
-              $current->{'extra'}->{'command_as_argument'}->{'cmdname'}}) {
+        } elsif ($self->{'brace_commands'}->{
+      $current->{'extra'}->{'command_as_argument'}->{'cmdname'}} eq 'noarg') {
           $self->_command_error($current, $source_info,
               __("command \@%s not accepting argument in brace should not be 
on \@%s line"),
               $current->{'extra'}->{'command_as_argument'}->{'cmdname'},
@@ -5145,10 +5146,10 @@ sub _process_remaining_on_line($$$$)
         my $command = $current->{'cmdname'};
         $current->{'args'} = [ { 'parent' => $current } ];
 
-        if ($brace_commands{$command}
-            and $brace_commands{$command} =~ /^\d$/
-            and $brace_commands{$command} > 1) {
-          $current->{'remaining_args'} = $brace_commands{$command} - 1;
+        if (defined($brace_commands_args_number{$command})
+            and $brace_commands_args_number{$command} > 1) {
+          $current->{'remaining_args'}
+              = $brace_commands_args_number{$command} - 1;
         }
 
         $current = $current->{'args'}->[-1];
@@ -5203,11 +5204,9 @@ sub _process_remaining_on_line($$$$)
           };
         } else {
           $current->{'type'} = 'brace_command_arg';
-          # only put spaces in spaces_before_argument if the @-command
-          # has an explicit positive number of arguments.
+          # Commands that disregard leading and trailing whitespace.
           if ($brace_commands{$command}
-              and $brace_commands{$command} =~ /^\d$/
-              and $brace_commands{$command} > 0) {
+              and $brace_commands{$command} eq 'arguments') {
             # internal_spaces_before_argument is a transient internal type,
             # which should end up in extra spaces_before_argument.
             push @{$current->{'contents'}}, {
@@ -5287,8 +5286,7 @@ sub _process_remaining_on_line($$$$)
         }
         # first is the arg.
         if ($brace_commands{$current->{'parent'}->{'cmdname'}}
-            and $brace_commands{$current->{'parent'}{'cmdname'}} =~ /^\d$/
-            and $brace_commands{$current->{'parent'}->{'cmdname'}} > 0
+            and $brace_commands{$current->{'parent'}{'cmdname'}} eq 'arguments'
             and $current->{'parent'}->{'cmdname'} ne 'math') {
           # @inline* always have end spaces considered as normal text
           _isolate_last_space($self, $current)
@@ -5299,7 +5297,7 @@ sub _process_remaining_on_line($$$$)
           if ($self->{'DEBUG'});
         delete $current->{'parent'}->{'remaining_args'};
         if (defined($brace_commands{$closed_command})
-             and $brace_commands{$closed_command} eq '0'
+             and $brace_commands{$closed_command} eq 'noarg'
              and $current->{'contents'}
              and @{$current->{'contents'}}) {
           $self->_line_warn(sprintf(__(
diff --git a/tp/Texinfo/XS/parsetexi/command_data.txt 
b/tp/Texinfo/XS/parsetexi/command_data.txt
index 74929f4847..b186abacb5 100644
--- a/tp/Texinfo/XS/parsetexi/command_data.txt
+++ b/tp/Texinfo/XS/parsetexi/command_data.txt
@@ -300,17 +300,17 @@ t                       brace                           
BRACE_style_code
 # No code style commands
 r                       brace                           BRACE_style_no_code
 
-U                       brace                           1
-dmn                     brace                           1
-titlefont               brace,global                    1
-hyphenation             brace,global                    1
-anchor                  brace                           1
-errormsg                brace                           1
-sortas                  brace                           1
-seeentry                brace                           1
-seealso                 brace                           1
-indicateurl             brace                           1
-key                     brace                           1
+U                       brace                           BRACE_arguments     1
+dmn                     brace                           BRACE_arguments     1
+titlefont               brace,global                    BRACE_arguments     1
+hyphenation             brace,global                    BRACE_arguments     1
+anchor                  brace                           BRACE_arguments     1
+errormsg                brace                           BRACE_arguments     1
+sortas                  brace                           BRACE_arguments     1
+seeentry                brace                           BRACE_arguments     1
+seealso                 brace                           BRACE_arguments     1
+indicateurl             brace                           BRACE_arguments     1
+key                     brace                           BRACE_arguments     1
 
 verb                    brace                           BRACE_other
 w                       brace                           BRACE_other
@@ -322,28 +322,28 @@ shortcaption            brace                           
BRACE_context
 math                    brace                           BRACE_context
 
 # explained commands
-abbr                    brace                           2
-acronym                 brace                           2
+abbr                    brace                           BRACE_arguments     2
+acronym                 brace                           BRACE_arguments     2
 
 # inline format command
-inlineraw               brace,inline                    2
-inlinefmt               brace,inline                    2
-inlinefmtifelse         brace,inline                    3
+inlineraw               brace,inline                    BRACE_arguments     2
+inlinefmt               brace,inline                    BRACE_arguments     2
+inlinefmtifelse         brace,inline                    BRACE_arguments     3
 
 # inline conditional commands
-inlineifclear           brace,inline                    2
-inlineifset             brace,inline                    2
+inlineifclear           brace,inline                    BRACE_arguments     2
+inlineifset             brace,inline                    BRACE_arguments     2
 
-email                   brace                           2
+email                   brace                           BRACE_arguments     2
 
-uref                    brace                           3
-url                     brace                           3
-inforef                 brace,ref,deprecated            3
+uref                    brace                           BRACE_arguments     3
+url                     brace                           BRACE_arguments     3
+inforef                 brace,ref,deprecated            BRACE_arguments     3
 
-xref                    brace,ref                       5
-ref                     brace,ref                       5
-pxref                   brace,ref                       5
-image                   brace                           5
+xref                    brace,ref                       BRACE_arguments     5
+ref                     brace,ref                       BRACE_arguments     5
+pxref                   brace,ref                       BRACE_arguments     5
+image                   brace                           BRACE_arguments     5
 
 
 ##########################################################
diff --git a/tp/Texinfo/XS/parsetexi/commands.h 
b/tp/Texinfo/XS/parsetexi/commands.h
index 86af60b323..58f2210c4b 100644
--- a/tp/Texinfo/XS/parsetexi/commands.h
+++ b/tp/Texinfo/XS/parsetexi/commands.h
@@ -116,6 +116,7 @@ void wipe_user_commands (void);
 #define BLOCK_variadic -5
 
 /* Types of brace command (CF_brace). */
+#define BRACE_arguments 1
 #define BRACE_noarg 0
 #define BRACE_context -1 /* Can enclose paragraph breaks. */
 #define BRACE_accent -2
diff --git a/tp/Texinfo/XS/parsetexi/handle_commands.c 
b/tp/Texinfo/XS/parsetexi/handle_commands.c
index 04ab4a3549..a23b1698f4 100644
--- a/tp/Texinfo/XS/parsetexi/handle_commands.c
+++ b/tp/Texinfo/XS/parsetexi/handle_commands.c
@@ -280,7 +280,7 @@ handle_line_command (ELEMENT *current, char **line_inout,
     }
 
   /* Look up information about this command ( skipline text 
-     line lineraw (a number) ). */
+     line lineraw specific ). */
   arg_spec = command_data(cmd).data;
 
   /* All the cases using the raw line.
diff --git a/tp/Texinfo/XS/parsetexi/separator.c 
b/tp/Texinfo/XS/parsetexi/separator.c
index a4256d9484..47fc44c1bc 100644
--- a/tp/Texinfo/XS/parsetexi/separator.c
+++ b/tp/Texinfo/XS/parsetexi/separator.c
@@ -37,7 +37,7 @@ handle_open_brace (ELEMENT *current, char **line_inout)
 
       command = current->cmd;
       counter_push (&count_remaining_args, current,
-                    command_data(current->cmd).data);
+                    command_data(current->cmd).args_number);
       counter_dec (&count_remaining_args);
 
       arg = new_element (ET_NONE);
@@ -136,9 +136,8 @@ handle_open_brace (ELEMENT *current, char **line_inout)
         {
           current->type = ET_brace_command_arg;
 
-          /* Commands which are said to take a positive number of arguments
-             disregard leading and trailing whitespace. */
-          if (command_data(command).data > 0)
+          /* Commands that disregard leading and trailing whitespace. */
+          if (command_data(command).data == BRACE_arguments)
             {
               ELEMENT *e;
               e = new_element (ET_internal_spaces_before_argument);
@@ -249,7 +248,8 @@ handle_close_brace (ELEMENT *current, char **line_inout)
           else if (pop_context () != ct_brace_command)
             fatal ("context brace command context expected");
         }
-      else if (command_data(current->parent->cmd).data > 0)
+      /* determine if trailing spaces are ignored */
+      else if (command_data(current->parent->cmd).data == BRACE_arguments)
         {
           /* @inline* always have end spaces considered as normal text */
           if (!(command_flags(current->parent) & CF_inline))
@@ -261,7 +261,7 @@ handle_close_brace (ELEMENT *current, char **line_inout)
       counter_pop (&count_remaining_args);
 
       if (current->contents.number > 0
-          && command_data(closed_command).data == 0)
+          && command_data(closed_command).data == BRACE_noarg)
         line_warn ("command @%s does not accept arguments",
                    command_name(closed_command));
 



reply via email to

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