- Added debug.parser=3 support to ::categorize.
This commit is contained in:
Paul Beckingham 2014-10-31 19:57:08 -04:00
parent 9deb9e9f8f
commit ea8663652f

View file

@ -636,6 +636,7 @@ void CLI::findOverrides ()
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
void CLI::categorize () void CLI::categorize ()
{ {
bool changes = false;
bool foundCommand = false; bool foundCommand = false;
bool readOnly = false; bool readOnly = false;
bool terminated = false; bool terminated = false;
@ -647,23 +648,26 @@ void CLI::categorize ()
if (raw == "--") if (raw == "--")
{ {
a->unTagAll ();
a->tag ("ORIGINAL"); a->tag ("ORIGINAL");
a->tag ("TERMINATOR"); a->tag ("TERMINATOR");
terminated = true; terminated = true;
changes = true;
continue; continue;
} }
if (terminated) else if (terminated)
{ {
a->unTagAll ();
a->tag ("ORIGINAL"); a->tag ("ORIGINAL");
a->tag ("TERMINATED"); a->tag ("TERMINATED");
a->tag ("WORD"); a->tag ("WORD");
changes = true;
} }
if (raw.find (' ') != std::string::npos) if (raw.find (' ') != std::string::npos)
{
a->tag ("QUOTED"); a->tag ("QUOTED");
changes = true;
}
std::string canonical; std::string canonical;
if (! terminated && if (! terminated &&
@ -676,6 +680,7 @@ void CLI::categorize ()
a->tag (readOnly ? "READCMD" : "WRITECMD"); a->tag (readOnly ? "READCMD" : "WRITECMD");
a->attribute ("canonical", canonical); a->attribute ("canonical", canonical);
foundCommand = true; foundCommand = true;
changes = true;
} }
else if (a->hasTag ("TERMINATOR") || else if (a->hasTag ("TERMINATOR") ||
a->hasTag ("BINARY") || a->hasTag ("BINARY") ||
@ -691,6 +696,8 @@ void CLI::categorize ()
// If the argument contains a space, it was quoted. Record that. // If the argument contains a space, it was quoted. Record that.
if (! noSpaces (raw)) if (! noSpaces (raw))
a->tag ("QUOTED"); a->tag ("QUOTED");
changes = true;
} }
else if (!foundCommand || (foundCommand && readOnly)) else if (!foundCommand || (foundCommand && readOnly))
{ {
@ -699,8 +706,14 @@ void CLI::categorize ()
// If the argument contains a space, it was quoted. Record that. // If the argument contains a space, it was quoted. Record that.
if (! noSpaces (raw)) if (! noSpaces (raw))
a->tag ("QUOTED"); a->tag ("QUOTED");
changes = true;
} }
} }
if (changes &&
context.config.getInteger ("debug.parser") >= 3)
context.debug (context.cli.dump ("CLI::analyze categorize"));
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////