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 (%line_commands), tp/Texin


From: Patrice Dumas
Subject: branch master updated: * tp/Texinfo/Common.pm (%line_commands), tp/Texinfo/Convert/DocBook.pm (_convert), tp/Texinfo/Convert/TexinfoMarkup.pm (_convert), tp/Texinfo/ParserNonXS.pm (_end_line), tp/Texinfo/XS/parsetexi/command_data.txt, tp/Texinfo/XS/parsetexi/end_line.c (end_line_misc_line), tp/Texinfo/XS/parsetexi/parser.c (check_valid_nesting): use a new type for command line, 'specific' for line @-commands with specific args, such as @printindex, @alias... that had previously a positive number as type.
Date: Sun, 25 Sep 2022 13:21:16 -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 4072525543 * tp/Texinfo/Common.pm (%line_commands), 
tp/Texinfo/Convert/DocBook.pm (_convert), tp/Texinfo/Convert/TexinfoMarkup.pm 
(_convert), tp/Texinfo/ParserNonXS.pm (_end_line), 
tp/Texinfo/XS/parsetexi/command_data.txt, tp/Texinfo/XS/parsetexi/end_line.c 
(end_line_misc_line), tp/Texinfo/XS/parsetexi/parser.c (check_valid_nesting): 
use a new type for command line, 'specific' for line @-commands with specific 
args, such as @printindex, @alias... that had previously a positive nu [...]
4072525543 is described below

commit 40725255437fb36eba32a5bae2ba19a5c3f3716d
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sun Sep 25 19:21:02 2022 +0200

    * tp/Texinfo/Common.pm (%line_commands), tp/Texinfo/Convert/DocBook.pm
    (_convert), tp/Texinfo/Convert/TexinfoMarkup.pm (_convert),
    tp/Texinfo/ParserNonXS.pm (_end_line),
    tp/Texinfo/XS/parsetexi/command_data.txt,
    tp/Texinfo/XS/parsetexi/end_line.c (end_line_misc_line),
    tp/Texinfo/XS/parsetexi/parser.c (check_valid_nesting): use
    a new type for command line, 'specific' for line @-commands with
    specific args, such as @printindex, @alias... that had previously
    a positive number as type.
    
    * tp/Texinfo/XS/parsetexi/handle_commands.c (handle_block_command):
    use args_number.
    
    * tp/Texinfo/XS/parsetexi/end_line.c (end_line_starting_block),
    tp/Texinfo/XS/parsetexi/parser.c (check_valid_nesting):
    use BRACE_noarg instead of 0.
    
    * tp/Texinfo/XS/parsetexi/commands.c (add_texinfo_command),
    tp/Texinfo/XS/parsetexi/end_line.c (parse_line_command_args): set
    args_number for user defined commands.
---
 ChangeLog                                 | 23 +++++++++++
 tp/Texinfo/Common.pm                      | 66 +++++++++++++++----------------
 tp/Texinfo/Convert/DocBook.pm             |  2 +-
 tp/Texinfo/Convert/TexinfoMarkup.pm       |  3 +-
 tp/Texinfo/ParserNonXS.pm                 |  4 +-
 tp/Texinfo/XS/parsetexi/command_data.txt  | 66 ++++++++++++++++---------------
 tp/Texinfo/XS/parsetexi/commands.c        |  1 +
 tp/Texinfo/XS/parsetexi/commands.h        |  1 +
 tp/Texinfo/XS/parsetexi/end_line.c        |  7 +++-
 tp/Texinfo/XS/parsetexi/handle_commands.c |  4 +-
 tp/Texinfo/XS/parsetexi/parser.c          |  4 +-
 11 files changed, 106 insertions(+), 75 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 2a80eca9b3..960fcea10a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,26 @@
