- ::findUUIDList now safely removes nodes out of the iterator loop.
This commit is contained in:
Paul Beckingham 2014-08-24 12:53:50 -04:00
parent f6c422385b
commit df80050c13

View file

@ -1432,22 +1432,32 @@ void Parser::findIdSequence ()
void Parser::findUUIDList () void Parser::findUUIDList ()
{ {
context.debug ("Parser::findUUIDList"); context.debug ("Parser::findUUIDList");
bool action = false; bool action = true;
do
{
action = false;
std::vector <Tree*> nodes; std::vector <Tree*> nodes;
collect (nodes); collect (nodes, collectAll);
std::vector <Tree*>::iterator i; std::vector <Tree*>::iterator i;
for (i = nodes.begin (); i != nodes.end (); ++i) for (i = nodes.begin (); i != nodes.end (); ++i)
{ {
std::string raw = (*i)->attribute ("raw"); std::string raw = (*i)->attribute ("raw");
Nibbler n (raw);
std::vector <std::string> sequence; if (raw == "--")
break;
if (! (*i)->hasTag ("?"))
continue;
Nibbler n (raw);
std::vector <std::string> uuidList;
std::string uuid; std::string uuid;
if (n.getUUID (uuid) || if (n.getUUID (uuid) ||
n.getPartialUUID (uuid)) n.getPartialUUID (uuid))
{ {
sequence.push_back (uuid); uuidList.push_back (uuid);
while (n.skip (',')) while (n.skip (','))
{ {
@ -1455,7 +1465,7 @@ void Parser::findUUIDList ()
!n.getPartialUUID (uuid)) !n.getPartialUUID (uuid))
throw std::string (STRING_PARSER_UUID_AFTER_COMMA); throw std::string (STRING_PARSER_UUID_AFTER_COMMA);
sequence.push_back (uuid); uuidList.push_back (uuid);
} }
if (n.depleted ()) if (n.depleted ())
@ -1469,9 +1479,9 @@ void Parser::findUUIDList ()
branch->tag ("OP"); branch->tag ("OP");
std::vector <std::string>::iterator u; std::vector <std::string>::iterator u;
for (u = sequence.begin (); u != sequence.end (); ++u) for (u = uuidList.begin (); u != uuidList.end (); ++u)
{ {
if (u != sequence.begin ()) if (u != uuidList.begin ())
{ {
branch = (*i)->addBranch (new Tree ("argSeq")); branch = (*i)->addBranch (new Tree ("argSeq"));
branch->attribute ("raw", "or"); branch->attribute ("raw", "or");
@ -1493,11 +1503,13 @@ void Parser::findUUIDList ()
branch->attribute ("raw", ")"); branch->attribute ("raw", ")");
branch->tag ("OP"); branch->tag ("OP");
action = true; action = true;
break;
} }
} }
} }
}
while (action);
if (action)
context.debug (_tree->dump ()); context.debug (_tree->dump ());
} }