Jean-Marc, this is an untested patch against LyX 1.3.x. I'll test this
patch out on a Windows machine this evening and, if successful, will also
make a similar patch for the 1.4.x tree.
It introduces a new 'latex_path' function and uses it in place of
os::external_path in:
buffer.C's Buffer::makeLaTeXFile
insetbib.C's InsetBibtex::latex
insetgraphics.C's InsetGraphics::latex
InsetExternal would also need something similar, but that will require
more extensive surgery.
Assuming that it works as expected, I propose to also change:
os_win32.C's implementation of os::external_path to replace those
bogus '/' with '\'. That will enable us to have a native look for the name
of the file in the window title.
the code in the File dialog browser that currently prevents a user
from selecting a file containing spaces.
Have I missed anything?
--
Angus
Index: src/support/filetools.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/support/filetools.h,v
retrieving revision 1.38.2.5
diff -u -p -r1.38.2.5 filetools.h
--- src/support/filetools.h 2 Feb 2005 12:58:07 -0000 1.38.2.5
+++ src/support/filetools.h 11 Apr 2005 11:19:59 -0000
@@ -136,6 +136,19 @@ bool PutEnv(string const & envstr);
///
bool PutEnvPath(string const & envstr);
+/** @param path a file path in internal_path format. Ie, directories
+ * are indicated by '/', not by '\'.
+ *
+ * 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~'
+ * 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.
+ */
+string const latex_path(string const & path);
+
/// Substitutes active latex characters with underscores in filename
string const MakeLatexName(string const & file);
Index: src/support/filetools.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/support/filetools.C,v
retrieving revision 1.146.2.15
diff -u -p -r1.146.2.15 filetools.C
--- src/support/filetools.C 15 Feb 2005 18:56:13 -0000 1.146.2.15
+++ src/support/filetools.C 11 Apr 2005 11:19:59 -0000
@@ -91,6 +91,16 @@ bool IsSGMLFilename(string const & filen
}
+string const latex_path(string const & original_path)
+{
+ string path = original_path;
+ subst(path, "~", "\\string~");
+ if (path.find(' ') != string::npos)
+ path = '"' + path + '"';
+ return path;
+}
+
+
// Substitutes spaces with underscores in filename (and path)
string const MakeLatexName(string const & file)
{
Index: src/buffer.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/buffer.C,v
retrieving revision 1.399.2.15
diff -u -p -r1.399.2.15 buffer.C
--- src/buffer.C 25 Mar 2005 15:35:51 -0000 1.399.2.15
+++ src/buffer.C 11 Apr 2005 11:19:57 -0000
@@ -1742,10 +1742,7 @@ void Buffer::makeLaTeXFile(ostream & os,
texrow.newline();
}
if (!original_path.empty()) {
- string inputpath = os::external_path(original_path);
- subst(inputpath, "~", "\\string~");
- if (inputpath.find(' ') != string::npos)
- inputpath = '"' + inputpath + '"';
+ string const inputpath = latex_path(original_path);
os << "\\makeatletter\n"
<< "[EMAIL PROTECTED]"
<< inputpath << "/}}\n"
Index: src/insets/insetbib.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/Attic/insetbib.C,v
retrieving revision 1.97.2.3
diff -u -p -r1.97.2.3 insetbib.C
--- src/insets/insetbib.C 7 Mar 2005 14:03:08 -0000 1.97.2.3
+++ src/insets/insetbib.C 11 Apr 2005 11:19:58 -0000
@@ -179,7 +179,7 @@ int InsetBibtex::latex(Buffer const * bu
if (!style.empty()) { // we want no \biblio...{}
os << "\\bibliographystyle{"
- << os::external_path(normalize_name(buffer, style, ".bst"))
+ << latex_path(normalize_name(buffer, style, ".bst"))
<< "}\n";
}
@@ -216,8 +216,7 @@ int InsetBibtex::latex(Buffer const * bu
string db_in = getContents();
db_in = split(db_in, adb, ',');
while (!adb.empty()) {
- db_out += os::external_path(normalize_name(buffer,
- adb, ".bib"));
+ db_out += latex_path(normalize_name(buffer, adb, ".bib"));
db_out += ',';
db_in= split(db_in, adb,',');
}
Index: src/insets/insetgraphics.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetgraphics.C,v
retrieving revision 1.146.2.7
diff -u -p -r1.146.2.7 insetgraphics.C
--- src/insets/insetgraphics.C 7 Apr 2005 10:20:37 -0000 1.146.2.7
+++ src/insets/insetgraphics.C 11 Apr 2005 11:19:58 -0000
@@ -772,7 +772,7 @@ int InsetGraphics::latex(Buffer const *b
buf->filePath()),
m_buffer->filePath());
}
- latex_str += os::external_path(fname);
+ latex_str += latex_path(fname);
}
latex_str += '}' + after;