1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-03-27 18:50:07 +03:00

fixed problem pointed out by Stphane Bidoul on the list. completed

* python/generator.py, python/libxml2class.txt: fixed problem
  pointed out by Stphane Bidoul on the list.
* xinclude.c, xpointer.c, xpath.c, include/libxml/xpointer.h:
  completed modifications required to fix Bug 129967 (at last!).
  Now wait to see how long before further trouble...
This commit is contained in:
William M. Brack 2003-12-31 07:59:17 +00:00
parent 72ee48d55f
commit f7eb794c14
7 changed files with 82 additions and 55 deletions

View File

@ -1,3 +1,11 @@
Wed Dec 31 15:55:55 HKT 2003 William Brack <wbrack@mmm.com.hk>
* python/generator.py, python/libxml2class.txt: fixed problem
pointed out by Stéphane Bidoul on the list.
* xinclude.c, xpointer.c, xpath.c, include/libxml/xpointer.h:
completed modifications required to fix Bug 129967 (at last!).
Now wait to see how long before further trouble...
Tue Dec 30 16:26:13 HKT 2003 William Brack <wbrack@mmm.com.hk>
* parser.c, xmlmemory.c, include/libxml/xmlmemory.h: Fixed

View File

@ -103,8 +103,6 @@ XMLPUBFUN xmlNodePtr XMLCALL
xmlXPtrBuildNodeList (xmlXPathObjectPtr obj);
XMLPUBFUN void XMLCALL
xmlXPtrEvalRangePredicate (xmlXPathParserContextPtr ctxt);
XMLPUBFUN xmlNodePtr XMLCALL
xmlXPtrAdvanceNode (xmlNodePtr cur);
#ifdef __cplusplus
}
#endif

View File

@ -325,6 +325,8 @@ def skip_function(name):
return 1
if name == "xmlOutputBufferFlush": # handled by by the superclass
return 1
if name == "xmlErrMemory":
return 1
return 0
def print_function_wrapper(name, output, export, include):
@ -573,8 +575,6 @@ def buildStubs():
wrapper = open("libxml2-py.c", "w")
wrapper.write("/* Generated */\n\n")
wrapper.write("#include <Python.h>\n")
# wrapper.write("#include \"config.h\"\n")
wrapper.write("#define IN_LIBXML\n")
wrapper.write("#include <libxml/xmlversion.h>\n")
wrapper.write("#include <libxml/tree.h>\n")
wrapper.write("#include <libxml/xmlschemastypes.h>\n")

View File

@ -896,7 +896,6 @@ Class parserCtxt(parserCtxtCore)
# functions from module parserInternals
decodeEntities()
errMemory()
handleEntity()
namespaceParseNCName()
namespaceParseNSDef()

View File

