[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] gnash/server/asobj xmlnode.cpp
From: |
Martin Guy |
Subject: |
[Gnash-commit] gnash/server/asobj xmlnode.cpp |
Date: |
Sat, 03 Mar 2007 17:07:47 +0000 |
CVSROOT: /sources/gnash
Module name: gnash
Changes by: Martin Guy <martinwguy> 07/03/03 17:07:47
Modified files:
server/asobj : xmlnode.cpp
Log message:
Fix garbled code in {previous,next}Sibling
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/xmlnode.cpp?cvsroot=gnash&r1=1.13&r2=1.14
Patches:
Index: xmlnode.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/xmlnode.cpp,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -b -r1.13 -r1.14
--- xmlnode.cpp 3 Mar 2007 13:03:19 -0000 1.13
+++ xmlnode.cpp 3 Mar 2007 17:07:47 -0000 1.14
@@ -14,7 +14,7 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-/* $Id: xmlnode.cpp,v 1.13 2007/03/03 13:03:19 martinwguy Exp $ */
+/* $Id: xmlnode.cpp,v 1.14 2007/03/03 17:07:47 martinwguy Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -300,26 +300,21 @@
log_msg("%s: unimplemented \n", __PRETTY_FUNCTION__);
}
-// I see bugs:
-// - there are two variables called "node" here, one always set to 0,
-// one set but never user.
-// Query: here ".begin" and ".end" are used; elsewhere ".front" and ".back".
-// What's the difference?
XMLNode *
XMLNode::previousSibling()
{
GNASH_REPORT_FUNCTION;
vector<XMLNode *>::iterator itx;
- XMLNode *node = 0;
+ XMLNode *previous_node = NULL;
if (_parent) {
if (_parent->_children.size() > 1) {
for (itx = _parent->_children.begin(); itx !=
_parent->_children.end(); itx++) {
if ((*itx) == this) {
// log_msg("Found the previous XMLNode child !!!! %s
<%p>\n", (*itx)->nodeName(), (void*)*itx);
- return node;
+ return previous_node;
}
- XMLNode *node = *itx;
+ previous_node = *itx;
}
}
}
@@ -327,10 +322,6 @@
return NULL;
}
-// I see bugs:
-// - itx gets incremented twice per loop cycle
-// - if the next sibling is also _parent->_children.end, it will not be
returned
-// but NULL will instead
XMLNode *
XMLNode::nextSibling()
{
@@ -339,10 +330,14 @@
if (_parent) {
if (_parent->_children.size() > 1) {
for (itx = _parent->_children.begin(); itx !=
_parent->_children.end(); itx++) {
- if (((*itx++) == this) && (itx != _parent->_children.end())) {
- XMLNode *node = *itx;
- // log_msg("Found the previous XMLNode child !!!! %s
<%p>\n", (*itx)->nodeName(), (void*)*itx);
- return node;
+ if ((*itx) == this) {
+ // We've found ourselves; now find next sibling if any
+ XMLNode *sibling = *++itx;
+ if (itx == _parent->_children.end()) return NULL;
+ else {
+ // log_msg("Found the next XMLNode child !!!! %s
<%p>\n", (*itx)->nodeName(), (void*)*itx);
+ return sibling;
+ }
}
}
}