Open MayeulC opened 1 year ago
After testing some more, the issue comes from the following regex:
Which matches the wrong filename (capture group 3), as subfile.tex}
(including the curly bracket).
Including the curly bracket in the list of non-matching symbols seems to fix it, and it is highly unlikely to have this in a filename, especially when it comes to TeX source code, so I'll submit a PR.
I submitted a PR, but there is another issue (besides the error message that I should improve): \input{subfile.pgf}
won't work with a pgf
extension, weirdly (it works with other random extensions I tried). It displays the same error:
Use of uninitialized value $newfilepath in string eq at /usr/share/perl5/vendor_perl/Locale/Po4a/TeX.pm line 999.
po4a::tex: Cannot find main.tex with kpsewhich
I don't think I'll try to fix that one, I usually use the following snippet for including pgf
plots anyway:
\newcommand{\importpgf}[2]{% see https://tex.stackexchange.com/a/640884 include from subfolders with \importpgf{figures/path}{img}
\tikzsetnextfilename{pgf-#2}%
\begin{tikzpicture}%
\node[inner sep=0pt] {\import{#1}{#2.pgf}};
\end{tikzpicture}
}
Maybe the following patch fixes the confusing "Use of uninitialized value" part of the error message? Not tested at all.
--- a/lib/Locale/Po4a/TeX.pm
+++ b/lib/Locale/Po4a/TeX.pm
@@ -993,7 +993,7 @@ sub read_file {
# search the file
open( KPSEA, "kpsewhich " . $newfilename . " |" );
- my $newfilepath = <KPSEA>;
+ my $newfilepath = <KPSEA> // ""; # Use an empty string if the content is undef
if ( $newfilename ne "" and $newfilepath eq "" ) {
die wrap_mod( "po4a::tex", dgettext( "po4a", "Cannot find %s with kpsewhich" ), $filename );
Possibly, I'll try that, thank you. It's my first time touching Perl code, though I am comfortable enough with regexes (and... they aren't the best tool for parsers).
I was thinking of checking if it was undef, and displaying an error message containing $newfilename
instead of $filename
because that's much more useful for the user.
Actually, maybe that's an oversight in the die
expression below, and it should read something like "Cannot find %s with kpsewhich, included from %s" ), $newfilename, $filename )
(not sure if multiple arguments need to be specified separately or in an array edit: tested, works as-is).
Edit: I suggest doing both. Your suggestion is very good, it avoids the confusing "Use of uninitialized value", I tested it and it works.
However, the current message is still misleading, as it is not $filename
that cannot be found, but $newfilename
. Hence why I also suggest rewording the message. I may submit another PR later if you want, but feel free to do so :)
You should post new messages, not edit the old ones : I don't get any notification per email when you edit your messages ;)
If you can prepare a PR, it'd be really appreciated as I'm somewhat overloaded these days. If not, I'll eventually do it at some point, but I feel less confident because testing po4a on latex is not 100% trivial for me right now.
You should post new messages, not edit the old ones : I don't get any notification per email when you edit your messages ;)
Okay, I'll do that :)
I have a bit more time these days, I'll try to send another PR for the error message when I can.
Minimal reproducer (
main.tex
, with at least an emptysubfile.tex
next to it):See that
\input
is surrounded by curly braces. Compilation fails when that is the case, and succeeds otherwise. As to why I need this: I use multipletikzpicture
graphs insubcaptionbox
that I input from other files.This is the (confusing) error:
Even more confusingly, the exact same error is displayed when
subfile.tex
does not exist (with or without curly braces), and complains that the parent file cannot be found, while it's the included file that does not exist.