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: Sat, 06 Oct 2007 07:08:52 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Changes by:     Sandro Santilli <strk>  07/10/06 07:08:52

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

Log message:
                * server/asobj/string.cpp (string_index_of): only use second 
argument
                  if it casts to positive integer.
                * testsuite/actionscript.all/String.as: more tests.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.4550&r2=1.4551
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/string.cpp?cvsroot=gnash&r1=1.37&r2=1.38
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/actionscript.all/String.as?cvsroot=gnash&r1=1.24&r2=1.25

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.4550
retrieving revision 1.4551
diff -u -b -r1.4550 -r1.4551
--- ChangeLog   6 Oct 2007 06:28:29 -0000       1.4550
+++ ChangeLog   6 Oct 2007 07:08:52 -0000       1.4551
@@ -1,5 +1,11 @@
 2007-10-06 Sandro Santilli <address@hidden>
 
+       * server/asobj/string.cpp (string_index_of): only use second argument
+         if it casts to positive integer.
+       * testsuite/actionscript.all/String.as: more tests.
+
+2007-10-06 Sandro Santilli <address@hidden>
+
        * server/as_function.cpp (function_call): handle the case in which
          first argument given to Function.call does not cast to an object.
          The handling is not correct, but at least prevents assertion

Index: server/asobj/string.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/string.cpp,v
retrieving revision 1.37
retrieving revision 1.38
diff -u -b -r1.37 -r1.38
--- server/asobj/string.cpp     27 Sep 2007 22:20:07 -0000      1.37
+++ server/asobj/string.cpp     6 Oct 2007 07:08:52 -0000       1.38
@@ -16,7 +16,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.37 2007/09/27 22:20:07 strk Exp $ */
+/* $Id: string.cpp,v 1.38 2007/10/06 07:08:52 strk Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -409,12 +409,27 @@
 
     ENSURE_FN_ARGS(1, 2, -1);
 
-    const std::string& toFind = fn.arg(0).to_string(&(fn.env()));
+    as_value& tfarg = fn.arg(0); // to find arg
+    const std::string& toFind = tfarg.to_string(&(fn.env()));
 
     size_t start = 0;
 
-    if (fn.nargs >= 2) {
-        start = fn.arg(1).to_number<size_t>();
+    if (fn.nargs >= 2)
+    {
+        as_value& saval = fn.arg(1); // start arg val
+        int start_arg = saval.to_int(fn.env());
+        if ( start_arg > 0 ) start = (size_t) start_arg;
+       else
+       {
+               IF_VERBOSE_ASCODING_ERRORS(
+               if ( start_arg < 0 )
+               {
+                       log_aserror("String.indexOf(%s, %s): second argument 
casts to invalid offset (%d)",
+                               tfarg.to_debug_string().c_str(),
+                               saval.to_debug_string().c_str(), start_arg);
+               }
+               );
+       }
     }
 
     size_t pos = str.find(toFind, start);

Index: testsuite/actionscript.all/String.as
===================================================================
RCS file: /sources/gnash/gnash/testsuite/actionscript.all/String.as,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -b -r1.24 -r1.25
--- testsuite/actionscript.all/String.as        5 Oct 2007 22:27:57 -0000       
1.24
+++ testsuite/actionscript.all/String.as        6 Oct 2007 07:08:52 -0000       
1.25
@@ -16,7 +16,7 @@
 
 // Original author: Mike Carlson - June 19th, 2006
 
-rcsid="$Id: String.as,v 1.24 2007/10/05 22:27:57 strk Exp $";
+rcsid="$Id: String.as,v 1.25 2007/10/06 07:08:52 strk Exp $";
 
 #include "check.as"
 
@@ -34,19 +34,34 @@
 check_equals ( a.charAt(4), "a" );
 isNaN ( a.charAt(-1) );
 isNaN (a.charAt(21) );
-check_equals ( a.indexOf("lawa"), 3 );
 check_equals ( a.lastIndexOf("lawa"), 8);
 
 //----------------------------------------
 // Check String.indexOf
 //-----------------------------------------
 
+// wallawallawashinGTON
+check_equals ( a.indexOf("lawa"), 3 );
 check_equals ( a.indexOf("lawas"), 8 );
 check_equals ( a.indexOf("hinG"), 13 );
 check_equals ( a.indexOf("hing"), -1 );
 check_equals ( a.indexOf("lawas", -1), 8 );
 check_equals ( a.indexOf("a", 2), 4 );
-//TODO: add many more tests with a second argument to indexOf !
+check_equals ( a.indexOf("a", -1), 1 ); 
+check_equals ( a.indexOf("a", -2), 1 ); 
+check_equals ( a.indexOf("l"), 2 ); 
+check_equals ( a.indexOf("l", 2.1), 2 ); 
+check_equals ( a.indexOf("l", 2.8), 2 ); 
+check_equals ( a.indexOf("l", 3), 3 ); 
+check_equals ( a.indexOf("l", 3.5), 3 ); 
+check_equals ( a.indexOf("l", 3.8), 3 ); 
+check_equals ( a.indexOf("l", -3.8), 2 ); 
+check_equals ( a.indexOf("l", -4.8), 2 ); 
+check_equals ( a.indexOf("l", -4), 2 ); 
+o = {}; o.valueOf = function() { return 2; };
+check_equals ( a.indexOf("a", o), 4 ); 
+o2 = {}; o2.toString = function() { return "a"; };
+check_equals ( a.indexOf(o2, o), 4 ); 
 
 //----------------------------------------
 // Check String.split




reply via email to

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