derick Mon Jul 14 17:30:09 2008 UTC
Modified files:
/php-src/ext/date php_date.c
/php-src/ext/date/lib dow.c parse_date.c parse_date.re timelib.h
Log:
- Added a warning to the error struct in case a parsed-date was found to be
invalid.
http://cvs.php.net/viewvc.cgi/php-src/ext/date/php_date.c?r1=1.193&r2=1.194&diff_format=u
Index: php-src/ext/date/php_date.c
diff -u php-src/ext/date/php_date.c:1.193 php-src/ext/date/php_date.c:1.194
--- php-src/ext/date/php_date.c:1.193 Wed Jul 9 12:51:26 2008
+++ php-src/ext/date/php_date.c Mon Jul 14 17:30:08 2008
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_date.c,v 1.193 2008/07/09 12:51:26 felipe Exp $ */
+/* $Id: php_date.c,v 1.194 2008/07/14 17:30:08 derick Exp $ */
#include "php.h"
#include "php_streams.h"
@@ -1736,7 +1736,7 @@
RETURN_FALSE;
}
- if (y < 1 || y > 32767 || m < 1 || m > 12 || d < 1 || d >
timelib_days_in_month(y, m)) {
+ if (y < 1 || y > 32767 || timelib_valid_date(y, m, d)) {
RETURN_FALSE;
}
RETURN_TRUE; /* True : This month, day, year arguments are valid */
http://cvs.php.net/viewvc.cgi/php-src/ext/date/lib/dow.c?r1=1.14&r2=1.15&diff_format=u
Index: php-src/ext/date/lib/dow.c
diff -u php-src/ext/date/lib/dow.c:1.14 php-src/ext/date/lib/dow.c:1.15
--- php-src/ext/date/lib/dow.c:1.14 Fri Feb 22 17:48:31 2008
+++ php-src/ext/date/lib/dow.c Mon Jul 14 17:30:08 2008
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: dow.c,v 1.14 2008/02/22 17:48:31 derick Exp $ */
+/* $Id: dow.c,v 1.15 2008/07/14 17:30:08 derick Exp $ */
#include "timelib.h"
@@ -140,6 +140,13 @@
return day + ((w - 1) * 7) + d;
}
+int timelib_valid_date(timelib_sll y, timelib_sll m, timelib_sll d)
+{
+ if (m < 1 || m > 12 || d < 1 || d > timelib_days_in_month(y, m)) {
+ return 0;
+ }
+ return 1;
+}
#if 0
int main(void)
{
http://cvs.php.net/viewvc.cgi/php-src/ext/date/lib/parse_date.c?r1=1.92&r2=1.93&diff_format=u
Index: php-src/ext/date/lib/parse_date.c
diff -u php-src/ext/date/lib/parse_date.c:1.92
php-src/ext/date/lib/parse_date.c:1.93
--- php-src/ext/date/lib/parse_date.c:1.92 Fri Jul 11 08:42:10 2008
+++ php-src/ext/date/lib/parse_date.c Mon Jul 14 17:30:08 2008
@@ -1,4 +1,4 @@
-/* Generated by re2c 0.13.5 on Fri Jul 11 10:41:19 2008 */
+/* Generated by re2c 0.13.5 on Mon Jul 14 19:27:22 2008 */
#line 1 "ext/date/lib/parse_date.re"
/*
+----------------------------------------------------------------------+
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: parse_date.c,v 1.92 2008/07/11 08:42:10 derick Exp $ */
+/* $Id: parse_date.c,v 1.93 2008/07/14 17:30:08 derick Exp $ */
#include "timelib.h"
@@ -23358,6 +23358,11 @@
#endif
} while(t != EOI);
+ /* do funky checking whether the parsed date was valid date */
+ if (in.time->have_date && !timelib_valid_date( in.time->y, in.time->m,
in.time->d)) {
+ add_warning(&in, "The parsed date was invalid");
+ }
+
free(in.str);
if (errors) {
*errors = in.errors;
@@ -23625,6 +23630,12 @@
}
}
+ /* do funky checking whether the parsed date was valid date */
+ if (s->time->y != TIMELIB_UNSET && s->time->m != TIMELIB_UNSET &&
+ s->time->d != TIMELIB_UNSET &&
+ !timelib_valid_date( s->time->y, s->time->m, s->time->d)) {
+ add_pbf_warning(s, "The parsed date was invalid", string, ptr);
+ }
if (errors) {
*errors = in.errors;
http://cvs.php.net/viewvc.cgi/php-src/ext/date/lib/parse_date.re?r1=1.83&r2=1.84&diff_format=u
Index: php-src/ext/date/lib/parse_date.re
diff -u php-src/ext/date/lib/parse_date.re:1.83
php-src/ext/date/lib/parse_date.re:1.84
--- php-src/ext/date/lib/parse_date.re:1.83 Fri Jul 11 08:42:11 2008
+++ php-src/ext/date/lib/parse_date.re Mon Jul 14 17:30:09 2008
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: parse_date.re,v 1.83 2008/07/11 08:42:11 derick Exp $ */
+/* $Id: parse_date.re,v 1.84 2008/07/14 17:30:09 derick Exp $ */
#include "timelib.h"
@@ -1768,6 +1768,11 @@
#endif
} while(t != EOI);
+ /* do funky checking whether the parsed date was valid date */
+ if (in.time->have_date && !timelib_valid_date( in.time->y, in.time->m,
in.time->d)) {
+ add_warning(&in, "The parsed date was invalid");
+ }
+
free(in.str);
if (errors) {
*errors = in.errors;
@@ -2035,6 +2040,12 @@
}
}
+ /* do funky checking whether the parsed date was valid date */
+ if (s->time->y != TIMELIB_UNSET && s->time->m != TIMELIB_UNSET &&
+ s->time->d != TIMELIB_UNSET &&
+ !timelib_valid_date( s->time->y, s->time->m, s->time->d)) {
+ add_pbf_warning(s, "The parsed date was invalid", string, ptr);
+ }
if (errors) {
*errors = in.errors;
http://cvs.php.net/viewvc.cgi/php-src/ext/date/lib/timelib.h?r1=1.30&r2=1.31&diff_format=u
Index: php-src/ext/date/lib/timelib.h
diff -u php-src/ext/date/lib/timelib.h:1.30 php-src/ext/date/lib/timelib.h:1.31
--- php-src/ext/date/lib/timelib.h:1.30 Sun May 4 20:50:46 2008
+++ php-src/ext/date/lib/timelib.h Mon Jul 14 17:30:09 2008
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: timelib.h,v 1.30 2008/05/04 20:50:46 derick Exp $ */
+/* $Id: timelib.h,v 1.31 2008/07/14 17:30:09 derick Exp $ */
#ifndef __TIMELIB_H__
#define __TIMELIB_H__
@@ -56,6 +56,7 @@
timelib_sll timelib_daynr_from_weeknr(timelib_sll y, timelib_sll w,
timelib_sll d);
timelib_sll timelib_days_in_month(timelib_sll y, timelib_sll m);
void timelib_isoweek_from_date(timelib_sll y, timelib_sll m, timelib_sll d,
timelib_sll *iw, timelib_sll *iy);
+int timelib_valid_date(timelib_sll y, timelib_sll m, timelib_sll d);
/* From parse_date.re */
timelib_time *timelib_strtotime(char *s, int len, timelib_error_container
**errors, const timelib_tzdb *tzdb);
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php