[Swfdec] Branch 'as' - 8 commits - libswfdec/swfdec_as_context.c libswfdec/swfdec_as_interpret.c libswfdec/swfdec_as_string.c libswfdec/swfdec_as_strings.c libswfdec/swfdec_as_types.c test/trace

Benjamin Otte company at kemper.freedesktop.org
Thu May 31 14:56:53 PDT 2007


 libswfdec/swfdec_as_context.c               |   20 +
 libswfdec/swfdec_as_interpret.c             |    9 
 libswfdec/swfdec_as_string.c                |   15 -
 libswfdec/swfdec_as_strings.c               |    2 
 libswfdec/swfdec_as_types.c                 |    2 
 test/trace/Makefile.am                      |   28 +
 test/trace/isnan-5.swf                      |binary
 test/trace/isnan-5.swf.trace                |    7 
 test/trace/isnan-6.swf                      |binary
 test/trace/isnan-6.swf.trace                |    7 
 test/trace/isnan-7.swf                      |binary
 test/trace/isnan-7.swf.trace                |    7 
 test/trace/isnan.as                         |    9 
 test/trace/set-overwrite-global-5.swf       |binary
 test/trace/set-overwrite-global-5.swf.trace |    7 
 test/trace/set-overwrite-global-6.swf       |binary
 test/trace/set-overwrite-global-6.swf.trace |    7 
 test/trace/set-overwrite-global-7.swf       |binary
 test/trace/set-overwrite-global-7.swf.trace |    7 
 test/trace/set-overwrite-global.as          |   13 
 test/trace/string-convert-5.swf             |binary
 test/trace/string-convert-5.swf.trace       |    5 
 test/trace/string-convert-6.swf             |binary
 test/trace/string-convert-6.swf.trace       |    6 
 test/trace/string-convert-7.swf             |binary
 test/trace/string-convert-7.swf.trace       |    6 
 test/trace/string-convert.as                |   37 ++
 test/trace/substr-5.swf                     |binary
 test/trace/substr-5.swf.trace               |  420 ++++++++++++++++++++++++++++
 test/trace/substr-6.swf                     |binary
 test/trace/substr-6.swf.trace               |  420 ++++++++++++++++++++++++++++
 test/trace/substr-7.swf                     |binary
 test/trace/substr-7.swf.trace               |  420 ++++++++++++++++++++++++++++
 test/trace/substr.as                        |   12 
 34 files changed, 1458 insertions(+), 8 deletions(-)

New commits:
diff-tree 3c0a7a24da1aa0e7f87c65deb3872b6e95dfa5e4 (from 41b2667964b52d329563d8dc1416159db3fc8fe4)
Author: Benjamin Otte <otte at gnome.org>
Date:   Thu May 31 12:35:57 2007 +0200

    add simple test for isNaN and isFinite

diff --git a/test/trace/Makefile.am b/test/trace/Makefile.am
index a4df73a..273b70b 100644
--- a/test/trace/Makefile.am
+++ b/test/trace/Makefile.am
@@ -166,6 +166,13 @@ EXTRA_DIST = \
 	height3.swf.trace \
 	height4.swf \
 	height4.swf.trace \
+	isnan.as \
+	isnan-5.swf \
+	isnan-5.swf.trace \
+	isnan-6.swf \
+	isnan-6.swf.trace \
+	isnan-7.swf \
+	isnan-7.swf.trace \
 	lifetime1.swf \
 	lifetime1.swf.trace \
 	load-4.swf \
