From 11009fd3ffa87ced916697be98cfa0e82f5ce58c Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Mon, 14 Sep 2015 07:55:51 -0400 Subject: [PATCH] CLI2: Multiple 'limit:N' args are now properly handled - The 'next' report has 'limit:page' in the filter, and when an additional arg was specified, only the first was obeyed. This means that it could not be effectively overriden. --- src/CLI2.cpp | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/CLI2.cpp b/src/CLI2.cpp index 66b10a7c4..098fbed07 100644 --- a/src/CLI2.cpp +++ b/src/CLI2.cpp @@ -511,7 +511,9 @@ void CLI2::lexArguments () void CLI2::demotion () { bool changes = false; + std::vector replacement; + std::string canonical; for (auto& a : _args) { if (a._lextype == Lexer::Type::tag && @@ -525,22 +527,18 @@ void CLI2::demotion () changes = true; } } - } - int count = 0; - for (auto& a : _args) - { - std::string canonical; - if (a._lextype == Lexer::Type::pair && + else if (a._lextype == Lexer::Type::pair && canonicalize (canonical, "pseudo", a.attribute ("name"))) { context.config.set (canonical, a.attribute ("value")); changes = true; - _args.erase (_args.begin () + count); - break; + + // Equivalent to erasing 'a'. + continue; } - ++count; + replacement.push_back (a); } if (changes &&