convert all input paths

This commit is contained in:
Julian Daube 2017-10-08 19:03:39 +02:00
parent b1e359d4e0
commit 5c60585a90

View File

@ -189,22 +189,32 @@ InputExtractor::List InputExtractor::Include(Path::Path path) {
cout << path << "done" << endl; cout << path << "done" << endl;
} }
Path::Path fixFilename(const Path::Path &file, const Path::Path &root) {
Path::Path temp(file);
// try to make path absolute
if (Path::isRelative(temp)) {
// add current file's path
temp = Path::Join(root, temp);
}
if (Path::isRelative(temp)) {
// add process working directory
temp = Path::Join(fs::cwd(), temp);
}
return Path::Clean(temp);
}
InputExtractor::List InputExtractor::operator()(const Path::Path &file, const MemoryString &str){ InputExtractor::List InputExtractor::operator()(const Path::Path &file, const MemoryString &str){
List result; List result;
CommandList IncludeCommands; CommandList IncludeCommands;
IncludeCommands["input"] = [&file, this](List &l, std::string a) { IncludeCommands["input"] = [&file, this](List &l, std::string a) {
if (a.empty()) return; if (a.empty()) return;
if (Path::Extension(a) != ".tex") a += ".tex"; if (Path::Extension(a) != ".tex") a += ".tex";
// try to make path absolute a = fixFilename(a, file);
if (Path::isRelative(a)) {
// add current file's path
a = Path::Join(file, a);
}
if (Path::isRelative(a)) {
// add process working directory
a = Path::Join(fs::cwd(), a);
}
l.push_back(a); l.push_back(a);
// try to extract all inputs of that file // try to extract all inputs of that file
@ -214,7 +224,7 @@ InputExtractor::List InputExtractor::operator()(const Path::Path &file, const Me
}; };
IncludeCommands["include"] = IncludeCommands["input"]; IncludeCommands["include"] = IncludeCommands["input"];
IncludeCommands["lstinputlisting"] = [](List &l, std::string a){ l.push_back(a); }; IncludeCommands["lstinputlisting"] = [file](List &l, std::string a){ l.push_back(fixFilename(a, file)); };
MemoryString::const_iterator current = str.begin(); MemoryString::const_iterator current = str.begin();