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


From: Benjamin Wolsey
Subject: [Gnash-commit] gnash ChangeLog server/asobj/string.cpp
Date: Fri, 07 Mar 2008 16:17:54 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Changes by:     Benjamin Wolsey <bwy>   08/03/07 16:17:54

Modified files:
        .              : ChangeLog 
        server/asobj   : string.cpp 

Log message:
                * server/asobj/string.cpp: substring end pos is also set to
                  0 if it's a negative number and, where relevant, swapped
                  with start pos. More swfdec testsuite passes.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.5840&r2=1.5841
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/string.cpp?cvsroot=gnash&r1=1.56&r2=1.57

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.5840
retrieving revision 1.5841
diff -u -b -r1.5840 -r1.5841
--- ChangeLog   7 Mar 2008 12:39:18 -0000       1.5840
+++ ChangeLog   7 Mar 2008 16:17:52 -0000       1.5841
@@ -1,5 +1,11 @@
 2008-03-07 Benjamin Wolsey <address@hidden>
 
+       * server/asobj/string.cpp: substring end pos is also set to
+         0 if it's a negative number and, where relevant, swapped with
+         start pos. More swfdec testsuite passes.
+       
+2008-03-07 Benjamin Wolsey <address@hidden>
+
        * gui/gui.{h,cpp}: make data tree-shaped instead of flat.
        * gui/gtk.cpp: update properties dialogue to use tree view.
 

Index: server/asobj/string.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/string.cpp,v
retrieving revision 1.56
retrieving revision 1.57
diff -u -b -r1.56 -r1.57
--- server/asobj/string.cpp     6 Mar 2008 15:29:57 -0000       1.56
+++ server/asobj/string.cpp     7 Mar 2008 16:17:54 -0000       1.57
@@ -419,8 +419,11 @@
     return as_value(utf8::encodeCanonicalString(wstr.substr(start, num), 
version));
 }
 
-// 1st param: start_index, 2nd param: end_index
-// end_index is 1-based.
+// string.substring(start[, end])
+// If *either* value is less than 0, 0 is used.
+// The values are swapped if end is smaller than start.
+// Valid values for the start position are up to string 
+// length - 1.
 static as_value
 string_sub_string(const fn_call& fn)
 {
@@ -433,39 +436,38 @@
     ENSURE_FN_ARGS(1, 2, obj->str());
 
     int start = fn.arg(0).to_number<int>();
+    int end = wstr.size();
 
     if (start < 0) {
         start = 0;
     }
 
-    if (static_cast<unsigned>(start) > wstr.size()) {
+    if (static_cast<unsigned>(start) >= wstr.size()) {
         return as_value("");
     }
 
-    int end = wstr.size();
-
     if (fn.nargs >= 2) {
         int num = fn.arg(1).to_number<int>();
 
         if (num < 0) {
-            return as_value("");
+            num = 0;
         }
 
-        if (num >= 1 && static_cast<unsigned>(num) < wstr.size()) {
             end = num;
 
             if (end < start) {
                 IF_VERBOSE_ASCODING_ERRORS(
                     log_aserror(_("string.slice() called with end < start"));
                 )
-                std::swap(end, start);
+            std::swap (end, start);
             }
-
-            end -= start;
         }
 
+    if (static_cast<unsigned>(end) > wstr.size()) {
+        end = wstr.size();
     }
 
+    end -= start;
     //log_debug("Start: %d, End: %d", start, end);
 
     return as_value(utf8::encodeCanonicalString(wstr.substr(start, end), 
version));




reply via email to

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