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; std::string canonical;
if (! foundCommand && if (canonicalize (canonical, "cmd", a.attribute ("raw")))
canonicalize (canonical, "cmd", raw))
{ {
readOnly = ! exactMatch ("writecmd", canonical);
a.tag ("CMD");
a.tag (readOnly ? "READCMD" : "WRITECMD");
a.attribute ("canonical", canonical); a.attribute ("canonical", canonical);
foundCommand = true; a.tag ("CMD");
changes = true;
}
}
}
if (changes && bool readOnly = ! exactMatch ("writecmd", canonical);
context.config.getInteger ("debug.parser") >= 3) a.tag (readOnly ? "READCMD" : "WRITECMD");
if (context.config.getInteger ("debug.parser") >= 3)
context.debug (dump ("CLI2::analyze findCommand")); context.debug (dump ("CLI2::analyze findCommand"));
// Stop at first command.
break;
}
}
} }
/* /*