]> git.lyx.org Git - features.git/commitdiff
forward port latex_path quoting fix from 1.3
authorGeorg Baum <Georg.Baum@post.rwth-aachen.de>
Fri, 8 Jul 2005 15:43:46 +0000 (15:43 +0000)
committerGeorg Baum <Georg.Baum@post.rwth-aachen.de>
Fri, 8 Jul 2005 15:43:46 +0000 (15:43 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@10157 a592a061-630c-0410-9148-cb99ea01b6c8

src/insets/ChangeLog
src/insets/ExternalSupport.C
src/insets/insetgraphics.C
src/support/ChangeLog
src/support/filetools.C
src/support/filetools.h

index fbefd62675d2d2d6528388cbe8184a7fa579ed0b..f6b934a9d038ce2db86d6c21b406ba576f722559 100644 (file)
@@ -1,3 +1,11 @@
+2005-07-08  Georg Baum  <Georg.Baum@post.rwth-aachen.de>
+
+       * 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  <lasgouttes@lyx.org>
 
        * insetquotes.C (latex): always use \og/\fg for the french
index a03cb901e5cc3cb8c43cb75b68f0c57b435dd8a4..4bb3f46d20ab5cf326027d619a2226f0f47ce550 100644 (file)
@@ -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);
index b91a4e134e3761632d54e3c76baeca5259216742..d8e10b67bd5bcb25328c1f61cae8f8c00d717bfb 100644 (file)
@@ -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");
 
index 25f25ef37c15e5cf189e69b05bb655a79f34152d..927dacbc26e283f1240323af0d26ceb03a7ae8b2 100644 (file)
@@ -1,3 +1,7 @@
+2005-07-08  Georg Baum  <Georg.Baum@post.rwth-aachen.de>
+
+       * filetools.[Ch] (latex_path): add exclude_extension argument
+
 2005-07-05  Jürgen Spitzmüller  <j.spitzmueller@gmx.de>
 
        * lyxtime.[Ch]: two new functions formatted_time, which return
index a80f3eccf1c12113ce39bd496049875326263ace..a5e47c18f5ec58c20562e69b7a2cd6ab46276eae 100644 (file)
@@ -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;
 }
 
index 1dd2e0d2a4a45b9283314ba17f91e4c5ba59a2ce..fba202e24f3b0fc530708d9e9e62532e588bfd8e 100644 (file)
@@ -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);