From fc98bf23c16baf836d2c841792d4e0b35dd82727 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Sat, 24 Mar 2018 13:27:35 +0200 Subject: Return bool from parse() indicating whether anything has been parsed --- cli/options.cxx | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'cli/options.cxx') 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. -- cgit v1.1