Error in kdeartwork in screensavers added from #70246

Michael Nottebrock michaelnottebrock at gmx.net
Wed Jun 23 17:23:29 BST 2004


On Wednesday 23 June 2004 16:09, Michael Nottebrock wrote:
> On Sunday 20 June 2004 22:13, Stefan Teleman wrote:
> > using namespace std;
> >
> > static const double doubleNaN =
> > std::numeric_limits<double>::quiet_NaN();
>
> No, numeric limits aren't available either.

The attached patch works for me (stolen from the Qt sources). Overkill or okay 
to commit?

-- 
   ,_,   | Michael Nottebrock               | lofi at freebsd.org
 (/^ ^\) | FreeBSD - The Power to Serve     | http://www.freebsd.org
   \u/   | K Desktop Environment on FreeBSD | http://freebsd.kde.org
-------------- next part --------------
Index: kscreensaver/kdesavers/vec3.cpp
===================================================================
RCS file: /home/kde/kdeartwork/kscreensaver/kdesavers/vec3.cpp,v
retrieving revision 1.2
diff -u -r1.2 vec3.cpp
--- kscreensaver/kdesavers/vec3.cpp	20 Apr 2004 05:19:52 -0000	1.2
+++ kscreensaver/kdesavers/vec3.cpp	23 Jun 2004 16:13:12 -0000
@@ -10,10 +10,35 @@
 //
 //============================================================================
 
-#ifndef _ISOC99_SOURCE
-// NAN is not defined by default for gcc 2.95. Enable the ISO C99 extensions
-// which includes the definition of NAN.
-#define _ISOC99_SOURCE 1
+enum {
+    LittleEndian,
+    BigEndian
+
+#ifdef Q_BYTE_ORDER
+#  if Q_BYTE_ORDER == Q_BIG_ENDIAN
+    , ByteOrder = BigEndian
+#  elif Q_BYTE_ORDER == Q_LITTLE_ENDIAN
+    , ByteOrder = LittleEndian
+#  else
+#    error "undefined byte order"
+#  endif
+};
+#else
+};
+static const unsigned int one = 1;
+static const bool ByteOrder = ((*((unsigned char *) &one) == 0) ? BigEndian : LittleEndian);
+#endif
+
+#if !defined(NAN)
+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 };
+static inline double nan()
+{
+return (ByteOrder == BigEndian ?
+   *((const double *) be_nan_bytes) :
+   *((const double *) le_nan_bytes));
+}
+#   define NAN (::nan())
 #endif
 
 #include <config.h>


More information about the kde-core-devel mailing list