mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-02-05 05:47:00 +03:00
Remove useless comparisons
Found by lgtm.com
This commit is contained in:
parent
c9faa29259
commit
9bd7abfba4
@ -1251,8 +1251,7 @@ xmlNanoFTPConnectTo(const char *server, int port) {
|
||||
xmlNanoFTPFreeCtxt(ctxt);
|
||||
return(NULL);
|
||||
}
|
||||
if (port != 0)
|
||||
ctxt->port = port;
|
||||
ctxt->port = port;
|
||||
res = xmlNanoFTPConnect(ctxt);
|
||||
if (res < 0) {
|
||||
xmlNanoFTPFreeCtxt(ctxt);
|
||||
|
1
parser.c
1
parser.c
@ -3912,7 +3912,6 @@ xmlParseAttValueComplex(xmlParserCtxtPtr ctxt, int *attlen, int normalize) {
|
||||
"AttValue length too long\n");
|
||||
goto mem_error;
|
||||
}
|
||||
if (c == 0) break;
|
||||
if (c == '&') {
|
||||
in_space = 0;
|
||||
if (NXT(1) == '#') {
|
||||
|
41
valid.c
41
valid.c
@ -5919,28 +5919,27 @@ xmlValidatePushCData(xmlValidCtxtPtr ctxt, const xmlChar *data, int len) {
|
||||
break;
|
||||
case XML_ELEMENT_TYPE_MIXED:
|
||||
break;
|
||||
case XML_ELEMENT_TYPE_ELEMENT:
|
||||
if (len > 0) {
|
||||
int i;
|
||||
case XML_ELEMENT_TYPE_ELEMENT: {
|
||||
int i;
|
||||
|
||||
for (i = 0;i < len;i++) {
|
||||
if (!IS_BLANK_CH(data[i])) {
|
||||
xmlErrValidNode(ctxt, state->node,
|
||||
XML_DTD_CONTENT_MODEL,
|
||||
"Element %s content does not follow the DTD, Text not allowed\n",
|
||||
state->node->name, NULL, NULL);
|
||||
ret = 0;
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* TODO:
|
||||
* VC: Standalone Document Declaration
|
||||
* element types with element content, if white space
|
||||
* occurs directly within any instance of those types.
|
||||
*/
|
||||
}
|
||||
break;
|
||||
for (i = 0;i < len;i++) {
|
||||
if (!IS_BLANK_CH(data[i])) {
|
||||
xmlErrValidNode(ctxt, state->node,
|
||||
XML_DTD_CONTENT_MODEL,
|
||||
"Element %s content does not follow the DTD, Text not allowed\n",
|
||||
state->node->name, NULL, NULL);
|
||||
ret = 0;
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* TODO:
|
||||
* VC: Standalone Document Declaration
|
||||
* element types with element content, if white space
|
||||
* occurs directly within any instance of those types.
|
||||
*/
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6055,7 +6055,7 @@ xmlAutomataNewOnceTrans2(xmlAutomataPtr am, xmlAutomataStatePtr from,
|
||||
return(NULL);
|
||||
if (min < 1)
|
||||
return(NULL);
|
||||
if ((max < min) || (max < 1))
|
||||
if (max < min)
|
||||
return(NULL);
|
||||
atom = xmlRegNewAtom(am, XML_REGEXP_STRING);
|
||||
if (atom == NULL)
|
||||
@ -6134,7 +6134,7 @@ xmlAutomataNewOnceTrans(xmlAutomataPtr am, xmlAutomataStatePtr from,
|
||||
return(NULL);
|
||||
if (min < 1)
|
||||
return(NULL);
|
||||
if ((max < min) || (max < 1))
|
||||
if (max < min)
|
||||
return(NULL);
|
||||
atom = xmlRegNewAtom(am, XML_REGEXP_STRING);
|
||||
if (atom == NULL)
|
||||
|
187
xmlschemas.c
187
xmlschemas.c
@ -24184,7 +24184,7 @@ xmlSchemaValidateFacets(xmlSchemaAbstractCtxtPtr actxt,
|
||||
unsigned long length,
|
||||
int fireErrors)
|
||||
{
|
||||
int ret, error = 0;
|
||||
int ret, error = 0, found;
|
||||
|
||||
xmlSchemaTypePtr tmpType;
|
||||
xmlSchemaFacetLinkPtr facetLink;
|
||||
@ -24308,103 +24308,98 @@ WXS_IS_LIST:
|
||||
}
|
||||
|
||||
pattern_and_enum:
|
||||
if (error >= 0) {
|
||||
int found = 0;
|
||||
/*
|
||||
* Process enumerations. Facet values are in the value space
|
||||
* of the defining type's base type. This seems to be a bug in the
|
||||
* XML Schema 1.0 spec. Use the whitespace type of the base type.
|
||||
* Only the first set of enumerations in the ancestor-or-self axis
|
||||
* is used for validation.
|
||||
*/
|
||||
ret = 0;
|
||||
tmpType = type;
|
||||
do {
|
||||
for (facet = tmpType->facets; facet != NULL; facet = facet->next) {
|
||||
if (facet->type != XML_SCHEMA_FACET_ENUMERATION)
|
||||
continue;
|
||||
found = 1;
|
||||
ret = xmlSchemaAreValuesEqual(facet->val, val);
|
||||
if (ret == 1)
|
||||
break;
|
||||
else if (ret < 0) {
|
||||
AERROR_INT("xmlSchemaValidateFacets",
|
||||
"validating against an enumeration facet");
|
||||
return (-1);
|
||||
}
|
||||
}
|
||||
if (ret != 0)
|
||||
break;
|
||||
/*
|
||||
* Break on the first set of enumerations. Any additional
|
||||
* enumerations which might be existent on the ancestors
|
||||
* of the current type are restricted by this set; thus
|
||||
* *must* *not* be taken into account.
|
||||
*/
|
||||
if (found)
|
||||
break;
|
||||
tmpType = tmpType->baseType;
|
||||
} while ((tmpType != NULL) &&
|
||||
(tmpType->type != XML_SCHEMA_TYPE_BASIC));
|
||||
if (found && (ret == 0)) {
|
||||
ret = XML_SCHEMAV_CVC_ENUMERATION_VALID;
|
||||
if (fireErrors) {
|
||||
xmlSchemaFacetErr(actxt, ret, node,
|
||||
value, 0, type, NULL, NULL, NULL, NULL);
|
||||
} else
|
||||
return (ret);
|
||||
if (error == 0)
|
||||
error = ret;
|
||||
}
|
||||
found = 0;
|
||||
/*
|
||||
* Process enumerations. Facet values are in the value space
|
||||
* of the defining type's base type. This seems to be a bug in the
|
||||
* XML Schema 1.0 spec. Use the whitespace type of the base type.
|
||||
* Only the first set of enumerations in the ancestor-or-self axis
|
||||
* is used for validation.
|
||||
*/
|
||||
ret = 0;
|
||||
tmpType = type;
|
||||
do {
|
||||
for (facet = tmpType->facets; facet != NULL; facet = facet->next) {
|
||||
if (facet->type != XML_SCHEMA_FACET_ENUMERATION)
|
||||
continue;
|
||||
found = 1;
|
||||
ret = xmlSchemaAreValuesEqual(facet->val, val);
|
||||
if (ret == 1)
|
||||
break;
|
||||
else if (ret < 0) {
|
||||
AERROR_INT("xmlSchemaValidateFacets",
|
||||
"validating against an enumeration facet");
|
||||
return (-1);
|
||||
}
|
||||
}
|
||||
if (ret != 0)
|
||||
break;
|
||||
/*
|
||||
* Break on the first set of enumerations. Any additional
|
||||
* enumerations which might be existent on the ancestors
|
||||
* of the current type are restricted by this set; thus
|
||||
* *must* *not* be taken into account.
|
||||
*/
|
||||
if (found)
|
||||
break;
|
||||
tmpType = tmpType->baseType;
|
||||
} while ((tmpType != NULL) &&
|
||||
(tmpType->type != XML_SCHEMA_TYPE_BASIC));
|
||||
if (found && (ret == 0)) {
|
||||
ret = XML_SCHEMAV_CVC_ENUMERATION_VALID;
|
||||
if (fireErrors) {
|
||||
xmlSchemaFacetErr(actxt, ret, node,
|
||||
value, 0, type, NULL, NULL, NULL, NULL);
|
||||
} else
|
||||
return (ret);
|
||||
if (error == 0)
|
||||
error = ret;
|
||||
}
|
||||
|
||||
if (error >= 0) {
|
||||
int found;
|
||||
/*
|
||||
* Process patters. Pattern facets are ORed at type level
|
||||
* and ANDed if derived. Walk the base type axis.
|
||||
*/
|
||||
tmpType = type;
|
||||
facet = NULL;
|
||||
do {
|
||||
found = 0;
|
||||
for (facetLink = tmpType->facetSet; facetLink != NULL;
|
||||
facetLink = facetLink->next) {
|
||||
if (facetLink->facet->type != XML_SCHEMA_FACET_PATTERN)
|
||||
continue;
|
||||
found = 1;
|
||||
/*
|
||||
* NOTE that for patterns, @value needs to be the
|
||||
* normalized value.
|
||||
*/
|
||||
ret = xmlRegexpExec(facetLink->facet->regexp, value);
|
||||
if (ret == 1)
|
||||
break;
|
||||
else if (ret < 0) {
|
||||
AERROR_INT("xmlSchemaValidateFacets",
|
||||
"validating against a pattern facet");
|
||||
return (-1);
|
||||
} else {
|
||||
/*
|
||||
* Save the last non-validating facet.
|
||||
*/
|
||||
facet = facetLink->facet;
|
||||
}
|
||||
}
|
||||
if (found && (ret != 1)) {
|
||||
ret = XML_SCHEMAV_CVC_PATTERN_VALID;
|
||||
if (fireErrors) {
|
||||
xmlSchemaFacetErr(actxt, ret, node,
|
||||
value, 0, type, facet, NULL, NULL, NULL);
|
||||
} else
|
||||
return (ret);
|
||||
if (error == 0)
|
||||
error = ret;
|
||||
break;
|
||||
}
|
||||
tmpType = tmpType->baseType;
|
||||
} while ((tmpType != NULL) && (tmpType->type != XML_SCHEMA_TYPE_BASIC));
|
||||
}
|
||||
/*
|
||||
* Process patters. Pattern facets are ORed at type level
|
||||
* and ANDed if derived. Walk the base type axis.
|
||||
*/
|
||||
tmpType = type;
|
||||
facet = NULL;
|
||||
do {
|
||||
found = 0;
|
||||
for (facetLink = tmpType->facetSet; facetLink != NULL;
|
||||
facetLink = facetLink->next) {
|
||||
if (facetLink->facet->type != XML_SCHEMA_FACET_PATTERN)
|
||||
continue;
|
||||
found = 1;
|
||||
/*
|
||||
* NOTE that for patterns, @value needs to be the
|
||||
* normalized value.
|
||||
*/
|
||||
ret = xmlRegexpExec(facetLink->facet->regexp, value);
|
||||
if (ret == 1)
|
||||
break;
|
||||
else if (ret < 0) {
|
||||
AERROR_INT("xmlSchemaValidateFacets",
|
||||
"validating against a pattern facet");
|
||||
return (-1);
|
||||
} else {
|
||||
/*
|
||||
* Save the last non-validating facet.
|
||||
*/
|
||||
facet = facetLink->facet;
|
||||
}
|
||||
}
|
||||
if (found && (ret != 1)) {
|
||||
ret = XML_SCHEMAV_CVC_PATTERN_VALID;
|
||||
if (fireErrors) {
|
||||
xmlSchemaFacetErr(actxt, ret, node,
|
||||
value, 0, type, facet, NULL, NULL, NULL);
|
||||
} else
|
||||
return (ret);
|
||||
if (error == 0)
|
||||
error = ret;
|
||||
break;
|
||||
}
|
||||
tmpType = tmpType->baseType;
|
||||
} while ((tmpType != NULL) && (tmpType->type != XML_SCHEMA_TYPE_BASIC));
|
||||
|
||||
return (error);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user