1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-08-07 06:43:02 +03:00

patch from Mark Vakoc to fix xmlNodeGetPath() Daniel

* tree.c: patch from Mark Vakoc to fix xmlNodeGetPath()
Daniel
This commit is contained in:
Daniel Veillard
2002-10-08 08:26:11 +00:00
parent 80ce373e9a
commit 9dc1cf1d9d
3 changed files with 14 additions and 9 deletions

View File

@@ -1,3 +1,7 @@
Tue Oct 8 10:25:07 CEST 2002 Daniel Veillard <daniel@veillard.com>
* tree.c: patch from Mark Vakoc to fix xmlNodeGetPath()
Mon Oct 7 13:12:03 CEST 2002 Daniel Veillard <daniel@veillard.com> Mon Oct 7 13:12:03 CEST 2002 Daniel Veillard <daniel@veillard.com>
* doc/index.py: improved HTML indexing * doc/index.py: improved HTML indexing

14
tree.c
View File

@@ -3438,7 +3438,7 @@ xmlGetNodePath(xmlNodePtr node)
xmlChar *buffer = NULL, *temp; xmlChar *buffer = NULL, *temp;
size_t buf_len; size_t buf_len;
xmlChar *buf; xmlChar *buf;
char sep; char *sep;
const char *name; const char *name;
char nametemp[100]; char nametemp[100];
int occur = 0; int occur = 0;
@@ -3460,16 +3460,16 @@ xmlGetNodePath(xmlNodePtr node)
cur = node; cur = node;
do { do {
name = ""; name = "";
sep = '?'; sep = "?";
occur = 0; occur = 0;
if ((cur->type == XML_DOCUMENT_NODE) || if ((cur->type == XML_DOCUMENT_NODE) ||
(cur->type == XML_HTML_DOCUMENT_NODE)) { (cur->type == XML_HTML_DOCUMENT_NODE)) {
if (buffer[0] == '/') if (buffer[0] == '/')
break; break;
sep = '/'; sep = "/";
next = NULL; next = NULL;
} else if (cur->type == XML_ELEMENT_NODE) { } else if (cur->type == XML_ELEMENT_NODE) {
sep = '/'; sep = "/";
name = (const char *) cur->name; name = (const char *) cur->name;
if (cur->ns) { if (cur->ns) {
snprintf(nametemp, sizeof(nametemp) - 1, snprintf(nametemp, sizeof(nametemp) - 1,
@@ -3501,7 +3501,7 @@ xmlGetNodePath(xmlNodePtr node)
} else } else
occur++; occur++;
} else if (cur->type == XML_ATTRIBUTE_NODE) { } else if (cur->type == XML_ATTRIBUTE_NODE) {
sep = '@'; sep = "/@";
name = (const char *) (((xmlAttrPtr) cur)->name); name = (const char *) (((xmlAttrPtr) cur)->name);
next = ((xmlAttrPtr) cur)->parent; next = ((xmlAttrPtr) cur)->parent;
} else { } else {
@@ -3530,10 +3530,10 @@ xmlGetNodePath(xmlNodePtr node)
buf = temp; buf = temp;
} }
if (occur == 0) if (occur == 0)
snprintf((char *) buf, buf_len, "%c%s%s", snprintf((char *) buf, buf_len, "%s%s%s",
sep, name, (char *) buffer); sep, name, (char *) buffer);
else else
snprintf((char *) buf, buf_len, "%c%s[%d]%s", snprintf((char *) buf, buf_len, "%s%s[%d]%s",
sep, name, occur, (char *) buffer); sep, name, occur, (char *) buffer);
snprintf((char *) buffer, buf_len, "%s", buf); snprintf((char *) buffer, buf_len, "%s", buf);
cur = next; cur = next;

View File

@@ -2169,8 +2169,9 @@ xmlFreeIDTable(xmlIDTablePtr table) {
* @attr: the attribute * @attr: the attribute
* *
* Determine whether an attribute is of type ID. In case we have DTD(s) * Determine whether an attribute is of type ID. In case we have DTD(s)
* then this is simple, otherwise we use an heuristic: name ID (upper * then this is done if DTD loading has been requested. In the case
* or lowercase). * of HTML documents parsed with the HTML parser, then ID detection is
* done systematically.
* *
* Returns 0 or 1 depending on the lookup result * Returns 0 or 1 depending on the lookup result
*/ */