The attached trial_tex.tar.gz expands to: trial_tex/ trial.lyx sub~dir/ im~ge.eps incl~de.lyx inp~t.tex
where trial.lyx \includegraphics sub~dir/im~ge.eps \include sub~dir/incl~de.lyx \input sub~dir/inp~t.tex The attached patch to LyX 1.3.x allows View->DVI to succeed. Obviously, I should test out the changes to InsetExternal and InsetBib too, but now it's late and I'm tired and, anyway, I'd like to check that what I've done looks reasonable. ATM the ~ in the file names is sufficient to ascertain the veracity of the approach I think, but feel free to suggest more evil tests. -- Angus
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 21:36:21 -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 21:36:27 -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/insetexternal.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetexternal.C,v retrieving revision 1.53.2.5 diff -u -p -r1.53.2.5 insetexternal.C --- src/insets/insetexternal.C 7 Apr 2005 10:20:37 -0000 1.53.2.5 +++ src/insets/insetexternal.C 11 Apr 2005 21:36:27 -0000 @@ -72,7 +72,7 @@ void InsetExternal::setFromParams(Params string const InsetExternal::editMessage() const { - return doSubstitution(0, params_.templ.guiName); + return doSubstitution(0, params_.templ.guiName, false); } @@ -147,7 +147,9 @@ int InsetExternal::write(string const & } updateExternal(format, buf); - string const outstring = doSubstitution(buf, cit->second.product); + bool const use_latex_path = format == "LaTeX"; + string const outstring = doSubstitution(buf, cit->second.product, + use_latex_path); os << outstring; return lyx::count(outstring.begin(), outstring.end(), '\n'); } @@ -213,7 +215,7 @@ string const InsetExternal::getScreenLab if (et.guiName.empty()) return _("External"); else - return doSubstitution(0, et.guiName); + return doSubstitution(0, et.guiName, false); } @@ -231,7 +233,8 @@ void InsetExternal::executeCommand(strin string const InsetExternal::doSubstitution(Buffer const * buffer, - string const & s) const + string const & s, + bool use_latex_path) const { string result; string const basename = ChangeExtension(params_.filename, string()); @@ -239,11 +242,17 @@ string const InsetExternal::doSubstituti if (buffer && !buffer->tmppath.empty() && !buffer->niceFile) { filepath = buffer->filePath(); } - result = subst(s, "$$FName", params_.filename); + string subst_path = use_latex_path ? + latex_path(params_.filename) : params_.filename; + result = subst(s, "$$FName", subst_path); result = subst(result, "$$Basename", basename); result = subst(result, "$$Parameters", params_.parameters); - result = subst(result, "$$FPath", filepath); - result = subst(result, "$$Tempname", tempname_); + subst_path = use_latex_path ? + latex_path(filepath) : filepath; + result = subst(result, "$$FPath", subst_path); + subst_path = use_latex_path ? + latex_path(tempname_) : tempname_; + result = subst(result, "$$Tempname", subst_path); result = subst(result, "$$Sysdir", lyx::package().system_support()); // Handle the $$Contents(filename) syntax @@ -287,8 +296,10 @@ void InsetExternal::updateExternal(strin return; if (!cit->second.updateResult.empty()) { + bool const use_latex_path = format == "LaTeX"; string const resultfile = doSubstitution(buf, - cit->second.updateResult); + cit->second.updateResult, + use_latex_path); FileInfo fi(params_.filename); FileInfo fi2(resultfile); if (fi2.exist() && fi.exist() && @@ -300,7 +311,11 @@ void InsetExternal::updateExternal(strin } } - executeCommand(doSubstitution(buf, cit->second.updateCommand), buf); + bool const use_latex_path = format == "LaTeX"; + executeCommand(doSubstitution(buf, + cit->second.updateCommand, + use_latex_path), + buf); } @@ -312,7 +327,7 @@ void InsetExternal::viewExternal() const updateExternal(); executeCommand(doSubstitution(view_->buffer(), - et.viewCommand), + et.viewCommand, false), view_->buffer()); } @@ -325,7 +340,7 @@ void InsetExternal::editExternal() const updateExternal(); executeCommand(doSubstitution(view_->buffer(), - et.editCommand), + et.editCommand, false), view_->buffer()); } Index: src/insets/insetexternal.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetexternal.h,v retrieving revision 1.24.2.1 diff -u -p -r1.24.2.1 insetexternal.h --- src/insets/insetexternal.h 7 Dec 2004 10:49:32 -0000 1.24.2.1 +++ src/insets/insetexternal.h 11 Apr 2005 21:36:27 -0000 @@ -110,7 +110,9 @@ private: void executeCommand(string const & s, Buffer const * buf) const; /// Substitute meta-variables in this string - string const doSubstitution(Buffer const *, string const & s) const; + string const doSubstitution(Buffer const *, + string const & s, + bool use_latex_path) const; /// our owning view BufferView * view_; 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 21:36:28 -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; Index: src/insets/insetinclude.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetinclude.C,v retrieving revision 1.91.2.4 diff -u -p -r1.91.2.4 insetinclude.C --- src/insets/insetinclude.C 5 Jan 2005 15:53:22 -0000 1.91.2.4 +++ src/insets/insetinclude.C 11 Apr 2005 21:36:29 -0000 @@ -297,7 +297,7 @@ int InsetInclude::latex(Buffer const * b if (!AbsolutePath(incfile)) { incfile = MakeRelPath(getFileName(), m_buffer->filePath()); } - + if (loadIfNeeded()) { Buffer * tmp = bufferlist.getBuffer(getFileName()); @@ -324,7 +324,7 @@ int InsetInclude::latex(Buffer const * b #endif writefile = AddName(m_buffer->tmppath, incfile); } else - writefile = getFileName(); + writefile = getFileName(); writefile = ChangeExtension(writefile, ".tex"); lyxerr[Debug::LATEX] << "incfile:" << incfile << endl; @@ -344,21 +344,27 @@ int InsetInclude::latex(Buffer const * b } if (isVerbatim()) { + incfile = latex_path(incfile); os << '\\' << params_.cparams.getCmdName() << '{' << incfile << '}'; } else if (params_.flag == INPUT) { // \input wants file with extension (default is .tex) if (!IsLyXFilename(getFileName())) { + incfile = latex_path(incfile); os << '\\' << params_.cparams.getCmdName() << '{' << incfile << '}'; } else { + incfile = ChangeExtension(incfile, ".tex"); + incfile = latex_path(incfile); os << '\\' << params_.cparams.getCmdName() << '{' - << ChangeExtension(incfile, ".tex") + << incfile << '}'; } } else { // \include don't want extension and demands that the // file really have .tex + incfile = ChangeExtension(incfile, string()); + incfile = latex_path(incfile); os << '\\' << params_.cparams.getCmdName() << '{' - << ChangeExtension(incfile, string()) + << incfile << '}'; } 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 21:36:31 -0000 @@ -91,6 +91,16 @@ bool IsSGMLFilename(string const & filen } +string const latex_path(string const & original_path) +{ + string path = subst(original_path, "~", "\\string~"); + if (path.find(' ') != string::npos) + path = '"' + path + '"'; + lyxerr << "latex_path(" << original_path << ") == " << path << std::endl; + return path; +} + + // Substitutes spaces with underscores in filename (and path) string const MakeLatexName(string const & file) { 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 21:36:31 -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);
trial_tex.tar.gz
Description: GNU Zip compressed data