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
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)

View file

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

View file

@ -32,7 +32,7 @@
#include <stdlib.h> /* for random(), srandom() */
#include <time.h> /* for time() to seed srandom() */
#include <Debug/fg_debug.h>
/* #include <Debug/fg_debug.h> */
#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 <config.h>" in "#ifdef HAVE_CONFIG_H"
*

View file

@ -24,45 +24,41 @@
// (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 <Misc/fgstream.hxx>
#include "interpolater.hxx"
// Constructor -- loads the interpolation table from the specified
// file
fgINTERPTABLE::fgINTERPTABLE( char *file ) {
char fgfile[256], line[256];
fgFile fd;
fgINTERPTABLE::fgINTERPTABLE( const string& file ) {
string fgfile, line;
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"
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);
}
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.
//

View file

@ -33,6 +33,9 @@
#endif
#include <string>
#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.
//

View file

@ -65,19 +65,7 @@
# define ios_badbit ios::badbit
# define ios_failbit ios::failbit
// Dummy up some char traits for now.
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; }
};
# 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.
//