1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2024-12-25 23:21:26 +03:00

some warning removal on Igor's patch seems I messed up with #106788 fix

* uri.c parser.c: some warning removal on Igor's patch
* tree.c: seems I messed up with #106788 fix
* python/libxml.c: fixed some base problems when Python provides
  the resolver.
* relaxng.c: fixed the interleave algorithm
  found 373 test schemas: 364 success 9 failures
  found 529 test instances: 525 success 4 failures
  the resulting failures are bug in the algorithm from 7.3 and
  lack of support for params
Daniel
This commit is contained in:
Daniel Veillard 2003-02-24 11:47:13 +00:00
parent 0046c0fec2
commit c64b8e984c
6 changed files with 127 additions and 86 deletions

View File

@ -1,3 +1,15 @@
Mon Feb 24 12:41:54 CET 2003 Daniel Veillard <daniel@veillard.com>
* uri.c parser.c: some warning removal on Igor's patch
* tree.c: seems I messed up with #106788 fix
* python/libxml.c: fixed some base problems when Python provides
the resolver.
* relaxng.c: fixed the interleave algorithm
found 373 test schemas: 364 success 9 failures
found 529 test instances: 525 success 4 failures
the resulting failures are bug in the algorithm from 7.3 and
lack of support for params
Sun Feb 23 14:49:39 CET 2003 Daniel Veillard <daniel@veillard.com>
* parser.c: another fix for nodeinfo in entities problem

View File

@ -10356,7 +10356,7 @@ xmlCreateFileParserCtxt(const char *filename)
return(NULL);
}
canonicFilename = xmlCanonicPath(filename);
canonicFilename = (char *) xmlCanonicPath((const xmlChar *) filename);
if (canonicFilename == NULL) {
if (xmlDefaultSAXHandler.error != NULL) {
xmlDefaultSAXHandler.error(NULL, "out of memory\n");

View File

@ -463,6 +463,9 @@ pythonExternalEntityLoader(const char *URL, const char *ID,
}
if (result == NULL) {
Py_DECREF(ret);
} else if (URL != NULL) {
result->filename = xmlStrdup(URL);
result->directory = xmlParserGetDirectory((const char *) URL);
}
}
}

184
relaxng.c
View File

