aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--odb/options.cxx80
1 files changed, 46 insertions, 34 deletions
diff --git a/odb/options.cxx b/odb/options.cxx
index f52289c..98af4e9 100644
--- a/odb/options.cxx
+++ b/odb/options.cxx
@@ -373,45 +373,59 @@ namespace cli
if (line.empty () || line[0] == '#')
continue;
- string::size_type p (line.find (' '));
-
- if (p == string::npos)
+ string::size_type p (string::npos);
+ if (line.compare (0, 1, "-") == 0)
{
- if (!skip_)
- skip_ = (line == "--");
+ p = line.find (' ');
- args_.push_back (line);
+ string::size_type q (line.find ('='));
+ if (q != string::npos && q < p)
+ p = q;
}
- else
+
+ string s1;
+ if (p != string::npos)
{
- string s1 (line, 0, p);
+ s1.assign (line, 0, p);
// Skip leading whitespaces in the argument.
//
- n = line.size ();
- for (++p; p < n; ++p)
+ if (line[p] == '=')
+ ++p;
+ else
{
- char c (line[p]);
-
- if (c != ' ' && c != '\t' && c != '\r')
- break;
+ n = line.size ();
+ for (++p; p < n; ++p)
+ {
+ char c (line[p]);
+ if (c != ' ' && c != '\t' && c != '\r')
+ break;
+ }
}
+ }
+ else if (!skip_)
+ skip_ = (line == "--");
- string s2 (line, p);
+ string s2 (line, p != string::npos ? p : 0);
- // If the string is wrapped in quotes, remove them.
- //
- n = s2.size ();
- char cf (s2[0]), cl (s2[n - 1]);
+ // If the string (which is an option value or argument) is
+ // wrapped in quotes, remove them.
+ //
+ n = s2.size ();
+ char cf (s2[0]), cl (s2[n - 1]);
- if (cf == '"' || cf == '\'' || cl == '"' || cl == '\'')
- {
- if (n == 1 || cf != cl)
- throw unmatched_quote (s2);
+ if (cf == '"' || cf == '\'' || cl == '"' || cl == '\'')
+ {
+ if (n == 1 || cf != cl)
+ throw unmatched_quote (s2);
- s2 = string (s2, 1, n - 2);
- }
+ s2 = string (s2, 1, n - 2);
+ }
+ if (!s1.empty ())
+ {
+ // See if this is another file option.
+ //
const option_info* oi;
if (!skip_ && (oi = find (s1.c_str ())))
{
@@ -421,19 +435,19 @@ namespace cli
if (oi->search_func != 0)
{
std::string f (oi->search_func (s2.c_str (), oi->arg));
-
if (!f.empty ())
load (f);
}
else
load (s2);
+
+ continue;
}
- else
- {
- args_.push_back (s1);
- args_.push_back (s2);
- }
+
+ args_.push_back (s1);
}
+
+ args_.push_back (s2);
}
}
@@ -2201,9 +2215,7 @@ print_usage (::std::ostream& os, ::cli::usage_para p)
<< " source lines of code (SLOC) does not exceed" << ::std::endl
<< " <num>." << ::std::endl;
- os << "--options-file <file> Read additional options from <file> with each" << ::std::endl
- << " option appearing on a separate line optionally" << ::std::endl
- << " followed by space and an option value." << ::std::endl;
+ os << "--options-file <file> Read additional options from <file>." << ::std::endl;
os << "-x <option> Pass <option> to the underlying C++ compiler" << ::std::endl
<< " (g++)." << ::std::endl;