com php-src: fixed ext/date for php_int_t usage: Zend /zend_int.h ext/date/lib/timelib.c ext/date/lib/timel ib.h ext/date/php_date.c
ext/date/php_date.h
| From: | Anatol Belski | Date: | Wed, 13 Nov 2013 14:22:56 +0000 |
| Subject: | com php-src: fixed ext/date for php_int_t usage: Zend /zend_int.h ext/date/lib/timelib.c ext/date/lib/timel ib.h ext/date/php_date.c ext/date/php_date.h |
||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-73950@lists.php.net to get a copy of this message | ||
Commit: 6b229d541adad9b4dac492ec5bf952841000a2cf
Author: Anatol Belski <ab@php.net> Wed, 13 Nov 2013 15:22:56 +0100
Parents: bd81a99ab34ed1b1a312da5ba4b465f93a5fd9c1
Branches: str_size_and_int64
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=6b229d541adad9b4dac492ec5bf952841000a2cf
Log:
fixed ext/date for php_int_t usage
Changed paths:
M Zend/zend_int.h
M ext/date/lib/timelib.c
M ext/date/lib/timelib.h
M ext/date/php_date.c
M ext/date/php_date.h
Diff:
diff --git a/Zend/zend_int.h b/Zend/zend_int.h
index fe94420..734c834 100644
--- a/Zend/zend_int.h
+++ b/Zend/zend_int..h
@@ -57,6 +57,8 @@ typedef off_t zend_off_t;
# define ZEND_STRTOUL(s0, s1, base) _strtoui64((s0), (s1), (base))
# define ZEND_INT_FMT "%I64d"
# define ZEND_UINT_FMT "%I64u"
+# define ZEND_INT_FMT_SPEC "I64d"
+# define ZEND_UINT_FMT_SPEC "I64u"
# define ZEND_STRTOL_PTR _strtoi64
# define ZEND_STRTOUL_PTR _strtoui64
# else
@@ -70,6 +72,8 @@ typedef off_t zend_off_t;
# define ZEND_STRTOUL(s0, s1, base) strtoull((s0), (s1), (base))
# define ZEND_INT_FMT "%lld"
# define ZEND_UINT_FMT "%llu"
+# define ZEND_INT_FMT_SPEC "lld"
+# define ZEND_UINT_FMT_SPEC "llu"
# define ZEND_STRTOL_PTR strtoll
# define ZEND_STRTOUL_PTR strtoull
# endif
@@ -89,6 +93,8 @@ typedef off_t zend_off_t;
# endif
# define ZEND_INT_FMT "%ld"
# define ZEND_UINT_FMT "%lu"
+# define ZEND_INT_FMT_SPEC "ld"
+# define ZEND_UINT_FMT_SPEC "lu"
# define ZEND_STRTOL_PTR strtol
# define ZEND_STRTOUL_PTR strtoul
#endif
diff --git a/ext/date/lib/timelib.c b/ext/date/lib/timelib.c
index 84354e3..439046e 100644
--- a/ext/date/lib/timelib.c
+++ b/ext/date/lib/timelib.c
@@ -176,13 +176,13 @@ void timelib_error_container_dtor(timelib_error_container *errors)
free(errors);
}
-signed long timelib_date_to_int(timelib_time *d, int *error)
+php_int_t timelib_date_to_int(timelib_time *d, int *error)
{
timelib_sll ts;
ts = d->sse;
- if (ts < LONG_MIN || ts > LONG_MAX) {
+ if (ts < PHP_INT_MIN || ts > PHP_INT_MAX) {
if (error) {
*error = 1;
}
@@ -191,7 +191,7 @@ signed long timelib_date_to_int(timelib_time *d, int *error)
if (error) {
*error = 0;
}
- return (signed long) d->sse;
+ return (php_int_t) d->sse;
}
void timelib_decimal_hour_to_hms(double h, int *hour, int *min, int *sec)
diff --git a/ext/date/lib/timelib.h b/ext/date/lib/timelib.h
index dfb7dc0..20e7739 100644
--- a/ext/date/lib/timelib.h
+++ b/ext/date/lib/timelib.h
@@ -21,6 +21,7 @@
#ifndef __TIMELIB_H__
#define __TIMELIB_H__
+#include "php.h" /* for php_int_t */
#include "timelib_structs.h"
#if HAVE_LIMITS_H
#include <limits.h>
@@ -125,7 +126,7 @@ void timelib_time_offset_dtor(timelib_time_offset* t);
void timelib_error_container_dtor(timelib_error_container *errors);
-signed long timelib_date_to_int(timelib_time *d, int *error);
+php_int_t timelib_date_to_int(timelib_time *d, int *error);
void timelib_dump_date(timelib_time *d, int options);
void timelib_dump_rel_time(timelib_rel_time *d);
diff --git a/ext/date/php_date.c b/ext/date/php_date.c
index c1041ab..efcc9e5 100644
--- a/ext/date/php_date.c
+++ b/ext/date/php_date.c
@@ -1397,12 +1397,12 @@ PHPAPI void php_date_set_tzdb(timelib_tzdb *tzdb)
/* }}} */
/* {{{ php_parse_date: Backwards compatibility function */
-PHPAPI signed long php_parse_date(char *string, signed long *now)
+PHPAPI php_int_t php_parse_date(char *string, php_int_t *now)
{
timelib_time *parsed_time;
timelib_error_container *error = NULL;
int error2;
- signed long retval;
+ php_int_t retval;
parsed_time = timelib_strtotime(string, strlen(string), &error, DATE_TIMEZONEDB,
php_date_parse_tzfile_wrapper);
if (error->error_count) {
@@ -1621,7 +1621,7 @@ PHPAPI void php_strftime(INTERNAL_FUNCTION_PARAMETERS, int gmt)
timelib_tzinfo *tzi;
timelib_time_offset *offset = NULL;
- timestamp = (long) time(NULL);
+ timestamp = (php_int_t) time(NULL);
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "S|i", &format,
&format_len, ×tamp) == FAILURE) {
RETURN_FALSE;
@@ -1723,7 +1723,7 @@ PHP_FUNCTION(gmstrftime)
Return current UNIX timestamp */
PHP_FUNCTION(time)
{
- RETURN_LONG((long)time(NULL));
+ RETURN_LONG((php_int_t)time(NULL));
}
/* }}} */
@@ -2389,7 +2389,7 @@ static HashTable *date_object_get_properties_interval(zval *object TSRMLS_DC)
#define PHP_DATE_INTERVAL_ADD_PROPERTY(n,f) \
MAKE_STD_ZVAL(zv); \
- ZVAL_LONG(zv, (long)intervalobj->diff->f); \
+ ZVAL_LONG(zv, (php_int_t)intervalobj->diff->f); \
zend_hash_update(props, n, strlen(n) + 1, &zv, sizeof(zv), NULL);
PHP_DATE_INTERVAL_ADD_PROPERTY("y", y);
@@ -3875,7 +3875,7 @@ PHP_FUNCTION(timezone_transitions_get)
zval *object, *element;
php_timezone_obj *tzobj;
unsigned int i, begin = 0, found;
- php_int_t timestamp_begin = LONG_MIN, timestamp_end = LONG_MAX;
+ php_int_t timestamp_begin = PHP_INT_MIN, timestamp_end = PHP_INT_MAX;
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O|ii",
&object, date_ce_timezone, ×tamp_begin, ×tamp_end) == FAILURE) {
RETURN_FALSE;
@@ -3910,7 +3910,7 @@ PHP_FUNCTION(timezone_transitions_get)
array_init(return_value);
- if (timestamp_begin == LONG_MIN) {
+ if (timestamp_begin == PHP_INT_MIN) {
add_nominal();
begin = 0;
found = 1;
@@ -4295,8 +4295,8 @@ static char *date_interval_format(char *format, zend_str_size_int format_len,
ti
case 'I': length = slprintf(buffer, 32, "%02d", (int) t->i); break;
case 'i': length = slprintf(buffer, 32, "%d", (int) t->i); break;
- case 'S': length = slprintf(buffer, 32, "%02ld", (long) t->s); break;
- case 's': length = slprintf(buffer, 32, "%ld", (long) t->s); break;
+ case 'S': length = slprintf(buffer, 32, "%02" ZEND_INT_FMT_SPEC,
(php_int_t) t->s); break;
+ case 's': length = slprintf(buffer, 32, ZEND_INT_FMT, (php_int_t) t->s); break;
case 'a': {
if ((int) t->days != -99999) {
diff --git a/ext/date/php_date.h b/ext/date/php_date.h
index 11a72b5..bd44a81 100644
--- a/ext/date/php_date.h
+++ b/ext/date/php_date.h
@@ -183,7 +183,7 @@ ZEND_END_MODULE_GLOBALS(date)
#endif
/* Backwards compatibility wrapper */
-PHPAPI signed long php_parse_date(char *string, signed long *now);
+PHPAPI php_int_t php_parse_date(char *string, php_int_t *now);
PHPAPI void php_mktime(INTERNAL_FUNCTION_PARAMETERS, int gmt);
PHPAPI int php_idate(char format, time_t ts, int localtime TSRMLS_DC);
#if HAVE_STRFTIME