[Kst] extragear/graphics/kst/src/datasources/dirfile

Matthew D Truch matt at truch.net
Tue Apr 11 22:30:20 CEST 2006


SVN commit 528830 by truch:

Don't cleanup to Don's own patch.


 M  +1 -2      getdata.c  
 M  +21 -0     getdata.h  


--- trunk/extragear/graphics/kst/src/datasources/dirfile/getdata.c #528829:528830
@@ -38,8 +38,6 @@
                             "Too many levels of recursion"
 };
 
-#define NaN (0. / 0.)
-
 /* Suberror codes -- these don't need to be public */
 #define GD_E_FORMAT_SE_BAD_TYPE   0
 #define GD_E_FORMAT_SE_BAD_SPF    1
@@ -984,6 +982,7 @@
 /***************************************************************************/
 static int FillZero(char *databuffer, char type, int s0, int ns) {
   int i, nz;
+  const double NaN = NAN;
 
   if (s0>=0) return 0;
 
--- trunk/extragear/graphics/kst/src/datasources/dirfile/getdata.h #528829:528830
@@ -2,6 +2,27 @@
 #ifndef GETDATA_H
 #define GETDATA_H
 
+/* The following has been extracted from kstmath.h */
+
+/*
+** For systems without NAN, this is a NAN in IEEE double format.
+** Code lifted from kde screensavers.
+*/
+#if !defined(NAN)
+static inline double nan__()
+{
+  static const unsigned int one = 1;
+  const int BigEndian = (*((unsigned char*)&one) == 0);
+
+  static const unsigned char be_nan_bytes[] = { 0x7f, 0xf8, 0, 0, 0, 0, 0, 0 };
+  static const unsigned char le_nan_bytes[] = { 0, 0, 0, 0, 0, 0, 0xf8, 0x7f };
+
+  return *( ( const double * )( BigEndian ? be_nan_bytes : le_nan_bytes ) );
+}
+#define NAN (nan__())
+#endif
+
+
 extern const char *GD_ERROR_CODES[15];
 
 #define GD_E_OK                0


More information about the Kst mailing list