derick Mon Jul 14 17:36:27 2008 UTC
Modified files: (Branch: PHP_5_3)
/php-src/ext/date php_date.c
/php-src/ext/date/lib dow.c parse_date.c parse_date.re timelib.h
Log:
- MFH: 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.43.2.45.2.51.2.42&r2=1.43.2.45.2.51.2.43&diff_format=u
Index: php-src/ext/date/php_date.c
diff -u php-src/ext/date/php_date.c:1.43.2.45.2.51.2.42
php-src/ext/date/php_date.c:1.43.2.45.2.51.2.43
--- php-src/ext/date/php_date.c:1.43.2.45.2.51.2.42 Wed Jul 9 12:50:57 2008
+++ php-src/ext/date/php_date.c Mon Jul 14 17:35:52 2008
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_date.c,v 1.43.2.45.2.51.2.42 2008/07/09 12:50:57 felipe Exp $ */
+/* $Id: php_date.c,v 1.43.2.45.2.51.2.43 2008/07/14 17:35:52 derick Exp $ */
#include "php.h"
#include "php_streams.h"
@@ -1610,7 +1610,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.8.2.3.2.3.2.2&r2=1.8.2.3.2.3.2.3&diff_format=u
Index: php-src/ext/date/lib/dow.c
diff -u php-src/ext/date/lib/dow.c:1.8.2.3.2.3.2.2
php-src/ext/date/lib/dow.c:1.8.2.3.2.3.2.3
--- php-src/ext/date/lib/dow.c:1.8.2.3.2.3.2.2 Fri Feb 22 17:48:46 2008
+++ php-src/ext/date/lib/dow.c Mon Jul 14 17:35:52 2008
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: dow.c,v 1.8.2.3.2.3.2.2 2008/02/22 17:48:46 derick Exp $ */
+/* $Id: dow.c,v 1.8.2.3.2.3.2.3 2008/07/14 17:35:52 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.29.2.30.2.14.2.19&r2=1.29.2.30.2.14.2.20&diff_format=u
Index: php-src/ext/date/lib/parse_date.c
diff -u php-src/ext/date/lib/parse_date.c:1.29.2.30.2.14.2.19
php-src/ext/date/lib/parse_date.c:1.29.2.30.2.14.2.20
--- php-src/ext/date/lib/parse_date.c:1.29.2.30.2.14.2.19 Fri Jul 11
08:42:35 2008
+++ php-src/ext/date/lib/parse_date.c Mon Jul 14 17:35:52 2008
@@ -1,4 +1,4 @@
-/* Generated by re2c 0.13.5 on Fri Jul 11 10:39:11 2008 */
+/* Generated by re2c 0.13.5 on Mon Jul 14 19:34:39 2008 */
#line 1 "ext/date/lib/parse_date.re"
/*
+----------------------------------------------------------------------+
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: parse_date.c,v 1.29.2.30.2.14.2.19 2008/07/11 08:42:35 derick Exp $ */
+/* $Id: parse_date.c,v 1.29.2.30.2.14.2.20 2008/07/14 17:35:52 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.26.2.27.2.12.2.17&r2=1.26.2.27.2.12.2.18&diff_format=u
Index: php-src/ext/date/lib/parse_date.re
diff -u php-src/ext/date/lib/parse_date.re:1.26.2.27.2.12.2.17
php-src/ext/date/lib/parse_date.re:1.26.2.27.2.12.2.18
--- php-src/ext/date/lib/parse_date.re:1.26.2.27.2.12.2.17 Fri Jul 11
08:42:54 2008
+++ php-src/ext/date/lib/parse_date.re Mon Jul 14 17:36:12 2008
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: parse_date.re,v 1.26.2.27.2.12.2.17 2008/07/11 08:42:54 derick Exp $ */
+/* $Id: parse_date.re,v 1.26.2.27.2.12.2.18 2008/07/14 17:36:12 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.10.2.11.2.3.2.6&r2=1.10.2.11.2.3.2.7&diff_format=u
Index: php-src/ext/date/lib/timelib.h
diff -u php-src/ext/date/lib/timelib.h:1.10.2.11.2.3.2.6
php-src/ext/date/lib/timelib.h:1.10.2.11.2.3.2.7
--- php-src/ext/date/lib/timelib.h:1.10.2.11.2.3.2.6 Sun May 4 20:52:56 2008
+++ php-src/ext/date/lib/timelib.h Mon Jul 14 17:36:12 2008
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: timelib.h,v 1.10.2.11.2.3.2.6 2008/05/04 20:52:56 derick Exp $ */
+/* $Id: timelib.h,v 1.10.2.11.2.3.2.7 2008/07/14 17:36:12 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