Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 1149


Ignore:
Timestamp:
Apr 23, 2008, 11:10:22 PM (16 years ago)
Author:
landauf
Message:

removed multi-command parsing (~pipe) in CommandExecutor

Location:
code/branches/console/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/branches/console/src/core/CommandExecutor.cc

    r1059 r1149  
    338338    bool CommandExecutor::execute(const std::string& command)
    339339    {
    340         std::string strippedCommand = stripEnclosingQuotes(command);
    341 
    342         SubString tokensIO(strippedCommand, " ", SubString::WhiteSpaces, false, '\\', false, '"', false, '(', ')', false, '\0');
    343         if (tokensIO.size() >= 2)
    344         {
    345             if (tokensIO[tokensIO.size() - 2] == ">")
    346             {
    347                 bool success = CommandExecutor::execute(tokensIO.subSet(0, tokensIO.size() - 2).join());
    348                 write(tokensIO[tokensIO.size() - 1], CommandExecutor::getEvaluation().getReturnvalue());
    349                 return success;
    350             }
    351             else if (tokensIO[tokensIO.size() - 2] == "<")
    352             {
    353                 std::string input = read(tokensIO[tokensIO.size() - 1]);
    354                 if (input == "" || input.size() == 0)
    355                     return CommandExecutor::execute(tokensIO.subSet(0, tokensIO.size() - 2).join());
    356                 else
    357                     return CommandExecutor::execute(tokensIO.subSet(0, tokensIO.size() - 2).join() + " " + input);
    358             }
    359         }
    360 
    361 
    362         SubString tokensPipeline(strippedCommand, "|", SubString::WhiteSpaces, false, '\\', false, '"', false, '(', ')', false, '\0');
    363         if (tokensPipeline.size() > 1)
    364         {
    365             bool success = true;
    366             std::string returnValue = "";
    367             for (int i = tokensPipeline.size() - 1; i >= 0; i--)
    368             {
    369                 if (returnValue == "" || returnValue.size() == 0)
    370                 {
    371                     //CommandEvaluation evaluation = CommandExecutor::evaluate(tokens[i]);
    372                     if (!CommandExecutor::execute(tokensPipeline[i]))
    373                         success = false;
    374                 }
    375                 else
    376                 {
    377                     //CommandEvaluation evaluation = CommandExecutor::evaluate(tokens[i] + " " + returnValue);
    378                     if (!CommandExecutor::execute(tokensPipeline[i] + " " + returnValue))
    379                         success = false;
    380                 }
    381 
    382                 //CommandExecutor::execute(evaluation);
    383                 //returnValue = evaluation.getReturnvalue();
    384                 returnValue = CommandExecutor::getEvaluation().getReturnvalue().toString();
    385             }
    386             return success;
    387         }
    388 
    389         if ((CommandExecutor::getEvaluation().processedCommand_ != strippedCommand) || (CommandExecutor::getEvaluation().state_ == CS_Uninitialized))
    390             CommandExecutor::parse(strippedCommand);
     340        if ((CommandExecutor::getEvaluation().processedCommand_ != command) || (CommandExecutor::getEvaluation().state_ == CS_Uninitialized))
     341            CommandExecutor::parse(command);
    391342
    392343        return CommandExecutor::execute(CommandExecutor::getEvaluation());
  • code/branches/console/src/util/String.cc

    r1111 r1149  
    272272std::string removeSlashes(const std::string& str)
    273273{
    274     if (str.size() == 0)
     274    if (str.size() <= 1)
    275275        return str;
    276     else if (str.size() == 1)
    277     {
    278       //TODO: decide whether we need the commented code
    279       /*if (str[0] != '\\')
    280         return "";
    281       else*/
    282       return str;
    283     }
    284276
    285277    std::string output = "";
Note: See TracChangeset for help on using the changeset viewer.