]> granicus.if.org Git - php/commitdiff
sizeof(time_t) !== sizeof(int)
authorWez Furlong <wez@php.net>
Fri, 12 Aug 2005 23:46:42 +0000 (23:46 +0000)
committerWez Furlong <wez@php.net>
Fri, 12 Aug 2005 23:46:42 +0000 (23:46 +0000)
also, sizeof(timelib_sll) != sizeof(int)

We get loads of truncation errors int this code when we assign 64 values into smaller ints.

ext/date/lib/timelib.h
ext/date/php_date.c
ext/date/php_date.h

index 594f8caecbbaf6c5eacba419d06c4425b6bc0c41..02c8e4542d52e216effbe651dd742541924d3f80 100644 (file)
@@ -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
 
index bee2a4e89318a1bc4502bb30d662146f8f101fa7..16e6ce806de87db24e370d0a744268e9453d7dbd 100644 (file)
@@ -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;
index 896813f75bcb068b54e495802051c85bd4ec2425..87c2311e7c8a4c973fa24dd0c243beb16a3c9cb6 100644 (file)
@@ -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 */