]> Creatis software - bbtk.git/blobdiff - kernel/src/bbtkInterpreter.cxx
Works with visual studio 2009
[bbtk.git] / kernel / src / bbtkInterpreter.cxx
index 8e87d7a4dd0d72222eed7f8549de2ee25639447e..ea9adc9ba8f1ef9bae578080dc75dcf682a015a9 100644 (file)
@@ -2,8 +2,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbtkInterpreter.cxx,v $
   Language:  C++
-  Date:      $Date: 2009/06/08 14:50:03 $
-  Version:   $Revision: 1.86 $
+  Date:      $Date: 2009/10/05 22:44:48 $
+  Version:   $Revision: 1.87 $
 =========================================================================*/
 
 /* ---------------------------------------------------------------------
@@ -687,17 +687,20 @@ namespace bbtk
          char buf[500];
          mFile.back()->getline(buf,500);
          std::string str(buf);
-         
+         //size 0 JCP 21-09-2009
          int size=str.length();
-         if ( str[ size-1 ]==13  )
+         if(size != 0){
+                 if ( str[ size-1 ]==13  )
             {
              str.erase(size-1,1);
             }
-         try
-           {
-             DoInterpretLine(str);
-           }
-         CATCH_MACRO;
+                 try
+                       {
+                         DoInterpretLine(str);
+                       }
+                 CATCH_MACRO;
+         }
+         
        } 
        CloseCurrentFile();
       }
@@ -718,6 +721,7 @@ namespace bbtk
     {
       mStatus = Interpreter_OK;
       mInsideComment = false;
+//std::cout<<"JCP bbtkInterpreter.cxx Interpreter::InterpretLine("<<std::endl;
       DoInterpretLine(line );
     }
     CATCH_MACRO;
@@ -735,7 +739,6 @@ namespace bbtk
   {
     bbtkDebugMessage("interpreter",6,"==> Interpreter::DoInterpretLine(\""
                     <<line<<"\")"<<std::endl);
-    
     std::vector<std::string> words;
     SplitLine(line,words);
 
@@ -786,7 +789,7 @@ namespace bbtk
     // Command 
     CommandInfoType command;
     InterpretCommand(words,command);
-
+//std::cout<<"JCP bbtkInterpreter command.keyword ="<<command.keyword<<std::endl;
     bbtkDebugMessage("interpreter",9,
                      "Command='"<<command.keyword
                       <<"' code="<<command.code<<std::endl); 
@@ -819,6 +822,7 @@ namespace bbtk
        bool in_script = false;
        std::string file("");
        int line = 0;
+
        if (mFileName.size()) 
          {
            std::ifstream* fs = dynamic_cast<std::ifstream*>(mFile.back());
@@ -844,7 +848,7 @@ namespace bbtk
          }
        return;
       }   
-
+//std::cout<<" mVirtualExecuter->Create(words[1],words[2]); "<<line<<std::endl;
     // other cammands
     switch (command.code) 
       {
@@ -1373,49 +1377,52 @@ namespace bbtk
                }
          
                std::string tfullPathScriptName = Utilities::MakePkgnameFromPath(path, name, false);
-               if (tfullPathScriptName.substr(tfullPathScriptName.size()-4, 3)==".bb")
-               {
-                 fullPathScriptName = tfullPathScriptName;
-                       if ( ! Utilities::FileExists(fullPathScriptName) )
+//Addition JCP tfullPathScriptName.size()>=4 
+               if(tfullPathScriptName.size()>=4){
+                       if (tfullPathScriptName.substr(tfullPathScriptName.size()-4, 3)==".bb")
                        {
-                               // The following is *NOT* a debug time message :
-                               // It's a user intended message.
-                               // Please don't remove it.
-                               bbtkMessage("interpreter",2,
-                         "   [" <<fullPathScriptName <<"] : does not exist" 
-                         <<std::endl);
-                               continue;  // try next path
-                       }
-                       bbtkMessage("interpreter",2,
-                             "   [" <<fullPathScriptName 
-                                 <<"] : found" <<std::endl);
-                       foundFile = true;
-                       break; // a script was found; we stop iterating
-               }
-               else 
-               {
-                       fullPathScriptName = tfullPathScriptName + ".bbs";
-                       // Check if library exists
-                       if ( ! Utilities::FileExists(fullPathScriptName) )
-                       {
-                               fullPathScriptName = tfullPathScriptName + ".bbp";
+                         fullPathScriptName = tfullPathScriptName;
                                if ( ! Utilities::FileExists(fullPathScriptName) )
                                {
                                        // The following is *NOT* a debug time message :
                                        // It's a user intended message.
                                        // Please don't remove it.
                                        bbtkMessage("interpreter",2,
-                                       "   [" <<tfullPathScriptName <<".bbs/.bbp] : do not exist" 
-                                       <<std::endl);
+                                 "   [" <<fullPathScriptName <<"] : does not exist" 
+                                 <<std::endl);
                                        continue;  // try next path
                                }
+                               bbtkMessage("interpreter",2,
+                                         "   [" <<fullPathScriptName 
+                                         <<"] : found" <<std::endl);
+                               foundFile = true;
+                               break; // a script was found; we stop iterating
                        }
-                       bbtkMessage("interpreter",2,
-                     "   [" <<fullPathScriptName 
-                     <<"] : found" <<std::endl);
-                       foundFile = true;
-                       break; // a script was found; we stop iterating
-               }
+                       else 
+                       {
+                               fullPathScriptName = tfullPathScriptName + ".bbs";
+                               // Check if library exists
+                               if ( ! Utilities::FileExists(fullPathScriptName) )
+                               {
+                                       fullPathScriptName = tfullPathScriptName + ".bbp";
+                                       if ( ! Utilities::FileExists(fullPathScriptName) )
+                                       {
+                                               // The following is *NOT* a debug time message :
+                                               // It's a user intended message.
+                                               // Please don't remove it.
+                                               bbtkMessage("interpreter",2,
+                                               "   [" <<tfullPathScriptName <<".bbs/.bbp] : do not exist" 
+                                               <<std::endl);
+                                               continue;  // try next path
+                                       }
+                               }
+                               bbtkMessage("interpreter",2,
+                                 "   [" <<fullPathScriptName 
+                                 <<"] : found" <<std::endl);
+                               foundFile = true;
+                               break; // a script was found; we stop iterating
+                       }
+               }               
        } //------------------ // end for ( package_paths.begin();i!=package_paths.end() )
   }
 
@@ -1570,7 +1577,7 @@ void Interpreter::SwitchToStream( std::stringstream* stream )
        HelpCommand(words[0]);
        bbtkError(words[0]<<" : wrong number of arguments");
     }
-
+//std::cout<<"Interpreter::InterpretCommand( const std::vector<std::string>& words,"<<std::endl;
     info = c->second;
 
     bbtkDebugMessage("interpreter",9,"<== Interpreter::InterpretCommand(...)"<<std::endl);