gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] gnash server/vm/ASHandlers.cpp testsuite/action...


From: Sandro Santilli
Subject: [Gnash-commit] gnash server/vm/ASHandlers.cpp testsuite/action...
Date: Thu, 07 Dec 2006 17:43:38 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Changes by:     Sandro Santilli <strk>  06/12/07 17:43:38

Modified files:
        server/vm      : ASHandlers.cpp 
        testsuite/actionscript.all: String.as 

Log message:
                * testsuite/actionscript.all/String.as: more
                  tests for ActionSubString (invalid calls...)
                * server/vm/ASHandlers.cpp (ActionSubString):
                  do the right thing on invalid calls.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/server/vm/ASHandlers.cpp?cvsroot=gnash&r1=1.11&r2=1.12
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/actionscript.all/String.as?cvsroot=gnash&r1=1.7&r2=1.8

Patches:
Index: server/vm/ASHandlers.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/vm/ASHandlers.cpp,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -b -r1.11 -r1.12
--- server/vm/ASHandlers.cpp    7 Dec 2006 15:08:13 -0000       1.11
+++ server/vm/ASHandlers.cpp    7 Dec 2006 17:43:38 -0000       1.12
@@ -16,7 +16,7 @@
 
 //
 
-/* $Id: ASHandlers.cpp,v 1.11 2006/12/07 15:08:13 strk Exp $ */
+/* $Id: ASHandlers.cpp,v 1.12 2006/12/07 17:43:38 strk Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -940,21 +940,29 @@
     // TODO: if 'base' or 'size' do not evaluate to numbers return 
     //       the empty string (how do we check if they evaluate ??)
 
-    // negative base refer to index from end
-    // -1 is *last* character, otherwise
-    // they are 1-based index from start
-    if ( base < 0 ) base += str.length();
-    else base = base-1;
+    if ( base < 1 )
+    {
+       IF_VERBOSE_ASCODING_ERRORS (
+       log_warning("Less then 1 base in ActionSubString, "
+               "setting to 1.");
+       );
+       base=1;
+    }
 
-    if ( base < 0 || base >= str.length() )
+    else if ( base >= str.length() )
     {
-       log_warning("Invalid base passed to ActionSubString, "
-               "returning undefined");
+       IF_VERBOSE_ASCODING_ERRORS (
+       log_warning("base goes beyond input string in ActionSubString, "
+               "returning the empty string.");
+       );
        env.drop(2);
-       env.top(0).set_undefined();
+       env.top(0).set_string("");
        return;
     }
 
+    // Base is 1-based, we'll use 0-based from now on...
+    base -= 1;
+
     if ( base+size > str.length() )
     {
        IF_VERBOSE_ASCODING_ERRORS (

Index: testsuite/actionscript.all/String.as
===================================================================
RCS file: /sources/gnash/gnash/testsuite/actionscript.all/String.as,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -b -r1.7 -r1.8
--- testsuite/actionscript.all/String.as        7 Dec 2006 15:13:33 -0000       
1.7
+++ testsuite/actionscript.all/String.as        7 Dec 2006 17:43:38 -0000       
1.8
@@ -1,7 +1,7 @@
 // Mike Carlson's test program for actionscript strings
 // June 19th, 2006
 
-rcsid="$Id: String.as,v 1.7 2006/12/07 15:13:33 strk Exp $";
+rcsid="$Id: String.as,v 1.8 2006/12/07 17:43:38 strk Exp $";
 
 #include "check.as"
 
@@ -55,6 +55,7 @@
 check_equals ( b.substring(3, 6), "4");
 check_equals ( b.substr(3, 6), "4");
 
+#define MING_SUPPORTS_ASM
 #ifdef MING_SUPPORTS_ASM
 // We need ming-0.4.0beta2 or later for this to work...
 // This is the only way to generate an SWFACTION_SUBSTRING
@@ -70,6 +71,33 @@
        setvariable
 };
 check_equals( b, "iao");
+asm {
+       push "b"
+       push "ciao"
+       push "-2" // negative base should be interpreted as 1
+       push "1" 
+       substring
+       setvariable
+};
+check_equals( b, "c");
+asm {
+       push "b"
+       push "ciao"
+       push "0" // zero base is invalid, but taken as 1
+       push "1" 
+       substring
+       setvariable
+};
+check_equals( b, "c");
+asm {
+       push "b"
+       push "ciao"
+       push "10" // too large base ...
+       push "1" 
+       substring
+       setvariable
+};
+check_equals( b, "");
 #endif
 
 




reply via email to

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