1
0
Fork 0

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.
This commit is contained in:
curt 1998-11-06 21:17:23 +00:00
parent 6766825159
commit 6816ecb3ea
6 changed files with 58 additions and 44 deletions

View file

@ -1,5 +1,11 @@
EXTRA_DIST = logtest.cxx
noinst_LIBRARIES = libDebug.a 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) INCLUDES += -I$(top_builddir)

View file

@ -23,6 +23,7 @@
* (Log is kept at end of this file) * (Log is kept at end of this file)
**************************************************************************/ **************************************************************************/
#error "use logstream"
#ifndef _FG_DEBUG_H #ifndef _FG_DEBUG_H
#define _FG_DEBUG_H #define _FG_DEBUG_H

View file

@ -32,7 +32,7 @@
#include <stdlib.h> /* for random(), srandom() */ #include <stdlib.h> /* for random(), srandom() */
#include <time.h> /* for time() to seed srandom() */ #include <time.h> /* for time() to seed srandom() */
#include <Debug/fg_debug.h> /* #include <Debug/fg_debug.h> */
#include "fg_random.h" #include "fg_random.h"
@ -54,7 +54,7 @@
/* Seed the random number generater with time() so we don't see the /* Seed the random number generater with time() so we don't see the
* same sequence every time */ * same sequence every time */
void fg_srandom(void) { 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 #ifdef HAVE_RAND
srand(time(NULL)); srand(time(NULL));
@ -75,9 +75,14 @@ double fg_random(void) {
/* $Log$ /* $Log$
/* Revision 1.8 1998/04/25 22:06:23 curt /* Revision 1.9 1998/11/06 21:17:26 curt
/* Edited cvs log messages in source files ... bad bad bad! /* 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 * Revision 1.7 1998/04/24 00:43:13 curt
* Wrapped "#include <config.h>" in "#ifdef HAVE_CONFIG_H" * Wrapped "#include <config.h>" in "#ifdef HAVE_CONFIG_H"
* *

View file

@ -24,45 +24,41 @@
// (Log is kept at end of this file) // (Log is kept at end of this file)
#include <string.h> #include <string>
#include <Debug/fg_debug.h> #include <Debug/logstream.hxx>
#include <Include/fg_zlib.h> #include <Include/fg_zlib.h>
#include <Misc/fgstream.hxx>
#include "interpolater.hxx" #include "interpolater.hxx"
// Constructor -- loads the interpolation table from the specified // Constructor -- loads the interpolation table from the specified
// file // file
fgINTERPTABLE::fgINTERPTABLE( char *file ) { fgINTERPTABLE::fgINTERPTABLE( const string& file ) {
char fgfile[256], line[256]; string fgfile, line;
fgFile fd;
fgPrintf( FG_MATH, FG_INFO, "Initializing Interpolator for %s\n", file); FG_LOG( FG_MATH, FG_INFO, "Initializing Interpolator for " << file );
// First try "file.gz" fg_gzifstream in( file );
strcpy(fgfile, file); if ( !in ) {
strcat(fgfile, ".gz"); FG_LOG( FG_GENERAL, FG_ALERT, "Cannot open file: " << file );
if ( (fd = fgopen(fgfile, "rb")) == NULL ) { exit(-1);
// Next try "path"
if ( (fd = fgopen(file, "rb")) == NULL ) {
fgPrintf(FG_MATH, FG_EXIT, "Cannot open file: %s\n", file);
}
} }
size = 0; size = 0;
while ( fggets(fd, line, 250) != NULL ) { in >> skipcomment;
while ( ! in.eof() ){
if ( size < MAX_TABLE_SIZE ) { if ( size < MAX_TABLE_SIZE ) {
sscanf(line, "%lf %lf\n", &(table[size][0]), &(table[size][1])); in >> table[size][0] >> table[size][1];
size++; size++;
} else { } else {
fgPrintf( FG_MATH, FG_EXIT, FG_LOG( FG_MATH, FG_ALERT,
"fgInterpolateInit(): Exceed max table size = %d\n", "fgInterpolateInit(): Exceed max table size = "
MAX_TABLE_SIZE ); << MAX_TABLE_SIZE );
exit(-1);
} }
} }
fgclose(fd);
} }
@ -80,14 +76,14 @@ double fgINTERPTABLE::interpolate(double x) {
// printf ("i = %d ", i); // printf ("i = %d ", i);
if ( (i == 0) && (x < table[0][0]) ) { if ( (i == 0) && (x < table[0][0]) ) {
fgPrintf( FG_MATH, FG_ALERT, FG_LOG( FG_MATH, FG_ALERT,
"fgInterpolateInit(): lookup error, x to small = %.2f\n", x); "fgInterpolateInit(): lookup error, x to small = " << x );
return(0.0); return(0.0);
} }
if ( x > table[i][0] ) { if ( x > table[i][0] ) {
fgPrintf( FG_MATH, FG_ALERT, FG_LOG( FG_MATH, FG_ALERT,
"fgInterpolateInit(): lookup error, x to big = %.2f\n", x); "fgInterpolateInit(): lookup error, x to big = " << x );
return(0.0); return(0.0);
} }
@ -107,6 +103,11 @@ fgINTERPTABLE::~fgINTERPTABLE( void ) {
// $Log$ // $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 // Revision 1.4 1998/05/13 18:24:25 curt
// Wrapped zlib calls so zlib can be optionally disabled. // Wrapped zlib calls so zlib can be optionally disabled.
// //

View file

@ -33,6 +33,9 @@
#endif #endif
#include <string>
#define MAX_TABLE_SIZE 32 #define MAX_TABLE_SIZE 32
@ -44,7 +47,7 @@ public:
// Constructor -- loads the interpolation table from the specified // Constructor -- loads the interpolation table from the specified
// file // file
fgINTERPTABLE( char *file ); fgINTERPTABLE( const string& file );
// Given an x value, linearly interpolate the y value from the table // Given an x value, linearly interpolate the y value from the table
double interpolate(double x); double interpolate(double x);
@ -58,6 +61,11 @@ public:
// $Log$ // $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 // Revision 1.2 1998/04/22 13:18:10 curt
// C++ - ified comments. Make file open errors fatal. // C++ - ified comments. Make file open errors fatal.
// //

View file

@ -65,19 +65,7 @@
# define ios_badbit ios::badbit # define ios_badbit ios::badbit
# define ios_failbit ios::failbit # define ios_failbit ios::failbit
// Dummy up some char traits for now. # include "Include/fg_traits.hxx"
template<class charT> struct char_traits{};
FG_TEMPLATE_NULL
struct char_traits<char>
{
typedef char char_type;
typedef int int_type;
typedef streampos pos_type;
typedef streamoff off_type;
static int_type eof() { return EOF; }
};
#endif // FG_HAVE_STD_INCLUDES #endif // FG_HAVE_STD_INCLUDES
@ -154,6 +142,11 @@ struct gzifstream_base
#endif // _zfstream_hxx #endif // _zfstream_hxx
// $Log$ // $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 // Revision 1.4 1998/11/06 14:05:16 curt
// More portability improvements by Bernie Bright. // More portability improvements by Bernie Bright.
// //