]> git.lyx.org Git - features.git/commitdiff
Fix encoding problems in \input@path
authorJuergen Spitzmueller <spitz@lyx.org>
Sun, 27 May 2018 09:54:07 +0000 (11:54 +0200)
committerJuergen Spitzmueller <spitz@lyx.org>
Sun, 27 May 2018 09:54:07 +0000 (11:54 +0200)
As of LaTeX2e 2018, characters are made active earlier, which results
in new expansion problems.

Following a suggestion of Markus Kohm (pc) and the TL mailing list [1],
we embrace non-ASCII input paths in \detokenize. This relies on e-tex,
but I think we can assume this is nowadays available everywhere.

[1] http://tug.org/pipermail/tex-live/2018-May/041691.html

Fixes: #11146
src/Buffer.cpp

index b436a0f8a55bf591da3de515de9468e9b4059914..e05c4d07bb96e2373dbe1d50f41c64d49d1a93d1 100644 (file)
@@ -1898,8 +1898,7 @@ Buffer::ExportStatus Buffer::writeLaTeXSource(otexstream & os,
                                            "file path name."),
                                          inputpath, uncodable_glyphs));
                        } else {
-                               string docdir =
-                                       latex_path(original_path);
+                               string docdir = os::latex_path(original_path);
                                if (contains(docdir, '#')) {
                                        docdir = subst(docdir, "#", "\\#");
                                        os << "\\catcode`\\#=11"
@@ -1910,9 +1909,20 @@ Buffer::ExportStatus Buffer::writeLaTeXSource(otexstream & os,
                                        os << "\\catcode`\\%=11"
                                              "\\def\\%{%}\\catcode`\\%=14\n";
                                }
+                               bool const detokenize = !isAscii(from_utf8(docdir));
+                               bool const quote = contains(docdir, ' ');
                                os << "\\makeatletter\n"
-                                  << "\\def\\input@path{{"
-                                  << docdir << "}}\n"
+                                  << "\\def\\input@path{{";
+                               if (detokenize)
+                                       os << "\\detokenize{";
+                               if (quote)
+                                       os << "\"";
+                               os << docdir;
+                               if (quote)
+                                       os << "\"";
+                               if (detokenize)
+                                       os << "}";
+                               os << "}}\n"
                                   << "\\makeatother\n";
                        }
                }