+2022-09-25  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/Texinfo/Common.pm (%line_commands), tp/Texinfo/Convert/DocBook.pm
+       (_convert), tp/Texinfo/Convert/TexinfoMarkup.pm (_convert),
+       tp/Texinfo/ParserNonXS.pm (_end_line),
+       tp/Texinfo/XS/parsetexi/command_data.txt,
+       tp/Texinfo/XS/parsetexi/end_line.c (end_line_misc_line),
+       tp/Texinfo/XS/parsetexi/parser.c (check_valid_nesting): use
+       a new type for command line, 'specific' for line @-commands with
+       specific args, such as @printindex, @alias... that had previously
+       a positive number as type.
+
+       * tp/Texinfo/XS/parsetexi/handle_commands.c (handle_block_command):
+       use args_number.
+       
+       * tp/Texinfo/XS/parsetexi/end_line.c (end_line_starting_block),
+       tp/Texinfo/XS/parsetexi/parser.c (check_valid_nesting):
+       use BRACE_noarg instead of 0.
+
+       * tp/Texinfo/XS/parsetexi/commands.c (add_texinfo_command),
+       tp/Texinfo/XS/parsetexi/end_line.c (parse_line_command_args): set
+       args_number for user defined commands.
+
 2022-09-25  Patrice Dumas  <pertusus@free.fr>
 
        * tp/Texinfo/XS/parsetexi/command_data.awk,
