[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] gnash/server as_value.cpp
From: |
Martin Guy |
Subject: |
[Gnash-commit] gnash/server as_value.cpp |
Date: |
Sat, 03 Mar 2007 17:22:59 +0000 |
CVSROOT: /sources/gnash
Module name: gnash
Changes by: Martin Guy <martinwguy> 07/03/03 17:22:59
Modified files:
server : as_value.cpp
Log message:
More conservative fixes to number code
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/server/as_value.cpp?cvsroot=gnash&r1=1.19&r2=1.20
Patches:
Index: as_value.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/as_value.cpp,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -b -r1.19 -r1.20
--- as_value.cpp 3 Mar 2007 15:44:33 -0000 1.19
+++ as_value.cpp 3 Mar 2007 17:22:59 -0000 1.20
@@ -30,6 +30,8 @@
#include "gstring.h" // for automatic as_value::STRING => String as object
#include "Number.h" // for automatic as_value::NUMBER => Number as object
+#include <cmath> // for NAN
+
using namespace std;
#ifdef WIN32
@@ -38,6 +40,12 @@
namespace gnash {
+#ifndef NAN
+// If this makes your compiler die with div by zero,
+// use "static double zzzero = 0.0;" and "(zzzero/zzzero)"
+# define NAN (0.0/0.0)
+#endif
+
//
// as_value -- ActionScript value type
//
@@ -264,25 +272,22 @@
// gets converted; otherwise it is set to NaN.
//
// Also, "Infinity", "-Infinity", and "NaN"
- // are recognized.
+ // are recognized by strtod() but not by Flash Player.
char* tail=0;
m_number_value = strtod(m_string_value.c_str(), &tail);
if ( tail == m_string_value.c_str() || *tail != 0 )
{
// Failed conversion to Number.
-
- // avoid divide by zero compiler warning by using a variable
- double temp = 0.0;
-
- // this division by zero creates a NaN value in the double
- m_number_value = temp / temp;
+ m_number_value = NAN;
}
return m_number_value;
} else if (m_type == NULLTYPE) {
// Evan: from my tests
+ // Martin: I tried var foo = new Number(null) and got NaN
return 0;
} else if (m_type == BOOLEAN) {
// Evan: from my tests
+ // Martin: confirmed
return (this->m_boolean_value) ? 1 : 0;
} else if (m_type == NUMBER) {
return m_number_value;
@@ -302,6 +307,8 @@
return 0.0;
} else {
+ // Other object types should return NaN, but if we implement that,
+ // every GUI's movie canvas shrinks to size 0x0. No idea why.
return 0.0;
}
}