gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] /srv/bzr/gnash/trunk r10522: Make XML errors compatible (


From: Benjamin Wolsey
Subject: [Gnash-commit] /srv/bzr/gnash/trunk r10522: Make XML errors compatible (according to the swfdec testsuite).
Date: Thu, 08 Jan 2009 17:46:59 +0100
User-agent: Bazaar (1.5)

------------------------------------------------------------
revno: 10522
committer: Benjamin Wolsey <address@hidden>
branch nick: trunk
timestamp: Thu 2009-01-08 17:46:59 +0100
message:
  Make XML errors compatible (according to the swfdec testsuite).
  
  Correct ActionDivide when dividing by 0.
modified:
  libcore/asobj/XML_as.cpp
  libcore/vm/ASHandlers.cpp
  testsuite/swfdec/PASSING
    ------------------------------------------------------------
    revno: 10521.1.1
    committer: Benjamin Wolsey <address@hidden>
    branch nick: work
    timestamp: Thu 2009-01-08 16:29:18 +0100
    message:
      An empty tag counts as unterminated, and therefore malformed XML.
    modified:
      libcore/asobj/XML_as.cpp
    ------------------------------------------------------------
    revno: 10521.1.2
    committer: Benjamin Wolsey <address@hidden>
    branch nick: work
    timestamp: Thu 2009-01-08 16:35:29 +0100
    message:
      Report missing closing tag. Tests in swfdec testsuite now pass (xml-error)
      for versions 7 and 8. The earlier version fail due to the string_table
      case bug.
    modified:
      libcore/asobj/XML_as.cpp
    ------------------------------------------------------------
    revno: 10521.1.3
    committer: Benjamin Wolsey <address@hidden>
    branch nick: work
    timestamp: Thu 2009-01-08 17:20:10 +0100
    message:
      Handle division by 0 compatibly (and C++ standard compliant).
    modified:
      libcore/vm/ASHandlers.cpp
=== modified file 'libcore/asobj/XML_as.cpp'
--- a/libcore/asobj/XML_as.cpp  2009-01-08 09:06:51 +0000
+++ b/libcore/asobj/XML_as.cpp  2009-01-08 15:35:29 +0000
@@ -370,12 +370,16 @@
 
     // Knock off the "/>" of a self-closing tag.
     if (std::equal(endName - 1, endName + 1, "/>")) {
+        // This can leave endName before it, e.g when a self-closing tag is
+        // empty ("</>"). This must be checked before trying to construct
+        // a string!
         --endName;
-        // This can leave endName before it, e.g when the tag is "</>".
-        if (it >= endName) {
-            _status = XML_UNTERMINATED_ELEMENT;
-            return;
-        }
+    }
+    
+    // If the tag is empty, the XML counts as malformed. 
+    if (it >= endName) {
+        _status = XML_UNTERMINATED_ELEMENT;
+        return;
     }
 
     std::string tagName(it, endName);
@@ -575,8 +579,13 @@
         }
         else parseText(node, xml, it);
     }
-  
-    return;
+
+    // If everything parsed correctly, check that we've got back to the
+    // parent node. If not, there is a missing closing tag.
+    if (_status == XML_OK && node != this) {
+        _status = XML_MISSING_CLOSE_TAG;
+    }
+
 }
 
 bool

=== modified file 'libcore/vm/ASHandlers.cpp'
--- a/libcore/vm/ASHandlers.cpp 2009-01-07 13:41:57 +0000
+++ b/libcore/vm/ASHandlers.cpp 2009-01-08 16:46:59 +0000
@@ -752,6 +752,11 @@
     env.drop(1);
 }
 
+
+// Negative number / 0: -infinity
+// Positive number / 0: infinity
+// 0 / 0 : NaN
+// Either operand is NaN: NaN
 void
 SWFHandlers::ActionDivide(ActionExec& thread)
 {
@@ -761,10 +766,25 @@
     const double operand1 = env.top(1).to_number();
     const double operand2 = env.top(0).to_number();
 
-    if (operand2 == 0 && env.get_version() < 5)
+    if (operand2 == 0)
     {
-        env.top(1).set_string("#ERROR#");
-        }
+        if (env.get_version() < 5) {
+            env.top(1).set_string("#ERROR#");
+        }
+        else if (operand1 == 0 || isNaN(operand1) || isNaN(operand2)) {
+            env.top(1).set_nan();
+        }
+        else {
+            // Division by -0.0 is not possible in AS, so 
+            // the sign of the resulting infinity should match the 
+            // sign of operand1. Division by 0 in C++ is undefined
+            // behaviour.
+            env.top(1) = operand1 < 0 ?
+                - std::numeric_limits<double>::infinity() :
+                std::numeric_limits<double>::infinity();
+        }
+
+    }
     else
     {
         env.top(1) = operand1 / operand2;

=== modified file 'testsuite/swfdec/PASSING'
--- a/testsuite/swfdec/PASSING  2009-01-08 07:05:33 +0000
+++ b/testsuite/swfdec/PASSING  2009-01-08 16:46:59 +0000
@@ -1209,6 +1209,8 @@
 xml-cdata-6.swf:d7559375e07591033d7739671a8c4d42
 xml-cdata-7.swf:5e51dafbe7f6af8206041ecabf0016f8
 xml-cdata-8.swf:d5537f4fb83eaf49d615eecb89b2ae95
+xml-errors-7.swf:0f90a1e9ae561ecc4c3206bb1e966ca1
+xml-errors-8.swf:321a6535952813fadeaef64c99fa467d
 xml-escape-6.swf:302349505514bd60239c7019355f6ab8
 xml-escape-7.swf:31cca7515723685cf0384bf7e059e8ac
 xml-escape-8.swf:cbd1f724a3dc3e73697535468443171d


reply via email to

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