summaryrefslogtreecommitdiff
path: root/cli/cli/options.cxx
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2020-12-06 20:30:45 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2020-12-08 17:32:31 +0300
commit276d476943a10bddf42b65302754e5e56367c465 (patch)
tree5c59dd93f6d99f80323e7d0726af2ba2840dcf71 /cli/cli/options.cxx
parentc918f33c44f660116a09c5ee3db44b6a70c26269 (diff)
Regenerate options parsing code
Diffstat (limited to 'cli/cli/options.cxx')
-rw-r--r--cli/cli/options.cxx30
1 files changed, 23 insertions, 7 deletions
diff --git a/cli/cli/options.cxx b/cli/cli/options.cxx
index d64e801..0f0604a 100644
--- a/cli/cli/options.cxx
+++ b/cli/cli/options.cxx
@@ -459,12 +459,28 @@ namespace cli
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 ())
load (f);
}
else
+ {
+ // If the path of the file being parsed is not simple and the
+ // path of the file that needs to be loaded is relative, then
+ // complete the latter using the former as a base.
+ //
+#ifndef _WIN32
+ string::size_type p (file.find_last_of ('/'));
+ bool c (p != string::npos && s2[0] != '/');
+#else
+ string::size_type p (file.find_last_of ("/\\"));
+ bool c (p != string::npos && s2[1] != ':');
+#endif
+ if (c)
+ s2.insert (0, file, 0, p + 1);
+
load (s2);
+ }
continue;
}
@@ -543,11 +559,11 @@ namespace cli
}
};
- template <typename X>
- struct parser<std::set<X> >
+ template <typename X, typename C>
+ struct parser<std::set<X, C> >
{
static void
- parse (std::set<X>& c, bool& xs, scanner& s)
+ parse (std::set<X, C>& c, bool& xs, scanner& s)
{
X x;
bool dummy;
@@ -557,11 +573,11 @@ namespace cli
}
};
- template <typename K, typename V>
- struct parser<std::map<K, V> >
+ template <typename K, typename V, typename C>
+ struct parser<std::map<K, V, C> >
{
static void
- parse (std::map<K, V>& m, bool& xs, scanner& s)
+ parse (std::map<K, V, C>& m, bool& xs, scanner& s)
{
const char* o (s.next ());