1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-07-29 11:41:22 +03:00

fixed gMonth parsing routine accordingly to the XML Schemas errata

* xmlschemastypes.c: fixed gMonth parsing routine accordingly
  to the XML Schemas errata
  http://www.w3.org/2001/05/xmlschema-errata#e2-12
Daniel
This commit is contained in:
Daniel Veillard
2003-03-31 10:13:23 +00:00
parent e637c4ad2e
commit 455cc07308
2 changed files with 23 additions and 16 deletions

View File

@ -1,3 +1,9 @@
Mon Mar 31 12:11:47 CEST 2003 Daniel Veillard <daniel@veillard.com>
* xmlschemastypes.c: fixed gMonth parsing routine accordingly
to the XML Schemas errata
http://www.w3.org/2001/05/xmlschema-errata#e2-12
Sun Mar 30 23:04:18 CEST 2003 Daniel Veillard <daniel@veillard.com> Sun Mar 30 23:04:18 CEST 2003 Daniel Veillard <daniel@veillard.com>
* relaxng.c xmlschemastypes.c: more work on XML Schemas datatypes * relaxng.c xmlschemastypes.c: more work on XML Schemas datatypes

View File

@ -837,7 +837,7 @@ _xmlSchemaParseTimeZone (xmlSchemaValDatePtr dt, const xmlChar **str) {
/** /**
* xmlSchemaValidateDates: * xmlSchemaValidateDates:
* @type: the predefined type * @type: the expected type or XML_SCHEMAS_UNKNOWN
* @dateTime: string to analyze * @dateTime: string to analyze
* @val: the return computed value * @val: the return computed value
* *
@ -848,7 +848,7 @@ _xmlSchemaParseTimeZone (xmlSchemaValDatePtr dt, const xmlChar **str) {
* and -1 in case of internal or API error. * and -1 in case of internal or API error.
*/ */
static int static int
xmlSchemaValidateDates (xmlSchemaTypePtr type ATTRIBUTE_UNUSED, xmlSchemaValidateDates (xmlSchemaValType type,
const xmlChar *dateTime, xmlSchemaValPtr *val) { const xmlChar *dateTime, xmlSchemaValPtr *val) {
xmlSchemaValPtr dt; xmlSchemaValPtr dt;
int ret; int ret;
@ -861,11 +861,7 @@ xmlSchemaValidateDates (xmlSchemaTypePtr type ATTRIBUTE_UNUSED,
if (*cur != 0) \ if (*cur != 0) \
goto error; \ goto error; \
dt->type = t; \ dt->type = t; \
if (val != NULL) \ goto done; \
*val = dt; \
else \
xmlSchemaFreeValue(dt); \
return 0; \
} \ } \
} }
@ -888,6 +884,8 @@ xmlSchemaValidateDates (xmlSchemaTypePtr type ATTRIBUTE_UNUSED,
/* is it an xs:gDay? */ /* is it an xs:gDay? */
if (*cur == '-') { if (*cur == '-') {
if (type == XML_SCHEMAS_GMONTH)
goto error;
++cur; ++cur;
ret = _xmlSchemaParseGDay(&(dt->value.date), &cur); ret = _xmlSchemaParseGDay(&(dt->value.date), &cur);
if (ret != 0) if (ret != 0)
@ -905,18 +903,14 @@ xmlSchemaValidateDates (xmlSchemaTypePtr type ATTRIBUTE_UNUSED,
if (ret != 0) if (ret != 0)
goto error; goto error;
if (*cur != '-') if (*cur != '-') {
goto error;
cur++;
/* is it an xs:gMonth? */
if (*cur == '-') {
cur++;
RETURN_TYPE_IF_VALID(XML_SCHEMAS_GMONTH); RETURN_TYPE_IF_VALID(XML_SCHEMAS_GMONTH);
goto error; goto error;
} }
if (type == XML_SCHEMAS_GMONTH)
goto error;
/* it should be an xs:gMonthDay */ /* it should be an xs:gMonthDay */
cur++;
ret = _xmlSchemaParseGDay(&(dt->value.date), &cur); ret = _xmlSchemaParseGDay(&(dt->value.date), &cur);
if (ret != 0) if (ret != 0)
goto error; goto error;
@ -983,8 +977,15 @@ xmlSchemaValidateDates (xmlSchemaTypePtr type ATTRIBUTE_UNUSED,
if ((ret != 0) || (*cur != 0) || !VALID_DATETIME((&(dt->value.date)))) if ((ret != 0) || (*cur != 0) || !VALID_DATETIME((&(dt->value.date))))
goto error; goto error;
dt->type = XML_SCHEMAS_DATETIME; dt->type = XML_SCHEMAS_DATETIME;
done:
#if 0
if ((type != XML_SCHEMAS_UNKNOWN) && (type != XML_SCHEMAS_DATETIME))
goto error;
#endif
if (val != NULL) if (val != NULL)
*val = dt; *val = dt;
else else
@ -1404,7 +1405,7 @@ xmlSchemaValAtomicType(xmlSchemaTypePtr type, const xmlChar *value,
case XML_SCHEMAS_GYEARMONTH: case XML_SCHEMAS_GYEARMONTH:
case XML_SCHEMAS_DATE: case XML_SCHEMAS_DATE:
case XML_SCHEMAS_DATETIME: case XML_SCHEMAS_DATETIME:
ret = xmlSchemaValidateDates(type, value, val); ret = xmlSchemaValidateDates(type->flags, value, val);
break; break;
case XML_SCHEMAS_DURATION: case XML_SCHEMAS_DURATION:
ret = xmlSchemaValidateDuration(type, value, val); ret = xmlSchemaValidateDuration(type, value, val);