diff options
author | Karen Arutyunov <karen@codesynthesis.com> | 2020-12-05 21:42:21 +0300 |
---|---|---|
committer | Karen Arutyunov <karen@codesynthesis.com> | 2020-12-08 17:29:36 +0300 |
commit | c918f33c44f660116a09c5ee3db44b6a70c26269 (patch) | |
tree | 1ade7833261577f56345ddeae8fc6f0b3d0fab15 /cli | |
parent | 562a765969f015eda26d27091edc3172e5639f9c (diff) |
Complete options file path using referencing file path as base
Diffstat (limited to 'cli')
-rw-r--r-- | cli/cli/runtime-source.cxx | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/cli/cli/runtime-source.cxx b/cli/cli/runtime-source.cxx index e3d904a..3864163 100644 --- a/cli/cli/runtime-source.cxx +++ b/cli/cli/runtime-source.cxx @@ -648,13 +648,28 @@ generate_runtime_source (context& ctx, bool complete) << endl << "if (oi->search_func != 0)" << "{" - << "std::string f (oi->search_func (s2.c_str (), oi->arg));" + << "string f (oi->search_func (s2.c_str (), oi->arg));" << "if (!f.empty ())" << endl << "load (f);" << "}" << "else" << endl - << "load (s2);" + << "{" + << "// If the path of the file being parsed is not simple and the" << endl + << "// path of the file that needs to be loaded is relative, then" << endl + << "// complete the latter using the former as a base." << endl + << "//" << endl + << "#ifndef _WIN32" << endl + << "string::size_type p (file.find_last_of ('/'));" + << "bool c (p != string::npos && s2[0] != '/');" + << "#else" << endl + << "string::size_type p (file.find_last_of (\"/\\\\\"));" + << "bool c (p != string::npos && s2[1] != ':');" + << "#endif" << endl + << "if (c)" << endl + << "s2.insert (0, file, 0, p + 1);" << endl + << "load (s2);" + << "}" << "continue;" << "}" << "a.value = s1;" |