Index: xmlschemastypes.c =================================================================== RCS file: /cvs/gnome/libxml2/xmlschemastypes.c,v retrieving revision 1.35 diff -c -r1.35 xmlschemastypes.c *** xmlschemastypes.c 31 Mar 2003 11:22:25 -0000 1.35 --- xmlschemastypes.c 4 Apr 2003 02:34:19 -0000 *************** *** 903,921 **** if (ret != 0) goto error; ! if (*cur != '-') { ! RETURN_TYPE_IF_VALID(XML_SCHEMAS_GMONTH); ! goto error; ! } ! if (type == XML_SCHEMAS_GMONTH) ! goto error; ! /* it should be an xs:gMonthDay */ ! cur++; ! ret = _xmlSchemaParseGDay(&(dt->value.date), &cur); ! if (ret != 0) ! goto error; ! RETURN_TYPE_IF_VALID(XML_SCHEMAS_GMONTHDAY); goto error; } --- 903,944 ---- if (ret != 0) goto error; ! /* ! * a '-' char could indicate this type is xs:gMonthDay or ! * a negative time zone offset. Check for xs:gMonthDay first. ! * Also the first three char's of a negative tzo (-MM:SS) can ! * appear to be a valid day; so even if the day portion ! * of the xs:gMonthDay verifies, we must insure it was not ! * a tzo. ! */ ! if (*cur == '-') { ! const xmlChar *rewind = cur; ! cur++; ! ! ret = _xmlSchemaParseGDay(&(dt->value.date), &cur); ! if ((ret == 0) && ((*cur == 0) || (*cur != ':'))) { ! ! /* ! * we can use the VALID_MDAY macro to validate the month ! * and day because the leap year test will flag year zero ! * as a leap year (even though zero is an invalid year). ! */ ! if (VALID_MDAY((&(dt->value.date)))) { ! ! RETURN_TYPE_IF_VALID(XML_SCHEMAS_GMONTHDAY); ! ! goto error; ! } ! } ! ! /* ! * not xs:gMonthDay so rewind and check if just xs:gMonth ! * with an optional time zone. ! */ ! cur = rewind; ! } ! RETURN_TYPE_IF_VALID(XML_SCHEMAS_GMONTH); goto error; } *************** *** 981,989 **** dt->type = XML_SCHEMAS_DATETIME; done: ! #if 0 ! if ((type != XML_SCHEMAS_UNKNOWN) && (type != XML_SCHEMAS_DATETIME)) ! goto error; #endif if (val != NULL) --- 1004,1040 ---- dt->type = XML_SCHEMAS_DATETIME; done: ! #if 1 ! if ((type != XML_SCHEMAS_UNKNOWN) && (type != dt->type)) ! goto error; ! #else ! /* ! * insure the parsed type is equal to or less significant (right ! * truncated) than the desired type. ! */ ! if ((type != XML_SCHEMAS_UNKNOWN) && (type != dt->type)) { ! ! /* time only matches time */ ! if ((type == XML_SCHEMAS_TIME) && (dt->type == XML_SCHEMAS_TIME)) ! goto error; ! ! if ((type == XML_SCHEMAS_DATETIME) && ! ((dt->type != XML_SCHEMAS_DATE) || ! (dt->type != XML_SCHEMAS_GYEARMONTH) || ! (dt->type != XML_SCHEMAS_GYEAR))) ! goto error; ! ! if ((type == XML_SCHEMAS_DATE) && ! ((dt->type != XML_SCHEMAS_GYEAR) || ! (dt->type != XML_SCHEMAS_GYEARMONTH))) ! goto error; ! ! if ((type == XML_SCHEMAS_GYEARMONTH) && (dt->type != XML_SCHEMAS_GYEAR)) ! goto error; ! ! if ((type == XML_SCHEMAS_GMONTHDAY) && (dt->type != XML_SCHEMAS_GMONTH)) ! goto error; ! } #endif if (val != NULL) *************** *** 1018,1023 **** --- 1069,1078 ---- xmlSchemaValPtr dur; int isneg = 0; unsigned int seq = 0; + double num; + int num_type = 0; /* -1 = invalid, 0 = int, 1 = floating */ + const xmlChar desig[] = {'Y', 'M', 'D', 'H', 'M', 'S'}; + const double multi[] = { 0.0, 0.0, 86400.0, 3600.0, 60.0, 1.0, 0.0}; if (duration == NULL) return -1; *************** *** 1039,1048 **** return -1; while (*cur != 0) { - double num; - int num_type = 0; /* -1 = invalid, 0 = int, 1 = floating */ - const xmlChar desig[] = {'Y', 'M', 'D', 'H', 'M', 'S'}; - const double multi[] = { 0.0, 0.0, 86400.0, 3600.0, 60.0, 1.0, 0.0}; /* input string should be empty or invalid date/time item */ if (seq >= sizeof(desig)) --- 1094,1099 ---- *************** *** 1328,1334 **** xmlSchemaValPtr *val, xmlNodePtr node, int flags) { xmlSchemaValPtr v; xmlChar *norm = NULL; ! int ret; if (xmlSchemaTypesInitialized == 0) return(-1); --- 1379,1385 ---- xmlSchemaValPtr *val, xmlNodePtr node, int flags) { xmlSchemaValPtr v; xmlChar *norm = NULL; ! int ret = 0; if (xmlSchemaTypesInitialized == 0) return(-1);