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 (%contain_plain_text_comma


From: Patrice Dumas
Subject: branch master updated: * tp/Texinfo/Common.pm (%contain_plain_text_commands), tp/Texinfo/ParserNonXS.pm (%plain_text_commands), tp/Texinfo/XS/parsetexi/command_data.txt, tp/Texinfo/XS/parsetexi/commands.h, tp/Texinfo/XS/parsetexi/parser.c (check_valid_nesting): add a contain_plain_text flag/hash to warn if 'dmn', 'key', 'hyphenation', 'sortas' contain anything else than accent and glyph commands (similar as accent commands).
Date: Sun, 02 Oct 2022 07:41:17 -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 9e4390be17 * tp/Texinfo/Common.pm (%contain_plain_text_commands), 
tp/Texinfo/ParserNonXS.pm (%plain_text_commands), 
tp/Texinfo/XS/parsetexi/command_data.txt, tp/Texinfo/XS/parsetexi/commands.h, 
tp/Texinfo/XS/parsetexi/parser.c (check_valid_nesting): add a 
contain_plain_text flag/hash to warn if 'dmn', 'key', 'hyphenation', 'sortas' 
contain anything else than accent and glyph commands (similar as accent 
commands).
9e4390be17 is described below

commit 9e4390be1797276cbad83f136b79e455537275c0
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sun Oct 2 13:41:05 2022 +0200

    * tp/Texinfo/Common.pm (%contain_plain_text_commands),
    tp/Texinfo/ParserNonXS.pm (%plain_text_commands),
    tp/Texinfo/XS/parsetexi/command_data.txt,
    tp/Texinfo/XS/parsetexi/commands.h, tp/Texinfo/XS/parsetexi/parser.c
    (check_valid_nesting): add a contain_plain_text flag/hash to warn
    if 'dmn', 'key', 'hyphenation', 'sortas' contain anything else
    than accent and glyph commands (similar as accent commands).
---
 ChangeLog                                 | 10 ++++++++++
 tp/Texinfo/Common.pm                      | 10 +++++++---
 tp/Texinfo/ParserNonXS.pm                 | 14 ++++++++++++--
 tp/Texinfo/XS/parsetexi/command_data.txt  |  8 ++++----
 tp/Texinfo/XS/parsetexi/commands.h        |  5 ++---
 tp/Texinfo/XS/parsetexi/parser.c          |  5 +++--
 tp/t/results/indices/explicit_sort_key.pl |  9 +++++++++
 7 files changed, 47 insertions(+), 14 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 47dc318f70..00832a93da 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2022-10-02  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/Texinfo/Common.pm (%contain_plain_text_commands),
+       tp/Texinfo/ParserNonXS.pm (%plain_text_commands),
+       tp/Texinfo/XS/parsetexi/command_data.txt,
+       tp/Texinfo/XS/parsetexi/commands.h, tp/Texinfo/XS/parsetexi/parser.c
+       (check_valid_nesting): add a contain_plain_text flag/hash to warn
+       if 'dmn', 'key', 'hyphenation', 'sortas' contain anything else
+       than accent and glyph commands (similar as accent commands).
+
 2022-10-02  Patrice Dumas  <pertusus@free.fr>
 
         * tp/Texinfo/XS/parsetexi/command_data.txt,
diff --git a/tp/Texinfo/Common.pm b/tp/Texinfo/Common.pm
index 57ec339970..115ea72d49 100644
--- a/tp/Texinfo/Common.pm
+++ b/tp/Texinfo/Common.pm
@@ -746,9 +746,7 @@ foreach my $command ('code', 'command', 'env', 'file', 
'indicateurl', 'kbd',
   $brace_commands{$command} = 'style_code';
 }
 
-# FIXME Some commands should only contain text/accents and
-# could be checked for that: 'dmn', 'key', 'hyphenation', 'sortas'.
-# Some commands can contain @-commands, but not all, for example no @ref,
+# FIXME Some commands can contain @-commands, but not all, for example no @ref,
 # no @footnote: 'anchor', 'indicateurl', 'errormsg', 'seeentry', 'seealso'.
 # 'titlefont' may be less constrained.
 
@@ -760,6 +758,12 @@ foreach my $one_arg_command ('U', 'hyphenation',
   $commands_args_number{$one_arg_command} = 1;
 }
 
+# only accept plain text, ie only accent, symbol and glyph commands
+our %contain_plain_text_commands;
+foreach my $command ('dmn', 'key', 'hyphenation', 'sortas') {
+  $contain_plain_text_commands{$command} = 1;
+}
+
 # Leading and trailing spaces kept in main text.
 # verb is treated especially, it should not matter much in which category it 
is.
 # value also is treated especially.
diff --git a/tp/Texinfo/ParserNonXS.pm b/tp/Texinfo/ParserNonXS.pm
index b187939adb..683dccec28 100644
--- a/tp/Texinfo/ParserNonXS.pm
+++ b/tp/Texinfo/ParserNonXS.pm
@@ -268,6 +268,7 @@ my %brace_commands            = 
%Texinfo::Common::brace_commands;
 my %commands_args_number      = %Texinfo::Common::commands_args_number;
 my %accent_commands           = %Texinfo::Common::accent_commands;
 my %context_brace_commands    = %Texinfo::Common::context_brace_commands;
+my %contain_plain_text_commands = 
%Texinfo::Common::contain_plain_text_commands;
 my %block_commands            = %Texinfo::Common::block_commands;
 my %blockitem_commands        = %Texinfo::Common::blockitem_commands;
 my %close_paragraph_commands  = %Texinfo::Common::close_paragraph_commands;
@@ -442,6 +443,14 @@ foreach my $in_full_text_not_in_simple_text 
(keys(%in_heading_spec_commands)) {
 }
 
 
+# commands that only accept plain text, ie only accent, symbol and glyph 
commands
+my %plain_text_commands;
+
+foreach my $command (keys(%accent_commands),
+                     keys(%contain_plain_text_commands)) {
+  $plain_text_commands{$command} = 1;
+}
+
 # commands that only accept simple text as argument in any context.
 my %simple_text_commands;
 foreach my $line_command(keys(%line_commands)) {
@@ -464,7 +473,8 @@ delete $simple_text_commands{'center'};
 delete $simple_text_commands{'exdent'};
 
 foreach my $command (keys (%brace_commands)) {
-  if ($brace_commands{$command} eq 'arguments') {
+  if ($brace_commands{$command} eq 'arguments'
+      and not $contain_plain_text_commands{$command}) {
     $simple_text_commands{$command} = 1;
   }
 }
@@ -501,7 +511,7 @@ $full_line_commands{'itemx'} = 1;
 # Index entry commands are dynamically set as %in_simple_text_commands
 my %default_valid_nestings;
 
-foreach my $command (keys(%accent_commands)) {
+foreach my $command (keys(%plain_text_commands)) {
   $default_valid_nestings{$command} = \%in_plain_text_commands;
 }
 foreach my $command (keys(%simple_text_commands)) {
diff --git a/tp/Texinfo/XS/parsetexi/command_data.txt 
b/tp/Texinfo/XS/parsetexi/command_data.txt
index 5baf912371..de3a673677 100644
--- a/tp/Texinfo/XS/parsetexi/command_data.txt
+++ b/tp/Texinfo/XS/parsetexi/command_data.txt
@@ -294,7 +294,7 @@ env                     brace                           
BRACE_style_code
 file                    brace                           BRACE_style_code
 indicateurl             brace                           BRACE_style_code
 kbd                     brace                           BRACE_style_code
-key                     brace                           BRACE_style_code
+key                     brace,contain_plain_text        BRACE_style_code
 option                  brace                           BRACE_style_code
 samp                    brace                           BRACE_style_code
 t                       brace                           BRACE_style_code
@@ -303,10 +303,10 @@ t                       brace                           
BRACE_style_code
 r                       brace                           BRACE_style_no_code
 
 U                       brace                           BRACE_arguments     1
-hyphenation             brace,global                    BRACE_arguments     1
+hyphenation             brace,global,contain_plain_text BRACE_arguments     1
 anchor                  brace                           BRACE_arguments     1
 errormsg                brace                           BRACE_arguments     1
-sortas                  brace                           BRACE_arguments     1
+sortas                  brace,contain_plain_text        BRACE_arguments     1
 seeentry                brace                           BRACE_arguments     1
 seealso                 brace                           BRACE_arguments     1
 
@@ -315,7 +315,7 @@ verb                    brace                           
BRACE_special
 w                       brace                           BRACE_special
 
 # other brace commands, leading and trailing spaces not ignored
-dmn                     brace                           BRACE_other         1
+dmn                     brace,contain_plain_text        BRACE_other         1
 titlefont               brace,global                    BRACE_other         1
 
 # context brace commands - commands that enclose full texts
diff --git a/tp/Texinfo/XS/parsetexi/commands.h 
b/tp/Texinfo/XS/parsetexi/commands.h
index a0667ae7be..ac564e2053 100644
--- a/tp/Texinfo/XS/parsetexi/commands.h
+++ b/tp/Texinfo/XS/parsetexi/commands.h
@@ -71,10 +71,9 @@ void wipe_user_commands (void);
 #define CF_global                      0x00010000
 #define CF_def                         0x00020000
 #define CF_def_alias                   0x00040000
-/* CF_menu is not used */
-#define CF_menu                                0x00080000
+#define CF_contain_plain_text          0x00080000
 /* CF_align is not used, in Common */
-#define CF_align                       0x00100000
+#define CF_align                       0x00100000
 /* CF_other is not used */
 #define CF_other                       0x00200000
 #define CF_preformatted                        0x00400000
diff --git a/tp/Texinfo/XS/parsetexi/parser.c b/tp/Texinfo/XS/parsetexi/parser.c
index 77a0e74a42..45d30d06fb 100644
--- a/tp/Texinfo/XS/parsetexi/parser.c
+++ b/tp/Texinfo/XS/parsetexi/parser.c
@@ -931,7 +931,8 @@ check_valid_nesting (ELEMENT *current, enum command_id cmd)
             && outer != CM_center
             && outer != CM_exdent)
       || ((outer_flags & CF_brace)
-           && command_data(outer).data == BRACE_arguments)
+           && command_data(outer).data == BRACE_arguments
+           && !(outer_flags & CF_contain_plain_text))
       || outer == CM_shortcaption
       || outer == CM_math
       || (outer_flags & CF_index_entry_command)
@@ -952,7 +953,7 @@ check_valid_nesting (ELEMENT *current, enum command_id cmd)
            || outer == CM_itemx)
            && current->type != ET_line_arg)
     ok = 1;
-  else if (outer_flags & CF_accent)
+  else if (outer_flags & (CF_accent | CF_contain_plain_text))
     {
       if ((cmd_flags & CF_accent)
           || (cmd_flags & CF_nobrace
diff --git a/tp/t/results/indices/explicit_sort_key.pl 
b/tp/t/results/indices/explicit_sort_key.pl
index 98b81ab4f5..5f0d3e6e96 100644
--- a/tp/t/results/indices/explicit_sort_key.pl
+++ b/tp/t/results/indices/explicit_sort_key.pl
@@ -919,6 +919,15 @@ $result_errors{'explicit_sort_key'} = [
     'text' => '@sortas should only appear in an index entry',
     'type' => 'warning'
   },
+  {
+    'error_line' => 'warning: @b should not appear in @sortas
+',
+    'file_name' => '',
+    'line_nr' => 15,
+    'macro' => '',
+    'text' => '@b should not appear in @sortas',
+    'type' => 'warning'
+  },
   {
     'error_line' => 'warning: @sortas should only appear in an index entry
 ',



reply via email to

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