derick Mon Feb 25 18:25:01 2008 UTC
Modified files: /php-src/ext/date/lib parse_date.c parse_date.re Log: - Added a few new separation specifiers. - Added specifiers that can reset or default the y/m/d/h/i/s/tz values. - Fixed a problem with parsing timezones as part of a format. #- [DOC]: Added format specifiers. http://cvs.php.net/viewvc.cgi/php-src/ext/date/lib/parse_date.c?r1=1.81&r2=1.82&diff_format=u Index: php-src/ext/date/lib/parse_date.c diff -u php-src/ext/date/lib/parse_date.c:1.81 php-src/ext/date/lib/parse_date.c:1.82 --- php-src/ext/date/lib/parse_date.c:1.81 Sun Feb 17 18:17:00 2008 +++ php-src/ext/date/lib/parse_date.c Mon Feb 25 18:25:00 2008 @@ -1,4 +1,4 @@ -/* Generated by re2c 0.12.1 on Sun Feb 17 19:16:04 2008 */ +/* Generated by re2c 0.12.1 on Mon Feb 25 19:12:37 2008 */ #line 1 "ext/date/lib/parse_date.re" /* +----------------------------------------------------------------------+ @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: parse_date.c,v 1.81 2008/02/17 18:17:00 derick Exp $ */ +/* $Id: parse_date.c,v 1.82 2008/02/25 18:25:00 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.72&r2=1.73&diff_format=u Index: php-src/ext/date/lib/parse_date.re diff -u php-src/ext/date/lib/parse_date.re:1.72 php-src/ext/date/lib/parse_date.re:1.73 --- php-src/ext/date/lib/parse_date.re:1.72 Sun Feb 17 18:17:01 2008 +++ php-src/ext/date/lib/parse_date.re Mon Feb 25 18:25:01 2008 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: parse_date.re,v 1.72 2008/02/17 18:17:01 derick Exp $ */ +/* $Id: parse_date.re,v 1.73 2008/02/25 18:25:01 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 {