From c5fd2700ef19c481289c6b5a233468a2bdf39596 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Thu, 24 Apr 2014 13:05:39 -0400 Subject: [PATCH] A3t - Modified ::findCommand to scan for already-found commands, so as not to find a second, if the method is called again. - Fixed a bug where all likely commands were tagged, not just the first. --- src/A3t.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/A3t.cpp b/src/A3t.cpp index b4676cf59..4d5e1bdf8 100644 --- a/src/A3t.cpp +++ b/src/A3t.cpp @@ -233,8 +233,15 @@ void A3t::findTerminator () // autoCompletes to a valid command/report. void A3t::findCommand () { + // There can be only one. + // Scan for an existing CMD tag, to short-circuit scanning for another. std::string command; std::vector ::iterator i; + for (i = _tree->_branches.begin (); i != _tree->_branches.end (); ++i) + if ((*i)->hasTag ("CMD")) + return; + + // No CMD tag found, now look for a command. for (i = _tree->_branches.begin (); i != _tree->_branches.end (); ++i) { // Parser override operator. @@ -252,6 +259,7 @@ void A3t::findCommand () (*i)->tag ("CMD"); (*i)->tag ("REPORT"); (*i)->attribute ("canonical", command); + break; } */ @@ -261,6 +269,7 @@ void A3t::findCommand () (*i)->tag ("CMD"); (*i)->tag ("READCMD"); (*i)->attribute ("canonical", command); + break; } else if (canonicalize (command, "writecmd", (*i)->attribute ("raw"))) @@ -269,6 +278,7 @@ void A3t::findCommand () (*i)->tag ("CMD"); (*i)->tag ("WRITECMD"); (*i)->attribute ("canonical", command); + break; } else if (canonicalize (command, "helper", (*i)->attribute ("raw"))) @@ -277,6 +287,7 @@ void A3t::findCommand () (*i)->tag ("CMD"); (*i)->tag ("HELPER"); (*i)->attribute ("canonical", command); + break; } /* @@ -286,6 +297,7 @@ void A3t::findCommand () (*i)->tag ("CMD"); (*i)->tag ("SPECIALCMD"); (*i)->attribute ("canonical", command); + break; } */ }