From b7a07affa53ddcd3b568dc0df67a10690ff8025c Mon Sep 17 00:00:00 2001 From: curt Date: Sat, 11 Sep 1999 14:35:28 +0000 Subject: [PATCH] MACos fixes. --- Include/compiler.h | 33 ++++++++------------ Lib/Debug/logstream.hxx | 2 +- Lib/Math/point3d.hxx | 7 +---- Lib/Misc/fgstream.cxx | 50 +++++++++++-------------------- Simulator/Main/options.cxx | 10 +++++-- Simulator/Objects/materialmgr.cxx | 8 ++++- Simulator/Objects/obj.cxx | 14 ++++++--- Thanks | 2 +- 8 files changed, 59 insertions(+), 67 deletions(-) diff --git a/Include/compiler.h b/Include/compiler.h index 2b4b940d3..95fd8afcb 100644 --- a/Include/compiler.h +++ b/Include/compiler.h @@ -98,33 +98,26 @@ /* CodeWarrior compiler from Metrowerks, Inc. */ -# if (__MWERKS__ < 0x0900) //|| macintosh -# define FG_HAVE_TRAITS -# define FG_HAVE_STD_INCLUDES -# define FG_HAVE_STD -# define FG_NAMESPACES +# define FG_HAVE_TRAITS +# define FG_HAVE_STD_INCLUDES +# define FG_HAVE_STD +# define FG_NAMESPACES -# define STL_ALGORITHM -# define STL_FUNCTIONAL -# define STL_IOMANIP -# define STL_IOSTREAM -# define STL_STDEXCEPT -# define STL_STRING +# define STL_ALGORITHM +# define STL_FUNCTIONAL +# define STL_IOMANIP +# define STL_IOSTREAM +# define STL_STDEXCEPT +# define STL_STRING // Temp: -# define bcopy(from, to, n) memcpy(to, from, n) +# define bcopy(from, to, n) memcpy(to, from, n) // -rp- please use FG_MEM_COPY everywhere ! -# define FG_MEM_COPY(to,from,n) memcpy(to, from, n) +# define FG_MEM_COPY(to,from,n) memcpy(to, from, n) // -dw- currently used glut has no game mode stuff -# define GLUT_WRONG_VERSION - -# elif (__MWERKS__ >= 0x0900) && __INTEL__ -# error still to be supported... -# else -# error unknown Metrowerks compiler -# endif +# define GLUT_WRONG_VERSION #endif // diff --git a/Lib/Debug/logstream.hxx b/Lib/Debug/logstream.hxx index c49e1ebaa..d55ff5629 100644 --- a/Lib/Debug/logstream.hxx +++ b/Lib/Debug/logstream.hxx @@ -48,7 +48,7 @@ FG_USING_STD(endl); #endif #ifdef __MWERKS__ -# define cerr std::cerr and +# define cerr std::cerr # define endl std::endl FG_USING_STD(iostream); #endif diff --git a/Lib/Math/point3d.hxx b/Lib/Math/point3d.hxx index e324410a1..d830825ff 100644 --- a/Lib/Math/point3d.hxx +++ b/Lib/Math/point3d.hxx @@ -49,7 +49,7 @@ // already depending on how you defined FG_HAVE_STD_INCLUDES, but I // can go ahead and add this -- CLO #ifdef __MWERKS__ -# include // needed fabs() +FG_USING_NAMESPACE(std); #endif #ifndef FG_HAVE_NATIVE_SGI_COMPILERS @@ -57,11 +57,6 @@ FG_USING_STD(ostream); FG_USING_STD(istream); #endif -// -dw- someone seems to have forgotten this... -#ifdef __MWERKS__ -FG_USING_STD(std); -#endif - const double fgPoint3_Epsilon = 0.0000001; diff --git a/Lib/Misc/fgstream.cxx b/Lib/Misc/fgstream.cxx index a7203de2c..2385dcdad 100644 --- a/Lib/Misc/fgstream.cxx +++ b/Lib/Misc/fgstream.cxx @@ -93,20 +93,17 @@ fg_gzifstream::attach( int fd, ios_openmode io_mode ) istream& skipeol( istream& in ) { - char c = 0; + char c = '\0'; // skip to end of line. - while ( in.get(c) ) { + +#ifdef __MWERKS__ + while ( in.get(c) && c != '\0' ) { +#else + while ( in.get(c) ) { +#endif if ( (c == '\n') || (c == '\r') ) { break; } - -#ifdef __MWERKS__ - // also break on '\0' - if ( c == '\0' ) { - break; - } -#endif - } return in; @@ -115,32 +112,21 @@ skipeol( istream& in ) istream& skipws( istream& in ) { char c; - while ( in.get(c) ) { - #ifdef __MWERKS__ - - // -dw- for unix file compatibility - // -clo- this causes problems for unix - if ( (c == '\n') || (c == '\r') || (c == '\0') ) { - break; - } - - if ( ! isspace( c ) && c != '\n' ) { - // put pack the non-space character - in.putback(c); - break; - } - + while ( in.get(c) && c != '\0' ) { #else - - if ( ! isspace( c ) ) { - // put pack the non-space character - in.putback(c); - break; - } - + while ( in.get(c) ) { #endif +#ifdef __MWERKS__ + if ( ! isspace( c ) && c != '\n' ) { +#else + if ( ! isspace( c ) ) { +#endif + // put pack the non-space character + in.putback(c); + break; + } } return in; } diff --git a/Simulator/Main/options.cxx b/Simulator/Main/options.cxx index da93926db..3701b495e 100644 --- a/Simulator/Main/options.cxx +++ b/Simulator/Main/options.cxx @@ -694,13 +694,19 @@ int fgOPTIONS::parse_command_line( int argc, char **argv ) { // Parse config file options int fgOPTIONS::parse_config_file( const string& path ) { fg_gzifstream in( path ); - if ( !in ) + if ( !in.is_open() ) return(FG_OPTIONS_ERROR); FG_LOG( FG_GENERAL, FG_INFO, "Processing config file: " << path ); in >> skipcomment; - while ( !in.eof() ) { +#ifndef __MWERKS__ + while ( ! in.eof() ) { +#else + char c = '\0'; + while ( in.get(c) && c != '\0' ) { + in.putback(c); +#endif string line; #ifdef GETLINE_NEEDS_TERMINATOR diff --git a/Simulator/Objects/materialmgr.cxx b/Simulator/Objects/materialmgr.cxx index 182235a6b..28e21c803 100644 --- a/Simulator/Objects/materialmgr.cxx +++ b/Simulator/Objects/materialmgr.cxx @@ -134,12 +134,18 @@ fgMATERIAL_MGR::load_lib ( void ) mpath.append( "materials" ); fg_gzifstream in( mpath.str() ); - if ( ! in ) { + if ( ! in.is_open() ) { FG_LOG( FG_GENERAL, FG_ALERT, "Cannot open file: " << mpath.str() ); exit(-1); } +#ifndef __MWERKS__ while ( ! in.eof() ) { +#else + char c = '\0'; + while ( in.get(c) && c != '\0' ) { + in.putback(c); +#endif // printf("%s", line); // strip leading white space and comments diff --git a/Simulator/Objects/obj.cxx b/Simulator/Objects/obj.cxx index b890d7dec..6172ac692 100644 --- a/Simulator/Objects/obj.cxx +++ b/Simulator/Objects/obj.cxx @@ -168,13 +168,19 @@ int fgObjLoad( const string& path, FGTileEntry *t) { // ignore initial comments and blank lines. (priming the pump) // in >> skipcomment; - string line; + // string line; + string token; + char c; + +#ifdef __MWERKS__ + while ( in.get(c) && c != '\0' ) { + in.putback(c); +#else while ( ! in.eof() ) { - string token; - char c; +#endif -#if defined( MACOS ) +#ifdef __MWERKS__ in >> ::skipws; #else in >> skipws; diff --git a/Thanks b/Thanks index fd2ea138a..29ff235f0 100644 --- a/Thanks +++ b/Thanks @@ -136,7 +136,7 @@ Bob Kuehne Redid the Makefile system so it is simpler and more robust. -Vasily Lewis http://www.woodsoup.org +WoodSoup Project http://www.woodsoup.org Provided computing resources and services so that the Flight Gear project could have real home. This includes, web services, ftp services shell accounts, email lists, dns services, etc.