@ -844,6 +844,7 @@ xmlXIncludeGetNthChild(xmlNodePtr cur, int no) {
return(cur);
}
xmlNodePtr xmlXPtrAdvanceNode(xmlNodePtr cur, int *level); /* in xpointer.c */
/**
* xmlXIncludeCopyRange:
* @ctxt: the XInclude context
@ -860,10 +861,12 @@ static xmlNodePtr
xmlXIncludeCopyRange(xmlXIncludeCtxtPtr ctxt, xmlDocPtr target,
xmlDocPtr source, xmlXPathObjectPtr range) {
/* pointers to generated nodes */
xmlNodePtr list = NULL, last = NULL, parent = NULL, tmp;
xmlNodePtr list = NULL, last = NULL, listParent = NULL;
xmlNodePtr tmp, tmp2;
/* pointers to traversal nodes */
xmlNodePtr start, cur, end;
int index1, index2;
int level = 0, lastLevel = 0;
if ((ctxt == NULL) || (target == NULL) || (source == NULL) ||
(range == NULL))
@ -881,7 +884,36 @@ xmlXIncludeCopyRange(xmlXIncludeCtxtPtr ctxt, xmlDocPtr target,
cur = start;
index1 = range->index;
index2 = range->index2;
/*
* level is depth of the current node under consideration
* list is the pointer to the root of the output tree
* listParent is a pointer to the parent of output tree (within
the included file) in case we need to add another level
* last is a pointer to the last node added to the output tree
* lastLevel is the depth of last (relative to the root)
*/
while (cur != NULL) {
/*
* Check if our output tree needs a parent
*/
if (level < 0) {
while (level < 0) {
tmp2 = xmlDocCopyNode(listParent, target, 0);
xmlAddChild(tmp2, list);
list = tmp2;
listParent = listParent->parent;
level++;
}
last = list;
lastLevel = 0;
}
/*
* Check whether we need to change our insertion point
*/
while (level < lastLevel) {
last = last->parent;
lastLevel --;
}
if (cur == end) { /* Are we at the end of the range? */
if (cur->type == XML_TEXT_NODE) {
const xmlChar *content = cur->content;
@ -904,23 +936,25 @@ xmlXIncludeCopyRange(xmlXIncludeCtxtPtr ctxt, xmlDocPtr target,
if (list == NULL)
return(tmp);
/* prune and return full set */
if (last != NULL)
if (level == lastLevel)
xmlAddNextSibling(last, tmp);
else
xmlAddChild(parent, tmp);
xmlAddChild(last, tmp);
return(list);
} else { /* ending node not a text node */
tmp = xmlDocCopyNode(cur, target, 0);
if (list == NULL)
if (list == NULL) {
list = tmp;
else {
if (last != NULL)
listParent = cur->parent;
} else {
if (level == lastLevel)
xmlAddNextSibling(last, tmp);
else
xmlAddChild(parent, tmp);
else {
xmlAddChild(last, tmp);
lastLevel = level;
}
}
last = NULL;
parent = tmp;
last = tmp;
if (index2 > 1) {
end = xmlXIncludeGetNthChild(cur, index2 - 1);
@ -937,8 +971,7 @@ xmlXIncludeCopyRange(xmlXIncludeCtxtPtr ctxt, xmlDocPtr target,
*/
continue; /* while */
}
} else if ((cur == start) && /* Not at the end, are we at start? */
(list == NULL) /* looks superfluous but ... */ ) {
} else if (cur == start) { /* Not at the end, are we at start? */
if ((cur->type == XML_TEXT_NODE) ||
(cur->type == XML_CDATA_SECTION_NODE)) {
const xmlChar *content = cur->content;
@ -953,23 +986,20 @@ xmlXIncludeCopyRange(xmlXIncludeCtxtPtr ctxt, xmlDocPtr target,
tmp = xmlNewText(content);
}
last = list = tmp;
listParent = cur->parent;
} else { /* Not text node */
tmp = xmlDocCopyNode(cur, target, 0);
list = last = tmp;
listParent = cur->parent;
if (index1 > 1) { /* Do we need to position? */
tmp = xmlDocCopyNode(cur, target, 0);
list = tmp;
parent = tmp;
last = NULL;
cur = xmlXIncludeGetNthChild(cur, index1 - 1);
level = lastLevel = 1;
index1 = 0;
/*
* Now gather the remaining nodes from cur to end
*/
continue; /* while */
}
tmp = xmlDocCopyNode(cur, target, 0);
list = tmp;
parent = NULL;
last = tmp;
}
} else {
tmp = NULL;
@ -995,24 +1025,19 @@ xmlXIncludeCopyRange(xmlXIncludeCtxtPtr ctxt, xmlDocPtr target,
break;
}
if (tmp != NULL) {
if ((list == NULL) || ((last == NULL) && (parent == NULL))) {
return(NULL);
}
if (last != NULL)
if (level == lastLevel)
xmlAddNextSibling(last, tmp);
else {
xmlAddChild(parent, tmp);
last = tmp;
xmlAddChild(last, tmp);
lastLevel = level;
}
last = tmp;
}
}
/*
* Skip to next node in document order
*/
if ((list == NULL) || ((last == NULL) && (parent == NULL))) {
return(NULL);
}
cur = xmlXPtrAdvanceNode(cur);
cur = xmlXPtrAdvanceNode(cur, &level);
}
return(list);
}

18
xpath.c
View File

@ -10447,10 +10447,10 @@ xmlXPathCompOpEval(xmlXPathParserContextPtr ctxt, xmlXPathStepOpPtr op)
* single item in the nodelocset.
*/
ctxt->context->node = oldlocset->locTab[i]->user;
tmp = xmlXPathNewNodeSet(ctxt->context->node);
valuePush(ctxt, tmp);
ctxt->context->contextSize = oldlocset->locNr;
ctxt->context->proximityPosition = i + 1;
tmp = xmlXPathNewNodeSet(ctxt->context->node);
valuePush(ctxt, tmp);
if (op->ch2 != -1)
total +=
@ -10632,9 +10632,9 @@ xmlXPathCompOpEval(xmlXPathParserContextPtr ctxt, xmlXPathStepOpPtr op)
* Run the evaluation with a node list made of a
* single item in the nodelocset.
*/
ctxt->context->node = (xmlNodePtr)ctxt->context->doc;
ctxt->context->contextSize = 1;
ctxt->context->proximityPosition = 1;
ctxt->context->node = oldlocset->locTab[i]->user;
ctxt->context->contextSize = oldlocset->locNr;
ctxt->context->proximityPosition = i + 1;
tmp = xmlXPathNewNodeSet(ctxt->context->node);
valuePush(ctxt, tmp);
@ -10644,10 +10644,6 @@ xmlXPathCompOpEval(xmlXPathParserContextPtr ctxt, xmlXPathStepOpPtr op)
&comp->steps[op->ch2]);
CHECK_ERROR0;
/*
* The result of the evaluation needs to be tested to
* decide whether the filter succeeded or not
*/
res = valuePop(ctxt);
if (res->type == XPATH_LOCATIONSET) {
xmlLocationSetPtr rloc =
@ -10706,10 +10702,6 @@ xmlXPathCompOpEval(xmlXPathParserContextPtr ctxt, xmlXPathStepOpPtr op)
&comp->steps[op->ch2]);
CHECK_ERROR0;
/*
* The result of the evaluation need to be tested to
* decided whether the filter succeeded or not
*/
res = valuePop(ctxt);
range =
xmlXPtrNewRangeNodeObject(oldset->nodeTab[i],

View File

@ -123,7 +123,8 @@ xmlXPtrErr(xmlXPathParserContextPtr ctxt, int error,
* A few helper functions for child sequences *
* *
************************************************************************/
/* xmlXPtrAdvanceNode is a private function, but used by xinclude.c */
xmlNodePtr xmlXPtrAdvanceNode(xmlNodePtr cur, int *level);
/**
* xmlXPtrGetArity:
* @cur: the node
@ -1582,7 +1583,7 @@ xmlXPtrBuildRangeNodeList(xmlXPathObjectPtr range) {
STRANGE
return(NULL);
}
cur = xmlXPtrAdvanceNode(cur);
cur = xmlXPtrAdvanceNode(cur, NULL);
}
return(list);
}
@ -2296,12 +2297,14 @@ xmlXPtrRangeToFunction(xmlXPathParserContextPtr ctxt, int nargs) {
* Returns -1 in case of failure, 0 otherwise
*/
xmlNodePtr
xmlXPtrAdvanceNode(xmlNodePtr cur) {
xmlXPtrAdvanceNode(xmlNodePtr cur, int *level) {
next:
if (cur == NULL)
return(NULL);
if (cur->children != NULL) {
cur = cur->children ;
if (level != NULL)
(*level)++;
goto found;
}
if (cur->next != NULL) {
@ -2310,6 +2313,8 @@ next:
}
do {
cur = cur->parent;
if (level != NULL)
(*level)--;
if (cur == NULL) return(NULL);
if (cur->next != NULL) {
cur = cur->next;
@ -2366,7 +2371,7 @@ xmlXPtrAdvanceChar(xmlNodePtr *node, int *indx, int bytes) {
cur = xmlXPtrGetNthChild(cur, pos);
pos = 0;
} else {
cur = xmlXPtrAdvanceNode(cur);
cur = xmlXPtrAdvanceNode(cur, NULL);
pos = 0;
}
}
@ -2401,7 +2406,7 @@ xmlXPtrAdvanceChar(xmlNodePtr *node, int *indx, int bytes) {
}
if (pos + bytes >= len) {
bytes -= (len - pos);
cur = xmlXPtrAdvanceNode(cur);
cur = xmlXPtrAdvanceNode(cur, NULL);
cur = 0;
} else if (pos + bytes < len) {
pos += bytes;
@ -2490,7 +2495,7 @@ xmlXPtrMatchString(const xmlChar *string, xmlNodePtr start, int startindex,
}
}
}
cur = xmlXPtrAdvanceNode(cur);
cur = xmlXPtrAdvanceNode(cur, NULL);
if (cur == NULL)
return(0);
pos = 0;
@ -2583,7 +2588,7 @@ xmlXPtrSearchString(const xmlChar *string, xmlNodePtr *start, int *startindex,
}
if ((cur == *end) && (pos >= *endindex))
return(0);
cur = xmlXPtrAdvanceNode(cur);
cur = xmlXPtrAdvanceNode(cur, NULL);
if (cur == NULL)
return(0);
pos = 1;