- TW-1400 task "" gives a segfault (thanks to Scott Kostyshak).
This commit is contained in:
Paul Beckingham 2014-09-06 17:22:27 -04:00
parent 04b2378d57
commit b4438b4e8f
2 changed files with 130 additions and 125 deletions

View file

@ -149,6 +149,7 @@
- TW-1381 blocking report exits with "Unknown error" and exit code 3. - TW-1381 blocking report exits with "Unknown error" and exit code 3.
- TW-1383 Segmentation fault running import-yaml.pl with included example - TW-1383 Segmentation fault running import-yaml.pl with included example
(thanks to Markus Beppler). (thanks to Markus Beppler).
- TW-1400 task "" gives a segfault (thanks to Scott Kostyshak).
- TW-1403 fish shell: no option "modify" after task selection (thanks to Roman - TW-1403 fish shell: no option "modify" after task selection (thanks to Roman
Infliansksas). Infliansksas).
- TW-1405 Add command _zshattributes (thanks to Roman Inflianskas). - TW-1405 Add command _zshattributes (thanks to Roman Inflianskas).

View file

@ -1298,142 +1298,144 @@ void Parser::findIdSequence ()
// Split the ID list into elements. // Split the ID list into elements.
std::vector <std::string> elements; std::vector <std::string> elements;
split (elements, raw, ','); split (elements, raw, ',');
if (elements.size ())
bool not_an_id = false;
std::vector <std::string>::iterator e;
for (e = elements.begin (); e != elements.end (); ++e)
{ {
// Split the ID range into min/max. bool not_an_id = false;
std::vector <std::string> terms; std::vector <std::string>::iterator e;
split (terms, *e, '-'); for (e = elements.begin (); e != elements.end (); ++e)
if (terms.size () == 1)
{ {
if (! digitsOnly (terms[0])) // Split the ID range into min/max.
std::vector <std::string> terms;
split (terms, *e, '-');
if (terms.size () == 1)
{ {
not_an_id = true; if (! digitsOnly (terms[0]))
break; {
not_an_id = true;
break;
}
Nibbler n (terms[0]);
int id;
if (n.getUnsignedInt (id) &&
n.depleted ())
{
ranges.push_back (std::pair <int, int> (id, id));
}
else
{
not_an_id = true;
break;
}
}
else if (terms.size () == 2)
{
if (! digitsOnly (terms[0]) ||
! digitsOnly (terms[1]))
{
not_an_id = true;
break;
}
Nibbler n_min (terms[0]);
Nibbler n_max (terms[1]);
int id_min;
int id_max;
if (n_min.getUnsignedInt (id_min) &&
n_min.depleted () &&
n_max.getUnsignedInt (id_max) &&
n_max.depleted ())
{
if (id_min > id_max)
throw std::string (STRING_PARSER_RANGE_INVERTED);
ranges.push_back (std::pair <int, int> (id_min, id_max));
}
else
{
not_an_id = true;
break;
}
}
}
if (not_an_id)
continue;
// Now convert the ranges into an infix expression.
(*i)->unTag ("?");
(*i)->removeAllBranches ();
(*i)->tag ("ID");
Tree* branch = (*i)->addBranch (new Tree ("argSeq"));
branch->attribute ("raw", "(");
branch->tag ("OP");
std::vector <std::pair <int, int> >::iterator r;
for (r = ranges.begin (); r != ranges.end (); ++r)
{
if (r != ranges.begin ())
{
branch = (*i)->addBranch (new Tree ("argSeq"));
branch->attribute ("raw", "or");
branch->tag ("OP");
} }
Nibbler n (terms[0]); if (r->first == r->second)
int id;
if (n.getUnsignedInt (id) &&
n.depleted ())
{ {
ranges.push_back (std::pair <int, int> (id, id)); branch = (*i)->addBranch (new Tree ("argSeq"));
branch->attribute ("raw", "id");
branch = (*i)->addBranch (new Tree ("argSeq"));
branch->attribute ("raw", "==");
branch->tag ("OP");
branch = (*i)->addBranch (new Tree ("argSeq"));
branch->attribute ("raw", r->first);
} }
else else
{ {
not_an_id = true; branch = (*i)->addBranch (new Tree ("argSeq"));
break; branch->attribute ("raw", "(");
branch->tag ("OP");
branch = (*i)->addBranch (new Tree ("argSeq"));
branch->attribute ("raw", "id");
branch = (*i)->addBranch (new Tree ("argSeq"));
branch->attribute ("raw", ">=");
branch->tag ("OP");
branch = (*i)->addBranch (new Tree ("argSeq"));
branch->attribute ("raw", r->first);
branch = (*i)->addBranch (new Tree ("argSeq"));
branch->attribute ("raw", "and");
branch->tag ("OP");
branch = (*i)->addBranch (new Tree ("argSeq"));
branch->attribute ("raw", "id");
branch = (*i)->addBranch (new Tree ("argSeq"));
branch->attribute ("raw", "<=");
branch->tag ("OP");
branch = (*i)->addBranch (new Tree ("argSeq"));
branch->attribute ("raw", r->second);
branch = (*i)->addBranch (new Tree ("argSeq"));
branch->attribute ("raw", ")");
branch->tag ("OP");
} }
} }
else if (terms.size () == 2)
{
if (! digitsOnly (terms[0]) ||
! digitsOnly (terms[1]))
{
not_an_id = true;
break;
}
Nibbler n_min (terms[0]); branch = (*i)->addBranch (new Tree ("argSeq"));
Nibbler n_max (terms[1]); branch->attribute ("raw", ")");
int id_min; branch->tag ("OP");
int id_max; action = true;
if (n_min.getUnsignedInt (id_min) && break;
n_min.depleted () &&
n_max.getUnsignedInt (id_max) &&
n_max.depleted ())
{
if (id_min > id_max)
throw std::string (STRING_PARSER_RANGE_INVERTED);
ranges.push_back (std::pair <int, int> (id_min, id_max));
}
else
{
not_an_id = true;
break;
}
}
} }
if (not_an_id)
continue;
// Now convert the ranges into an infix expression.
(*i)->unTag ("?");
(*i)->removeAllBranches ();
(*i)->tag ("ID");
Tree* branch = (*i)->addBranch (new Tree ("argSeq"));
branch->attribute ("raw", "(");
branch->tag ("OP");
std::vector <std::pair <int, int> >::iterator r;
for (r = ranges.begin (); r != ranges.end (); ++r)
{
if (r != ranges.begin ())
{
branch = (*i)->addBranch (new Tree ("argSeq"));
branch->attribute ("raw", "or");
branch->tag ("OP");
}
if (r->first == r->second)
{
branch = (*i)->addBranch (new Tree ("argSeq"));
branch->attribute ("raw", "id");
branch = (*i)->addBranch (new Tree ("argSeq"));
branch->attribute ("raw", "==");
branch->tag ("OP");
branch = (*i)->addBranch (new Tree ("argSeq"));
branch->attribute ("raw", r->first);
}
else
{
branch = (*i)->addBranch (new Tree ("argSeq"));
branch->attribute ("raw", "(");
branch->tag ("OP");
branch = (*i)->addBranch (new Tree ("argSeq"));
branch->attribute ("raw", "id");
branch = (*i)->addBranch (new Tree ("argSeq"));
branch->attribute ("raw", ">=");
branch->tag ("OP");
branch = (*i)->addBranch (new Tree ("argSeq"));
branch->attribute ("raw", r->first);
branch = (*i)->addBranch (new Tree ("argSeq"));
branch->attribute ("raw", "and");
branch->tag ("OP");
branch = (*i)->addBranch (new Tree ("argSeq"));
branch->attribute ("raw", "id");
branch = (*i)->addBranch (new Tree ("argSeq"));
branch->attribute ("raw", "<=");
branch->tag ("OP");
branch = (*i)->addBranch (new Tree ("argSeq"));
branch->attribute ("raw", r->second);
branch = (*i)->addBranch (new Tree ("argSeq"));
branch->attribute ("raw", ")");
branch->tag ("OP");
}
}
branch = (*i)->addBranch (new Tree ("argSeq"));
branch->attribute ("raw", ")");
branch->tag ("OP");
action = true;
break;
} }
} }
while (action); while (action);
@ -1580,7 +1582,8 @@ void Parser::findFilter ()
! (*i)->hasTag ("CMD") && ! (*i)->hasTag ("CMD") &&
! (*i)->hasTag ("BINARY") && ! (*i)->hasTag ("BINARY") &&
! (*i)->hasTag ("RC") && ! (*i)->hasTag ("RC") &&
! (*i)->hasTag ("CONFIG")) ! (*i)->hasTag ("CONFIG") &&
(*i)->attribute ("raw") != "")
{ {
(*i)->unTag ("?"); (*i)->unTag ("?");
(*i)->tag ("FILTER"); (*i)->tag ("FILTER");
@ -1591,7 +1594,8 @@ void Parser::findFilter ()
! (*i)->hasTag ("CMD") && ! (*i)->hasTag ("CMD") &&
! (*i)->hasTag ("BINARY") && ! (*i)->hasTag ("BINARY") &&
! (*i)->hasTag ("RC") && ! (*i)->hasTag ("RC") &&
! (*i)->hasTag ("CONFIG")) ! (*i)->hasTag ("CONFIG") &&
(*i)->attribute ("raw") != "")
{ {
(*i)->unTag ("?"); (*i)->unTag ("?");
(*i)->tag ("FILTER"); (*i)->tag ("FILTER");