]> git.mxchange.org Git - flightgear.git/blobdiff - src/FDM/UIUCModel/uiuc_parsefile.cpp
Goodbye automake.
[flightgear.git] / src / FDM / UIUCModel / uiuc_parsefile.cpp
index d74caa281a5070f6cf2dd0514bb57b0e2fd27368..640df9e75134c51485cbb5e06f69a87fd8a9a4eb 100644 (file)
 
 ----------------------------------------------------------------------
 
- HISTORY:      01/30/2000   initial release
+ HISTORY:      01/30/2000   (BS) initial release
+               09/19/2002   (MSS) appended zeros to lines w/ comments
 
 ----------------------------------------------------------------------
 
  AUTHOR(S):    Bipin Sehgal       <bsehgal@uiuc.edu>
+               Michael Selig
 
 ----------------------------------------------------------------------
 
@@ -58,8 +60,7 @@
 
  You should have received a copy of the GNU General Public License
  along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
- USA or view http://www.gnu.org/copyleft/gpl.html.
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
 **********************************************************************/
 
@@ -80,27 +81,34 @@ ParseFile :: ~ParseFile ()
 
 void ParseFile :: removeComments(string& inputLine)
 {
-  int pos = inputLine.find_first_of(COMMENT);
+  string::size_type pos = inputLine.find_first_of(COMMENT);
   
   if (pos != inputLine.npos) // a "#" exists in the line 
   {
         if (inputLine.find_first_not_of(DELIMITERS) == pos)
-          inputLine = ""; // Complete line a comment
+         {
+           inputLine = ""; // Complete line a comment
+         }
         else
-          inputLine = inputLine.substr(0,pos); //Truncate the comment from the line
+          {
+           inputLine = inputLine.substr(0,pos); //Truncate the comment from the line
+           // append zeros to the input line after stripping off the comments
+           // mss added from Bipin email of 9/3/02
+           //      inputLine += " 0 0 0 0 0 0";
+         }
   }
 }
 
 
 string ParseFile :: getToken(string inputLine, int tokenNo)
 {
-  int pos = 0;
-  int pos1 = 0;
+  string::size_type pos = 0;
+  string::size_type pos1 = 0;
   int tokencounter = 0;
 
   while (tokencounter < tokenNo)
   {
-        if ((pos1 == inputLine.npos) || (pos1 == -1) || (pos == -1) )
+    if ((pos1 == inputLine.npos) || (pos1 == -1) || (pos == -1) )
           return ""; //return an empty string if tokenNo exceeds the No of tokens in the line
         
         inputLine = inputLine.substr(pos1 , MAXLINE);
@@ -110,7 +118,7 @@ string ParseFile :: getToken(string inputLine, int tokenNo)
   }
 
   if (pos1== -1 || pos == -1)
-      return "";
+    return "";
   else
       return inputLine.substr(pos , pos1-pos); // return the desired token 
 }
@@ -118,8 +126,8 @@ string ParseFile :: getToken(string inputLine, int tokenNo)
 
 void ParseFile :: storeCommands(string inputLine)
 {
-  int pos;
-  int pos1;
+  string::size_type pos;
+  string::size_type pos1;
   // int wordlength;
   string line;
  
@@ -139,18 +147,37 @@ void ParseFile :: storeCommands(string inputLine)
   commands.push_back(line);
 }
 
+//  void ParseFile :: readFile()
+//  {
+//    string line;
+
+//    while (getline(file , line))
+//    {
+//     removeComments(line);
+//     if (line.find_first_not_of(DELIMITERS) != line.npos) // strip off blank lines
+//     {
+//             line += "     0 0 0 0 0";
+//          storeCommands(line);
+//     }
+//    }
+//  }
+
 void ParseFile :: readFile()
 {
   string line;
 
   while (getline(file , line))
-  {
-        removeComments(line);
-        if (line.find_first_not_of(DELIMITERS) != line.npos) // strip off blank lines
-          storeCommands(line);
-  }
+    {
+      removeComments(line);
+      if (line.find_first_not_of(DELIMITERS) != line.npos) // strip off blank lines
+       {
+         line += "     ";
+         // append some zeros, but this is doing something strange!
+         //              line += "  0 0 0 0 0   ";
+         storeCommands(line);
+       }
+    }
 }
-
 stack ParseFile :: getCommands()
 {
   return commands;