svn: /php/php-src/ branches/PHP_5_3/NEWS branches/PHP_5_3/ext/date/lib/parse_date.c branches/PHP_5_3/ext/date/lib/parse_date.re
branches/PHP_5_3/ext/date/tests/bug45554.phpt trunk/ext/date/lib/parse_date.c trunk/ext/date/lib/parse_date.re trunk/ext/date/tests/bug45554.phpt
| From: | Derick Rethans | Date: | Wed, 29 Jul 2009 15:34:59 +0000 |
| Subject: | svn: /php/php-src/ branches/PHP_5_3/NEWS branches/PHP_5_3/ext/date/lib/parse_date.c branches/PHP_5_3/ext/date/lib/parse_date.re branches/PHP_5_3/ext/date/tests/bug45554.phpt trunk/ext/date/lib/parse_date.c trunk/ext/date/lib/parse_date.re trunk/ext/date/tests/bug45554.phpt |
||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-59901@lists.php.net to get a copy of this message | ||
derick Wed, 29 Jul 2009 15:34:59 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=286515
Log:
- Fixed bug #45554 (Inconsistent behavior of the u format char).
Bug: http://bugs.php.net/45554 (Assigned) Inconsistent
behavior of the u format char
Changed paths:
U php/php-src/branches/PHP_5_3/NEWS
U php/php-src/branches/PHP_5_3/ext/date/lib/parse_date.c
U php/php-src/branches/PHP_5_3/ext/date/lib/parse_date.re
A php/php-src/branches/PHP_5_3/ext/date/tests/bug45554.phpt
U php/php-src/trunk/ext/date/lib/parse_date.c
U php/php-src/trunk/ext/date/lib/parse_date.re
A php/php-src/trunk/ext/date/tests/bug45554.phpt
Modified: php/php-src/branches/PHP_5_3/NEWS
===================================================================
--- php/php-src/branches/PHP_5_3/NEWS 2009-07-29 15:29:59 UTC (rev 286514)
+++ php/php-src/branches/PHP_5_3/NEWS 2009-07-29 15:34:59 UTC (rev 286515)
@@ -80,6 +80,7 @@
(Sriram Natarajan)
- Fixed bug #48182 (ssl handshake fails during asynchronous socket connection).
(Sriram Natarajan)
+- Fixed bug #45554 (Inconsistent behavior of the u format char). (Derick)
- Fixed bug #42434 (ImageLine w/ antialias = 1px shorter). (wojjie at gmail dot
com, Kalle)
Modified: php/php-src/branches/PHP_5_3/ext/date/lib/parse_date.c
===================================================================
--- php/php-src/branches/PHP_5_3/ext/date/lib/parse_date.c 2009-07-29 15:29:59 UTC (rev 286514)
+++ php/php-src/branches/PHP_5_3/ext/date/lib/parse_date.c 2009-07-29 15:34:59 UTC (rev 286515)
@@ -1,4 +1,4 @@
-/* Generated by re2c 0.13.5 on Thu Dec 18 14:58:43 2008 */
+/* Generated by re2c 0.13.5 on Wed Jul 29 16:20:12 2009 */
#line 1 "ext/date/lib/parse_date.re"
/*
+----------------------------------------------------------------------+
@@ -24086,10 +24086,18 @@
add_pbf_error(s, "A two digit second could not be found", string, begin);
}
break;
- case 'u': /* five digit millisecond, with leading zero */
- TIMELIB_CHECK_NUMBER;
- if ((s->time->f = timelib_get_nr((char **) &ptr, 5)) == TIMELIB_UNSET) {
- add_pbf_error(s, "A five digit millisecond could not be found", string, begin);
+ case 'u': /* six digit millisecond */
+ {
+ double f;
+ char *tptr;
+
+ TIMELIB_CHECK_NUMBER;
+ tptr = ptr;
+ if ((f = timelib_get_nr((char **) &ptr, 6)) == TIMELIB_UNSET || ptr - tptr != 6) {
+ add_pbf_error(s, "A six digit millisecond could not be found", string, begin);
+ } else {
+ s->time->f = (f / 1000000);
+ }
}
break;
case ' ': /* any sort of whitespace (' ' and \t) */
Modified: php/php-src/branches/PHP_5_3/ext/date/lib/parse_date.re
===================================================================
--- php/php-src/branches/PHP_5_3/ext/date/lib/parse_date.re 2009-07-29 15:29:59 UTC (rev 286514)
+++ php/php-src/branches/PHP_5_3/ext/date/lib/parse_date.re 2009-07-29 15:34:59 UTC (rev 286515)
@@ -1943,10 +1943,18 @@
add_pbf_error(s, "A two digit second could not be found", string, begin);
}
break;
- case 'u': /* five digit millisecond, with leading zero */
- TIMELIB_CHECK_NUMBER;
- if ((s->time->f = timelib_get_nr((char **) &ptr, 5)) == TIMELIB_UNSET) {
- add_pbf_error(s, "A five digit millisecond could not be found", string, begin);
+ case 'u': /* six digit millisecond */
+ {
+ double f;
+ char *tptr;
+
+ TIMELIB_CHECK_NUMBER;
+ tptr = ptr;
+ if ((f = timelib_get_nr((char **) &ptr, 6)) == TIMELIB_UNSET || ptr - tptr != 6) {
+ add_pbf_error(s, "A six digit millisecond could not be found", string, begin);
+ } else {
+ s->time->f = (f / 1000000);
+ }
}
break;
case ' ': /* any sort of whitespace (' ' and \t) */
Added: php/php-src/branches/PHP_5_3/ext/date/tests/bug45554.phpt
===================================================================
--- php/php-src/branches/PHP_5_3/ext/date/tests/bug45554.phpt (rev 0)
+++ php/php-src/branches/PHP_5_3/ext/date/tests/bug45554.phpt 2009-07-29 15:34:59 UTC (rev 286515)
@@ -0,0 +1,20 @@
+--TEST--
+Bug #45554 (Inconsistent behavior of the u format char)
+--INI--
+date.timezone=UTC
+--FILE--
+<?php
+$format = "m-d-Y H:i:s.u T";
+$d = date_create_from_format($format, "03-15-2005 12:22:29.000000 PST");
+echo $d->format($format), "\n";
+
+$d = date_create_from_format($format, "03-15-2005 12:22:29.001001 PST");
+echo $d->format($format), "\n";
+
+$d = date_create_from_format($format, "03-15-2005 12:22:29.0010 PST");
+var_dump( $d );
+?>
+--EXPECT--
+03-15-2005 12:22:29.000000 PST
+03-15-2005 12:22:29.001000 PST
+bool(false)
Modified: php/php-src/trunk/ext/date/lib/parse_date.c
===================================================================
--- php/php-src/trunk/ext/date/lib/parse_date.c 2009-07-29 15:29:59 UTC (rev 286514)
+++ php/php-src/trunk/ext/date/lib/parse_date.c 2009-07-29 15:34:59 UTC (rev 286515)
@@ -1,8 +1,8 @@
-/* Generated by re2c 0.13.5 on Thu Dec 18 15:50:45 2008 */
+/* Generated by re2c 0.13.5 on Wed Jul 29 16:31:12 2009 */
#line 1 "ext/date/lib/parse_date.re"
/*
+----------------------------------------------------------------------+
- | PHP Version 6 |
+ | PHP Version 5 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2006 The PHP Group |
+----------------------------------------------------------------------+
@@ -24086,10 +24086,18 @@
add_pbf_error(s, "A two digit second could not be found", string, begin);
}
break;
- case 'u': /* five digit millisecond, with leading zero */
- TIMELIB_CHECK_NUMBER;
- if ((s->time->f = timelib_get_nr((char **) &ptr, 5)) == TIMELIB_UNSET) {
- add_pbf_error(s, "A five digit millisecond could not be found", string, begin);
+ case 'u': /* six digit millisecond */
+ {
+ double f;
+ char *tptr;
+
+ TIMELIB_CHECK_NUMBER;
+ tptr = ptr;
+ if ((f = timelib_get_nr((char **) &ptr, 6)) == TIMELIB_UNSET || ptr - tptr != 6) {
+ add_pbf_error(s, "A six digit millisecond could not be found", string, begin);
+ } else {
+ s->time->f = (f / 1000000);
+ }
}
break;
case ' ': /* any sort of whitespace (' ' and \t) */
Modified: php/php-src/trunk/ext/date/lib/parse_date.re
===================================================================
--- php/php-src/trunk/ext/date/lib/parse_date.re 2009-07-29 15:29:59 UTC (rev 286514)
+++ php/php-src/trunk/ext/date/lib/parse_date.re 2009-07-29 15:34:59 UTC (rev 286515)
@@ -1943,10 +1943,18 @@
add_pbf_error(s, "A two digit second could not be found", string, begin);
}
break;
- case 'u': /* five digit millisecond, with leading zero */
- TIMELIB_CHECK_NUMBER;
- if ((s->time->f = timelib_get_nr((char **) &ptr, 5)) == TIMELIB_UNSET) {
- add_pbf_error(s, "A five digit millisecond could not be found", string, begin);
+ case 'u': /* six digit millisecond */
+ {
+ double f;
+ char *tptr;
+
+ TIMELIB_CHECK_NUMBER;
+ tptr = ptr;
+ if ((f = timelib_get_nr((char **) &ptr, 6)) == TIMELIB_UNSET || ptr - tptr != 6) {
+ add_pbf_error(s, "A six digit millisecond could not be found", string, begin);
+ } else {
+ s->time->f = (f / 1000000);
+ }
}
break;
case ' ': /* any sort of whitespace (' ' and \t) */
Added: php/php-src/trunk/ext/date/tests/bug45554.phpt
===================================================================
--- php/php-src/trunk/ext/date/tests/bug45554.phpt (rev 0)
+++ php/php-src/trunk/ext/date/tests/bug45554.phpt 2009-07-29 15:34:59 UTC (rev 286515)
@@ -0,0 +1,20 @@
+--TEST--
+Bug #45554 (Inconsistent behavior of the u format char)
+--INI--
+date.timezone=UTC
+--FILE--
+<?php
+$format = "m-d-Y H:i:s.u T";
+$d = date_create_from_format($format, "03-15-2005 12:22:29.000000 PST");
+echo $d->format($format), "\n";
+
+$d = date_create_from_format($format, "03-15-2005 12:22:29.001001 PST");
+echo $d->format($format), "\n";
+
+$d = date_create_from_format($format, "03-15-2005 12:22:29.0010 PST");
+var_dump( $d );
+?>
+--EXPECT--
+03-15-2005 12:22:29.000000 PST
+03-15-2005 12:22:29.001000 PST
+bool(false)