From 0c85725a4c211d120760857f944091dd67a943e1 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sun, 2 Aug 2015 11:17:05 -0400 Subject: [PATCH] CLI2: Plain arg detection was failing if the arg was the last arg --- src/CLI2.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/CLI2.cpp b/src/CLI2.cpp index 7899e04df..10f63403f 100644 --- a/src/CLI2.cpp +++ b/src/CLI2.cpp @@ -1673,6 +1673,27 @@ void CLI2::desugarFilterPlainArgs () prev = &a; } + // Cover the case where the *last* argument is a plain arg. + auto& penultimate = _args[_args.size () - 2]; + auto praw = penultimate.attribute ("raw"); + auto& last = _args[_args.size () - 1]; + if ((penultimate._lextype != Lexer::Type::op || // argX + praw == "(" || + praw == ")" || + praw == "and" || + praw == "or" || + praw == "xor") && + + (last._lextype == Lexer::Type::identifier || // candidate + last._lextype == Lexer::Type::word) && // candidate + + last.hasTag ("FILTER") && // candidate + ! last.hasTag ("PSEUDO")) // non-candidate + { + last.tag ("PLAIN"); + } + + // Walk the list again, upgrading PLAIN args. bool changes = false; std::vector reconstructed;