derick Mon Feb 25 18:26:44 2008 UTC
Modified files: (Branch: PHP_5_3)
/php-src/ext/date/lib parse_date.c parse_date.re
Log:
- MFH: Added a few new separation specifiers.
- MFH: Added specifiers that can reset or default the y/m/d/h/i/s/tz values.
- MFH: Fixed a problem with parsing timezones as part of a format.
http://cvs.php.net/viewvc.cgi/php-src/ext/date/lib/parse_date.c?r1=1.29.2.30.2.14.2.8&r2=1.29.2.30.2.14.2.9&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.8
php-src/ext/date/lib/parse_date.c:1.29.2.30.2.14.2.9
--- php-src/ext/date/lib/parse_date.c:1.29.2.30.2.14.2.8 Sun Feb 17
18:17:28 2008
+++ php-src/ext/date/lib/parse_date.c Mon Feb 25 18:26:16 2008
@@ -1,4 +1,4 @@
-/* Generated by re2c 0.12.1 on Sun Feb 17 19:15:32 2008 */
+/* Generated by re2c 0.12.1 on Sun Feb 24 19:24:27 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.8 2008/02/17 18:17:28 derick Exp $ */
+/* $Id: parse_date.c,v 1.29.2.30.2.14.2.9 2008/02/25 18:26:16 derick Exp $ */
#include "timelib.h"
@@ -728,7 +728,7 @@
long value = 0;
const timelib_tz_lookup_table *tp;
- while (**ptr != '\0' && **ptr != ')') {
+ while (**ptr != '\0' && **ptr != ')' && **ptr != ' ') {
++*ptr;
}
end = *ptr;
@@ -23095,6 +23095,39 @@
}
break;
+ case ';':
+ case ':':
+ case '/':
+ case '.':
+ case ',':
+ case '-':
+ if (*ptr == *fptr) {
+ ++ptr;
+ } else {
+ add_pbf_error(s, "The separation symbol
could not be found", string, begin);
+ }
+ break;
+
+ case '!': // reset all fields to default
+ s->time->y = 1970;
+ s->time->m = 1;
+ s->time->d = 1;
+ s->time->h = s->time->i = s->time->s = 0;
+ s->time->f = 0.0;
+ s->time->tz_info = NULL;
+ break; // break intentionally not missing
+
+ case '|': // reset all fields to default when not set
+ if (s->time->y == TIMELIB_UNSET ) s->time->y =
1970;
+ if (s->time->m == TIMELIB_UNSET ) s->time->m =
1;
+ if (s->time->d == TIMELIB_UNSET ) s->time->d =
1;
+ if (s->time->h == TIMELIB_UNSET ) s->time->h =
0;
+ if (s->time->i == TIMELIB_UNSET ) s->time->i =
0;
+ if (s->time->s == TIMELIB_UNSET ) s->time->s =
0;
+ if (s->time->f == TIMELIB_UNSET ) s->time->f =
0.0;
+
+ break; // break intentionally not missing
+
case '?': // random char
++ptr;
break;
@@ -23118,6 +23151,20 @@
add_pbf_error(s, "Data missing", string, ptr);
}
+ // clean up a bit
+ if (s->time->h != TIMELIB_UNSET || s->time->i != TIMELIB_UNSET ||
s->time->s != TIMELIB_UNSET) {
+ if (s->time->h == TIMELIB_UNSET ) {
+ s->time->h = 0;
+ }
+ if (s->time->i == TIMELIB_UNSET ) {
+ s->time->i = 0;
+ }
+ if (s->time->s == TIMELIB_UNSET ) {
+ s->time->s = 0;
+ }
+ }
+
+
if (errors) {
*errors = in.errors;
} else {
http://cvs.php.net/viewvc.cgi/php-src/ext/date/lib/parse_date.re?r1=1.26.2.27.2.12.2.7&r2=1.26.2.27.2.12.2.8&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.7
php-src/ext/date/lib/parse_date.re:1.26.2.27.2.12.2.8
--- php-src/ext/date/lib/parse_date.re:1.26.2.27.2.12.2.7 Sun Feb 17
18:17:45 2008
+++ php-src/ext/date/lib/parse_date.re Mon Feb 25 18:26:33 2008
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: parse_date.re,v 1.26.2.27.2.12.2.7 2008/02/17 18:17:45 derick Exp $ */
+/* $Id: parse_date.re,v 1.26.2.27.2.12.2.8 2008/02/25 18:26:33 derick Exp $ */
#include "timelib.h"
@@ -726,7 +726,7 @@
long value = 0;
const timelib_tz_lookup_table *tp;
- while (**ptr != '\0' && **ptr != ')') {
+ while (**ptr != '\0' && **ptr != ')' && **ptr != ' ') {
++*ptr;
}
end = *ptr;
@@ -1867,6 +1867,39 @@
}
break;
+ case ';':
+ case ':':
+ case '/':
+ case '.':
+ case ',':
+ case '-':
+ if (*ptr == *fptr) {
+ ++ptr;
+ } else {
+ add_pbf_error(s, "The separation symbol
could not be found", string, begin);
+ }
+ break;
+
+ case '!': // reset all fields to default
+ s->time->y = 1970;
+ s->time->m = 1;
+ s->time->d = 1;
+ s->time->h = s->time->i = s->time->s = 0;
+ s->time->f = 0.0;
+ s->time->tz_info = NULL;
+ break; // break intentionally not missing
+
+ case '|': // reset all fields to default when not set
+ if (s->time->y == TIMELIB_UNSET ) s->time->y =
1970;
+ if (s->time->m == TIMELIB_UNSET ) s->time->m =
1;
+ if (s->time->d == TIMELIB_UNSET ) s->time->d =
1;
+ if (s->time->h == TIMELIB_UNSET ) s->time->h =
0;
+ if (s->time->i == TIMELIB_UNSET ) s->time->i =
0;
+ if (s->time->s == TIMELIB_UNSET ) s->time->s =
0;
+ if (s->time->f == TIMELIB_UNSET ) s->time->f =
0.0;
+
+ break; // break intentionally not missing
+
case '?': // random char
++ptr;
break;
@@ -1890,6 +1923,20 @@
add_pbf_error(s, "Data missing", string, ptr);
}
+ // clean up a bit
+ if (s->time->h != TIMELIB_UNSET || s->time->i != TIMELIB_UNSET ||
s->time->s != TIMELIB_UNSET) {
+ if (s->time->h == TIMELIB_UNSET ) {
+ s->time->h = 0;
+ }
+ if (s->time->i == TIMELIB_UNSET ) {
+ s->time->i = 0;
+ }
+ if (s->time->s == TIMELIB_UNSET ) {
+ s->time->s = 0;
+ }
+ }
+
+
if (errors) {
*errors = in.errors;
} else {
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php