bug-texinfo
[Top][All Lists]
Advanced

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

Difference between XS and pure perl test results for source_info hash


From: Gavin Smith
Subject: Difference between XS and pure perl test results for source_info hash
Date: Sun, 2 Apr 2023 12:30:05 +0100

A difference shows up when the test results are regenerated with the
XS modules if they have been generated with the pure Perl modules:

diff --git a/tp/t/results/linemacro/nested_linemacro_calls.pl 
b/tp/t/results/linemacro/nested_linemacro_calls.pl
index 1ccd88ab8e..0fc191544e 100644
--- a/tp/t/results/linemacro/nested_linemacro_calls.pl
+++ b/tp/t/results/linemacro/nested_linemacro_calls.pl
@@ -336,7 +336,11 @@ $result_trees{'nested_linemacro_calls'} = {
                                         'text' => ' ( remaining, type typed )}'
                                       }
                                     ],
-                                    'source_info' => {},
+                                    'source_info' => {
+                                      'file_name' => '',
+                                      'line_nr' => 11,
+                                      'macro' => 'inside'
+                                    },
                                     'type' => 'balanced_braces'
                                   }
                                 ],

This does not cause a test failure, but is distracting when checking
results.

The problem is that the 'source_info' hash are being shared in
the pure Perl results, but not for the XS code, where a new hash
is created each time.

This problem occurs for input like

     @code{aa} @anchor{bb}

where the same source_info is used in two places on a single input line.

I don't remember if we ever had this problem before or how we dealt with
it.  Maybe it has just surfaced recently due to new tests being added.

One solution is to duplicate the hash:

--- a/tp/Texinfo/ParserNonXS.pm
+++ b/tp/Texinfo/ParserNonXS.pm
@@ -5679,7 +5679,7 @@ sub _handle_brace_command($$$$)
      if ($self->{'DEBUG'});
 
   my $command_e = { 'cmdname' => $command, 'parent' => $current,};
-  $command_e->{'source_info'} = $source_info;
+  $command_e->{'source_info'} = {%{$source_info}};
   push @{$current->{'contents'}}, $command_e;
   if ($in_index_commands{$command}
       and !_is_index_element($self, $current->{'parent'})) {

I'm going to try to do this.

Another option is to set 'source_info' on fewer tree elements, but
this may not work if error messages need to be output for elements
in output converters.



reply via email to

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