mirror of
https://gitea.psi.ch/ELOG/elog.git
synced 2026-09-08 17:13:56 +00:00
Compare root node correctly in mxml_find_nodes
SVN revision: 1281
This commit is contained in:
parent
6aaa259dfd
commit
fcab6118f2
25
src/mxml.c
25
src/mxml.c
@ -627,7 +627,7 @@ int mxml_add_resultnode(PMXML_NODE node, char *xml_path, PMXML_NODE **nodelist,
|
|||||||
(*found)++;
|
(*found)++;
|
||||||
} else {
|
} else {
|
||||||
/* if not at end of path, branch into subtree */
|
/* if not at end of path, branch into subtree */
|
||||||
return mxml_find_nodes1(node, xml_path, nodelist, found);
|
return mxml_find_nodes1(node, xml_path+1, nodelist, found);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
@ -655,10 +655,29 @@ int mxml_find_nodes1(PMXML_NODE tree, char *xml_path, PMXML_NODE **nodelist, int
|
|||||||
p1 = xml_path;
|
p1 = xml_path;
|
||||||
pnode = tree;
|
pnode = tree;
|
||||||
|
|
||||||
/* skip leading '/' */
|
if (*p1 && *p1 == '/') {
|
||||||
if (*p1 && *p1 == '/')
|
|
||||||
|
/* if path starts with '/', compare root node */
|
||||||
p1++;
|
p1++;
|
||||||
|
|
||||||
|
p2 = p1;
|
||||||
|
while (*p2 && *p2 != '/')
|
||||||
|
p2++;
|
||||||
|
len = (size_t)p2 - (size_t)p1;
|
||||||
|
if (len >= sizeof(node_name))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
memcpy(node_name, p1, len);
|
||||||
|
node_name[len] = 0;
|
||||||
|
|
||||||
|
if (strcmp(pnode->name, node_name) != 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
p1 = p2;
|
||||||
|
if (*p1 == '/')
|
||||||
|
p1++;
|
||||||
|
}
|
||||||
|
|
||||||
do {
|
do {
|
||||||
p2 = p1;
|
p2 = p1;
|
||||||
while (*p2 && *p2 != '/' && *p2 != '[')
|
while (*p2 && *p2 != '/' && *p2 != '[')
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user