- Implemented A3t::capture_first, for command injection.
This commit is contained in:
Paul Beckingham 2014-04-16 17:03:38 -04:00
parent 16fc71e2ef
commit 3afaa2fd0b
2 changed files with 39 additions and 10 deletions

View file

@ -444,41 +444,51 @@ void A3t::inject_defaults ()
std::string defaultCommand = context.config.get ("default.command");
if (defaultCommand != "")
{
/*
std::cout << "# defaultCommand\n";
context.debug ("No command or sequence found - assuming default.command.");
capture_first (defaultCommand);
context.header ("[" + combine () + "]");
*/
std::string combined;
std::vector <Tree*>::iterator i;
for (i = _tree->_branches.begin (); i != _tree->_branches.end (); ++i)
{
if (combined.length ())
combined += ' ';
combined += (*i)->attribute ("raw");
}
context.header ("[" + combined + "]");
}
/*
else
{
std::cout << "# ! defaultCommand\n";
throw std::string (STRING_TRIVIAL_INPUT);
*/
}
}
else
{
std::cout << "# found_sequence\n";
/*
// Modify command.
if (found_other)
{
std::cout << "# found_other\n";
/*
context.debug ("Sequence and filter, but no command found - assuming 'modify' command.");
capture_first ("modify");
*/
}
// Information command.
else
{
*/
std::cout << "# ! found_other\n";
/*
context.debug ("Sequence but no command found - assuming 'information' command.");
context.header (STRING_ASSUME_INFO);
capture_first ("information");
*/
/*
}
*/
}
}
}
@ -552,6 +562,24 @@ void A3t::resolve_aliases ()
*/
}
////////////////////////////////////////////////////////////////////////////////
void A3t::capture_first (const std::string& arg)
{
std::cout << "# capture_first (" << arg << ")\n";
// Insert the arg as the new first branch.
Tree* t = new Tree ("argIns");
t->attribute ("raw", arg);
t->tag ("?");
t->_trunk = _tree;
std::vector <Tree*>::iterator i = _tree->_branches.begin ();
i++; // Walk past the binary.
_tree->_branches.insert (i, t);
findCommand ();
}
////////////////////////////////////////////////////////////////////////////////
// /pattern/
void A3t::findPattern ()

View file

@ -54,6 +54,7 @@ public:
void apply_overrides ();
void inject_defaults ();
void resolve_aliases ();
void capture_first (const std::string&);
private:
void findBinary ();