gnash-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gnash-commit] gnash ChangeLog server/as_value.cpp testsuite/m...


From: Benjamin Wolsey
Subject: [Gnash-commit] gnash ChangeLog server/as_value.cpp testsuite/m...
Date: Wed, 02 Apr 2008 08:53:46 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Changes by:     Benjamin Wolsey <bwy>   08/04/02 08:53:46

Modified files:
        .              : ChangeLog 
        server         : as_value.cpp 
        testsuite/misc-swfc.all: swf4opcode.sc 

Log message:
                * server/as_value.cpp: use stringstream instead of strtod to 
avoid
                  different locales changing the result (SWF4 only).
                * testsuite/misc-swfc.all: tests passing.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.6157&r2=1.6158
http://cvs.savannah.gnu.org/viewcvs/gnash/server/as_value.cpp?cvsroot=gnash&r1=1.128&r2=1.129
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/misc-swfc.all/swf4opcode.sc?cvsroot=gnash&r1=1.12&r2=1.13

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.6157
retrieving revision 1.6158
diff -u -b -r1.6157 -r1.6158
--- ChangeLog   2 Apr 2008 08:34:33 -0000       1.6157
+++ ChangeLog   2 Apr 2008 08:53:44 -0000       1.6158
@@ -1,3 +1,9 @@
+2008-04-01 Benjamin Wolsey <address@hidden>
+
+       * server/as_value.cpp: use stringstream instead of strtod to avoid
+         different locales changing the result (SWF4 only).
+       * testsuite/misc-swfc.all: tests passing.
+
 2008-04-01 Sandro Santilli <address@hidden>
 
        * testsuite/misc-swfc.all/swf4opcode.sc: make swf4 dejagnu interface

Index: server/as_value.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/as_value.cpp,v
retrieving revision 1.128
retrieving revision 1.129
diff -u -b -r1.128 -r1.129
--- server/as_value.cpp 2 Apr 2008 08:21:49 -0000       1.128
+++ server/as_value.cpp 2 Apr 2008 08:53:45 -0000       1.129
@@ -399,16 +399,25 @@
             }
             else if(swfversion <= 4)
             {
-               const std::string& s = getStr();
-               const char* nptr = s.c_str();
-               char* endptr = NULL;
-               double d = strtod(nptr, &endptr);
+                // For SWF4, any valid number before non-numerical
+                // characters is returned, including exponent, positive
+                // and negative signs and whitespace before. A stringstream
+                // does the job. Locale differences (decimal separator) arise
+                // with strtod.                
+                double d = 0;
+                std::istringstream is (getStr());
+                is >> d;
                return d;
             }
 
             // @@ Moock says the rule here is: if the
             // string is a valid float literal, then it
             // gets converted; otherwise it is set to NaN.
+            // Valid for SWF5 and above.
+            //
+            // boost::lexical_cast is remarkably inflexible and 
+            // fails for anything that has non-numerical characters.
+            // Fortunately, actionscript is equally inflexible.
             try 
             { 
                 double d = boost::lexical_cast<double>(getStr());

Index: testsuite/misc-swfc.all/swf4opcode.sc
===================================================================
RCS file: /sources/gnash/gnash/testsuite/misc-swfc.all/swf4opcode.sc,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -b -r1.12 -r1.13
--- testsuite/misc-swfc.all/swf4opcode.sc       2 Apr 2008 08:34:34 -0000       
1.12
+++ testsuite/misc-swfc.all/swf4opcode.sc       2 Apr 2008 08:53:45 -0000       
1.13
@@ -134,22 +134,22 @@
     y = '4.5';
         check_equals( y, 4.5 );
     y = '4,5';
-        xcheck_equals( y, 4 ); 
+        check_equals( y, 4 ); 
     // exponent       
     y = '4.5e4';
-        xcheck_equals( y, 45000 );
+        check_equals( y, 45000 );
     y = '4.5E4';
-        xcheck_equals( y, 45000 );
+        check_equals( y, 45000 );
     y = '+4.5e4';
-        xcheck_equals( y, 45000 );
+        check_equals( y, 45000 );
     y = '-4.5e4';
-        xcheck_equals( y, -45000 );
+        check_equals( y, -45000 );
     y = '4.5e+4';
-        xcheck_equals( y, 45000 );
+        check_equals( y, 45000 );
     y = '4.5e-4';
-        xcheck_equals( y, 0.00045 );
+        check_equals( y, 0.00045 );
     y = '-4.5e-4';
-        xcheck_equals( y, -0.00045 );
+        check_equals( y, -0.00045 );
        x = '2e1';
         check_equals(x+1, 21);
         //




reply via email to

[Prev in Thread] Current Thread [Next in Thread]