From c918f33c44f660116a09c5ee3db44b6a70c26269 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Sat, 5 Dec 2020 21:42:21 +0300 Subject: Complete options file path using referencing file path as base --- cli/cli/runtime-source.cxx | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'cli') 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;" -- cgit v1.1