bug-texinfo
[Top][All Lists]
Advanced

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

Re: Difference between XS and pure perl test results for source_info has


From: Patrice Dumas
Subject: Re: Difference between XS and pure perl test results for source_info hash
Date: Sun, 2 Apr 2023 13:46:01 +0200

On Sun, Apr 02, 2023 at 12:30:05PM +0100, Gavin Smith wrote:
> 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.

I think this is an old issue.

> 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.

Looks good to me.  The $source_info returned by _next_text is already
duplicated for this reason (I remember that it was not before), but more
duplication may still be needed.

> 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.

I think that the 'source_info' information is already only set on the
elements may need them, so I think it should be best to keep them as
they are now.

-- 
Pat



reply via email to

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