diff --git a/tp/Texinfo/Common.pm b/tp/Texinfo/Common.pm
index 4446ba5c34..ea57ca872e 100644
--- a/tp/Texinfo/Common.pm
+++ b/tp/Texinfo/Common.pm
@@ -527,10 +527,10 @@ our %line_commands = (
   'comment'           => 'lineraw',
   'c'                 => 'lineraw',
   # special
-  'definfoenclose'    => 3,
-  'alias'             => 2,
+  'definfoenclose'    => 'specific', # 3
+  'alias'             => 'specific', # 2
   # number of arguments is not known in advance.
-  'columnfractions'   => 1,
+  'columnfractions'   => 'specific',
   # file names
   'setfilename'       => 'text',
   'verbatiminclude'   => 'text',
@@ -544,63 +544,63 @@ our %line_commands = (
   'insertcopying'     => 'skipline', # no arg
   'clickstyle'        => 'special', # arg should be an @-command
   # more relevant in preamble
-  'documentencoding'  => 'text', # or 1?
+  'documentencoding'  => 'text', # or 'specific'?
   'novalidate'        => 'skipline', # no arg
   'dircategory'       => 'line', # line. Position with regard
                                  # with direntry is significant
   'pagesizes'         => 'line', # can have 2 args
                            # or one? 200mm,150mm 11.5in
   'finalout'          => 'skipline', # no arg
-  'paragraphindent'   => 1, # arg none asis
+  'paragraphindent'   => 'specific', # 1: arg none asis
                        # or a number and forbids anything else on the line
-  'firstparagraphindent' => 1, # none insert
-  'frenchspacing'     => 1, # on off
-  'codequoteundirected'       => 1, # on off
-  'codequotebacktick'         => 1, # on off
-  'xrefautomaticsectiontitle' => 1, # on off
-  'deftypefnnewline'  => 1, # on off
-  'microtype'         => 1, # on off
-  'fonttextsize'      => 1, # 10 11
-  'allowcodebreaks'   => 1, # false or true
-  'exampleindent'     => 1, # asis or a number
-  'footnotestyle'     => 1, # end and separate, nothing else on the line
-  'urefbreakstyle'    => 1, # after|before|none
+  'firstparagraphindent' => 'specific', # 1: none insert
+  'frenchspacing'     => 'specific', # 1: on off
+  'codequoteundirected'       => 'specific', # 1: on off
+  'codequotebacktick'         => 'specific', # 1: on off
+  'xrefautomaticsectiontitle' => 'specific', # 1: on off
+  'deftypefnnewline'  => 'specific', # 1: on off
+  'microtype'         => 'specific', # 1: on off
+  'fonttextsize'      => 'specific', # 1: 10 11
+  'allowcodebreaks'   => 'specific', # 1: false or true
+  'exampleindent'     => 'specific', # 1: asis or a number
+  'footnotestyle'     => 'specific', # 1: end and separate, nothing else on 
the line
+  'urefbreakstyle'    => 'specific', # 1: after|before|none
   'smallbook'         => 'skipline', # no arg
   'afourpaper'        => 'skipline', # no arg
   'afivepaper'        => 'skipline', # no arg
   'afourlatex'        => 'skipline', # no arg
   'afourwide'         => 'skipline', # no arg
   'bsixpaper'         => 'skipline', # no arg
-  'headings'          => 1, #off on single double singleafter doubleafter
+  'headings'          => 'specific', # 1: off on single double singleafter 
doubleafter
                             # interacts with setchapternewpage
-  'setchapternewpage' => 1, # off on odd
+  'setchapternewpage' => 'specific', # 1: off on odd
 
-  'syncodeindex'      => 2,   # args are index identifiers
-  'synindex'          => 2,
-  'defindex'          => 1, # one identifier arg
-  'defcodeindex'      => 1, # one identifier arg
+  'syncodeindex'      => 'specific', # 2: args are index identifiers
+  'synindex'          => 'specific', # 2
+  'defindex'          => 'specific', # 1: one identifier arg
+  'defcodeindex'      => 'specific', # 1: one identifier arg
   'documentlanguage'  => 'text',     # language code arg
-  'kbdinputstyle'     => 1,          # code example distinct
-  'everyheadingmarks' => 1, # top bottom
-  'everyfootingmarks' => 1,
-  'evenheadingmarks'  => 1,
-  'oddheadingmarks'   => 1,
-  'evenfootingmarks'  => 1,
-  'oddfootingmarks'   => 1,
+  'kbdinputstyle'     => 'specific', # 1: code example distinct
+  'everyheadingmarks' => 'specific', # 1: top bottom
+  'everyfootingmarks' => 'specific', # 1:
+  'evenheadingmarks'  => 'specific', # 1:
+  'oddheadingmarks'   => 'specific', # 1:
+  'evenfootingmarks'  => 'specific', # 1:
+  'oddfootingmarks'   => 'specific', # 1:
   'shorttitlepage'    => 'line',
   'settitle'          => 'line',
 
   # formatting
   'center'            => 'line',
-  'printindex'        => 1,
+  'printindex'        => 'specific', # 1:
   'listoffloats'      => 'line',
   # especially in titlepage
   'author'            => 'line',
   'subtitle'          => 'line',
   'title'             => 'line',
-  'sp'                => 1, # numerical arg
+  'sp'                => 'specific', # 1: numerical arg
   'page'              => 'skipline', # no arg (pagebreak)
-  'need'              => 1, # one numerical/real arg
+  'need'              => 'specific', # 1: one numerical/real arg
   # formatting
   'exdent'            => 'line',
   'item'              => 'line', # or skipspace, depending on the context
diff --git a/tp/Texinfo/Convert/DocBook.pm b/tp/Texinfo/Convert/DocBook.pm
index c424df575d..9713b58294 100644
--- a/tp/Texinfo/Convert/DocBook.pm
+++ b/tp/Texinfo/Convert/DocBook.pm
@@ -956,7 +956,7 @@ sub _convert($$;$)
         }
       } else {
         $self->present_bug_message("unknown misc_command style $type", 
$element)
-          if ($type !~ /^\d$/);
+          if ($type ne 'specific');
         if ($element->{'cmdname'} eq 'printindex') {
           if (defined($element->{'extra'})
               and defined($element->{'extra'}->{'misc_args'})) {
diff --git a/tp/Texinfo/Convert/TexinfoMarkup.pm 
b/tp/Texinfo/Convert/TexinfoMarkup.pm
index c3905d5cb7..f142efcecb 100644
--- a/tp/Texinfo/Convert/TexinfoMarkup.pm
+++ b/tp/Texinfo/Convert/TexinfoMarkup.pm
@@ -905,7 +905,8 @@ sub _convert($$;$)
                     .$self->txi_markup_close_element($cmdname)."\n";
         }
       } else {
-        print STDERR "BUG: unknown misc_command style $type\n" if ($type !~ 
/^\d$/);
+        print STDERR "BUG: unknown misc_command style $type\n"
+           if ($type ne 'specific');
         my $args_attributes;
         if ($misc_command_numbered_arguments_attributes{$cmdname}) {
           $args_attributes = 
$misc_command_numbered_arguments_attributes{$cmdname};
diff --git a/tp/Texinfo/ParserNonXS.pm b/tp/Texinfo/ParserNonXS.pm
index ed5cf91f7e..e31ec43fbb 100644
--- a/tp/Texinfo/ParserNonXS.pm
+++ b/tp/Texinfo/ParserNonXS.pm
@@ -438,7 +438,7 @@ foreach my $in_full_text_no_in_simple_text 
(keys(%in_heading_commands)) {
 # commands that only accept simple text as argument in any context.
 my %simple_text_commands;
 foreach my $line_command(keys(%line_commands)) {
-  if ($line_commands{$line_command} =~ /^\d+$/
+  if ($line_commands{$line_command} eq 'specific'
       or ($line_commands{$line_command} eq 'line'
           and !($sectioning_heading_commands{$line_command}
                 or $def_commands{$line_command}
@@ -3219,7 +3219,7 @@ sub _end_line($$$)
     print STDERR "MISC END \@$command: $self->{'line_commands'}->{$command}\n"
        if ($self->{'DEBUG'});
 
-    if ($self->{'line_commands'}->{$command} =~ /^\d$/) {
+    if ($self->{'line_commands'}->{$command} eq 'specific') {
       my $args = _parse_line_command_args($self, $current, $source_info);
       $current->{'extra'}->{'misc_args'} = $args if (defined($args));
     } elsif ($self->{'line_commands'}->{$command} eq 'text') {
diff --git a/tp/Texinfo/XS/parsetexi/command_data.txt 
b/tp/Texinfo/XS/parsetexi/command_data.txt
index 3284e88789..74929f4847 100644
--- a/tp/Texinfo/XS/parsetexi/command_data.txt
+++ b/tp/Texinfo/XS/parsetexi/command_data.txt
@@ -48,6 +48,8 @@ txiinternalvalue        brace
 # line commands
 #
 ##########################################################
+# line commands number of arguments is only set for LINE_specific commands
+# and is not used anywhere in the code, it is here as documentation only
 node                    line                            LINE_line
 bye                     line                            LINE_skipline
 end                     line                            LINE_text
@@ -59,10 +61,10 @@ unmacro                 line                            
LINE_special
 c                       line                            LINE_lineraw
 comment                 line                            LINE_lineraw
 # special
-definfoenclose          line,deprecated                 3
-alias                   line                            2
+definfoenclose          line,deprecated                 LINE_specific  3
+alias                   line                            LINE_specific  2
 # number of arguments is not known in advance.
-columnfractions         line                            1
+columnfractions         line                            LINE_specific
 # file names
 setfilename             line,global_unique              LINE_text
 verbatiminclude         line                            LINE_text
@@ -83,28 +85,28 @@ dircategory             line                            
LINE_line
 pagesizes               line,global_unique              LINE_line
 # or one? 200mm,150mm 11.5in
 finalout                line                            LINE_skipline
-paragraphindent         line,global                     1
+paragraphindent         line,global                     LINE_specific  1
 # or a number and forbids anything else on the line
-firstparagraphindent    line,global                     1
-frenchspacing           line,global                     1
-codequoteundirected     line,global                     1
-codequotebacktick       line,global                     1
-xrefautomaticsectiontitle line,global                   1
-deftypefnnewline        line,global                     1
-fonttextsize            line,global_unique              1
-allowcodebreaks         line,global                     1
-exampleindent           line,global                     1
-footnotestyle           line,global_unique              1
-urefbreakstyle          line,global                     1
+firstparagraphindent    line,global                     LINE_specific  1
+frenchspacing           line,global                     LINE_specific  1
+codequoteundirected     line,global                     LINE_specific  1
+codequotebacktick       line,global                     LINE_specific  1
+xrefautomaticsectiontitle line,global                   LINE_specific  1
+deftypefnnewline        line,global                     LINE_specific  1
+fonttextsize            line,global_unique              LINE_specific  1
+allowcodebreaks         line,global                     LINE_specific  1
+exampleindent           line,global                     LINE_specific  1
+footnotestyle           line,global_unique              LINE_specific  1
+urefbreakstyle          line,global                     LINE_specific  1
 smallbook               line,global_unique              LINE_skipline
 afourpaper              line,global_unique              LINE_skipline
 afivepaper              line,global_unique              LINE_skipline
 afourlatex              line,global_unique              LINE_skipline
 afourwide               line,global_unique              LINE_skipline
 bsixpaper               line,global_unique              LINE_skipline
-headings                line,global                     1
-setchapternewpage       line,global_unique              1
-microtype               line,global                     1
+headings                line,global                     LINE_specific  1
+setchapternewpage       line,global_unique              LINE_specific  1
+microtype               line,global                     LINE_specific  1
 
 everyheading            line,global                     LINE_heading_spec
 everyfooting            line,global                     LINE_heading_spec
@@ -113,22 +115,22 @@ evenfooting             line,global                     
LINE_heading_spec
 oddheading              line,global                     LINE_heading_spec
 oddfooting              line,global                     LINE_heading_spec
 
-syncodeindex            line                            2
-synindex                line                            2
-defindex                line                            1
-defcodeindex            line                            1
+syncodeindex            line                            LINE_specific  2
+synindex                line                            LINE_specific  2
+defindex                line                            LINE_specific  1
+defcodeindex            line                            LINE_specific  1
 documentlanguage        line,global                     LINE_text
-kbdinputstyle           line,global                     1
-everyheadingmarks       line,global_unique              1
-everyfootingmarks       line,global_unique              1
-evenheadingmarks        line,global_unique              1
-oddheadingmarks         line,global_unique              1
-evenfootingmarks        line,global_unique              1
-oddfootingmarks         line,global_unique              1
+kbdinputstyle           line,global                     LINE_specific  1
+everyheadingmarks       line,global_unique              LINE_specific  1
+everyfootingmarks       line,global_unique              LINE_specific  1
+evenheadingmarks        line,global_unique              LINE_specific  1
+oddheadingmarks         line,global_unique              LINE_specific  1
+evenfootingmarks        line,global_unique              LINE_specific  1
+oddfootingmarks         line,global_unique              LINE_specific  1
 
 # formatting
 center                  line                            LINE_line
-printindex              line,global                     1
+printindex              line,global                     LINE_specific  1
 listoffloats            line,global                     LINE_line
 # especially in titlepage
 #  shorttitle
@@ -137,9 +139,9 @@ settitle                line,global_unique              
LINE_line
 author                  line,global                     LINE_line
 subtitle                line,global                     LINE_line
 title                   line,global_unique              LINE_line
-sp                      line                            1
+sp                      line                            LINE_specific  1
 page                    line                            LINE_skipline
-need                    line                            1
+need                    line                            LINE_specific  1
 
 # not valid for info (should be in @iftex)
 vskip                   line                            LINE_lineraw
diff --git a/tp/Texinfo/XS/parsetexi/commands.c 
b/tp/Texinfo/XS/parsetexi/commands.c
index 4a6c06b711..ef1c2dfbe2 100644
--- a/tp/Texinfo/XS/parsetexi/commands.c
+++ b/tp/Texinfo/XS/parsetexi/commands.c
@@ -107,6 +107,7 @@ add_texinfo_command (char *name)
   user_defined_command_data[user_defined_number].cmdname = strdup (name);
   user_defined_command_data[user_defined_number].flags = 0;
   user_defined_command_data[user_defined_number].data = 0;
+  user_defined_command_data[user_defined_number].args_number = 0;
 
   return ((enum command_id) user_defined_number++) | USER_COMMAND_BIT;
 }
diff --git a/tp/Texinfo/XS/parsetexi/commands.h 
b/tp/Texinfo/XS/parsetexi/commands.h
index 960253d5d8..86af60b323 100644
--- a/tp/Texinfo/XS/parsetexi/commands.h
+++ b/tp/Texinfo/XS/parsetexi/commands.h
@@ -99,6 +99,7 @@ void wipe_user_commands (void);
 #define LINE_special -1
 #define LINE_lineraw -2
 #define LINE_skipline -3
+#define LINE_specific -4
 #define LINE_text -6
 #define LINE_line -7
 #define LINE_heading_spec -8
diff --git a/tp/Texinfo/XS/parsetexi/end_line.c 
b/tp/Texinfo/XS/parsetexi/end_line.c
index 16095f1b73..fbf181783b 100644
--- a/tp/Texinfo/XS/parsetexi/end_line.c
+++ b/tp/Texinfo/XS/parsetexi/end_line.c
@@ -364,6 +364,8 @@ parse_line_command_args (ELEMENT *line_command)
         user_defined_command_data[new_cmd].flags |= CF_ALIAS;
 
         user_defined_command_data[new_cmd].data = existing_cmd;
+        user_defined_command_data[new_cmd].args_number
+                  = command_data(existing_cmd).args_number;
         /* Note the data field is an int, existing_cmd is
            enum command_id, so would have problems if enum command_id
            were wider than an int. */
@@ -416,6 +418,7 @@ parse_line_command_args (ELEMENT *line_command)
         user_defined_command_data[new_cmd].flags
           |= (CF_INFOENCLOSE | CF_brace);
         user_defined_command_data[new_cmd].data = BRACE_style_other;
+        user_defined_command_data[new_cmd].args_number = 1;
 
         ADD_ARG(new_command); free (new_command);
         ADD_ARG(start); free (start);
@@ -1152,7 +1155,7 @@ end_line_starting_block (ELEMENT *current)
             {
               ELEMENT *e = k->value;
               if (!(command_flags(e) & CF_brace)
-                  || (command_data(e->cmd).data == 0))
+                  || (command_data(e->cmd).data == BRACE_noarg))
                 {
                   command_error (current,
                                  "command @%s not accepting argument in brace "
@@ -1317,7 +1320,7 @@ end_line_misc_line (ELEMENT *current)
 
   debug ("MISC END %s", command_name(cmd));
 
-  if (arg_type > 0)
+  if (arg_type == LINE_specific)
     {
       ELEMENT *args = parse_line_command_args (current);
       if (args)
diff --git a/tp/Texinfo/XS/parsetexi/handle_commands.c 
b/tp/Texinfo/XS/parsetexi/handle_commands.c
index 1f85f2f122..04ab4a3549 100644
--- a/tp/Texinfo/XS/parsetexi/handle_commands.c
+++ b/tp/Texinfo/XS/parsetexi/handle_commands.c
@@ -937,11 +937,11 @@ handle_block_command (ELEMENT *current, char **line_inout,
       bla = new_element (ET_block_line_arg);
       add_to_element_args (current, bla);
 
-      if (command_data (current->cmd).data > 1)
+      if (command_data (current->cmd).args_number > 1)
         {
           counter_push (&count_remaining_args,
                         current,
-                        command_data (current->cmd).data - 1);
+                        command_data (current->cmd).args_number - 1);
         }
       else if (command_data (current->cmd).data == BLOCK_variadic)
         {
diff --git a/tp/Texinfo/XS/parsetexi/parser.c b/tp/Texinfo/XS/parsetexi/parser.c
index 892e728b98..7505c75c69 100644
--- a/tp/Texinfo/XS/parsetexi/parser.c
+++ b/tp/Texinfo/XS/parsetexi/parser.c
@@ -920,7 +920,7 @@ check_valid_nesting (ELEMENT *current, enum command_id cmd)
   // much TODO here.
 
   if ((outer_flags & CF_line
-            && (command_data(outer).data >= 0
+            && (command_data(outer).data == LINE_specific
                 || (command_data(outer).data == LINE_line
                     && !(outer_flags & (CF_def | CF_sectioning)))
                 || command_data(outer).data == LINE_text
@@ -955,7 +955,7 @@ check_valid_nesting (ELEMENT *current, enum command_id cmd)
       if (cmd_flags & (CF_nobrace | CF_accent))
         ok = 1;
       else if (cmd_flags & CF_brace
-               && command_data(cmd).data == 0)
+               && command_data(cmd).data == BRACE_noarg)
         ok = 1; /* glyph command */
       if (cmd == CM_c || cmd == CM_comment)
         ok = 1;



reply via email to

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