]> Creatis software - bbtk.git/blobdiff - kernel/src/bbtkInterpreter.cxx
BUG slash
[bbtk.git] / kernel / src / bbtkInterpreter.cxx
index c63ec51f30a6862bd033f3865c24fa0001386051..ab194e90913eb95ebf7b8e4ec58c7064dc6d48ff 100644 (file)
@@ -3,8 +3,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbtkInterpreter.cxx,v $ $
   Language:  C++
-  Date:      $Date: 2008/03/07 11:15:15 $
-  Version:   $Revision: 1.41 $
+  Date:      $Date: 2008/03/10 06:24:13 $
+  Version:   $Revision: 1.42 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -313,15 +313,26 @@ std::cout << "=========================================~Interpreter()" << std::e
     try 
     {
       SwitchToFile(filename);
+
+printf("EED Interpreter::InterpretFile 0001\n" );
+int ii,ssize = mFileName.size();
+for (ii=0;ii<ssize;ii++)
+{
+       printf("EED RRR Interpreter::InterpretFile %s\n", mFileName[ii].c_str() );
+}
+
       bool insideComment = false; // for multiline comment
       while (mFile.size()>0) 
       {
+printf("EED --- %s --- Interpreter::InterpretFile \n", mFileName[0].c_str() );
          while ((mFile.size()>0) && 
                 (!mFile.back()->eof()))
+//EED3                                 (!mFile[0]->eof()))
          {
             mLine.back()++;
             char buf[500];
             mFile.back()->getline(buf,500);
+//EED3            mFile[0]->getline(buf,500);
       
             std::string str(buf);
             int size=str.length();
@@ -331,6 +342,7 @@ std::cout << "=========================================~Interpreter()" << std::e
             }
       
             InterpretLine(str, insideComment);
+printf("EED Interpreter::InterpretFile %s\n", str.c_str() );
          }
         //if (mFile.size()>0) 
         CloseCurrentFile();
@@ -842,12 +854,13 @@ void Interpreter::SplitLine ( const std::string& str, std::vector<std::string>&
         }
         foundFile = true;
 
-
+               Filenames.clear();
         int nbFiles = Utilities::Explore(fullDirectoryName, false, Filenames);
 
         nbBssFiles = 0;
         for (std::vector<std::string>::iterator i = Filenames.begin(); i!= Filenames.end(); ++i)
         {
+//EEDprintf("EED Interpreter::SwitchToFile %s\n",(*i).c_str() );
            if ((*i).substr((*i).size()-4, 4) != ".bbs")
               continue;      // ignore non .bbs files
           std::string command("include ");
@@ -972,9 +985,25 @@ void Interpreter::SplitLine ( const std::string& str, std::vector<std::string>&
   void Interpreter::LoadScript( std::string fullPathScriptName,
                                std::string includeScriptName)
   {
-    if (find(mFileName.begin(),mFileName.end(),fullPathScriptName)
-       !=mFileName.end()) 
+//EED printf("EED Interpreter::LoadScript >>01\n");
+       Utilities::replace( fullPathScriptName , INVALID_FILE_SEPARATOR , VALID_FILE_SEPARATOR);
+
+       bool okScriptExist=false;
+       int iStrScript,sizeVecStricpt=mFileName.size();
+       for ( iStrScript=0;iStrScript<sizeVecStricpt;iStrScript++)
+       {
+//EED printf("  EED %d Interpreter::LoadScript %s __>>__ %s\n", iStrScript,mFileName[iStrScript].c_str(),fullPathScriptName.c_str() );
+               if (mFileName[iStrScript] == fullPathScriptName )
+               {
+                       printf("  EED %d Interpreter::LoadScript iguales\n",iStrScript ); 
+                       okScriptExist=true;
+               } // if
+       } // for
+
+    if (find(mFileName.begin(),mFileName.end(),fullPathScriptName)!=mFileName.end()) 
+//    if (okScriptExist==true) 
       {
+//EED printf("EED Interpreter::LoadScript Exit method\n");
        bbtkMessage("Interpreter",1,"file '"<<fullPathScriptName
                    <<"' already open : I do not open it once more to prevent recursive inclusion"<<std::endl);
        return;
@@ -996,6 +1025,7 @@ void Interpreter::SplitLine ( const std::string& str, std::vector<std::string>&
     mFileName.push_back(fullPathScriptName);
     mIncludeFileName.push_back(includeScriptName);
     mLine.push_back(0);
+//EED printf("EED Interpreter::LoadScript >>02\n");
     return;
   }
 
@@ -1014,15 +1044,23 @@ void Interpreter::SplitLine ( const std::string& str, std::vector<std::string>&
       return;
     }
 
+    bbtkDebugMessage("Interpreter",9," Closing file '"<<mFileName.back()<<"'"<<std::endl);
     mFile.back()->close();
     delete mFile.back();
     mFile.pop_back();
-    bbtkDebugMessage("Interpreter",9,
-                     " Closing file '"<<mFileName.back()<<"'"<<std::endl);
-
     mFileName.pop_back();
     mIncludeFileName.pop_back();
-    mLine.pop_back();
+       mLine.pop_back();
+/*EED3
+       bbtkDebugMessage("Interpreter",9," Closing file '"<<mFileName[0]<<"'"<<std::endl);
+       mFile[0]->close();
+    delete mFile[0];
+    mFile.erase( mFile.begin() );
+       mFileName.erase( mFileName.begin() );
+    mIncludeFileName.erase( mIncludeFileName.begin() );
+    mLine.erase( mLine.begin() );
+*/
+
     bbtkDebugMessage("Interpreter",9," Remains "
                      <<mFile.size()
                      <<" open"<<std::endl);