The branch, master, has been updated. - Log -----------------------------------------------------------------
commit e119ba60940adb865af3d370c51894b8356a006a Author: Georg Baum <[email protected]> Date: Sat Oct 6 13:55:25 2012 +0200 Refine tex2lyx -copyfiles logic. Now all files are copied if the resulting path is valid. Before the regressions tests would fail depending on the build directory location. diff --git a/src/tex2lyx/tex2lyx.1in b/src/tex2lyx/tex2lyx.1in index b430909..267d0d4 100644 --- a/src/tex2lyx/tex2lyx.1in +++ b/src/tex2lyx/tex2lyx.1in @@ -77,7 +77,7 @@ named \fIfoo.lyx.lyx\fR, and the re-exported file will be named \fIfoo.lyx.tex\fR. .TP .BI \-copyfiles -Copy all included files below the input directory and that \fBtex2lyx\fR is +Copy all included files \fBtex2lyx\fR is aware of to the output directory if the output file is located in a different directory than the input file. This is useful if you want to ensure that no included file is overwritten (either in roundtrip mode or by a later export diff --git a/src/tex2lyx/text.cpp b/src/tex2lyx/text.cpp index 34ffbe8..71379fd 100644 --- a/src/tex2lyx/text.cpp +++ b/src/tex2lyx/text.cpp @@ -1836,28 +1836,31 @@ void fix_child_filename(string & name) if (!isabs) name = makeAbsPath(name, absMasterTeX).absFileName(); bool copyfile = copyFiles(); - // convert from absolute original path to "relative to master file" - string const rel = to_utf8(makeRelPath(from_utf8(name), - from_utf8(absMasterTeX))); - // Do not copy if the file is not in or below the directory of the - // master, since in this case the new path might be impossible to - // create. Example: - // absMasterTeX = "/foo/bar/" - // absMasterLyX = "/bar/" - // name = "/baz.eps" => new absolute name would be "/../baz.eps" - if (copyfile && rel.substr(0, 3) == "../") - copyfile = false; string const absParentLyX = getParentFilePath(false); + string abs = name; if (copyfile) { + // convert from absolute original path to "relative to master file" + string const rel = to_utf8(makeRelPath(from_utf8(name), + from_utf8(absMasterTeX))); // re-interpret "relative to .tex file" as "relative to .lyx file" // (is different if the master .lyx file resides in a // different path than the master .tex file) string const absMasterLyX = getMasterFilePath(false); - name = makeAbsPath(rel, absMasterLyX).absFileName(); - if (!isabs) { + abs = makeAbsPath(rel, absMasterLyX).absFileName(); + // Do not copy if the new path is impossible to create. Example: + // absMasterTeX = "/foo/bar/" + // absMasterLyX = "/bar/" + // name = "/baz.eps" => new absolute name would be "/../baz.eps" + if (contains(name, "/../")) + copyfile = false; + } + if (copyfile) { + if (isabs) + name = abs; + else { // convert from absolute original path to // "relative to .lyx file" - name = to_utf8(makeRelPath(from_utf8(name), + name = to_utf8(makeRelPath(from_utf8(abs), from_utf8(absParentLyX))); } } @@ -1880,12 +1883,6 @@ void copy_file(FileName const & src, string dstname) else dst = makeAbsPath(dstname, absParent); string const absMaster = getMasterFilePath(false); - string const rel = to_utf8(makeRelPath(from_utf8(dst.absFileName()), - from_utf8(absMaster))); - // Do not copy if the file is not in or below the directory of the - // master (see above) - if (rel.substr(0, 3) == "../") - return; FileName const srcpath = src.onlyPath(); FileName const dstpath = dst.onlyPath(); if (equivalent(srcpath, dstpath)) ----------------------------------------------------------------------- Summary of changes: src/tex2lyx/tex2lyx.1in | 2 +- src/tex2lyx/text.cpp | 37 +++++++++++++++++-------------------- 2 files changed, 18 insertions(+), 21 deletions(-) hooks/post-receive -- The LyX Source Repository
