From: curt Date: Fri, 6 Nov 1998 21:17:23 +0000 (+0000) Subject: Converted to new logstream debugging facility. This allows release X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=6816ecb3eabdba7cef4df46db357a58603824cdd;p=flightgear.git Converted to new logstream debugging facility. This allows release builds with no messages at all (and no performance impact) by using the -DFG_NDEBUG flag. --- diff --git a/Debug/Makefile.am b/Debug/Makefile.am index ab447e4cd..f45c0bde7 100644 --- a/Debug/Makefile.am +++ b/Debug/Makefile.am @@ -1,5 +1,11 @@ +EXTRA_DIST = logtest.cxx + noinst_LIBRARIES = libDebug.a -libDebug_a_SOURCES = fg_debug.c fg_debug.h +libDebug_a_SOURCES = \ + debug_types.h \ + logstream.cxx logstream.hxx + +# fg_debug.c fg_debug.h \ INCLUDES += -I$(top_builddir) diff --git a/Debug/fg_debug.h b/Debug/fg_debug.h index 5a818697a..22adb912a 100644 --- a/Debug/fg_debug.h +++ b/Debug/fg_debug.h @@ -23,6 +23,7 @@ * (Log is kept at end of this file) **************************************************************************/ +#error "use logstream" #ifndef _FG_DEBUG_H #define _FG_DEBUG_H diff --git a/Math/fg_random.c b/Math/fg_random.c index 476e71992..1f6ad2cb6 100644 --- a/Math/fg_random.c +++ b/Math/fg_random.c @@ -32,7 +32,7 @@ #include /* for random(), srandom() */ #include /* for time() to seed srandom() */ -#include +/* #include */ #include "fg_random.h" @@ -54,7 +54,7 @@ /* Seed the random number generater with time() so we don't see the * same sequence every time */ void fg_srandom(void) { - fgPrintf( FG_MATH, FG_INFO, "Seeding random number generater\n"); + /* fgPrintf( FG_MATH, FG_INFO, "Seeding random number generater\n"); */ #ifdef HAVE_RAND srand(time(NULL)); @@ -75,9 +75,14 @@ double fg_random(void) { /* $Log$ -/* Revision 1.8 1998/04/25 22:06:23 curt -/* Edited cvs log messages in source files ... bad bad bad! +/* Revision 1.9 1998/11/06 21:17:26 curt +/* Converted to new logstream debugging facility. This allows release +/* builds with no messages at all (and no performance impact) by using +/* the -DFG_NDEBUG flag. /* + * Revision 1.8 1998/04/25 22:06:23 curt + * Edited cvs log messages in source files ... bad bad bad! + * * Revision 1.7 1998/04/24 00:43:13 curt * Wrapped "#include " in "#ifdef HAVE_CONFIG_H" * diff --git a/Math/interpolater.cxx b/Math/interpolater.cxx index c77529e55..394de5a8d 100644 --- a/Math/interpolater.cxx +++ b/Math/interpolater.cxx @@ -24,45 +24,41 @@ // (Log is kept at end of this file) -#include +#include -#include +#include #include +#include #include "interpolater.hxx" // Constructor -- loads the interpolation table from the specified // file -fgINTERPTABLE::fgINTERPTABLE( char *file ) { - char fgfile[256], line[256]; - fgFile fd; - - fgPrintf( FG_MATH, FG_INFO, "Initializing Interpolator for %s\n", file); - - // First try "file.gz" - strcpy(fgfile, file); - strcat(fgfile, ".gz"); - if ( (fd = fgopen(fgfile, "rb")) == NULL ) { - // Next try "path" - if ( (fd = fgopen(file, "rb")) == NULL ) { - fgPrintf(FG_MATH, FG_EXIT, "Cannot open file: %s\n", file); - } +fgINTERPTABLE::fgINTERPTABLE( const string& file ) { + string fgfile, line; + + FG_LOG( FG_MATH, FG_INFO, "Initializing Interpolator for " << file ); + + fg_gzifstream in( file ); + if ( !in ) { + FG_LOG( FG_GENERAL, FG_ALERT, "Cannot open file: " << file ); + exit(-1); } size = 0; - while ( fggets(fd, line, 250) != NULL ) { + in >> skipcomment; + while ( ! in.eof() ){ if ( size < MAX_TABLE_SIZE ) { - sscanf(line, "%lf %lf\n", &(table[size][0]), &(table[size][1])); + in >> table[size][0] >> table[size][1]; size++; } else { - fgPrintf( FG_MATH, FG_EXIT, - "fgInterpolateInit(): Exceed max table size = %d\n", - MAX_TABLE_SIZE ); + FG_LOG( FG_MATH, FG_ALERT, + "fgInterpolateInit(): Exceed max table size = " + << MAX_TABLE_SIZE ); + exit(-1); } } - - fgclose(fd); } @@ -80,14 +76,14 @@ double fgINTERPTABLE::interpolate(double x) { // printf ("i = %d ", i); if ( (i == 0) && (x < table[0][0]) ) { - fgPrintf( FG_MATH, FG_ALERT, - "fgInterpolateInit(): lookup error, x to small = %.2f\n", x); + FG_LOG( FG_MATH, FG_ALERT, + "fgInterpolateInit(): lookup error, x to small = " << x ); return(0.0); } if ( x > table[i][0] ) { - fgPrintf( FG_MATH, FG_ALERT, - "fgInterpolateInit(): lookup error, x to big = %.2f\n", x); + FG_LOG( FG_MATH, FG_ALERT, + "fgInterpolateInit(): lookup error, x to big = " << x ); return(0.0); } @@ -107,6 +103,11 @@ fgINTERPTABLE::~fgINTERPTABLE( void ) { // $Log$ +// Revision 1.5 1998/11/06 21:17:27 curt +// Converted to new logstream debugging facility. This allows release +// builds with no messages at all (and no performance impact) by using +// the -DFG_NDEBUG flag. +// // Revision 1.4 1998/05/13 18:24:25 curt // Wrapped zlib calls so zlib can be optionally disabled. // diff --git a/Math/interpolater.hxx b/Math/interpolater.hxx index 92a8a0319..9a7c0bd32 100644 --- a/Math/interpolater.hxx +++ b/Math/interpolater.hxx @@ -33,6 +33,9 @@ #endif +#include + + #define MAX_TABLE_SIZE 32 @@ -44,7 +47,7 @@ public: // Constructor -- loads the interpolation table from the specified // file - fgINTERPTABLE( char *file ); + fgINTERPTABLE( const string& file ); // Given an x value, linearly interpolate the y value from the table double interpolate(double x); @@ -58,6 +61,11 @@ public: // $Log$ +// Revision 1.3 1998/11/06 21:17:28 curt +// Converted to new logstream debugging facility. This allows release +// builds with no messages at all (and no performance impact) by using +// the -DFG_NDEBUG flag. +// // Revision 1.2 1998/04/22 13:18:10 curt // C++ - ified comments. Make file open errors fatal. // diff --git a/Misc/zfstream.hxx b/Misc/zfstream.hxx index b5567273c..8374575e9 100644 --- a/Misc/zfstream.hxx +++ b/Misc/zfstream.hxx @@ -65,19 +65,7 @@ # define ios_badbit ios::badbit # define ios_failbit ios::failbit -// Dummy up some char traits for now. -template struct char_traits{}; - -FG_TEMPLATE_NULL -struct char_traits -{ - typedef char char_type; - typedef int int_type; - typedef streampos pos_type; - typedef streamoff off_type; - - static int_type eof() { return EOF; } -}; +# include "Include/fg_traits.hxx" #endif // FG_HAVE_STD_INCLUDES @@ -154,6 +142,11 @@ struct gzifstream_base #endif // _zfstream_hxx // $Log$ +// Revision 1.5 1998/11/06 21:17:29 curt +// Converted to new logstream debugging facility. This allows release +// builds with no messages at all (and no performance impact) by using +// the -DFG_NDEBUG flag. +// // Revision 1.4 1998/11/06 14:05:16 curt // More portability improvements by Bernie Bright. //