Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: decode the name of the backup file #439

Merged
merged 1 commit into from Apr 7, 2023

Conversation

valtterikantanen
Copy link
Contributor

what is this pull request about?

This pull request features a fix to a bug that occurs when working with LaTeX files whose names include characters with diacritics (e.g. å, ä, and ö that are used in Finnish and Swedish among many other languages).

does this relate to an existing issue?

No.

does this change any existing behaviour?

Yes.

what does this add?

When calling latexindent.pl with the -w flag, latexindent.pl will make a copy of the original file before overwriting it. However, if the file path contains characters with diacritics, latexindent.pl will not work, instead it prints an error message. For example, create a directory called äö and add a LaTeX file called äö.tex inside it. äö.tex can have the following content:

\begin{document}
Some text...
    \end{document}

When calling latexindent.pl -w äö/äö.tex, the following error message will be printed:

FATAL Could not write to backup file äö/äö.bak0. Please check permissions.
      Exiting, no indentation done.

With the fix that I made, the problem goes away and the output is how it's supposed to be:

\begin{document}
Some text...
\end{document}

how do I test this?

Please consider the example given above.

anything else?

Please notice that I have never written any Perl code before this. Nevertheless this seems to be working. Documentation about the decode method can be found here.

@cmhughes cmhughes merged commit 584ca18 into cmhughes:develop Apr 7, 2023
2 checks passed
@cmhughes
Copy link
Owner

cmhughes commented Apr 7, 2023

Thanks very much, that's really helpful. I've merged this and it'll be part of the next release.

cmhughes added a commit that referenced this pull request Apr 7, 2023
@cmhughes
Copy link
Owner

cmhughes commented Apr 7, 2023

For reference, see also ee82ad0

@valtterikantanen
Copy link
Contributor Author

valtterikantanen commented Apr 8, 2023

Thank you for your quick response! I updated latexindent to v3.20.5 and tried the example on my previous comment. I noticed that there's still something wrong. After calling latexindent.pl -w äö/äö.tex, latexindent prints an error message but a different one than before:

FATAL Could not find directory ��
      Exiting, no indentation done.

If I cd into äö and try latexindent.pl -w äö.tex, everything goes well:

\begin{document}
Some text...
\end{document}

Does the same error occur on your computer?

EDIT: The same error occurs without the -w switch.

EDIT 2: It seems that latexindent works correctly if I comment out this line:

${$self}{cruftDirectory} = decode( "utf-8", ${$self}{cruftDirectory} );

cmhughes added a commit that referenced this pull request Apr 9, 2023
@cmhughes
Copy link
Owner

cmhughes commented Apr 9, 2023

Thanks for the follow-up.

I can confirm the behaviour you describe.

As of 1b859d3 I have updated develop branch which I hope fixes this. I have done the following tests

latexindent.pl -s -w äö.tex -g diacritics0.log
latexindent.pl -s -w äö/äö.tex 
latexindent.pl -s äö.tex -l äö.yaml -g diacritics.log
latexindent.pl -s äö.tex -l äö.yaml -g diacritics1.log -o=+-mod1
latexindent.pl -s äö.tex -l äö.yaml -g diacritics2.log -o=+-mod2 -c ./äö
latexindent.pl -s äö.tex -l äö.yaml -g äö-log-file.log -o=+-mod3 -c ./äö
latexindent.pl -s äö.tex -l äö.yaml -g diacritics3.log -o=+-äö1

Can you get the develop branch and test at your end?

@valtterikantanen
Copy link
Contributor Author

I ran the tests and everything is working now.

@cmhughes
Copy link
Owner

cmhughes commented Apr 9, 2023

Thanks I'll get this released soon.

@cmhughes
Copy link
Owner

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants