gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] gnash ChangeLog server/array.cpp testsuite/acti...


From: Sandro Santilli
Subject: [Gnash-commit] gnash ChangeLog server/array.cpp testsuite/acti...
Date: Sun, 29 Jul 2007 12:45:26 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Changes by:     Sandro Santilli <strk>  07/07/29 12:45:25

Modified files:
        .              : ChangeLog 
        server         : array.cpp 
        testsuite/actionscript.all: array.as 

Log message:
        Patch #6123 by address@hidden:
        
                * server/array.cpp: Fix bug in the array.splice(index) method to
                  prevent an incorrect number of elements being spliced; fix bug
                  in the array.slice(startindex, endindex) method for certain
                  negative endindexes; elements in a newly created array with
                  non-zero size are now assigned a value of 'undefined' rather
                  than 'null'; trivial optimizations/clean-ups.
                * testsuite/actionscript.all/array.as: more tests.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.3857&r2=1.3858
http://cvs.savannah.gnu.org/viewcvs/gnash/server/array.cpp?cvsroot=gnash&r1=1.65&r2=1.66
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/actionscript.all/array.as?cvsroot=gnash&r1=1.20&r2=1.21

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.3857
retrieving revision 1.3858
diff -u -b -r1.3857 -r1.3858
--- ChangeLog   29 Jul 2007 04:40:34 -0000      1.3857
+++ ChangeLog   29 Jul 2007 12:45:24 -0000      1.3858
@@ -1,3 +1,13 @@
+2007-07-29 <address@hidden>
+
+       * server/array.cpp: Fix bug in the array.splice(index) method to
+         prevent an incorrect number of elements being spliced; fix bug
+         in the array.slice(startindex, endindex) method for certain
+         negative endindexes; elements in a newly created array with
+         non-zero size are now assigned a value of 'undefined' rather
+         than 'null'; trivial optimizations/clean-ups.
+       * testsuite/actionscript.all/array.as: more tests.
+
 2007-07-28  Rob Savoye  <address@hidden>
 
        * macros/ffmpeg.m4: Add test for libswscale, which is needed if

