From: Wez Furlong Date: Fri, 12 Aug 2005 23:46:42 +0000 (+0000) Subject: sizeof(time_t) !== sizeof(int) X-Git-Tag: PRE_NEW_OCI8_EXTENSION~288 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=45412770a25b23790dc56b19f1ff5dbaca8ccd2e;p=php sizeof(time_t) !== sizeof(int) also, sizeof(timelib_sll) != sizeof(int) We get loads of truncation errors int this code when we assign 64 values into smaller ints. --- diff --git a/ext/date/lib/timelib.h b/ext/date/lib/timelib.h index 594f8caecb..02c8e4542d 100644 --- a/ext/date/lib/timelib.h +++ b/ext/date/lib/timelib.h @@ -34,7 +34,7 @@ #define LONG_MIN (- LONG_MAX - 1) #endif -#if defined(_MSC_VER) +#if defined(_MSC_VER) && !defined(strcasecmp) #define strcasecmp stricmp #endif diff --git a/ext/date/php_date.c b/ext/date/php_date.c index bee2a4e893..16e6ce806d 100644 --- a/ext/date/php_date.c +++ b/ext/date/php_date.c @@ -328,7 +328,7 @@ static char *day_short_names[] = { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" }; -static char *english_suffix(int number) +static char *english_suffix(timelib_sll number) { if (number >= 10 && number <= 19) { return "th"; @@ -471,7 +471,7 @@ static void php_date(INTERNAL_FUNCTION_PARAMETERS, int localtime) { char *format; int format_len; - long ts = time(NULL); + time_t ts = time(NULL); char *string; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|l", &format, &format_len, &ts) == FAILURE) { @@ -484,7 +484,7 @@ static void php_date(INTERNAL_FUNCTION_PARAMETERS, int localtime) } /* }}} */ -PHPAPI char *php_format_date(char *format, int format_len, long ts, int localtime TSRMLS_DC) /* {{{ */ +PHPAPI char *php_format_date(char *format, int format_len, time_t ts, int localtime TSRMLS_DC) /* {{{ */ { timelib_time *t; timelib_tzinfo *tzi; diff --git a/ext/date/php_date.h b/ext/date/php_date.h index 896813f75b..87c2311e7c 100644 --- a/ext/date/php_date.h +++ b/ext/date/php_date.h @@ -87,6 +87,6 @@ PHPAPI void php_mktime(INTERNAL_FUNCTION_PARAMETERS, int gmt); #define _php_strftime php_strftime PHPAPI void php_strftime(INTERNAL_FUNCTION_PARAMETERS, int gm); #endif -PHPAPI char *php_format_date(char *format, int format_len, long ts, int localtime TSRMLS_DC); +PHPAPI char *php_format_date(char *format, int format_len, time_t ts, int localtime TSRMLS_DC); #endif /* PHP_DATE_H */