CLI2: Simplified ::findCommand

This commit is contained in:
Paul Beckingham 2015-06-14 15:38:10 -04:00
parent cacc427cbd
commit d1e7537e76

View file

@ -927,44 +927,27 @@ void CLI2::findOverrides ()
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
void CLI2::findCommand () void CLI2::findCommand ()
{ {
bool changes = false;
bool foundCommand = false;
bool readOnly = false;
bool terminated = false;
for (auto& a : _args) for (auto& a : _args)
{ {
std::string raw = a.attribute ("raw");
if (a._lextype == Lexer::Type::separator) if (a._lextype == Lexer::Type::separator)
{ break;
terminated = true;
}
else if (terminated)
{
a.tag ("WORD");
changes = true;
}
else
{
std::string canonical;
if (! foundCommand &&
canonicalize (canonical, "cmd", raw))
{
readOnly = ! exactMatch ("writecmd", canonical);
a.tag ("CMD"); std::string canonical;
a.tag (readOnly ? "READCMD" : "WRITECMD"); if (canonicalize (canonical, "cmd", a.attribute ("raw")))
a.attribute ("canonical", canonical); {
foundCommand = true; a.attribute ("canonical", canonical);
changes = true; a.tag ("CMD");
}
bool readOnly = ! exactMatch ("writecmd", canonical);
a.tag (readOnly ? "READCMD" : "WRITECMD");
if (context.config.getInteger ("debug.parser") >= 3)
context.debug (dump ("CLI2::analyze findCommand"));
// Stop at first command.
break;
} }
} }
if (changes &&
context.config.getInteger ("debug.parser") >= 3)
context.debug (dump ("CLI2::analyze findCommand"));
} }
/* /*