diff --git a/test/trace/isnan-5.swf b/test/trace/isnan-5.swf
new file mode 100644
index 0000000..58da1e1
Binary files /dev/null and b/test/trace/isnan-5.swf differ
diff --git a/test/trace/isnan-5.swf.trace b/test/trace/isnan-5.swf.trace
new file mode 100644
index 0000000..4917d7e
--- /dev/null
+++ b/test/trace/isnan-5.swf.trace
@@ -0,0 +1,7 @@
+Check isNaN and isFinite
+Infinity: inifinite
+-Infinity: inifinite
+NaN: inifinite, NaN
+0: finite
+_level0: inifinite, NaN
+true: finite
diff --git a/test/trace/isnan-6.swf b/test/trace/isnan-6.swf
new file mode 100644
index 0000000..9983703
Binary files /dev/null and b/test/trace/isnan-6.swf differ
diff --git a/test/trace/isnan-6.swf.trace b/test/trace/isnan-6.swf.trace
new file mode 100644
index 0000000..4917d7e
--- /dev/null
+++ b/test/trace/isnan-6.swf.trace
@@ -0,0 +1,7 @@
+Check isNaN and isFinite
+Infinity: inifinite
+-Infinity: inifinite
+NaN: inifinite, NaN
+0: finite
+_level0: inifinite, NaN
+true: finite
diff --git a/test/trace/isnan-7.swf b/test/trace/isnan-7.swf
new file mode 100644
index 0000000..153586a
Binary files /dev/null and b/test/trace/isnan-7.swf differ
diff --git a/test/trace/isnan-7.swf.trace b/test/trace/isnan-7.swf.trace
new file mode 100644
index 0000000..4917d7e
--- /dev/null
+++ b/test/trace/isnan-7.swf.trace
@@ -0,0 +1,7 @@
+Check isNaN and isFinite
+Infinity: inifinite
+-Infinity: inifinite
+NaN: inifinite, NaN
+0: finite
+_level0: inifinite, NaN
+true: finite
diff --git a/test/trace/isnan.as b/test/trace/isnan.as
new file mode 100644
index 0000000..cc7690a
--- /dev/null
+++ b/test/trace/isnan.as
@@ -0,0 +1,9 @@
+// makeswf -v 7 -s 200x150 -r 1 -o isnan.swf isnan.as
+
+trace ("Check isNaN and isFinite");
+numbers = [ Infinity, -Infinity, NaN, 0, this, true ];
+for (i = 0; i < numbers.length; i++) {
+  trace (numbers[i] + (isFinite (numbers[i]) ? ": finite" : ": inifinite") + (isNaN (numbers[i]) ? ", NaN" : ""));
+};
+
+loadMovie ("FSCommand:quit", "");
diff-tree 41b2667964b52d329563d8dc1416159db3fc8fe4 (from 9455718a161adcddb76a64ad8e56574bf33a085f)
Author: Benjamin Otte <otte at gnome.org>
Date:   Thu May 31 12:34:57 2007 +0200

    implement isFinite and isNaN

diff --git a/libswfdec/swfdec_as_context.c b/libswfdec/swfdec_as_context.c
index 2b5cefe..d899d1e 100644
--- a/libswfdec/swfdec_as_context.c
+++ b/libswfdec/swfdec_as_context.c
@@ -763,6 +763,20 @@ swfdec_as_context_ASSetPropFlags (Swfdec
 }
 
 static void
