[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] /srv/bzr/gnash/trunk r10531: Skip leading blanks when doi
From: |
Sandro Santilli |
Subject: |
[Gnash-commit] /srv/bzr/gnash/trunk r10531: Skip leading blanks when doing string-to-number, fixes a few tests. |
Date: |
Fri, 09 Jan 2009 13:30:36 +0100 |
User-agent: |
Bazaar (1.5) |
------------------------------------------------------------
revno: 10531
committer: Sandro Santilli <address@hidden>
branch nick: trunk
timestamp: Fri 2009-01-09 13:30:36 +0100
message:
Skip leading blanks when doing string-to-number, fixes a few tests.
Left tests are for 0x## forms.
modified:
libcore/as_value.cpp
testsuite/actionscript.all/Global.as
testsuite/actionscript.all/Number.as
=== modified file 'libcore/as_value.cpp'
--- a/libcore/as_value.cpp 2009-01-03 15:29:43 +0000
+++ b/libcore/as_value.cpp 2009-01-09 12:30:36 +0000
@@ -659,16 +659,15 @@
if ( swfversion > 5 )
{
- if ( s.length() == 8 && s[0] == '0' && ( s[1] == 'x' || s[1] ==
'X' ) )
- {
- try {
- boost::uint8_t r = (parseHex(s[2])<<4) + parseHex(s[3]);
- boost::uint8_t g = (parseHex(s[4])<<4) + parseHex(s[5]);
- boost::uint8_t b = (parseHex(s[6])<<4) + parseHex(s[7]);
- return (double)((r<<16)|(g<<8)|b);
- } catch (invalidHexDigit) { }
-
- }
+ if ( s.length() == 8 && s[0] == '0' && ( s[1] == 'x' || s[1]
== 'X' ) )
+ {
+ try {
+ boost::uint8_t r = (parseHex(s[2])<<4) +
parseHex(s[3]);
+ boost::uint8_t g = (parseHex(s[4])<<4) +
parseHex(s[5]);
+ boost::uint8_t b = (parseHex(s[6])<<4) +
parseHex(s[7]);
+ return (double)((r<<16)|(g<<8)|b);
+ } catch (invalidHexDigit) { }
+ }
}
else if (swfversion <= 4)
{
@@ -691,7 +690,11 @@
// Fortunately, actionscript is equally inflexible.
try
{
- double d = boost::lexical_cast<double>(getStr());
+
+ const char* p = s.c_str();
+ // skip blanks
+ while (*p && isblank(*p)) ++p;
+ double d = boost::lexical_cast<double>(p);
return d;
}
catch (boost::bad_lexical_cast &)
@@ -706,11 +709,11 @@
case NULLTYPE:
case UNDEFINED:
- {
+ {
// Evan: from my tests
// Martin: FlashPlayer6 gives 0; FP9 gives NaN.
return ( swfversion >= 7 ? NaN : 0 );
- }
+ }
case BOOLEAN:
// Evan: from my tests
=== modified file 'testsuite/actionscript.all/Global.as'
--- a/testsuite/actionscript.all/Global.as 2008-03-31 22:48:31 +0000
+++ b/testsuite/actionscript.all/Global.as 2009-01-09 12:30:36 +0000
@@ -401,7 +401,7 @@
check_equals (int(6.1), 6);
check_equals (int("-7.8"), -7);
check_equals (int("6.1"), 6);
-xcheck_equals (int(" -7.8"), -7);
+check_equals (int(" -7.8"), -7);
/// Integer values
check_equals (int(0), 0);
@@ -432,7 +432,7 @@
xcheck_equals(int("0123"), 83);
xcheck_equals(int("-0123"), -83);
#endif
-xcheck_equals(int(" 0123"), 123);
+check_equals(int(" 0123"), 123);
check_equals(int("- 0123"), 0);
check_equals(int(" 0-123"), 0);
check_equals(int("01238"), 1238);
=== modified file 'testsuite/actionscript.all/Number.as'
--- a/testsuite/actionscript.all/Number.as 2009-01-09 12:07:45 +0000
+++ b/testsuite/actionscript.all/Number.as 2009-01-09 12:30:36 +0000
@@ -571,7 +571,7 @@
check_equals(a.toString(), "0.00123456789123456"); // round abs down (obvious?)
a=new Number(" 2");
-xcheck_equals(a, 2);
+check_equals(a, 2);
a=new Number("
2");
xcheck_equals(a, 2);
@@ -589,7 +589,7 @@
check_equals(a, 2);
a=new Number(new String(" 2"));
-xcheck_equals(a, 2);
+check_equals(a, 2);
a=new Number("0x2");
#if OUTPUT_VERSION < 6
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gnash-commit] /srv/bzr/gnash/trunk r10531: Skip leading blanks when doing string-to-number, fixes a few tests.,
Sandro Santilli <=