diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2018-03-24 13:27:35 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2018-03-24 13:27:35 +0200 |
commit | fc98bf23c16baf836d2c841792d4e0b35dd82727 (patch) | |
tree | 100aae5a488eddec339e5be579a83bd794134e54 /cli/options.cxx | |
parent | 74fff9901d9529cdde4ed42254aa21afe466ac3a (diff) |
Return bool from parse() indicating whether anything has been parsed
Diffstat (limited to 'cli/options.cxx')
-rw-r--r-- | cli/options.cxx | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/cli/options.cxx b/cli/options.cxx index 0a9c0e4..149cc50 100644 --- a/cli/options.cxx +++ b/cli/options.cxx @@ -1866,11 +1866,12 @@ _parse (const char* o, ::cli::scanner& s) return false; } -void options:: +bool options:: _parse (::cli::scanner& s, ::cli::unknown_mode opt_mode, ::cli::unknown_mode arg_mode) { + bool r = false; bool opt = true; while (s.more ()) @@ -1879,12 +1880,14 @@ _parse (::cli::scanner& s, if (std::strcmp (o, "--") == 0) { - s.skip (); opt = false; + s.skip (); + r = true; continue; } - if (opt && _parse (o, s)); + if (opt && _parse (o, s)) + r = true; else if (opt && std::strncmp (o, "-", 1) == 0 && o[1] != '\0') { switch (opt_mode) @@ -1892,6 +1895,7 @@ _parse (::cli::scanner& s, case ::cli::unknown_mode::skip: { s.skip (); + r = true; continue; } case ::cli::unknown_mode::stop: @@ -1913,6 +1917,7 @@ _parse (::cli::scanner& s, case ::cli::unknown_mode::skip: { s.skip (); + r = true; continue; } case ::cli::unknown_mode::stop: @@ -1928,6 +1933,8 @@ _parse (::cli::scanner& s, break; } } + + return r; } // Begin epilogue. |