summaryrefslogtreecommitdiff
path: root/xinclude.c
diff options
context:
space:
mode:
authorWilliam M. Brack <wbrack@src.gnome.org>2004-02-07 08:53:23 +0000
committerWilliam M. Brack <wbrack@src.gnome.org>2004-02-07 08:53:23 +0000
commit6bdacd7aee43a318575ffbb2b156c7c180d926ff (patch)
tree2bfc95159818819221293b141a9ce0b1f842c004 /xinclude.c
parent1ce3c802e2a77df4ef8cfef3f60015fb9e9debb6 (diff)
downloadlibxml2-6bdacd7aee43a318575ffbb2b156c7c180d926ff.tar.gz
fixed problem with function xmlXIncludeCopyRange (bug 133686).
* xinclude.c: fixed problem with function xmlXIncludeCopyRange (bug 133686).
Diffstat (limited to 'xinclude.c')
-rw-r--r--xinclude.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/xinclude.c b/xinclude.c
index a2a45c7c..d1c816f3 100644
--- a/xinclude.c
+++ b/xinclude.c
@@ -874,7 +874,7 @@ xmlXIncludeCopyRange(xmlXIncludeCtxtPtr ctxt, xmlDocPtr target,
/* pointers to traversal nodes */
xmlNodePtr start, cur, end;
int index1, index2;
- int level = 0, lastLevel = 0;
+ int level = 0, lastLevel = 0, endLevel = 0, endFlag = 0;
if ((ctxt == NULL) || (target == NULL) || (source == NULL) ||
(range == NULL))
@@ -950,6 +950,8 @@ xmlXIncludeCopyRange(xmlXIncludeCtxtPtr ctxt, xmlDocPtr target,
xmlAddChild(last, tmp);
return(list);
} else { /* ending node not a text node */
+ endLevel = level; /* remember the level of the end node */
+ endFlag = 1;
tmp = xmlDocCopyNode(cur, target, 0);
if (list == NULL) {
list = tmp;
@@ -971,13 +973,14 @@ xmlXIncludeCopyRange(xmlXIncludeCtxtPtr ctxt, xmlDocPtr target,
if ((cur == start) && (index1 > 1)) {
cur = xmlXIncludeGetNthChild(cur, index1 - 1);
index1 = 0;
- } else {
+ } else {
cur = cur->children;
}
+ level++; /* increment level to show change */
/*
* Now gather the remaining nodes from cur to end
*/
- continue; /* while */
+ continue; /* while */
}
} else if (cur == start) { /* Not at the end, are we at start? */
if ((cur->type == XML_TEXT_NODE) ||
@@ -1046,6 +1049,8 @@ xmlXIncludeCopyRange(xmlXIncludeCtxtPtr ctxt, xmlDocPtr target,
* Skip to next node in document order
*/
cur = xmlXPtrAdvanceNode(cur, &level);
+ if (endFlag && (level >= endLevel))
+ break;
}
return(list);
}