X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FFDM%2FJSBSim%2FFGConfigFile.cpp;h=8930caafd0af459284e5f093cc75a13cdc418ced;hb=95440173caef3ce92ee7308fd58a24dabe4c5f8a;hp=77d0628de2fc51b9e3254c45d1932c031423b4c0;hpb=a28b35f3f2a48187965f6063806cbc52e1d26bc9;p=flightgear.git diff --git a/src/FDM/JSBSim/FGConfigFile.cpp b/src/FDM/JSBSim/FGConfigFile.cpp index 77d0628de..8930caafd 100644 --- a/src/FDM/JSBSim/FGConfigFile.cpp +++ b/src/FDM/JSBSim/FGConfigFile.cpp @@ -21,6 +21,8 @@ INCLUDES #include #include +namespace JSBSim { + static const char *IdSrc = "$Id$"; static const char *IdHdr = ID_CONFIGFILE; @@ -30,7 +32,7 @@ CLASS IMPLEMENTATION FGConfigFile::FGConfigFile(string cfgFileName) { -#if defined ( sgi ) && !defined( __GNUC__ ) +#if defined ( sgi ) && !defined( __GNUC__ ) && (_COMPILER_VERSION < 740) cfgfile.open(cfgFileName.c_str(), ios::in ); #else cfgfile.open(cfgFileName.c_str(), ios::in | ios::binary ); @@ -38,7 +40,7 @@ FGConfigFile::FGConfigFile(string cfgFileName) CommentsOn = false; CurrentIndex = 0; Opened = true; -#if defined ( sgi ) && !defined( __GNUC__ ) +#if defined ( sgi ) && !defined( __GNUC__ ) && (_COMPILER_VERSION < 740) if (!cfgfile.fail() && !cfgfile.eof()) GetNextConfigLine(); #else if (cfgfile.is_open()) GetNextConfigLine(); @@ -212,7 +214,7 @@ string FGConfigFile::GetLine(void) } } else { if ((test = cfgfile.get()) != EOF) { // get *next* character -#if defined ( sgi ) && !defined( __GNUC__ ) +#if defined ( sgi ) && !defined( __GNUC__ ) && (_COMPILER_VERSION < 740) if (test >= 0x20 || test == 0x09) cfgfile.putback(test); #else if (test >= 0x20 || test == 0x09) cfgfile.unget(); @@ -221,6 +223,12 @@ string FGConfigFile::GetLine(void) } } } + + int index = scratch.find_last_not_of(" "); + if (index != string::npos && index < (scratch.size()-1)) { + scratch = scratch.substr(0,index+1); + } + if (cfgfile.eof() && scratch.empty()) return string("EOF"); return scratch; } @@ -271,28 +279,6 @@ FGConfigFile& FGConfigFile::operator>>(int& val) //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -FGConfigFile& FGConfigFile::operator>>(eParam& val) -{ - string::size_type pos, end; - - pos = CurrentLine.find_first_not_of(", ",CurrentIndex); - if (pos == CurrentLine.npos) pos = CurrentLine.length(); - end = CurrentLine.find_first_of(", ",pos+1); - if (end == CurrentLine.npos) end = CurrentLine.length(); - string str = CurrentLine.substr(pos, end - pos); - val = (eParam)atoi(str.c_str()); - CurrentIndex = end+1; - if (end == pos) { - GetNextConfigLine(); - *this >> val; - } else { - if (CurrentIndex >= CurrentLine.length()) GetNextConfigLine(); - } - return *this; -} - -//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - FGConfigFile& FGConfigFile::operator>>(string& str) { string::size_type pos, end; @@ -361,4 +347,4 @@ void FGConfigFile::Debug(int from) } } } - +}