mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-10-18 16:08:59 +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:
@@ -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<53>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>
|
Tue Dec 30 16:26:13 HKT 2003 William Brack <wbrack@mmm.com.hk>
|
||||||
|
|
||||||
* parser.c, xmlmemory.c, include/libxml/xmlmemory.h: Fixed
|
* parser.c, xmlmemory.c, include/libxml/xmlmemory.h: Fixed
|
||||||
|
@@ -103,8 +103,6 @@ XMLPUBFUN xmlNodePtr XMLCALL
|
|||||||
xmlXPtrBuildNodeList (xmlXPathObjectPtr obj);
|
xmlXPtrBuildNodeList (xmlXPathObjectPtr obj);
|
||||||
XMLPUBFUN void XMLCALL
|
XMLPUBFUN void XMLCALL
|
||||||
xmlXPtrEvalRangePredicate (xmlXPathParserContextPtr ctxt);
|
xmlXPtrEvalRangePredicate (xmlXPathParserContextPtr ctxt);
|
||||||
XMLPUBFUN xmlNodePtr XMLCALL
|
|
||||||
xmlXPtrAdvanceNode (xmlNodePtr cur);
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@@ -325,6 +325,8 @@ def skip_function(name):
|
|||||||
return 1
|
return 1
|
||||||
if name == "xmlOutputBufferFlush": # handled by by the superclass
|
if name == "xmlOutputBufferFlush": # handled by by the superclass
|
||||||
return 1
|
return 1
|
||||||
|
if name == "xmlErrMemory":
|
||||||
|
return 1
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
def print_function_wrapper(name, output, export, include):
|
def print_function_wrapper(name, output, export, include):
|
||||||
@@ -573,8 +575,6 @@ def buildStubs():
|
|||||||
wrapper = open("libxml2-py.c", "w")
|
wrapper = open("libxml2-py.c", "w")
|
||||||
wrapper.write("/* Generated */\n\n")
|
wrapper.write("/* Generated */\n\n")
|
||||||
wrapper.write("#include <Python.h>\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/xmlversion.h>\n")
|
||||||
wrapper.write("#include <libxml/tree.h>\n")
|
wrapper.write("#include <libxml/tree.h>\n")
|
||||||
wrapper.write("#include <libxml/xmlschemastypes.h>\n")
|
wrapper.write("#include <libxml/xmlschemastypes.h>\n")
|
||||||
|
@@ -896,7 +896,6 @@ Class parserCtxt(parserCtxtCore)
|
|||||||
|
|
||||||
# functions from module parserInternals
|
# functions from module parserInternals
|
||||||
decodeEntities()
|
decodeEntities()
|
||||||
errMemory()
|
|
||||||
handleEntity()
|
handleEntity()
|
||||||
namespaceParseNCName()
|
namespaceParseNCName()
|
||||||
namespaceParseNSDef()
|
namespaceParseNSDef()
|
||||||
|
85
xinclude.c
85
xinclude.c
@@ -844,6 +844,7 @@ xmlXIncludeGetNthChild(xmlNodePtr cur, int no) {
|
|||||||
return(cur);
|
return(cur);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
xmlNodePtr xmlXPtrAdvanceNode(xmlNodePtr cur, int *level); /* in xpointer.c */
|
||||||
/**
|
/**
|
||||||
* xmlXIncludeCopyRange:
|
* xmlXIncludeCopyRange:
|
||||||
* @ctxt: the XInclude context
|
* @ctxt: the XInclude context
|
||||||
@@ -860,10 +861,12 @@ static xmlNodePtr
|
|||||||
xmlXIncludeCopyRange(xmlXIncludeCtxtPtr ctxt, xmlDocPtr target,
|
xmlXIncludeCopyRange(xmlXIncludeCtxtPtr ctxt, xmlDocPtr target,
|
||||||
xmlDocPtr source, xmlXPathObjectPtr range) {
|
xmlDocPtr source, xmlXPathObjectPtr range) {
|
||||||
/* pointers to generated nodes */
|
/* 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 */
|
/* pointers to traversal nodes */
|
||||||
xmlNodePtr start, cur, end;
|
xmlNodePtr start, cur, end;
|
||||||
int index1, index2;
|
int index1, index2;
|
||||||
|
int level = 0, lastLevel = 0;
|
||||||
|
|
||||||
if ((ctxt == NULL) || (target == NULL) || (source == NULL) ||
|
if ((ctxt == NULL) || (target == NULL) || (source == NULL) ||
|
||||||
(range == NULL))
|
(range == NULL))
|
||||||
@@ -881,7 +884,36 @@ xmlXIncludeCopyRange(xmlXIncludeCtxtPtr ctxt, xmlDocPtr target,
|
|||||||
cur = start;
|
cur = start;
|
||||||
index1 = range->index;
|
index1 = range->index;
|
||||||
index2 = range->index2;
|
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) {
|
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 == end) { /* Are we at the end of the range? */
|
||||||
if (cur->type == XML_TEXT_NODE) {
|
if (cur->type == XML_TEXT_NODE) {
|
||||||
const xmlChar *content = cur->content;
|
const xmlChar *content = cur->content;
|
||||||
@@ -904,23 +936,25 @@ xmlXIncludeCopyRange(xmlXIncludeCtxtPtr ctxt, xmlDocPtr target,
|
|||||||
if (list == NULL)
|
if (list == NULL)
|
||||||
return(tmp);
|
return(tmp);
|
||||||
/* prune and return full set */
|
/* prune and return full set */
|
||||||
if (last != NULL)
|
if (level == lastLevel)
|
||||||
xmlAddNextSibling(last, tmp);
|
xmlAddNextSibling(last, tmp);
|
||||||
else
|
else
|
||||||
xmlAddChild(parent, tmp);
|
xmlAddChild(last, tmp);
|
||||||
return(list);
|
return(list);
|
||||||
} else { /* ending node not a text node */
|
} else { /* ending node not a text node */
|
||||||
tmp = xmlDocCopyNode(cur, target, 0);
|
tmp = xmlDocCopyNode(cur, target, 0);
|
||||||
if (list == NULL)
|
if (list == NULL) {
|
||||||
list = tmp;
|
list = tmp;
|
||||||
else {
|
listParent = cur->parent;
|
||||||
if (last != NULL)
|
} else {
|
||||||
|
if (level == lastLevel)
|
||||||
xmlAddNextSibling(last, tmp);
|
xmlAddNextSibling(last, tmp);
|
||||||
else
|
else {
|
||||||
xmlAddChild(parent, tmp);
|
xmlAddChild(last, tmp);
|
||||||
|
lastLevel = level;
|
||||||
}
|
}
|
||||||
last = NULL;
|
}
|
||||||
parent = tmp;
|
last = tmp;
|
||||||
|
|
||||||
if (index2 > 1) {
|
if (index2 > 1) {
|
||||||
end = xmlXIncludeGetNthChild(cur, index2 - 1);
|
end = xmlXIncludeGetNthChild(cur, index2 - 1);
|
||||||
@@ -937,8 +971,7 @@ xmlXIncludeCopyRange(xmlXIncludeCtxtPtr ctxt, xmlDocPtr target,
|
|||||||
*/
|
*/
|
||||||
continue; /* while */
|
continue; /* while */
|
||||||
}
|
}
|
||||||
} else if ((cur == start) && /* Not at the end, are we at start? */
|
} else if (cur == start) { /* Not at the end, are we at start? */
|
||||||
(list == NULL) /* looks superfluous but ... */ ) {
|
|
||||||
if ((cur->type == XML_TEXT_NODE) ||
|
if ((cur->type == XML_TEXT_NODE) ||
|
||||||
(cur->type == XML_CDATA_SECTION_NODE)) {
|
(cur->type == XML_CDATA_SECTION_NODE)) {
|
||||||
const xmlChar *content = cur->content;
|
const xmlChar *content = cur->content;
|
||||||
@@ -953,23 +986,20 @@ xmlXIncludeCopyRange(xmlXIncludeCtxtPtr ctxt, xmlDocPtr target,
|
|||||||
tmp = xmlNewText(content);
|
tmp = xmlNewText(content);
|
||||||
}
|
}
|
||||||
last = list = tmp;
|
last = list = tmp;
|
||||||
|
listParent = cur->parent;
|
||||||
} else { /* Not text node */
|
} else { /* Not text node */
|
||||||
if (index1 > 1) { /* Do we need to position? */
|
|
||||||
tmp = xmlDocCopyNode(cur, target, 0);
|
tmp = xmlDocCopyNode(cur, target, 0);
|
||||||
list = tmp;
|
list = last = tmp;
|
||||||
parent = tmp;
|
listParent = cur->parent;
|
||||||
last = NULL;
|
if (index1 > 1) { /* Do we need to position? */
|
||||||
cur = xmlXIncludeGetNthChild(cur, index1 - 1);
|
cur = xmlXIncludeGetNthChild(cur, index1 - 1);
|
||||||
|
level = lastLevel = 1;
|
||||||
index1 = 0;
|
index1 = 0;
|
||||||
/*
|
/*
|
||||||
* Now gather the remaining nodes from cur to end
|
* Now gather the remaining nodes from cur to end
|
||||||
*/
|
*/
|
||||||
continue; /* while */
|
continue; /* while */
|
||||||
}
|
}
|
||||||
tmp = xmlDocCopyNode(cur, target, 0);
|
|
||||||
list = tmp;
|
|
||||||
parent = NULL;
|
|
||||||
last = tmp;
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
tmp = NULL;
|
tmp = NULL;
|
||||||
@@ -995,24 +1025,19 @@ xmlXIncludeCopyRange(xmlXIncludeCtxtPtr ctxt, xmlDocPtr target,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (tmp != NULL) {
|
if (tmp != NULL) {
|
||||||
if ((list == NULL) || ((last == NULL) && (parent == NULL))) {
|
if (level == lastLevel)
|
||||||
return(NULL);
|
|
||||||
}
|
|
||||||
if (last != NULL)
|
|
||||||
xmlAddNextSibling(last, tmp);
|
xmlAddNextSibling(last, tmp);
|
||||||
else {
|
else {
|
||||||
xmlAddChild(parent, tmp);
|
xmlAddChild(last, tmp);
|
||||||
last = tmp;
|
lastLevel = level;
|
||||||
}
|
}
|
||||||
|
last = tmp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
* Skip to next node in document order
|
* Skip to next node in document order
|
||||||
*/
|
*/
|
||||||
if ((list == NULL) || ((last == NULL) && (parent == NULL))) {
|
cur = xmlXPtrAdvanceNode(cur, &level);
|
||||||
return(NULL);
|
|
||||||
}
|
|
||||||
cur = xmlXPtrAdvanceNode(cur);
|
|
||||||
}
|
}
|
||||||
return(list);
|
return(list);
|
||||||
}
|
}
|
||||||
|
18
xpath.c
18
xpath.c
@@ -10447,10 +10447,10 @@ xmlXPathCompOpEval(xmlXPathParserContextPtr ctxt, xmlXPathStepOpPtr op)
|
|||||||
* single item in the nodelocset.
|
* single item in the nodelocset.
|
||||||
*/
|
*/
|
||||||
ctxt->context->node = oldlocset->locTab[i]->user;
|
ctxt->context->node = oldlocset->locTab[i]->user;
|
||||||
tmp = xmlXPathNewNodeSet(ctxt->context->node);
|
|
||||||
valuePush(ctxt, tmp);
|
|
||||||
ctxt->context->contextSize = oldlocset->locNr;
|
ctxt->context->contextSize = oldlocset->locNr;
|
||||||
ctxt->context->proximityPosition = i + 1;
|
ctxt->context->proximityPosition = i + 1;
|
||||||
|
tmp = xmlXPathNewNodeSet(ctxt->context->node);
|
||||||
|
valuePush(ctxt, tmp);
|
||||||
|
|
||||||
if (op->ch2 != -1)
|
if (op->ch2 != -1)
|
||||||
total +=
|
total +=
|
||||||
@@ -10632,9 +10632,9 @@ xmlXPathCompOpEval(xmlXPathParserContextPtr ctxt, xmlXPathStepOpPtr op)
|
|||||||
* Run the evaluation with a node list made of a
|
* Run the evaluation with a node list made of a
|
||||||
* single item in the nodelocset.
|
* single item in the nodelocset.
|
||||||
*/
|
*/
|
||||||
ctxt->context->node = (xmlNodePtr)ctxt->context->doc;
|
ctxt->context->node = oldlocset->locTab[i]->user;
|
||||||
ctxt->context->contextSize = 1;
|
ctxt->context->contextSize = oldlocset->locNr;
|
||||||
ctxt->context->proximityPosition = 1;
|
ctxt->context->proximityPosition = i + 1;
|
||||||
tmp = xmlXPathNewNodeSet(ctxt->context->node);
|
tmp = xmlXPathNewNodeSet(ctxt->context->node);
|
||||||
valuePush(ctxt, tmp);
|
valuePush(ctxt, tmp);
|
||||||
|
|
||||||
@@ -10644,10 +10644,6 @@ xmlXPathCompOpEval(xmlXPathParserContextPtr ctxt, xmlXPathStepOpPtr op)
|
|||||||
&comp->steps[op->ch2]);
|
&comp->steps[op->ch2]);
|
||||||
CHECK_ERROR0;
|
CHECK_ERROR0;
|
||||||
|
|
||||||
/*
|
|
||||||
* The result of the evaluation needs to be tested to
|
|
||||||
* decide whether the filter succeeded or not
|
|
||||||
*/
|
|
||||||
res = valuePop(ctxt);
|
res = valuePop(ctxt);
|
||||||
if (res->type == XPATH_LOCATIONSET) {
|
if (res->type == XPATH_LOCATIONSET) {
|
||||||
xmlLocationSetPtr rloc =
|
xmlLocationSetPtr rloc =
|
||||||
@@ -10706,10 +10702,6 @@ xmlXPathCompOpEval(xmlXPathParserContextPtr ctxt, xmlXPathStepOpPtr op)
|
|||||||
&comp->steps[op->ch2]);
|
&comp->steps[op->ch2]);
|
||||||
CHECK_ERROR0;
|
CHECK_ERROR0;
|
||||||
|
|
||||||
/*
|
|
||||||
* The result of the evaluation need to be tested to
|
|
||||||
* decided whether the filter succeeded or not
|
|
||||||
*/
|
|
||||||
res = valuePop(ctxt);
|
res = valuePop(ctxt);
|
||||||
range =
|
range =
|
||||||
xmlXPtrNewRangeNodeObject(oldset->nodeTab[i],
|
xmlXPtrNewRangeNodeObject(oldset->nodeTab[i],
|
||||||
|
19
xpointer.c
19
xpointer.c
@@ -123,7 +123,8 @@ xmlXPtrErr(xmlXPathParserContextPtr ctxt, int error,
|
|||||||
* A few helper functions for child sequences *
|
* A few helper functions for child sequences *
|
||||||
* *
|
* *
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
|
/* xmlXPtrAdvanceNode is a private function, but used by xinclude.c */
|
||||||
|
xmlNodePtr xmlXPtrAdvanceNode(xmlNodePtr cur, int *level);
|
||||||
/**
|
/**
|
||||||
* xmlXPtrGetArity:
|
* xmlXPtrGetArity:
|
||||||
* @cur: the node
|
* @cur: the node
|
||||||
@@ -1582,7 +1583,7 @@ xmlXPtrBuildRangeNodeList(xmlXPathObjectPtr range) {
|
|||||||
STRANGE
|
STRANGE
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
cur = xmlXPtrAdvanceNode(cur);
|
cur = xmlXPtrAdvanceNode(cur, NULL);
|
||||||
}
|
}
|
||||||
return(list);
|
return(list);
|
||||||
}
|
}
|
||||||
@@ -2296,12 +2297,14 @@ xmlXPtrRangeToFunction(xmlXPathParserContextPtr ctxt, int nargs) {
|
|||||||
* Returns -1 in case of failure, 0 otherwise
|
* Returns -1 in case of failure, 0 otherwise
|
||||||
*/
|
*/
|
||||||
xmlNodePtr
|
xmlNodePtr
|
||||||
xmlXPtrAdvanceNode(xmlNodePtr cur) {
|
xmlXPtrAdvanceNode(xmlNodePtr cur, int *level) {
|
||||||
next:
|
next:
|
||||||
if (cur == NULL)
|
if (cur == NULL)
|
||||||
return(NULL);
|
return(NULL);
|
||||||
if (cur->children != NULL) {
|
if (cur->children != NULL) {
|
||||||
cur = cur->children ;
|
cur = cur->children ;
|
||||||
|
if (level != NULL)
|
||||||
|
(*level)++;
|
||||||
goto found;
|
goto found;
|
||||||
}
|
}
|
||||||
if (cur->next != NULL) {
|
if (cur->next != NULL) {
|
||||||
@@ -2310,6 +2313,8 @@ next:
|
|||||||
}
|
}
|
||||||
do {
|
do {
|
||||||
cur = cur->parent;
|
cur = cur->parent;
|
||||||
|
if (level != NULL)
|
||||||
|
(*level)--;
|
||||||
if (cur == NULL) return(NULL);
|
if (cur == NULL) return(NULL);
|
||||||
if (cur->next != NULL) {
|
if (cur->next != NULL) {
|
||||||
cur = cur->next;
|
cur = cur->next;
|
||||||
@@ -2366,7 +2371,7 @@ xmlXPtrAdvanceChar(xmlNodePtr *node, int *indx, int bytes) {
|
|||||||
cur = xmlXPtrGetNthChild(cur, pos);
|
cur = xmlXPtrGetNthChild(cur, pos);
|
||||||
pos = 0;
|
pos = 0;
|
||||||
} else {
|
} else {
|
||||||
cur = xmlXPtrAdvanceNode(cur);
|
cur = xmlXPtrAdvanceNode(cur, NULL);
|
||||||
pos = 0;
|
pos = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2401,7 +2406,7 @@ xmlXPtrAdvanceChar(xmlNodePtr *node, int *indx, int bytes) {
|
|||||||
}
|
}
|
||||||
if (pos + bytes >= len) {
|
if (pos + bytes >= len) {
|
||||||
bytes -= (len - pos);
|
bytes -= (len - pos);
|
||||||
cur = xmlXPtrAdvanceNode(cur);
|
cur = xmlXPtrAdvanceNode(cur, NULL);
|
||||||
cur = 0;
|
cur = 0;
|
||||||
} else if (pos + bytes < len) {
|
} else if (pos + bytes < len) {
|
||||||
pos += bytes;
|
pos += bytes;
|
||||||
@@ -2490,7 +2495,7 @@ xmlXPtrMatchString(const xmlChar *string, xmlNodePtr start, int startindex,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cur = xmlXPtrAdvanceNode(cur);
|
cur = xmlXPtrAdvanceNode(cur, NULL);
|
||||||
if (cur == NULL)
|
if (cur == NULL)
|
||||||
return(0);
|
return(0);
|
||||||
pos = 0;
|
pos = 0;
|
||||||
@@ -2583,7 +2588,7 @@ xmlXPtrSearchString(const xmlChar *string, xmlNodePtr *start, int *startindex,
|
|||||||
}
|
}
|
||||||
if ((cur == *end) && (pos >= *endindex))
|
if ((cur == *end) && (pos >= *endindex))
|
||||||
return(0);
|
return(0);
|
||||||
cur = xmlXPtrAdvanceNode(cur);
|
cur = xmlXPtrAdvanceNode(cur, NULL);
|
||||||
if (cur == NULL)
|
if (cur == NULL)
|
||||||
return(0);
|
return(0);
|
||||||
pos = 1;
|
pos = 1;
|
||||||
|
Reference in New Issue
Block a user