From 6520b63cb25580420e477cba2c776b2639cbf21b Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 21 Mar 2018 13:19:18 +0200 Subject: Guarantee validity of values returned by scanner for two arguments --- cli/runtime-header.cxx | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'cli/runtime-header.cxx') diff --git a/cli/runtime-header.cxx b/cli/runtime-header.cxx index 9861166..9f92262 100644 --- a/cli/runtime-header.cxx +++ b/cli/runtime-header.cxx @@ -246,7 +246,13 @@ generate_runtime_header (context& ctx) // scanner // - os << "class scanner" + os << "// Command line argument scanner interface." << endl + << "//" << endl + << "// The values returned by next() are guaranteed to be valid" << endl + << "// for the two previous arguments up until a call to a third" << endl + << "// peek() or next()." << endl + << "//" << endl + << "class scanner" << "{" << "public:" << endl << "virtual" << endl @@ -396,11 +402,16 @@ generate_runtime_header (context& ctx) << "const option_info* options_;" << "std::size_t options_count_;" << endl - << "std::string hold_;" - << "std::deque args_;"; + << "std::deque args_;" + << endl + << "// Circular buffer of two arguments." << endl + << "//" << endl + << "std::string hold_[2];" + << "std::size_t i_;"; if (!ctx.opt_sep.empty ()) - os << "bool skip_;"; + os << endl + << "bool skip_;"; os << "};"; } -- cgit v1.1