+swfdec_as_context_isFinite (SwfdecAsObject *object, guint argc, SwfdecAsValue *argv, SwfdecAsValue *retval)
+{
+  double d = swfdec_as_value_to_number (object->context, &argv[0]);
+  SWFDEC_AS_VALUE_SET_BOOLEAN (retval, isfinite (d) ? TRUE : FALSE);
+}
+
+static void
+swfdec_as_context_isNaN (SwfdecAsObject *object, guint argc, SwfdecAsValue *argv, SwfdecAsValue *retval)
+{
+  double d = swfdec_as_value_to_number (object->context, &argv[0]);
+  SWFDEC_AS_VALUE_SET_BOOLEAN (retval, isnan (d) ? TRUE : FALSE);
+}
+
+static void
 swfdec_as_context_parseInt (SwfdecAsObject *object, guint argc, SwfdecAsValue *argv, SwfdecAsValue *retval)
 {
   int i = swfdec_as_value_to_integer (object->context, &argv[0]);
@@ -780,6 +794,10 @@ swfdec_as_context_init_global (SwfdecAsC
   swfdec_as_object_set_variable (context->global, SWFDEC_AS_STR_NaN, &val);
   SWFDEC_AS_VALUE_SET_NUMBER (&val, HUGE_VAL);
   swfdec_as_object_set_variable (context->global, SWFDEC_AS_STR_Infinity, &val);
+  swfdec_as_object_add_function (context->global, SWFDEC_AS_STR_isFinite, 0,
+      swfdec_as_context_isFinite, 1);
+  swfdec_as_object_add_function (context->global, SWFDEC_AS_STR_isNaN, 0,
+      swfdec_as_context_isNaN, 1);
   swfdec_as_object_add_function (context->global, SWFDEC_AS_STR_parseInt, 0,
       swfdec_as_context_parseInt, 1);
 }
diff --git a/libswfdec/swfdec_as_strings.c b/libswfdec/swfdec_as_strings.c
index 5b3c2f2..a68b8e0 100644
--- a/libswfdec/swfdec_as_strings.c
+++ b/libswfdec/swfdec_as_strings.c
@@ -197,6 +197,8 @@ const char swfdec_as_strings[] = 
   SWFDEC_AS_CONSTANT_STRING ("substring")
   SWFDEC_AS_CONSTANT_STRING ("toLowerCase")
   SWFDEC_AS_CONSTANT_STRING ("toUpperCase")
+  SWFDEC_AS_CONSTANT_STRING ("isFinite")
+  SWFDEC_AS_CONSTANT_STRING ("isNaN")
   /* add more here */
 ;
 
diff-tree 9455718a161adcddb76a64ad8e56574bf33a085f (from 3f57d29295a312faa09d60fbaf9081c662fc4662)
Author: Benjamin Otte <otte at gnome.org>
Date:   Thu May 31 12:03:46 2007 +0200

    functions convert to string as [type Function] autmatically in Flash 5

diff --git a/libswfdec/swfdec_as_types.c b/libswfdec/swfdec_as_types.c
index fff1232..9105a96 100644
--- a/libswfdec/swfdec_as_types.c
+++ b/libswfdec/swfdec_as_types.c
@@ -194,6 +194,8 @@ swfdec_as_value_to_string (SwfdecAsConte
 	  swfdec_as_object_call (object, SWFDEC_AS_STR_toString, 0, NULL, &ret);
 	  if (SWFDEC_AS_VALUE_IS_STRING (&ret))
 	    return SWFDEC_AS_VALUE_GET_STRING (&ret);
+	  else if (context->version <= 5 && SWFDEC_IS_AS_FUNCTION (SWFDEC_AS_VALUE_GET_OBJECT (value)))
+	    return SWFDEC_AS_STR__type_Function_;
 	  else
 	    return SWFDEC_AS_STR__type_Object_;
 	}
diff-tree 3f57d29295a312faa09d60fbaf9081c662fc4662 (from 69b736a2fb59840c11fa4a5a79441e4af953a850)
Author: Benjamin Otte <otte at gnome.org>
Date:   Thu May 31 11:37:42 2007 +0200

    add test that checks global properties don't get overwritten by default

diff --git a/test/trace/Makefile.am b/test/trace/Makefile.am
index 1133cf7..a4df73a 100644
--- a/test/trace/Makefile.am
+++ b/test/trace/Makefile.am
@@ -218,6 +218,13 @@ EXTRA_DIST = \
 	scope.swf.trace \
 	scope2.swf \
 	scope2.swf.trace \
+	set-overwrite-global-5.swf \
+	set-overwrite-global-6.swf \
+	set-overwrite-global-7.swf \
+	set-overwrite-global.as \
+	set-overwrite-global-5.swf.trace \
+	set-overwrite-global-6.swf.trace \
+	set-overwrite-global-7.swf.trace \
 	setinterval.swf \
 	setinterval.swf.trace \
 	setinterval2.swf \
diff --git a/test/trace/set-overwrite-global-5.swf b/test/trace/set-overwrite-global-5.swf
new file mode 100644
index 0000000..bc9e4a7
Binary files /dev/null and b/test/trace/set-overwrite-global-5.swf differ
diff --git a/test/trace/set-overwrite-global-5.swf.trace b/test/trace/set-overwrite-global-5.swf.trace
new file mode 100644
index 0000000..cbba397
--- /dev/null
+++ b/test/trace/set-overwrite-global-5.swf.trace
@@ -0,0 +1,7 @@
+Check the global object doesn't get overwritten when defining variables
+[type Function]
+undefined
+42
+42
+[type Function]
+undefined
diff --git a/test/trace/set-overwrite-global-6.swf b/test/trace/set-overwrite-global-6.swf
new file mode 100644
index 0000000..b35ef23
Binary files /dev/null and b/test/trace/set-overwrite-global-6.swf differ
diff --git a/test/trace/set-overwrite-global-6.swf.trace b/test/trace/set-overwrite-global-6.swf.trace
new file mode 100644
index 0000000..cbba397
--- /dev/null
+++ b/test/trace/set-overwrite-global-6.swf.trace
@@ -0,0 +1,7 @@
+Check the global object doesn't get overwritten when defining variables
+[type Function]
+undefined
+42
+42
+[type Function]
+undefined
diff --git a/test/trace/set-overwrite-global-7.swf b/test/trace/set-overwrite-global-7.swf
new file mode 100644
index 0000000..2060852
Binary files /dev/null and b/test/trace/set-overwrite-global-7.swf differ
diff --git a/test/trace/set-overwrite-global-7.swf.trace b/test/trace/set-overwrite-global-7.swf.trace
new file mode 100644
index 0000000..cbba397
--- /dev/null
+++ b/test/trace/set-overwrite-global-7.swf.trace
@@ -0,0 +1,7 @@
+Check the global object doesn't get overwritten when defining variables
+[type Function]
+undefined
+42
+42
+[type Function]
+undefined
diff --git a/test/trace/set-overwrite-global.as b/test/trace/set-overwrite-global.as
new file mode 100644
index 0000000..032209c
--- /dev/null
+++ b/test/trace/set-overwrite-global.as
@@ -0,0 +1,13 @@
+// makeswf -v 7 -s 200x150 -r 1 -o set-overwrite-global.swf set-overwrite-global.as
+
+trace ("Check the global object doesn't get overwritten when defining variables");
+trace (String);
+trace (this.String);
+String = 42;
+trace (String);
+trace (this.String);
+delete String;
+trace (String);
+trace (this.String);
+
+loadMovie ("FSCommand:quit", "");
diff-tree 69b736a2fb59840c11fa4a5a79441e4af953a850 (from 58d960c87799a285ee740b474ab763dcc024db18)
Author: Benjamin Otte <otte at gnome.org>
Date:   Thu May 31 11:36:41 2007 +0200

    don't overwrite global properties automatically

diff --git a/libswfdec/swfdec_as_context.c b/libswfdec/swfdec_as_context.c
index 672567a..2b5cefe 100644
--- a/libswfdec/swfdec_as_context.c
+++ b/libswfdec/swfdec_as_context.c
@@ -626,7 +626,7 @@ swfdec_as_context_eval_set_property (Swf
       return;
     }
     obj = swfdec_as_frame_find_variable (cx->frame, name);
-    if (obj == NULL)
+    if (obj == NULL || obj == cx->global)
       obj = cx->frame->var_object;
   }
   swfdec_as_object_set_variable (obj, name, ret);