@ -6452,14 +6452,16 @@ xmlRelaxNGValidatePartGroup(xmlRelaxNGValidCtxtPtr ctxt,
static int
xmlRelaxNGValidateInterleave(xmlRelaxNGValidCtxtPtr ctxt,
xmlRelaxNGDefinePtr define) {
int ret = 0, nbchildren, nbtot, i, j;
int ret = 0, i, nbgroups, left;
xmlRelaxNGPartitionPtr partitions;
xmlNodePtr *children = NULL;
xmlNodePtr *order = NULL;
xmlNodePtr cur, oldseq;
xmlRelaxNGInterleaveGroupPtr group = NULL;
xmlNodePtr cur, start, last, lastchg = NULL, lastelem;
xmlNodePtr *list = NULL, *lasts = NULL;
if (define->data != NULL) {
partitions = (xmlRelaxNGPartitionPtr) define->data;
nbgroups = partitions->nbgroups;
left = nbgroups;
} else {
VALID_CTXT();
VALID_ERROR("Internal: interleave block has no data\n");
@ -6467,91 +6469,111 @@ xmlRelaxNGValidateInterleave(xmlRelaxNGValidCtxtPtr ctxt,
}
/*
* Build the sequence of child and an array preserving the children
* initial order.
* Build arrays to store the first and last node of the chain
* pertaining to each group
*/
cur = ctxt->state->seq;
oldseq = ctxt->state->seq;
nbchildren = 0;
nbtot = 0;
while (cur != NULL) {
if ((cur->type == XML_COMMENT_NODE) ||
(cur->type == XML_PI_NODE) ||
((cur->type == XML_TEXT_NODE) &&
(IS_BLANK_NODE(cur)))) {
nbtot++;
} else {
nbchildren++;
nbtot++;
}
cur = cur->next;
list = (xmlNodePtr *) xmlMalloc(nbgroups * sizeof(xmlNodePtr));
if (list == NULL) {
VALID_CTXT();
VALID_ERROR("Internal: out of memory in interleave check\n");
return(-1);
}
children = (xmlNodePtr *) xmlMalloc(nbchildren * sizeof(xmlNodePtr));
if (children == NULL)
goto error;
order = (xmlNodePtr *) xmlMalloc(nbtot * sizeof(xmlNodePtr));
if (order == NULL)
goto error;
cur = ctxt->state->seq;
i = 0;
j = 0;
while (cur != NULL) {
if ((cur->type == XML_COMMENT_NODE) ||
(cur->type == XML_PI_NODE) ||
((cur->type == XML_TEXT_NODE) &&
(IS_BLANK_NODE(cur)))) {
order[j++] = cur;
} else {
order[j++] = cur;
children[i++] = cur;
}
cur = cur->next;
memset(list, 0, nbgroups * sizeof(xmlNodePtr));
lasts = (xmlNodePtr *) xmlMalloc(nbgroups * sizeof(xmlNodePtr));
if (lasts == NULL) {
VALID_CTXT();
VALID_ERROR("Internal: out of memory in interleave check\n");
return(-1);
}
/* TODO: retry with a maller set of child if there is a next... */
ret = xmlRelaxNGValidatePartGroup(ctxt, partitions->groups,
partitions->nbgroups, children, nbchildren);
if (ret != 0)
ctxt->state->seq = oldseq;
memset(lasts, 0, nbgroups * sizeof(xmlNodePtr));
/*
* Cleanup: rebuid the child sequence and free the structure
* Walk the sequence of children finding the right group and
* sorting them in sequences.
*/
if (order != NULL) {
for (i = 0;i < nbtot;i++) {
if (i == 0)
order[i]->prev = NULL;
else
order[i]->prev = order[i - 1];
if (i == nbtot - 1)
order[i]->next = NULL;
else
order[i]->next = order[i + 1];
cur = ctxt->state->seq;
cur = xmlRelaxNGSkipIgnored(ctxt, cur);
start = cur;
while (cur != NULL) {
ctxt->state->seq = cur;
for (i = 0;i < nbgroups;i++) {
group = partitions->groups[i];
if (group == NULL)
continue;
if (xmlRelaxNGNodeMatchesList(cur, group->defs))
break;
}
xmlFree(order);
/*
* We break as soon as an element not matched is found
*/
if (i >= nbgroups) {
break;
}
if (lasts[i] != NULL) {
lasts[i]->next = cur;
lasts[i] = cur;
} else {
list[i] = cur;
lasts[i] = cur;
}
if (cur->next != NULL)
lastchg = cur->next;
else
lastchg = cur;
cur = xmlRelaxNGSkipIgnored(ctxt, cur->next);
}
if (ret != 0) {
VALID_CTXT();
VALID_ERROR("Invalid sequence in interleave\n");
ret = -1;
goto done;
}
lastelem = cur;
for (i = 0;i < nbgroups;i++) {
group = partitions->groups[i];
if (lasts[i] != NULL) {
last = lasts[i]->next;
lasts[i]->next = NULL;
}
ctxt->state->seq = list[i];
ret = xmlRelaxNGValidateDefinition(ctxt, group->rule);
if (ret != 0)
break;
cur = ctxt->state->seq;
cur = xmlRelaxNGSkipIgnored(ctxt, cur);
if (cur != NULL) {
VALID_CTXT();
VALID_ERROR2("Extra element %s in interleave\n", cur->name);
ret = -1;
goto done;
}
if (lasts[i] != NULL) {
lasts[i]->next = last;
}
}
ctxt->state->seq = lastelem;
if (ret != 0) {
VALID_CTXT();
VALID_ERROR("Invalid sequence in interleave\n");
ret = -1;
goto done;
}
if (children != NULL)
xmlFree(children);
done:
/*
* builds the next links chain from the prev one
*/
cur = lastchg;
while (cur != NULL) {
if ((cur == start) || (cur->prev == NULL))
break;
cur->prev->next = cur;
cur = cur->prev;
}
xmlFree(list);
xmlFree(lasts);
return(ret);
error:
if (order != NULL) {
for (i = 0;i < nbtot;i++) {
if (i == 0)
order[i]->prev = NULL;
else
order[i]->prev = order[i - 1];
if (i == nbtot - 1)
order[i]->next = NULL;
else
order[i]->next = order[i + 1];
}
xmlFree(order);
}
if (children != NULL)
xmlFree(children);
return(-1);
}
/**
@ -6776,8 +6798,10 @@ xmlRelaxNGValidateDefinition(xmlRelaxNGValidCtxtPtr ctxt,
* This node was already validated successfully against
* this definition.
*/
if (node->_private == define)
if (node->_private == define) {
ctxt->state->seq = xmlRelaxNGSkipIgnored(ctxt, node->next);
break;
}
ret = xmlRelaxNGElementMatch(ctxt, define, node);
if (ret <= 0) {

4
tree.c
View File

@ -6457,13 +6457,13 @@ xmlAttrSerializeContent(xmlBufferPtr buf, xmlDocPtr doc, xmlAttrPtr attr)
} else if (*cur == '\r') {
if (base != cur)
xmlBufferAdd(buf, base, cur - base);
xmlBufferAdd(buf, BAD_CAST "&#13;", 6);
xmlBufferAdd(buf, BAD_CAST "&#13;", 5);
cur++;
base = cur;
} else if (*cur == '\t') {
if (base != cur)
xmlBufferAdd(buf, base, cur - base);
xmlBufferAdd(buf, BAD_CAST "&#9;", 5);
xmlBufferAdd(buf, BAD_CAST "&#9;", 4);
cur++;
base = cur;
#if 0

8
uri.c
View File

@ -1985,15 +1985,17 @@ done:
xmlChar*
xmlCanonicPath(const xmlChar *path)
{
#if defined(_WIN32) && !defined(__CYGWIN__)
int len = 0;
int i = 0;
xmlChar *ret;
xmlChar *p = NULL;
#endif
xmlChar *ret;
xmlURIPtr uri;
if (path == NULL)
return(NULL);
if ((uri = xmlParseURI(path)) != NULL) {
if ((uri = xmlParseURI((const char *) path)) != NULL) {
xmlFreeURI(uri);
return xmlStrdup(path);
}
@ -2018,7 +2020,7 @@ xmlCanonicPath(const xmlChar *path)
p++;
}
#else
uri->path = xmlStrdup(path);
uri->path = (char *) xmlStrdup((const char *) path);
#endif
ret = xmlSaveUri(uri);