gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] gnash ChangeLog server/asobj/string.cpp testsui...


From: Sandro Santilli
Subject: [Gnash-commit] gnash ChangeLog server/asobj/string.cpp testsui...
Date: Thu, 29 Mar 2007 08:44:06 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Changes by:     Sandro Santilli <strk>  07/03/29 08:44:05

Modified files:
        .              : ChangeLog 
        server/asobj   : string.cpp 
        testsuite/actionscript.all: String.as 

Log message:
                * server/asobj/string.cpp (string_split): fix compiler wanring
                  and handle SWF5 case.
                * testsuite/actionscript.all/String.as: expect less failures.
        
        WARNING: there are a lot of String.split() testcases missing, 
specifically
        the ones taking more then a single argument (the 'limit' part, which 
would
        affect the warning fix) -- Anyone willing to add tests ?

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.2712&r2=1.2713
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/string.cpp?cvsroot=gnash&r1=1.24&r2=1.25
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/actionscript.all/String.as?cvsroot=gnash&r1=1.16&r2=1.17

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.2712
retrieving revision 1.2713
diff -u -b -r1.2712 -r1.2713
--- ChangeLog   29 Mar 2007 07:36:16 -0000      1.2712
+++ ChangeLog   29 Mar 2007 08:44:05 -0000      1.2713
@@ -1,5 +1,8 @@
 2007-03-29 Sandro Santilli <address@hidden>
 
+       * server/asobj/string.cpp (string_split): fix compiler wanring
+         and handle SWF5 case.
+       * testsuite/actionscript.all/String.as: expect less failures.
        * server/sprite_instance.{h,cpp} add queueActions() method.
        * server/swf/tag_loaders.cpp: fix compiler warnings.
        * testsuite/server/Makefile.am: link in libgnashparser for the

Index: server/asobj/string.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/string.cpp,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -b -r1.24 -r1.25
--- server/asobj/string.cpp     28 Mar 2007 15:22:24 -0000      1.24
+++ server/asobj/string.cpp     29 Mar 2007 08:44:05 -0000      1.25
@@ -14,7 +14,7 @@
 // along with this program; if not, write to the Free Software
 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
-/* $Id: string.cpp,v 1.24 2007/03/28 15:22:24 bjacques Exp $ */
+/* $Id: string.cpp,v 1.25 2007/03/29 08:44:05 strk Exp $ */
 
 // Implementation of ActionScript String class.
 
@@ -228,21 +228,34 @@
 
     std::string delim = fn.arg(0).to_std_string();
 
-    if (delim == "") {
-        for (unsigned i=0; i < str.size(); i++) {
-            val.set_std_string(str.substr(i, i+1));
+    // SWF5 didn't support multichar or empty delimiter
+    if ( fn.env().get_version() < 6 )
+    {
+           if ( delim.size() != 1 )
+           {
+                   val.set_std_string(str);
             array->push(val);
-        }
-
         return as_value(array.get());
     }
+    }
 
-    size_t max = -1;
+    size_t max = str.size();
 
     if (fn.nargs >= 2) {
-        max = fn.arg(1).to_number<size_t>();
+        max = iclamp(fn.arg(1).to_number<size_t>(), 0, str.size());
     }
 
+    //if (delim == "") {
+    if ( delim.empty() ) {
+        for (unsigned i=0; i <max; i++) {
+            val.set_std_string(str.substr(i, i+1));
+            array->push(val);
+        }
+
+        return as_value(array.get());
+    }
+
+
     size_t pos = 0, prevpos = 0;
     size_t num = 0;
 

Index: testsuite/actionscript.all/String.as
===================================================================
RCS file: /sources/gnash/gnash/testsuite/actionscript.all/String.as,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -b -r1.16 -r1.17
--- testsuite/actionscript.all/String.as        28 Mar 2007 15:22:24 -0000      
1.16
+++ testsuite/actionscript.all/String.as        29 Mar 2007 08:44:05 -0000      
1.17
@@ -16,7 +16,7 @@
 
 // Original author: Mike Carlson - June 19th, 2006
 
-rcsid="$Id: String.as,v 1.16 2007/03/28 15:22:24 bjacques Exp $";
+rcsid="$Id: String.as,v 1.17 2007/03/29 08:44:05 strk Exp $";
 
 #include "check.as"
 
@@ -39,9 +39,24 @@
 check_equals ( a.indexOf("lawas"), 8 );
 check_equals ( a.indexOf("hinG"), 13 );
 check_equals ( a.indexOf("hing"), -1 );
+
+//----------------------------------------
+// Check String.split
+//-----------------------------------------
+
+check_equals ( typeof(a.split), 'function' );
+check ( ! a.hasOwnProperty('split') );
+#if OUTPUT_VERSION > 5
+check ( a.__proto__.hasOwnProperty('split') );
+check ( a.__proto__ == String.prototype );
+#endif
+
 check_equals ( a.split()[0], "wallawallawashinGTON" );
 check_equals ( a.split().length, 1 );
 check ( a.split() instanceof Array );
+check_equals ( a.split("w").length, 4);
+check_equals ( a.split("  w").length, 1);
+
 #if OUTPUT_VERSION > 5
 check_equals ( a.split("")[0], "w" );
 check_equals ( a.split("")[19], "N" );
@@ -50,12 +65,14 @@
 check_equals ( a.split("la")[2], "washinGTON" );
 check_equals ( a.split("la").length, 3 );
 #else
-xcheck_equals ( a.split("")[0], "wallawallawashinGTON" );
-xcheck_equals ( a.split("")[19], undefined );
-xcheck_equals ( a.split("la")[0], "wallawallawashinGTON" );
-xcheck_equals ( a.split("la")[1], undefined );
-xcheck_equals ( a.split("la")[2], undefined );
-xcheck_equals ( a.split("la").length, 1 );
+// empty delimiter doesn't have a special meaning in SWF5
+check_equals ( a.split("")[0], "wallawallawashinGTON" );
+check_equals ( a.split("")[19], undefined );
+// mulit-char delimiter doesn't work in SWF5
+check_equals ( a.split("la")[0], "wallawallawashinGTON" );
+check_equals ( a.split("la")[1], undefined );
+check_equals ( a.split("la")[2], undefined );
+check_equals ( a.split("la").length, 1 );
 #endif
 
 




reply via email to

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