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 (_process_remaining_o


From: Patrice Dumas
Subject: branch master updated: * tp/Texinfo/ParserNonXS.pm (_process_remaining_on_line), tp/Texinfo/XS/parsetexi/parser.c (process_remaining_on_line): check the whole command name when checking for nested ignored @if* conditional block commands.
Date: Tue, 14 Feb 2023 18:31:50 -0500

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 be0d16fbf6 * tp/Texinfo/ParserNonXS.pm (_process_remaining_on_line), 
tp/Texinfo/XS/parsetexi/parser.c (process_remaining_on_line): check the whole 
command name when checking for nested ignored @if* conditional block commands.
be0d16fbf6 is described below

commit be0d16fbf6ba68cbbf29bf7cd30d46e40b6d7546
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Wed Feb 15 00:31:40 2023 +0100

    * tp/Texinfo/ParserNonXS.pm (_process_remaining_on_line),
    tp/Texinfo/XS/parsetexi/parser.c (process_remaining_on_line): check
    the whole command name when checking for nested ignored @if*
    conditional block commands.
    
    * tp/Makefile.tres, tp/t/55conditionals.t: add
    nested_ifset_prepended_to_command_name test.
---
 ChangeLog                                          |  10 ++
 tp/Makefile.tres                                   |   1 +
 tp/TODO                                            |   2 -
 tp/Texinfo/ParserNonXS.pm                          |   5 +-
 tp/Texinfo/XS/parsetexi/parser.c                   |  28 +++--
 tp/t/55conditionals.t                              |   7 ++
 .../nested_ifset_prepended_to_command_name.pl      | 122 +++++++++++++++++++++
 7 files changed, 161 insertions(+), 14 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 20ccce15fd..faeaf32fdd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2023-02-14  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/Texinfo/ParserNonXS.pm (_process_remaining_on_line),
+       tp/Texinfo/XS/parsetexi/parser.c (process_remaining_on_line): check
+       the whole command name when checking for nested ignored @if*
+       conditional block commands.
+
+       * tp/Makefile.tres, tp/t/55conditionals.t: add
+       nested_ifset_prepended_to_command_name test.
+
 2023-02-14  Patrice Dumas  <pertusus@free.fr>
 
        * tp/Texinfo/ParserNonXS.pm (_process_remaining_on_line),
diff --git a/tp/Makefile.tres b/tp/Makefile.tres
index 970dd04c38..de599f2819 100644
--- a/tp/Makefile.tres
+++ b/tp/Makefile.tres
@@ -127,6 +127,7 @@ test_files_generated_list = 
$(test_tap_files_generated_list) \
   t/results/conditionals/macro_in_ifset_set.pl \
   t/results/conditionals/many_conditionals.pl \
   t/results/conditionals/nested_ifset_ifclear.pl \
+  t/results/conditionals/nested_ifset_prepended_to_command_name.pl \
   t/results/conditionals/nested_ignore.pl \
   t/results/conditionals/nested_ignore_comment_no_eol.pl \
   t/results/conditionals/nested_ignore_with_comments.pl \
diff --git a/tp/TODO b/tp/TODO
index 25f7ed234f..907f03eee3 100644
--- a/tp/TODO
+++ b/tp/TODO
@@ -17,8 +17,6 @@ the line corresponding to @set anothervar, at:
 @conditionals{}
 and not in the following empty line.
 
-check @ifsettoto in nested ignored conditionals, the XS parser is probably 
fooled.
-
 Bugs
 ====
 
diff --git a/tp/Texinfo/ParserNonXS.pm b/tp/Texinfo/ParserNonXS.pm
index bab9707ace..f035d22492 100644
--- a/tp/Texinfo/ParserNonXS.pm
+++ b/tp/Texinfo/ParserNonXS.pm
@@ -4966,12 +4966,13 @@ sub _process_remaining_on_line($$$$)
       and $block_commands{$current->{'cmdname'}}
       and ($block_commands{$current->{'cmdname'}} eq 'conditional')) {
     # check for nested @ifset (so that @end ifset doesn't end the
-    # outermost @ifset).  It is discarded when the outermost is.
+    # outermost @ifset).
     if (($current->{'cmdname'} eq 'ifclear'
          or $current->{'cmdname'} eq 'ifset'
          or $current->{'cmdname'} eq 'ifcommanddefined'
          or $current->{'cmdname'} eq 'ifcommandnotdefined')
-        and $line =~ /^\s*\@$current->{'cmdname'}/) {
+        and ($line =~ /^\s*\@([a-zA-Z][\w-]*)/
+             and ($1 eq $current->{'cmdname'}))) {
       push @{$current->{'contents'}}, { 'cmdname' => $current->{'cmdname'},
                                         'parent' => $current,
                                       };
diff --git a/tp/Texinfo/XS/parsetexi/parser.c b/tp/Texinfo/XS/parsetexi/parser.c
index dd95b23bec..77f3db6ecb 100644
--- a/tp/Texinfo/XS/parsetexi/parser.c
+++ b/tp/Texinfo/XS/parsetexi/parser.c
@@ -1422,23 +1422,31 @@ process_remaining_on_line (ELEMENT **current_inout, 
char **line_inout)
       char *p = line;
 
       /* check for nested @ifset (so that @end ifset doesn't end the
-         the outermost @ifset).  It is discarded when the outermost is.*/
+         the outermost @ifset). */
       if (current->cmd == CM_ifclear || current->cmd == CM_ifset
           || current->cmd == CM_ifcommanddefined
           || current->cmd == CM_ifcommandnotdefined)
         {
           ELEMENT *e;
           p += strspn (p, whitespace_chars);
-          if (*p == '@'
-              && !strncmp (p + 1, command_name(current->cmd),
-                           strlen (command_name(current->cmd))))
+          if (*p == '@')
             {
-              e = new_element (ET_NONE);
-              e->cmd = current->cmd;
-              add_to_element_contents (current, e);
-              current = e;
-              retval = GET_A_NEW_LINE;
-              goto funexit;
+              p++;
+              char *command = read_command_name (&p);
+              if (command)
+                {
+                  cmd = lookup_command (command);
+                  free (command);
+                  if (cmd == current->cmd)
+                    {
+                      e = new_element (ET_NONE);
+                      e->cmd = current->cmd;
+                      add_to_element_contents (current, e);
+                      current = e;
+                      retval = GET_A_NEW_LINE;
+                      goto funexit;
+                    }
+                }
             }
         }
 
diff --git a/tp/t/55conditionals.t b/tp/t/55conditionals.t
index 9049c50b0d..f1dac82f13 100644
--- a/tp/t/55conditionals.t
+++ b/tp/t/55conditionals.t
@@ -373,6 +373,13 @@ text
 @end verbatim
 @end ifset
 '],
+['nested_ifset_prepended_to_command_name',
+'@ifset a
+@ifsettoto b
+GG
+@end ifset
+@end ifset
+'],
 ['macro_in_ifset',
 '
 @macro truc {}
diff --git 
a/tp/t/results/conditionals/nested_ifset_prepended_to_command_name.pl 
b/tp/t/results/conditionals/nested_ifset_prepended_to_command_name.pl
new file mode 100644
index 0000000000..5b3fd5c57c
--- /dev/null
+++ b/tp/t/results/conditionals/nested_ifset_prepended_to_command_name.pl
@@ -0,0 +1,122 @@
+use vars qw(%result_texis %result_texts %result_trees %result_errors 
+   %result_indices %result_sectioning %result_nodes %result_menus
+   %result_floats %result_converted %result_converted_errors 
+   %result_elements %result_directions_text %result_indices_sort_strings);
+
+use utf8;
+
+$result_trees{'nested_ifset_prepended_to_command_name'} = {
+  'contents' => [
+    {
+      'contents' => [
+        {
+          'source_marks' => [
+            {
+              'counter' => 1,
+              'element' => {
+                'args' => [
+                  {
+                    'contents' => [
+                      {
+                        'text' => 'a'
+                      }
+                    ],
+                    'info' => {
+                      'spaces_after_argument' => {
+                        'text' => '
+'
+                      }
+                    },
+                    'type' => 'block_line_arg'
+                  }
+                ],
+                'cmdname' => 'ifset',
+                'contents' => [
+                  {
+                    'text' => '@ifsettoto b
+',
+                    'type' => 'raw'
+                  },
+                  {
+                    'text' => 'GG
+',
+                    'type' => 'raw'
+                  },
+                  {
+                    'args' => [
+                      {
+                        'contents' => [
+                          {
+                            'text' => 'ifset'
+                          }
+                        ],
+                        'info' => {
+                          'spaces_after_argument' => {
+                            'text' => '
+'
+                          }
+                        },
+                        'type' => 'line_arg'
+                      }
+                    ],
+                    'cmdname' => 'end',
+                    'extra' => {
+                      'text_arg' => 'ifset'
+                    },
+                    'info' => {
+                      'spaces_before_argument' => {
+                        'text' => ' '
+                      }
+                    },
+                    'source_info' => {
+                      'file_name' => '',
+                      'line_nr' => 4,
+                      'macro' => ''
+                    }
+                  }
+                ],
+                'info' => {
+                  'spaces_before_argument' => {
+                    'text' => ' '
+                  }
+                },
+                'source_info' => {
+                  'file_name' => '',
+                  'line_nr' => 1,
+                  'macro' => ''
+                }
+              },
+              'sourcemark_type' => 'ignored_conditional_block'
+            }
+          ],
+          'text' => ''
+        }
+      ],
+      'type' => 'before_node_section'
+    }
+  ],
+  'type' => 'document_root'
+};
+
+$result_texis{'nested_ifset_prepended_to_command_name'} = '';
+
+
+$result_texts{'nested_ifset_prepended_to_command_name'} = '';
+
+$result_errors{'nested_ifset_prepended_to_command_name'} = [
+  {
+    'error_line' => 'unmatched `@end ifset\'
+',
+    'file_name' => '',
+    'line_nr' => 5,
+    'macro' => '',
+    'text' => 'unmatched `@end ifset\'',
+    'type' => 'error'
+  }
+];
+
+
+$result_floats{'nested_ifset_prepended_to_command_name'} = {};
+
+
+1;



reply via email to

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