Re: [xslt] exslt date bugs





Thomas Broyer wrote:


>>Anyway, attached is
>>    diff date.c date.c.orig
>>
> 
> Doh, this is a reversed patch, and it is not really readable. Could you use
> "diff -u date.c.orig date.c" and send me the patch back (sorry, I'm really
> busy, 'might even not find time to do it myself...)


Sorry! I only rarely use diff for patching, so I forget the
approp options. New diff attached.

> 
> Thanks, I'll try to integrate the whole thing asap.


Thanks, that'll be great.

--- date.c.orig	Mon Oct 29 10:44:34 2001
+++ date.c	Mon Oct 29 11:27:37 2001
@@ -697,6 +697,7 @@
 
 	/* is it an xs:gDay? */
 	if (*cur == '-') {
+	  ++cur;
 	    ret = _exsltDateParseGDay(dt, &cur);
 	    if (ret != 0)
 		goto error;
@@ -1149,7 +1150,8 @@
  */
 static const xmlChar *
 exsltDateMonthName (const xmlChar *dateTime) {
-    static const xmlChar monthNames[12][10] = {
+    static const xmlChar monthNames[13][10] = {
+        { 0 },
 	{ 'J', 'a', 'n', 'u', 'a', 'r', 'y', 0 },
 	{ 'F', 'e', 'b', 'r', 'u', 'a', 'r', 'y', 0 },
 	{ 'M', 'a', 'r', 'c', 'h', 0 },
@@ -1165,8 +1167,9 @@
     };
     int month;
     month = exsltDateMonthInYear(dateTime);
-
-    return monthNames[month - 1];
+    if (!VALID_MONTH(month))
+      month = 0;
+    return monthNames[month];
 }
 
 /**
@@ -1194,7 +1197,8 @@
  */
 static const xmlChar *
 exsltDateMonthAbbreviation (const xmlChar *dateTime) {
-    static const xmlChar monthAbbreviations[12][4] = {
+    static const xmlChar monthAbbreviations[13][4] = {
+        { 0 },
 	{ 'J', 'a', 'n', 0 },
 	{ 'F', 'e', 'b', 0 },
 	{ 'M', 'a', 'r', 0 },
@@ -1210,8 +1214,9 @@
     };
     int month;
     month = exsltDateMonthInYear(dateTime);
-
-    return monthAbbreviations[month - 1];
+    if(!VALID_MONTH(month))
+      month = 0;
+    return monthAbbreviations[month];
 }
 
 /**
@@ -1505,8 +1510,7 @@
 	dt = exsltDateParse(dateTime);
 	if (dt == NULL)
 	    return xmlXPathNAN;
-	if ((dt->type != XS_DATETIME) && (dt->type != XS_DATE) &&
-	    (dt->type != XS_GMONTHDAY) && (dt->type != XS_GDAY)) {
+	if ((dt->type != XS_DATETIME) && (dt->type != XS_DATE)) {
 	    exsltDateFreeDate(dt);
 	    return xmlXPathNAN;
 	}
@@ -1542,7 +1546,8 @@
  */
 static const xmlChar *
 exsltDateDayName (const xmlChar *dateTime) {
-    static const xmlChar dayNames[7][10] = {
+    static const xmlChar dayNames[8][10] = {
+        { 0 },
 	{ 'S', 'u', 'n', 'd', 'a', 'y', 0 },
 	{ 'M', 'o', 'n', 'd', 'a', 'y', 0 },
 	{ 'T', 'u', 'e', 's', 'd', 'a', 'y', 0 },
@@ -1553,8 +1558,9 @@
     };
     int day;
     day = exsltDateDayInWeek(dateTime);
-
-    return dayNames[day - 1];
+    if((day < 1) || (day > 7))
+      day = 0;
+    return dayNames[day];
 }
 
 /**
@@ -1579,7 +1585,8 @@
  */
 static const xmlChar *
 exsltDateDayAbbreviation (const xmlChar *dateTime) {
-    static const xmlChar dayAbbreviations[7][4] = {
+    static const xmlChar dayAbbreviations[8][4] = {
+        { 0 },
 	{ 'S', 'u', 'n', 0 },
 	{ 'M', 'o', 'n', 0 },
 	{ 'T', 'u', 'e', 0 },
@@ -1590,8 +1597,9 @@
     };
     int day;
     day = exsltDateDayInWeek(dateTime);
-
-    return dayAbbreviations[day - 1];
+    if((day < 1) || (day > 7))
+      day = 0;
+    return dayAbbreviations[day];
 }
 
 /**
@@ -1627,8 +1635,7 @@
 	dt = exsltDateParse(dateTime);
 	if (dt == NULL)
 	    return xmlXPathNAN;
-	if ((dt->type != XS_DATETIME) && (dt->type != XS_DATE) &&
-	    (dt->type != XS_GMONTHDAY) && (dt->type != XS_GDAY)) {
+	if ((dt->type != XS_DATETIME) && (dt->type != XS_TIME)) {
 	    exsltDateFreeDate(dt);
 	    return xmlXPathNAN;
 	}
@@ -1673,8 +1680,7 @@
 	dt = exsltDateParse(dateTime);
 	if (dt == NULL)
 	    return xmlXPathNAN;
-	if ((dt->type != XS_DATETIME) && (dt->type != XS_DATE) &&
-	    (dt->type != XS_GMONTHDAY) && (dt->type != XS_GDAY)) {
+	if ((dt->type != XS_DATETIME) && (dt->type != XS_TIME)) {
 	    exsltDateFreeDate(dt);
 	    return xmlXPathNAN;
 	}
@@ -1719,8 +1725,7 @@
 	dt = exsltDateParse(dateTime);
 	if (dt == NULL)
 	    return xmlXPathNAN;
-	if ((dt->type != XS_DATETIME) && (dt->type != XS_DATE) &&
-	    (dt->type != XS_GMONTHDAY) && (dt->type != XS_GDAY)) {
+	if ((dt->type != XS_DATETIME) && (dt->type != XS_TIME)) {
 	    exsltDateFreeDate(dt);
 	    return xmlXPathNAN;
 	}


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]