]> git.mxchange.org Git - flightgear.git/commitdiff
Converted to new logstream debugging facility. This allows release
authorcurt <curt>
Fri, 6 Nov 1998 21:17:23 +0000 (21:17 +0000)
committercurt <curt>
Fri, 6 Nov 1998 21:17:23 +0000 (21:17 +0000)
builds with no messages at all (and no performance impact) by using
the -DFG_NDEBUG flag.

Debug/Makefile.am
Debug/fg_debug.h
Math/fg_random.c
Math/interpolater.cxx
Math/interpolater.hxx
Misc/zfstream.hxx

index ab447e4cd0f7b93dd2a02d7241bf0804c0606493..f45c0bde73adfb7677744aa20b0ee596c55e5fc2 100644 (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)
index 5a818697adde03289fac148ff0386262c76fd28e..22adb912ab4136d0ce493737986a223a96e2f7b9 100644 (file)
@@ -23,6 +23,7 @@
  * (Log is kept at end of this file)
  **************************************************************************/
 
+#error "use logstream"
 
 #ifndef _FG_DEBUG_H
 #define _FG_DEBUG_H
index 476e719928c51c8b4f86b7ab855022fd55160322..1f6ad2cb600d15501148d19fa0211558ede52b0f 100644 (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"
  *
index c77529e5554a1b824dd5836d594bc42fec91ecc2..394de5a8dd360f047a15f25a929e6d11b788f4d9 100644 (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 <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;
-
-    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.
 //
index 92a8a031910e2a0e91b060ebd82e2a39be507ab6..9a7c0bd3263c5e9f249b1ac43171c00606ca5765 100644 (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.
 //
index b5567273cb558fcc45ca72d51634ccf7ba55c6d4..8374575e95e6514a8d76d3e8889f4ab30560268d 100644 (file)
 #  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.
 //