The branch, master, has been updated.

- Log -----------------------------------------------------------------

commit ccd3ecf1e9482b2c8ff8346b5dafc2cbae6949a8
Author: Georg Baum <[email protected]>
Date:   Sun Sep 30 15:03:07 2012 +0200

    Fix tex2lyx path handling for relative file names
    
    The input and output file names of tex2lyx may be relative. In this case,
    getMasterFilePath() and getParentFilePath() return relative paths as well.
    Now the file name translation logic for all kinds of included files can
    cope with that.

diff --git a/src/tex2lyx/text.cpp b/src/tex2lyx/text.cpp
index b3604b7..5383680 100644
--- a/src/tex2lyx/text.cpp
+++ b/src/tex2lyx/text.cpp
@@ -1839,8 +1839,10 @@ void fix_relative_filename(string & name)
        if (FileName::isAbsolute(name))
                return;
 
-       name = to_utf8(makeRelPath(from_utf8(makeAbsPath(name, 
getMasterFilePath()).absFileName()),
-                                  from_utf8(getParentFilePath())));
+       string const absMaster = makeAbsPath(getMasterFilePath()).absFileName();
+       string const absParent = makeAbsPath(getParentFilePath()).absFileName();
+       string const abs = makeAbsPath(name, absMaster).absFileName();
+       name = to_utf8(makeRelPath(from_utf8(abs), from_utf8(absParent)));
 }
 
 
@@ -2531,7 +2533,7 @@ void parse_text(Parser & p, ostream & os, unsigned flags, 
bool outer,
                                                skip_braces(p);
                                                p.get_token();
                                                string name = 
normalize_filename(p.verbatim_item());
-                                               string const path = 
getMasterFilePath();
+                                               string const path = 
makeAbsPath(getMasterFilePath()).absFileName();
                                                // We want to preserve relative 
/ absolute filenames,
                                                // therefore path is only used 
for testing
                                                // The file extension is in 
every case ".tex".
@@ -2758,7 +2760,7 @@ void parse_text(Parser & p, ostream & os, unsigned flags, 
bool outer,
                                opts["clip"] = string();
                        string name = normalize_filename(p.verbatim_item());
 
-                       string const path = getMasterFilePath();
+                       string const path = 
makeAbsPath(getMasterFilePath()).absFileName();
                        // We want to preserve relative / absolute filenames,
                        // therefore path is only used for testing
                        if (!makeAbsPath(name, path).exists()) {
@@ -3723,7 +3725,7 @@ void parse_text(Parser & p, ostream & os, unsigned flags, 
bool outer,
                                name += p.get_token().asInput();
                        context.check_layout(os);
                        string filename(normalize_filename(p.getArg('{', '}')));
-                       string const path = getMasterFilePath();
+                       string const path = 
makeAbsPath(getMasterFilePath()).absFileName();
                        // We want to preserve relative / absolute filenames,
                        // therefore path is only used for testing
                        if ((t.cs() == "include" || t.cs() == "input") &&
@@ -4183,7 +4185,7 @@ void parse_text(Parser & p, ostream & os, unsigned flags, 
bool outer,
                        vector<string> keys;
                        split_map(arg, opts, keys);
                        string name = normalize_filename(p.verbatim_item());
-                       string const path = getMasterFilePath();
+                       string const path = 
makeAbsPath(getMasterFilePath()).absFileName();
                        // We want to preserve relative / absolute filenames,
                        // therefore path is only used for testing
                        if (!makeAbsPath(name, path).exists()) {
@@ -4248,7 +4250,7 @@ void parse_text(Parser & p, ostream & os, unsigned flags, 
bool outer,
                else if (t.cs() == "loadgame") {
                        p.skip_spaces();
                        string name = normalize_filename(p.verbatim_item());
-                       string const path = getMasterFilePath();
+                       string const path = 
makeAbsPath(getMasterFilePath()).absFileName();
                        // We want to preserve relative / absolute filenames,
                        // therefore path is only used for testing
                        if (!makeAbsPath(name, path).exists()) {

-----------------------------------------------------------------------

Summary of changes:
 src/tex2lyx/text.cpp |   16 +++++++++-------
 1 files changed, 9 insertions(+), 7 deletions(-)


hooks/post-receive
-- 
The LyX Source Repository

Reply via email to