Index: server/array.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/array.cpp,v
retrieving revision 1.65
retrieving revision 1.66
diff -u -b -r1.65 -r1.66
--- server/array.cpp    13 Jul 2007 01:13:46 -0000      1.65
+++ server/array.cpp    29 Jul 2007 12:45:25 -0000      1.66
@@ -206,7 +206,7 @@
 as_array_object::pop()
 {
        // If the array is empty, report an error and return undefined!
-       if (elements.size() <= 0)
+       if ( elements.empty() ) 
        {
            log_error(_("tried to pop element from back of empty array, 
returning undef"));
                return as_value(); // undefined
@@ -222,7 +222,7 @@
 as_array_object::shift()
 {
        // If the array is empty, report an error and return undefined!
-       if (elements.size() <= 0)
+       if ( elements.empty() ) 
        {
                log_error(_("tried to shift element from front of empty array, 
returning undef"));
                return as_value(); // undefined
@@ -367,7 +367,7 @@
        }
 
        // Now insert the new stuff, if needed
-       if ( replace.size() )
+       if ( ! replace.empty() )
        {
                container::iterator itStart = elements.begin()+start;
                elements.insert(itStart, replace.begin(), replace.end());
@@ -545,7 +545,7 @@
        //----------------
        // Get length
        //----------------
-       unsigned len = 0;
+       unsigned len = origlen - start;
        if (fn.nargs > 1)
        {
                int lenval = fn.arg(1).to_number<int>(&(fn.env()));
@@ -787,6 +787,7 @@
 
        // start and end index of the part we're slicing
        int startindex, endindex;
+       unsigned int arraysize = array->size();
 
        if (fn.nargs > 2)
        {
@@ -810,7 +811,7 @@
 
        // if the index is negative, it means "places from the end"
        // where -1 is the last element
-       if (startindex < 0) startindex = startindex + array->size();
+       if (startindex < 0) startindex = startindex + arraysize;
 
        // if we sent at least two arguments, setup endindex
        if (fn.nargs >= 2)
@@ -819,26 +820,25 @@
 
                // if the index is negative, it means
                // "places from the end" where -1 is the last element
-               if (endindex < 0) endindex = endindex + array->size();
+               if (endindex < 0) endindex = endindex + arraysize;
        }
        else
        {
                // They didn't specify where to end,
                // so choose the end of the array
-               endindex = array->size();
+               endindex = arraysize;
        }
 
        if ( startindex < 0 ) startindex = 0;
-       else if ( static_cast<size_t>(startindex)  > array->size() ) startindex 
= array->size();
+       else if ( static_cast<size_t>(startindex) > arraysize ) startindex = 
arraysize;
 
-       if ( endindex < 1 ) endindex = 1;
-       else if ( static_cast<size_t>(endindex)  > array->size() ) endindex = 
array->size();
+       if ( endindex < startindex ) endindex = startindex;
+       else if ( static_cast<size_t>(endindex)  > arraysize ) endindex = 
arraysize;
 
        std::auto_ptr<as_array_object> newarray(array->slice(
                startindex, endindex));
 
        return as_value(newarray.release());            
-
 }
 
 static as_value
@@ -874,13 +874,13 @@
        {
                // Create an empty array with the given number of undefined 
elements.
                //
-               as_value        index_number;
-               as_value null_value;
-               null_value.set_null();
+               as_value index_number, undef_value;
+
+               undef_value.set_undefined();
                for (int i = 0; i < int(fn.arg(0).to_number()); i++)
                {
                        index_number.set_int(i);
-                       ao->set_member(index_number.to_string().c_str(), 
null_value);
+                       ao->set_member(index_number.to_string().c_str(), 
undef_value);
                }
        }
        else

Index: testsuite/actionscript.all/array.as
===================================================================
RCS file: /sources/gnash/gnash/testsuite/actionscript.all/array.as,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -b -r1.20 -r1.21
--- testsuite/actionscript.all/array.as 13 Jul 2007 01:13:46 -0000      1.20
+++ testsuite/actionscript.all/array.as 29 Jul 2007 12:45:25 -0000      1.21
@@ -5,7 +5,7 @@
 // Updated with sort functions, and to use check() macro
 // by Mike Carlson Feb. 14th, 2006
 
-rcsid="$Id: array.as,v 1.20 2007/07/13 01:13:46 strk Exp $";
+rcsid="$Id: array.as,v 1.21 2007/07/29 12:45:25 strk Exp $";
 
 #include "check.as"
 
@@ -60,6 +60,14 @@
 // that two arrays are always considered NOT equal - need to verify
 check ( a != b ); 
 
+
+tmp = new Array(2);
+#if OUTPUT_VERSION > 6
+check_equals ( tmp.toString(), "undefined,undefined" );
+#else
+check_equals ( tmp.toString(), "," );
+#endif
+
 check_equals ( a.length, 3 );
 check_equals ( a[2], 12 );
 popped=a.pop();
@@ -187,6 +195,8 @@
 check_equals ( mixed.toString(), "5,6,7,8,9,10,11,12,13");
 
 // invalid calls
+portion = concatted.slice(0, -8);
+check_equals ( portion.toString(), "");
 portion = concatted.slice(-18);
 check_equals ( portion.toString(), "0,1,2,3,4,5,6");
 portion = concatted.slice(-18, 3);
@@ -285,6 +295,11 @@
 check_equals ( ary.length, 4 ); // don't be fooled by toString output !
 check_equals ( spliced.toString(), '2,a,b,10,11,12,8' );
 
+// Finally, ensure the simplest usage cases are correct!
+spliced = ary.splice(1);
+check_equals ( spliced.toString(), "3,4,5,6");
+spliced = ary.splice(0);
+check_equals ( spliced.toString(), "1,2");
 
 //-------------------------------
 // Test single parameter constructor, and implicitly expanding array




reply via email to

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