diff-tree 58d960c87799a285ee740b474ab763dcc024db18 (from debd20cff40ff22082d31f715bc04a39dd0c3a27)
Author: Benjamin Otte <otte at gnome.org>
Date:   Thu May 31 11:36:12 2007 +0200

    add test to check that automatic to-object conversion calls _global.String ()

diff --git a/test/trace/Makefile.am b/test/trace/Makefile.am
index da7e158..1133cf7 100644
--- a/test/trace/Makefile.am
+++ b/test/trace/Makefile.am
@@ -236,6 +236,13 @@ EXTRA_DIST = \
 	string-construct-6.swf.trace \
 	string-construct-7.swf \
 	string-construct-7.swf.trace \
+	string-convert.as \
+	string-convert-5.swf \
+	string-convert-5.swf.trace \
+	string-convert-6.swf \
+	string-convert-6.swf.trace \
+	string-convert-7.swf \
+	string-convert-7.swf.trace \
 	substring.as \
 	substr.as \
 	substr-5.swf \
diff --git a/test/trace/string-convert-5.swf b/test/trace/string-convert-5.swf
new file mode 100644
index 0000000..f20be2a
Binary files /dev/null and b/test/trace/string-convert-5.swf differ
diff --git a/test/trace/string-convert-5.swf.trace b/test/trace/string-convert-5.swf.trace
new file mode 100644
index 0000000..c1c4b98
--- /dev/null
+++ b/test/trace/string-convert-5.swf.trace
@@ -0,0 +1,5 @@
+Check how automatic conversion to a string works
+5
+5
+5
+5
diff --git a/test/trace/string-convert-6.swf b/test/trace/string-convert-6.swf
new file mode 100644
index 0000000..402d71b
Binary files /dev/null and b/test/trace/string-convert-6.swf differ
diff --git a/test/trace/string-convert-6.swf.trace b/test/trace/string-convert-6.swf.trace
new file mode 100644
index 0000000..106bcd4
--- /dev/null
+++ b/test/trace/string-convert-6.swf.trace
@@ -0,0 +1,6 @@
+Check how automatic conversion to a string works
+5
+hello
+-1
+undefined
+undefined
diff --git a/test/trace/string-convert-7.swf b/test/trace/string-convert-7.swf
new file mode 100644
index 0000000..d583d3d
Binary files /dev/null and b/test/trace/string-convert-7.swf differ
diff --git a/test/trace/string-convert-7.swf.trace b/test/trace/string-convert-7.swf.trace
new file mode 100644
index 0000000..106bcd4
--- /dev/null
+++ b/test/trace/string-convert-7.swf.trace
@@ -0,0 +1,6 @@
+Check how automatic conversion to a string works
+5
+hello
+-1
+undefined
+undefined
diff --git a/test/trace/string-convert.as b/test/trace/string-convert.as
new file mode 100644
index 0000000..763cc64
--- /dev/null
+++ b/test/trace/string-convert.as
@@ -0,0 +1,37 @@
+// makeswf -v 7 -s 200x150 -r 1 -o string-convert.swf string-convert.as
+
+trace ("Check how automatic conversion to a string works");
+asm {
+  push "hello", "length"
+  getmember
+  trace
+};
+_global.String = function (foo) {
+  trace (foo);
+  this.length = -1;
+};
+String = function (foo) {
+  trace (foo);
+  this.length = 42;
+};
+asm {
+  push "hello", "length"
+  getmember
+  trace
+};
+
+_global.String = 13;
+asm {
+  push "hello", "length"
+  getmember
+  trace
+};
+
+_global.String = new Object ();
+asm {
+  push "hello", "length"
+  getmember
+  trace
+};
+
+loadMovie ("FSCommand:quit", "");
diff-tree debd20cff40ff22082d31f715bc04a39dd0c3a27 (from 32484780944578c9cb5ec71ac8a3df08574902c9)
Author: Benjamin Otte <otte at gnome.org>
Date:   Thu May 31 11:22:02 2007 +0200

    convert to objecct in GetMember action

