On Fri, Oct 31, 2025 at 09:04:46PM +0000, Gavin Smith wrote:
> On Fri, Oct 31, 2025 at 08:39:59PM +0000, Gavin Smith wrote:
> > I think this is a good idea. I can't remember if this issue has ever
> > come up before but I suspect it might have. I suspect there may have
> > been an issue with the test suite and getting consistent test results
> > but if so, that is something we should work around.
>
> So I can see the directories are stripped off in Texinfo/ParserNonXS.pm
> in _input_push_file. The directories are returned by the function but
> not stored in the input structure ($self->{'input'}).
'input_file_path', which is in $self->{'input'} should have the leading
path kept and could be used. Or 'input_source_info'->'file_name'
could be set to $input_file_path directly, maybe the best option.
> I checked the source code of Texinfo 5.2 and found the following in
> parse_texi_file in Texinfo/Parser.pm:
>
> my ($directories, $suffix);
> ($file_name, $directories, $suffix) = fileparse($file_name)
> if ($self->{'TEST'});
>
> There, the directories were only stripped off if "TEST" was set.
>
> Eventually I found the following ChangeLog entry:
>
> 2020-10-21 Gavin Smith <[email protected]>
>
> Remove TEST setting for parser
> (I had dimly remembered that this might have been a change I was
> responsible for.)
As a side note, there is a reference to TEST in the Perl Parser. For
some debugging code, but I will have a look nevertheless.
I think that avoiding to use TEST in the Parser is a good idea,
in any case.
> Unfortunately it will not be a quick change for me to revert as
> there has been a considerable amount of churn in the code since
> then (and most of it exists in at least 2 versions, both C and Perl),
> and I am now not very familiar with the code.
>
> I will slowly start looking at how this could be fixed in the coming days,
> but I will wait to see if Patrice has any suggestions first.
I see that in _output_error_messages in texi2any 'TEST' is checked, and
if set, fileparse is called. So it is possible that putting the full
path in the 'input_source_info'->'file_name' could be good. The code
for test that shows the source_info would also have to strip the leading
path to have reproducible tests, but it should not be an issue.
ndeed, it is already in the ocde, in Texinfo/ManipulateTree.pm, for
example, _print_element_source_info has a $use_filename argument, if
set, the leading path is stripped. If Data::Dumper is used, however,
the paths would not be reproducible. We do not use Data::Dumper much
nowadays, but we still use it for the representation of errors.
So, my proposal would be
* always keep the leading directories in source_info. This should be
the main place where the file names for error messages are kept, but
there could be others, for instance in HTML converter code when
parsing CSS files, I do not remember if source_info is used.
* replace Data::Dumper based representation of errors by a simpler text.
This makes sense independently of this issue as it is better to avoid
using Data::Dumper to have the same representation in Perl and C.
--
Pat