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
This commit is contained in:
Georg Baum 2005-07-08 15:43:46 +00:00
parent ea3930a7fd
commit 69241a6168
6 changed files with 42 additions and 17 deletions

View 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

View 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);

View 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");

View 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

View 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;
}

View 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);