[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] gnash ChangeLog server/asobj/xml.cpp server/aso...
From: |
Sandro Santilli |
Subject: |
[Gnash-commit] gnash ChangeLog server/asobj/xml.cpp server/aso... |
Date: |
Tue, 08 Apr 2008 10:09:21 +0000 |
CVSROOT: /sources/gnash
Module name: gnash
Changes by: Sandro Santilli <strk> 08/04/08 10:09:21
Modified files:
. : ChangeLog
server/asobj : xml.cpp xml.h
testsuite/actionscript.all: XML.as
testsuite/swfdec: PASSING
Log message:
* server/asobj/xml.{cpp,h}: rework parsing so it doesn't
try to recover at first, but does in a more compatible way
on second try. Fixes parsing of STUDENT.xml in bug #22819.
* testsuite/actionscript.all/XML.as: parsing of gnashrc.xml work
more compatibly now.
* testsuite/swfdec/PASSING: string-object-tostring-{5,6,7,8}.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.6214&r2=1.6215
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/xml.cpp?cvsroot=gnash&r1=1.77&r2=1.78
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/xml.h?cvsroot=gnash&r1=1.32&r2=1.33
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/actionscript.all/XML.as?cvsroot=gnash&r1=1.56&r2=1.57
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/swfdec/PASSING?cvsroot=gnash&r1=1.124&r2=1.125
Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.6214
retrieving revision 1.6215
diff -u -b -r1.6214 -r1.6215
--- ChangeLog 8 Apr 2008 02:56:28 -0000 1.6214
+++ ChangeLog 8 Apr 2008 10:09:20 -0000 1.6215
@@ -1,3 +1,12 @@
+2008-04-07 Sandro Santilli <address@hidden>
+
+ * server/asobj/xml.{cpp,h}: rework parsing so it doesn't
+ try to recover at first, but does in a more compatible way
+ on second try. Fixes parsing of STUDENT.xml in bug #22819.
+ * testsuite/actionscript.all/XML.as: parsing of gnashrc.xml work
+ more compatibly now.
+ * testsuite/swfdec/PASSING: string-object-tostring-{5,6,7,8}.
+
2008-04-07 Russ Nelson <address@hidden>
* GAH! Checked in too much.
Index: server/asobj/xml.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/xml.cpp,v
retrieving revision 1.77
retrieving revision 1.78
diff -u -b -r1.77 -r1.78
--- server/asobj/xml.cpp 28 Mar 2008 16:23:08 -0000 1.77
+++ server/asobj/xml.cpp 8 Apr 2008 10:09:21 -0000 1.78
@@ -60,6 +60,9 @@
// Define this to enable verbosity of XML loads
//#define DEBUG_XML_LOADS 1
+// Define this to enable verbosity of XML parsing
+//#define DEBUG_XML_PARSE 1
+
static as_object* getXMLInterface();
static void attachXMLInterface(as_object& o);
static void attachXMLProperties(as_object& o);
@@ -83,8 +86,8 @@
XML::XML()
:
XMLNode(getXMLInterface()),
- _doc(0),
- _firstChild(0),
+ //_doc(0),
+ //_firstChild(0),
_loaded(-1),
_status(sOK),
_loadThreads(),
@@ -105,8 +108,8 @@
XML::XML(const std::string& xml_in)
:
XMLNode(getXMLInterface()),
- _doc(0),
- _firstChild(0),
+ //_doc(0),
+ //_firstChild(0),
_loaded(-1),
_status(sOK),
_loadThreads(),
@@ -236,16 +239,18 @@
xmlChar *ptr = NULL;
boost::intrusive_ptr<XMLNode> child;
-// log_debug(_("Created new element for %s at %p"), node->name, element);
-
-// log_debug(_("%s: extracting node %s"), __FUNCTION__, node->name);
+#ifdef DEBUG_XML_PARSE
+ log_debug(_("%s: extracting node %s"), __FUNCTION__, node->name);
+#endif
// See if we have any Attributes (properties)
attr = node->properties;
while (attr != NULL)
{
- //log_debug(_("extractNode %s has property %s, value is %s"),
- // node->name, attr->name, attr->children->content);
+#ifdef DEBUG_XML_PARSE
+ log_debug(_("extractNode %s has property %s, value is %s"),
+ node->name, attr->name, attr->children->content);
+#endif
std::ostringstream name, content;
@@ -254,8 +259,11 @@
XMLAttr attrib(name.str(), content.str());
- //log_debug(_("\tPushing attribute %s for element %s has value %s"),
- // attr->name, node->name, attr->children->content);
+#ifdef DEBUG_XML_PARSE
+ log_debug(_("\tPushing attribute %s for element %s has value %s, next
attribute is %p"),
+ attr->name, node->name, attr->children->content, attr->next);
+#endif
+
element._attributes.push_back(attrib);
attr = attr->next;
}
@@ -290,7 +298,9 @@
{
if ( in.str().find_first_not_of(" \n\t\r") ==
std::string::npos )
{
+#ifdef DEBUG_XML_PARSE
log_debug("Text node value consists in blanks
only, discarding");
+#endif
xmlFree(ptr);
return false;
}
@@ -307,7 +317,10 @@
{
child = new XMLNode();
child->setParent(&element);
- if ( extractNode(*child, childnode, mem) )
element._children.push_back(child);
+ if ( extractNode(*child, childnode, mem) )
+ {
+ element._children.push_back(child);
+ }
childnode = childnode->next;
}
@@ -316,27 +329,22 @@
/*private*/
bool
-XML::parseDoc(xmlDocPtr document, bool mem)
+XML::parseDoc(xmlNodePtr cur, bool mem)
{
- //GNASH_REPORT_FUNCTION;
-
- xmlNodePtr cur;
-
- if (document == 0) {
- log_error(_("Can't load XML file"));
- return false;
- }
-
- cur = xmlDocGetRootElement(document);
+ GNASH_REPORT_FUNCTION;
- if (cur != NULL)
+ while (cur)
{
boost::intrusive_ptr<XMLNode> child = new XMLNode();
child->setParent(this);
+#ifdef DEBUG_XML_PARSE
+ log_debug("\tParsing top-level node %s", cur->name);
+#endif
if ( extractNode(*child, cur, mem) )
{
_children.push_back(child);
}
+ cur = cur->next;
}
return true;
@@ -367,16 +375,36 @@
initParser();
- //_doc = xmlParseMemory(xml_in.c_str(), xml_in.size());
- _doc = xmlReadMemory(xml_in.c_str(), xml_in.size(), NULL, NULL,
getXMLOptions());
- if (_doc == 0) {
- log_error(_("Can't parse XML data"));
+ xmlNodePtr firstNode;
+
+ xmlDocPtr doc = xmlReadMemory(xml_in.c_str(), xml_in.size(), NULL, NULL,
getXMLOptions()); // do NOT recover here !
+ if ( doc )
+ {
+ firstNode = doc->children; // xmlDocGetRootElement(doc);
+ }
+ else
+ {
+ log_debug(_("malformed XML, trying to recover"));
+ int ret = xmlParseBalancedChunkMemoryRecover(NULL, NULL, NULL, 0,
(const xmlChar*)xml_in.c_str(), &firstNode, 1);
+ log_debug("xmlParseBalancedChunkMemoryRecover returned %d", ret);
+ if ( ! firstNode )
+ {
+ log_error(_("unrecoverable malformed XML
(xmlParseBalancedChunkMemoryRecover returned %d)."), ret);
return false;
}
+ else
+ {
+ log_error(_("recovered malformed XML."));
+ }
+ }
+
+
+
+ bool ret = parseDoc(firstNode, true);
- bool ret = parseDoc(_doc, true);
xmlCleanupParser();
- xmlFreeDoc(_doc);
+ if ( doc ) xmlFreeDoc(doc); // TOCHECK: can it be freed before ?
+ else if ( firstNode ) xmlFreeNodeList(firstNode);
xmlMemoryDump();
#ifndef USE_DMALLOC
@@ -1022,12 +1050,8 @@
bool
XML::ignoreWhite() const
{
- // TODO: initialize this thing once...
- std::string propname;
- if ( VM::get().getSWFVersion() < 7 ) propname = "ignorewhite";
- else propname = "ignoreWhite";
- string_table::key propnamekey =
VM::get().getStringTable().find(propname);
+ string_table::key propnamekey =
VM::get().getStringTable().find("ignoreWhite");
as_value val;
if (!const_cast<XML*>(this)->get_member(propnamekey, &val) ) return false;
return val.to_bool();
@@ -1037,8 +1061,11 @@
int
XML::getXMLOptions() const
{
- int options = XML_PARSE_RECOVER | XML_PARSE_NOWARNING
- | XML_PARSE_NOERROR | XML_PARSE_NOCDATA;
+ int options = XML_PARSE_NOENT
+ //| XML_PARSE_RECOVER -- don't recover now, we'll call
xmlParseBalancedChunkRecover later
+ //| XML_PARSE_NOWARNING
+ //| XML_PARSE_NOERROR
+ | XML_PARSE_NOCDATA;
// Using libxml2 to convert CDATA nodes to text seems to be what is
// required.
Index: server/asobj/xml.h
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/xml.h,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -b -r1.32 -r1.33
--- server/asobj/xml.h 28 Mar 2008 16:23:08 -0000 1.32
+++ server/asobj/xml.h 8 Apr 2008 10:09:21 -0000 1.33
@@ -175,10 +175,7 @@
//
/// This is the base method used by both parseXML() and load().
///
- bool parseDoc(xmlDocPtr document, bool mem);
-
- xmlDocPtr _doc;
- xmlNodePtr _firstChild;
+ bool parseDoc(xmlNodePtr startNode, bool mem);
// -1 if never asked to load anything
// 0 if asked to load but not yet loaded (or failure)
Index: testsuite/actionscript.all/XML.as
===================================================================
RCS file: /sources/gnash/gnash/testsuite/actionscript.all/XML.as,v
retrieving revision 1.56
retrieving revision 1.57
diff -u -b -r1.56 -r1.57
--- testsuite/actionscript.all/XML.as 11 Mar 2008 19:31:48 -0000 1.56
+++ testsuite/actionscript.all/XML.as 8 Apr 2008 10:09:21 -0000 1.57
@@ -21,7 +21,7 @@
// execute it like this gnash -1 -r 0 -v out.swf
-rcsid="$Id: XML.as,v 1.56 2008/03/11 19:31:48 strk Exp $";
+rcsid="$Id: XML.as,v 1.57 2008/04/08 10:09:21 strk Exp $";
#include "check.as"
//#include "dejagnu.as"
#include "utils.as"
@@ -693,7 +693,7 @@
myxml.status = status_backup;
- //note("myxml.toString(): "+myxml.toString());
+ note("myxml.toString(): "+myxml.toString());
check_equals(typeof(myxml.attributes), 'object');
check(! myxml.attributes instanceof Object);
check_equals(typeof(myxml.attributes.__proto__), 'undefined');
@@ -714,7 +714,7 @@
{
check_equals(myxml.childNodes.length,
myxml.lastChildNodesCount);
}
- xcheck_equals(myxml.childNodes.length, 3); // gnash fails discarding
the comment and the ending blanks
+ check_equals(myxml.childNodes.length, 3); // gnash fails discarding the
comment and the ending blanks
// We're done
++this.onLoadCalls;
Index: testsuite/swfdec/PASSING
===================================================================
RCS file: /sources/gnash/gnash/testsuite/swfdec/PASSING,v
retrieving revision 1.124
retrieving revision 1.125
diff -u -b -r1.124 -r1.125
--- testsuite/swfdec/PASSING 7 Apr 2008 22:01:55 -0000 1.124
+++ testsuite/swfdec/PASSING 8 Apr 2008 10:09:21 -0000 1.125
@@ -734,6 +734,10 @@
stringlength-5.swf:bf014dcc64776fb859ff878286f56b16
stringlength-6.swf:94b4de2a590c915696b4a783338a1f05
stringlength-7.swf:140952977abb85b966f1e5c4447854ce
+string-object-tostring-5.swf:d45c1785719c3e2607f6ac10f48b2e80
+string-object-tostring-6.swf:f4970a48bfb3c5d5315699263c2a15a1
+string-object-tostring-7.swf:060a8f7ba61ae1501bdcb060cd321313
+string-object-tostring-8.swf:7741a0c0d26aef26bd46749457b0357a
string-properties-5.swf:39cc1143e531659d37072534a3d3455e
string-properties-6.swf:6e04c332f503311867082ab55f22b16b
string-properties-7.swf:bf61a4b0a4cc67c8df63203407ac243c
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gnash-commit] gnash ChangeLog server/asobj/xml.cpp server/aso...,
Sandro Santilli <=