From: Georg Baum Date: Fri, 8 Jul 2005 15:43:46 +0000 (+0000) Subject: forward port latex_path quoting fix from 1.3 X-Git-Tag: 1.6.10~14161 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=69241a6168d3999ae7f1b0695dced2933ec79aad;p=features.git forward port latex_path quoting fix from 1.3 git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@10157 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/insets/ChangeLog b/src/insets/ChangeLog index fbefd62675..f6b934a9d0 100644 --- a/src/insets/ChangeLog +++ b/src/insets/ChangeLog @@ -1,3 +1,11 @@ +2005-07-08 Georg Baum + + * ExternalSupport.C (subst_path): new argument exclude_extension + * ExternalSupport.C (doSubstitution): exclude the extension when + quoting $$FName + * insetgraphics.C (stripExtensionIfPossible, prepareFile): exclude + the extension when quoting the file name + 2005-06-16 Jean-Marc Lasgouttes * insetquotes.C (latex): always use \og/\fg for the french diff --git a/src/insets/ExternalSupport.C b/src/insets/ExternalSupport.C index a03cb901e5..4bb3f46d20 100644 --- a/src/insets/ExternalSupport.C +++ b/src/insets/ExternalSupport.C @@ -66,12 +66,14 @@ namespace { string const subst_path(string const & input, string const & placeholder, string const & path, - bool use_latex_path) + bool use_latex_path, + bool exclude_extension = false) { if (input.find(placeholder) == string::npos) return input; string const path2 = use_latex_path ? - support::latex_path(path) : support::os::external_path(path); + support::latex_path(path, exclude_extension, use_lyxdot) : + support::os::external_path(path); return support::subst(input, placeholder, path2); } @@ -133,7 +135,7 @@ string const doSubstitution(InsetExternalParams const & params, if (what == PATHS) return result; - result = subst_path(result, "$$FName", filename, use_latex_path); + result = subst_path(result, "$$FName", filename, use_latex_path, true); result = subst_path(result, "$$Basename", basename, use_latex_path); result = subst_path(result, "$$Extension", '.' + support::GetExtension(filename), use_latex_path); diff --git a/src/insets/insetgraphics.C b/src/insets/insetgraphics.C index b91a4e134e..d8e10b67bd 100644 --- a/src/insets/insetgraphics.C +++ b/src/insets/insetgraphics.C @@ -528,7 +528,7 @@ string const stripExtensionIfPossible(string const & file) // dots with a macro whose definition is just a dot ;-) // The automatic format selection does not work if the file // name is escaped. - string const latex_name = latex_path(file); + string const latex_name = latex_path(file, true); if (contains(latex_name, '"')) return latex_name; return subst(latex_path(RemoveExtension(file)), ".", "\\lyxdot "); @@ -546,7 +546,7 @@ string const stripExtensionIfPossible(string const & file, string const & to) (to_format == "eps" && file_format == "ps") || (to_format == "ps" && file_format == "eps")) return stripExtensionIfPossible(file); - return latex_path(file); + return latex_path(file, true); } } // namespace anon @@ -633,7 +633,7 @@ string const InsetGraphics::prepareFile(Buffer const & buf, source_file, output_file); // We can't strip the extension, because we don't know // the unzipped file format - return latex_path(output_file); + return latex_path(output_file, true); } string const unzipped_temp_file = unzippedFileName(temp_file); @@ -868,7 +868,7 @@ void InsetGraphics::validate(LaTeXFeatures & features) const return; features.includeFile(graphic_label, - RemoveExtension(params().filename.absFilename())); + RemoveExtension(params().filename.absFilename())); features.require("graphicx"); diff --git a/src/support/ChangeLog b/src/support/ChangeLog index 25f25ef37c..927dacbc26 100644 --- a/src/support/ChangeLog +++ b/src/support/ChangeLog @@ -1,3 +1,7 @@ +2005-07-08 Georg Baum + + * filetools.[Ch] (latex_path): add exclude_extension argument + 2005-07-05 Jürgen Spitzmüller * lyxtime.[Ch]: two new functions formatted_time, which return diff --git a/src/support/filetools.C b/src/support/filetools.C index a80f3eccf1..a5e47c18f5 100644 --- a/src/support/filetools.C +++ b/src/support/filetools.C @@ -82,14 +82,21 @@ bool IsSGMLFilename(string const & filename) } -string const latex_path(string const & original_path) +string const latex_path(string const & original_path, bool exclude_extension) { string path = subst(original_path, "\\", "/"); path = subst(path, "~", "\\string~"); if (path.find(' ') != string::npos) // We can't use '"' because " is sometimes active (e.g. if // babel is loaded with the "german" option) - path = "\\string\"" + path + "\\string\""; + if (exclude_extension) { + string const base = ChangeExtension(path, string()); + string const ext = GetExtension(path); + // ChangeExtension calls os::internal_path internally + // so don't use it to re-add the extension. + path = "\\string\"" + base + "\\string\"." + ext; + } else + path = "\\string\"" + path + "\\string\""; return path; } diff --git a/src/support/filetools.h b/src/support/filetools.h index 1dd2e0d2a4..fba202e24f 100644 --- a/src/support/filetools.h +++ b/src/support/filetools.h @@ -77,12 +77,10 @@ bool IsLyXFilename(std::string const & filename); bool IsSGMLFilename(std::string const & filename); /** Returns the path of a library data file. - Search the file name.ext in the subdirectory dir of - \begin{enumerate} - \item user_lyxdir - \item build_lyxdir (if not empty) - \item system_lyxdir - \end{enumerate} + Search the file name.ext in the subdirectory dir of + -# user_lyxdir + -# build_lyxdir (if not empty) + -# system_lyxdir The third parameter `ext' is optional. */ std::string const LibFileSearch(std::string const & dir, std::string const & name, @@ -110,12 +108,18 @@ std::string const LibScriptSearch(std::string const & command); * Manipulates @c path into a form suitable for inclusion in a LaTeX * document. * If @c path contains LaTeX special characters, these are escaped. - * Eg, '~' -> '\string~' + * Eg, '~' -> '\\string~' * If @c path contains spaces, then the returned path is enclosed in * "-quotes. This last fix will lead to successful compiliation of the * LaTeX file only if a sufficiently modern LaTeX compiler is used. + * If @c exclude_extension is true the extension is left outside the quotes. + * This is needed for pdfeTeX, Version 3.141592-1.21a-2.2 (Web2C 7.5.4) + * (format=pdflatex 2005.4.11) in combination with + * pdftex.def 2002/06/19 v0.03k graphics/color for pdftex: + * It does not recognize the file extension if it is inside the quotes. */ -std::string const latex_path(std::string const & path); +std::string const latex_path(std::string const & path, + bool exclude_extension = false) /// Substitutes active latex characters with underscores in filename std::string const MakeLatexName(std::string const & file);