diff --git a/libswfdec/swfdec_as_interpret.c b/libswfdec/swfdec_as_interpret.c
index e299b0d..ed4a917 100644
--- a/libswfdec/swfdec_as_interpret.c
+++ b/libswfdec/swfdec_as_interpret.c
@@ -535,15 +535,14 @@ out:
 static void
 swfdec_action_get_member (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
 {
-  /* FIXME: do we need a "convert to object" function here? */
-  if (SWFDEC_AS_VALUE_IS_OBJECT (swfdec_as_stack_peek (cx->frame->stack, 2))) {
+  SwfdecAsObject *object = swfdec_as_value_to_object (cx, swfdec_as_stack_peek (cx->frame->stack, 2));
+  if (object) {
     const char *name;
-    SwfdecAsObject *o = SWFDEC_AS_VALUE_GET_OBJECT (swfdec_as_stack_peek (cx->frame->stack, 2));
     name = swfdec_as_value_to_string (cx, swfdec_as_stack_peek (cx->frame->stack, 1));
-    swfdec_as_object_get_variable (o, name, swfdec_as_stack_peek (cx->frame->stack, 2));
+    swfdec_as_object_get_variable (object, name, swfdec_as_stack_peek (cx->frame->stack, 2));
 #ifdef SWFDEC_WARN_MISSING_PROPERTIES
     if (SWFDEC_AS_VALUE_IS_UNDEFINED (swfdec_as_stack_peek (cx->frame->stack, 2))) {
-	SWFDEC_WARNING ("no variable named %s:%s", G_OBJECT_TYPE_NAME (o), s);
+	SWFDEC_WARNING ("no variable named %s:%s", G_OBJECT_TYPE_NAME (object), s);
     }
 #endif
   } else {
diff --git a/test/trace/Makefile.am b/test/trace/Makefile.am
index dc9827c..da7e158 100644
--- a/test/trace/Makefile.am
+++ b/test/trace/Makefile.am
@@ -237,6 +237,13 @@ EXTRA_DIST = \
 	string-construct-7.swf \
 	string-construct-7.swf.trace \
 	substring.as \
+	substr.as \
+	substr-5.swf \
+	substr-5.swf.trace \
+	substr-6.swf \
+	substr-6.swf.trace \
+	substr-7.swf \
+	substr-7.swf.trace \
 	substring-5.swf \
 	substring-5.swf.trace \
 	substring-6.swf \
diff --git a/test/trace/substr-5.swf b/test/trace/substr-5.swf
new file mode 100644
index 0000000..3704fb9
Binary files /dev/null and b/test/trace/substr-5.swf differ
diff --git a/test/trace/substr-5.swf.trace b/test/trace/substr-5.swf.trace
new file mode 100644
index 0000000..4bcee52
--- /dev/null
+++ b/test/trace/substr-5.swf.trace
@@ -0,0 +1,420 @@
+-10 - ABCDEF
+-10:-10 - 
+-10:-9 - 
+-10:-8 - 
+-10:-7 - 
+-10:-6 - 
+-10:-5 - A
+-10:-4 - AB
+-10:-3 - ABC
+-10:-2 - ABCD
+-10:-1 - ABCDE
+-10:0 - 
+-10:1 - A
+-10:2 - AB
+-10:3 - ABC
+-10:4 - ABCD
+-10:5 - ABCDE
+-10:6 - ABCDEF
+-10:7 - ABCDEF
+-10:8 - ABCDEF
+-10:9 - ABCDEF
+-9 - ABCDEF
+-9:-10 - 
+-9:-9 - 
+-9:-8 - 
+-9:-7 - 
+-9:-6 - 
+-9:-5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2 - 
+5:-1 - 
+5:0 - 
+5:1 - F
+5:2 - F
+5:3 - F
+5:4 - F
+5:5 - F
+5:6 - F
+5:7 - F
+5:8 - F
+5:9 - F
+6 - 
+6:-10 - 
+6:-9 - 
+6:-8 - 
+6:-7 - 
+6:-6 - 
+6:-5 - 
+6:-4 - 
+6:-3 - 
+6:-2 - 
+6:-1 - 
+6:0 - 
+6:1 - 
+6:2 - 
+6:3 - 
+6:4 - 
+6:5 - 
+6:6 - 
+6:7 - 
+6:8 - 
+6:9 - 
+7 - 
+7:-10 - 
+7:-9 - 
+7:-8 - 
+7:-7 - 
+7:-6 - 
+7:-5 - 
+7:-4 - 
+7:-3 - 
+7:-2 - 
+7:-1 - 
+7:0 - 
+7:1 - 
+7:2 - 
+7:3 - 
+7:4 - 
+7:5 - 
+7:6 - 
+7:7 - 
+7:8 - 
+7:9 - 
+8 - 
+8:-10 - 
+8:-9 - 
+8:-8 - 
+8:-7 - 
+8:-6 - 
+8:-5 - 
+8:-4 - 
+8:-3 - 
+8:-2 - 
+8:-1 - 
+8:0 - 
+8:1 - 
+8:2 - 
+8:3 - 
+8:4 - 
+8:5 - 
+8:6 - 
+8:7 - 
+8:8 - 
+8:9 - 
+9 - 
+9:-10 - 
+9:-9 - 
+9:-8 - 
+9:-7 - 
+9:-6 - 
+9:-5 - 
+9:-4 - 
+9:-3 - 
+9:-2 - 
+9:-1 - 
+9:0 - 
+9:1 - 
+9:2 - 
+9:3 - 
+9:4 - 
+9:5 - 
+9:6 - 
+9:7 - 
+9:8 - 
+9:9 - 
diff --git a/test/trace/substr-6.swf b/test/trace/substr-6.swf
new file mode 100644
index 0000000..e72bbc9
Binary files /dev/null and b/test/trace/substr-6.swf differ
diff --git a/test/trace/substr-6.swf.trace b/test/trace/substr-6.swf.trace
new file mode 100644
index 0000000..4bcee52
--- /dev/null
+++ b/test/trace/substr-6.swf.trace
@@ -0,0 +1,420 @@
+-10 - ABCDEF
+-10:-10 - 
+-10:-9 - 
+-10:-8 - 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- 
+9:5 - 
+9:6 - 
+9:7 - 
+9:8 - 
+9:9 - 
diff --git a/test/trace/substr-7.swf b/test/trace/substr-7.swf
new file mode 100644
index 0000000..2c71c70
Binary files /dev/null and b/test/trace/substr-7.swf differ
diff --git a/test/trace/substr-7.swf.trace b/test/trace/substr-7.swf.trace
new file mode 100644
index 0000000..4bcee52
--- /dev/null
+++ b/test/trace/substr-7.swf.trace
@@ -0,0 +1,420 @@
+-10 - ABCDEF
+-10:-10 - 
+-10:-9 - 
+-10:-8 - 
+-10:-7 - 
+-10:-6 - 
+-10:-5 - A
+-10:-4 - AB
+-10:-3 - ABC
+-10:-2 - ABCD
+-10:-1 - ABCDE
+-10:0 - 
+-10:1 - A
+-10:2 - AB
+-10:3 - ABC
+-10:4 - ABCD
+-10:5 - ABCDE
+-10:6 - ABCDEF
+-10:7 - ABCDEF
+-10:8 - ABCDEF
+-10:9 - ABCDEF
+-9 - ABCDEF
+-9:-10 - 
+-9:-9 - 
+-9:-8 - 
+-9:-7 - 
+-9:-6 - 
+-9:-5 - A
+-9:-4 - AB
+-9:-3 - ABC
+-9:-2 - ABCD
+-9:-1 - ABCDE
+-9:0 - 
+-9:1 - A
+-9:2 - AB
+-9:3 - ABC
+-9:4 - ABCD
+-9:5 - ABCDE
+-9:6 - ABCDEF
+-9:7 - ABCDEF
+-9:8 - ABCDEF
+-9:9 - ABCDEF
+-8 - ABCDEF
+-8:-10 - 
+-8:-9 - 
+-8:-8 - 
+-8:-7 - 
+-8:-6 - 
+-8:-5 - A
+-8:-4 - AB
+-8:-3 - ABC
+-8:-2 - ABCD
+-8:-1 - ABCDE
+-8:0 - 
+-8:1 - A
+-8:2 - AB
+-8:3 - ABC
+-8:4 - ABCD
+-8:5 - ABCDE
+-8:6 - ABCDEF
+-8:7 - ABCDEF
+-8:8 - ABCDEF
+-8:9 - ABCDEF
+-7 - ABCDEF
+-7:-10 - 
+-7:-9 - 
+-7:-8 - 
+-7:-7 - 
+-7:-6 - 
+-7:-5 - A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
+8:-6 - 
+8:-5 - 
+8:-4 - 
+8:-3 - 
+8:-2 - 
+8:-1 - 
+8:0 - 
+8:1 - 
+8:2 - 
+8:3 - 
+8:4 - 
+8:5 - 
+8:6 - 
+8:7 - 
+8:8 - 
+8:9 - 
+9 - 
+9:-10 - 
+9:-9 - 
+9:-8 - 
+9:-7 - 
+9:-6 - 
+9:-5 - 
+9:-4 - 
+9:-3 - 
+9:-2 - 
+9:-1 - 
+9:0 - 
+9:1 - 
+9:2 - 
+9:3 - 
+9:4 - 
+9:5 - 
+9:6 - 
+9:7 - 
+9:8 - 
+9:9 - 
diff --git a/test/trace/substr.as b/test/trace/substr.as
new file mode 100644
index 0000000..09b19a2
--- /dev/null
+++ b/test/trace/substr.as
@@ -0,0 +1,12 @@
+// makeswf -v 7 -s 200x150 -r 1 -o substring.swf substring.as
+
+hi = String ("ABCDEF");
+
+for (from = -10; from < 10; from++) {
+  trace (from + " - " + hi.substr (from));
+  for (len = -10; len < 10; len++) {
+    trace (from + ":" + len + " - " + hi.substr (from, len));
+  };
+};
+
+loadMovie ("FSCommand:quit", "");
diff-tree 32484780944578c9cb5ec71ac8a3df08574902c9 (from 7a7f10a837491fee08b778ff84309021864fac8c)
Author: Benjamin Otte <otte at gnome.org>
Date:   Thu May 31 09:52:21 2007 +0200

    "Fix" String.substr()

diff --git a/libswfdec/swfdec_as_string.c b/libswfdec/swfdec_as_string.c
index c2da01d..b1f9206 100644
--- a/libswfdec/swfdec_as_string.c
+++ b/libswfdec/swfdec_as_string.c
@@ -191,14 +191,25 @@ swfdec_as_string_substr (SwfdecAsObject 
 
   from = swfdec_as_value_to_integer (object->context, &argv[0]);
   len = g_utf8_strlen (string->string, -1);
-  if (from < 0)
-    from += len; /* from = len - ABS (from) aka start from end */
   
   if (argc > 1) {
     to = swfdec_as_value_to_integer (object->context, &argv[1]);
+    /* FIXME: wtf? */
+    if (to < 0) {
+      if (-to <= from)
+	to = 0;
+      else
+	to += len;
+      if (to < 0)
+	to = 0;
+      if (from < 0 && to >= -from)
+	to = 0;
+    }
   } else {
     to = G_MAXINT;
   }
+  if (from < 0)
+    from += len;
   from = CLAMP (from, 0, len);
   to = CLAMP (to, 0, len - from);
   SWFDEC_AS_VALUE_SET_STRING (ret, swfdec_as_str_sub (object->context, string->string, from, to));


More information about the Swfdec mailing list