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
diff --git a/ChangeLog b/ChangeLog
index 78e0f45..17149c5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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>
 
 	* relaxng.c xmlschemastypes.c: more work on XML Schemas datatypes
diff --git a/xmlschemastypes.c b/xmlschemastypes.c
index ba96984..79cf833 100644
--- a/xmlschemastypes.c
+++ b/xmlschemastypes.c
@@ -837,7 +837,7 @@
 
 /**
  * xmlSchemaValidateDates:
- * @type: the predefined type
+ * @type: the expected type or XML_SCHEMAS_UNKNOWN
  * @dateTime:  string to analyze
  * @val:  the return computed value
  *
@@ -848,7 +848,7 @@
  *         and -1 in case of internal or API error.
  */
 static int
-xmlSchemaValidateDates (xmlSchemaTypePtr type ATTRIBUTE_UNUSED,
+xmlSchemaValidateDates (xmlSchemaValType type,
 	                const xmlChar *dateTime, xmlSchemaValPtr *val) {
     xmlSchemaValPtr dt;
     int ret;
@@ -861,11 +861,7 @@
 	    if (*cur != 0)					\
 		goto error;					\
 	    dt->type = t;					\
-            if (val != NULL)                                    \
-                *val = dt;                                      \
-            else						\
-		xmlSchemaFreeValue(dt);				\
-	    return 0;						\
+	    goto done;						\
 	}							\
     }
 
@@ -888,6 +884,8 @@
 
 	/* is it an xs:gDay? */
 	if (*cur == '-') {
+	    if (type == XML_SCHEMAS_GMONTH)
+		goto error;
 	  ++cur;
 	    ret = _xmlSchemaParseGDay(&(dt->value.date), &cur);
 	    if (ret != 0)
@@ -905,18 +903,14 @@
 	if (ret != 0)
 	    goto error;
 
-	if (*cur != '-')
-	    goto error;
-	cur++;
-
-	/* is it an xs:gMonth? */
-	if (*cur == '-') {
-	    cur++;
+	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;
@@ -983,8 +977,15 @@
     if ((ret != 0) || (*cur != 0) || !VALID_DATETIME((&(dt->value.date))))
 	goto error;
 
+
     dt->type = XML_SCHEMAS_DATETIME;
 
+done:
+#if 0
+    if ((type != XML_SCHEMAS_UNKNOWN) && (type != XML_SCHEMAS_DATETIME))
+	goto error;
+#endif
+
     if (val != NULL)
         *val = dt;
     else
@@ -1404,7 +1405,7 @@
         case XML_SCHEMAS_GYEARMONTH:
         case XML_SCHEMAS_DATE:
         case XML_SCHEMAS_DATETIME:
-	    ret = xmlSchemaValidateDates(type, value, val);
+	    ret = xmlSchemaValidateDates(type->flags, value, val);
 	    break;
         case XML_SCHEMAS_DURATION:
 	    ret = xmlSchemaValidateDuration(type, value, val);