0028643: Coding rules - eliminate GCC compiler warnings -Wmisleading-indentation
[occt.git] / src / IFSelect / IFSelect_SessionPilot.cxx
index 332d2dd..987c474 100644 (file)
 #include <TColStd_HSequenceOfAsciiString.hxx>
 
 #include <stdio.h>
+IMPLEMENT_STANDARD_RTTIEXT(IFSelect_SessionPilot,IFSelect_Activator)
+
 #define MAXWORDS 200
 #define MAXCARS 1000
 
-static int initactor = 0;
-static char* trace;
-
+static int THE_IFSelect_SessionPilot_initactor = 0;
 static TCollection_AsciiString nulword;
 
+//#define DEBUG_TRACE
+
 // Nb Maxi de words : cf thewords et method SetCommandLine
 
-    IFSelect_SessionPilot::IFSelect_SessionPilot (const Standard_CString prompt)
-    : theprompt (prompt) , thewords (0,MAXWORDS-1) , thewordeb (0,MAXWORDS-1)
+IFSelect_SessionPilot::IFSelect_SessionPilot (const Standard_CString prompt)
+: theprompt (prompt),
+  thewords  (0, MAXWORDS - 1),
+  thewordeb (0, MAXWORDS - 1)
 {
-  if (theprompt.Length() == 0) theprompt.AssignCat ("Test-XSTEP>");
-  therecord = Standard_False;  thenbwords = 0;
-  if (initactor) return;  initactor = 1;
+  if (theprompt.Length() == 0)
+  {
+    theprompt.AssignCat ("Test-XSTEP>");
+  }
+  therecord = Standard_False;
+  thenbwords = 0;
+  if (THE_IFSelect_SessionPilot_initactor)
+  {
+    return;
+  }
+
+  THE_IFSelect_SessionPilot_initactor = 1;
   Add (1,"x");
   Add (1,"exit");
   Add (2,"?");
@@ -55,7 +68,6 @@ static TCollection_AsciiString nulword;
   Add (4,"xsource");
   Add (5,"xstep");
   Add (6,"xnew");
-  trace = getenv("DEBUGMODE");
 }
 
 
@@ -98,7 +110,9 @@ static TCollection_AsciiString nulword;
       if (thenbwords >= MAXWORDS) {  unarg[nc] = val;  nc ++;  continue;  }
       unarg[nc] = '\0';
       thewords(thenbwords).Clear();  thewords(thenbwords).AssignCat(unarg);
-      if (trace) cout<<"thewords("<<thenbwords<<") ="<<unarg<<endl;
+#ifdef DEBUG_TRACE
+      cout<<"thewords("<<thenbwords<<") ="<<unarg<<endl;
+#endif
       thenbwords ++; nc = 0;
       continue;
     }
@@ -109,7 +123,9 @@ static TCollection_AsciiString nulword;
   if (nc > 0) {
     unarg[nc] = '\0'; thewords(thenbwords).Clear();
     thewords(thenbwords).AssignCat(unarg);
-    if (trace) cout<<"thewords("<<thenbwords<<")="<<unarg<<endl<<" .. Fin avec thenbwords="<<thenbwords+1<<endl;
+#ifdef DEBUG_TRACE
+    cout<<"thewords("<<thenbwords<<")="<<unarg<<endl<<" .. Fin avec thenbwords="<<thenbwords+1<<endl;
+#endif
     thenbwords ++;
   }
 /*
@@ -242,8 +258,11 @@ static TCollection_AsciiString nulword;
     char ligne[100];
     if (!lefic) std::cout << theprompt.ToCString();
     ligne[0] = '\0';
-    fgets(ligne,100,fic);
-    if (feof(fic)) break;
+    if (fgets(ligne,100,fic) == NULL
+     || feof(fic) != 0)
+    {
+      break;
+    }
     if (ligne[0] == '\0') continue;
 //    On interprete cette commande
     TCollection_AsciiString command(ligne);
@@ -280,8 +299,8 @@ static TCollection_AsciiString nulword;
 //  Ici, resultat non nomme;  Resultat nomme par commande x (plus loin)
     if (!theobjrec.IsNull()) {
       thesession->RemoveItem(theobjrec);  //// depannage ?
-      Standard_Boolean addws = thesession->AddItem(theobjrec);
-      if (!addws) { cout<<"Could not add item to session, sorry"<<endl; return IFSelect_RetFail; }
+      Standard_Integer addws = thesession->AddItem(theobjrec);
+      if (addws == 0) { cout<<"Could not add item to session, sorry"<<endl; return IFSelect_RetFail; }
     }
 
     if (stat == IFSelect_RetVoid || stat == IFSelect_RetDone) {
@@ -492,10 +511,10 @@ static TCollection_AsciiString nulword;
 //  Prise en compte des commandes a resultat
          if (!theobjrec.IsNull()) {
            thesession->RemoveItem(theobjrec);  //// depannage ?
-           Standard_Boolean addws =
+           Standard_Integer addws =
              thesession->AddNamedItem(name.ToCString(),theobjrec);
            theobjrec.Nullify();
-           if (!addws) { cout<<"Could not add named item:"<<name<<", sorry"<<endl; return IFSelect_RetFail; }
+           if (addws == 0) { cout<<"Could not add named item:"<<name<<", sorry"<<endl; return IFSelect_RetFail; }
          }
          else cout<<"Remark : xsnew with name:"<<name<<" and no result"<<endl;