summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKasimier T. Buchcik <kbuchcik@src.gnome.org>2006-02-15 10:57:50 +0000
committerKasimier T. Buchcik <kbuchcik@src.gnome.org>2006-02-15 10:57:50 +0000
commiteb46870850a8dec52a25ff63d406628cf31dcc9c (patch)
tree69fe14f5652658e1297920fb1614311d45734e0a
parenta29aca1819ff59a7c6e57429e3c73cc825153d00 (diff)
downloadlibxml2-eb46870850a8dec52a25ff63d406628cf31dcc9c.tar.gz
Fixed bug #328896 reported by Liron. The path for text- and
* tree.c: Fixed bug #328896 reported by Liron. The path for text- and CDATA-section-nodes was computed incorrectly in xmlGetNodePath().
-rw-r--r--ChangeLog6
-rw-r--r--tree.c25
2 files changed, 21 insertions, 10 deletions
diff --git a/ChangeLog b/ChangeLog
index b1f9e2c0..0c66d84c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Wed Feb 15 11:55:22 CET 2006 Kasimier Buchcik <libxml2-cvs@cazic.net>
+
+ * tree.c: Fixed bug #328896 reported by Liron. The path
+ for text- and CDATA-section-nodes was computed incorrectly
+ in xmlGetNodePath().
+
Sun Feb 12 20:12:22 CET 2006 Daniel Veillard <daniel@veillard.com>
* xmlregexp.c: bug fixes for #327167 as well as some cleanups
diff --git a/tree.c b/tree.c
index 578e5dad..2e7e856b 100644
--- a/tree.c
+++ b/tree.c
@@ -4341,21 +4341,26 @@ xmlGetNodePath(xmlNodePtr node)
*/
tmp = cur->prev;
while (tmp != NULL) {
- if ((cur->type == XML_TEXT_NODE) ||
- (cur->type == XML_CDATA_SECTION_NODE))
+ if ((tmp->type == XML_TEXT_NODE) ||
+ (tmp->type == XML_CDATA_SECTION_NODE))
occur++;
tmp = tmp->prev;
}
+ /*
+ * Evaluate if this is the only text- or CDATA-section-node;
+ * if yes, then we'll get "text()", otherwise "text()[1]".
+ */
if (occur == 0) {
tmp = cur->next;
- while (tmp != NULL && occur == 0) {
- if ((tmp->type == XML_TEXT_NODE) ||
- (tmp->type == XML_CDATA_SECTION_NODE))
- occur++;
- tmp = tmp->next;
- }
- if (occur != 0)
- occur = 1;
+ while (tmp != NULL) {
+ if ((tmp->type == XML_TEXT_NODE) ||
+ (tmp->type == XML_CDATA_SECTION_NODE))
+ {
+ occur = 1;
+ break;
+ }
+ tmp = tmp->next;
+ }
} else
occur++;
} else if (cur->type == XML_PI_NODE) {