]> granicus.if.org Git - php/commitdiff
- Make it compile cleanly with MS VC++ too, which is completely anal in some
authorDerick Rethans <derick@php.net>
Wed, 15 Jun 2005 11:01:07 +0000 (11:01 +0000)
committerDerick Rethans <derick@php.net>
Wed, 15 Jun 2005 11:01:07 +0000 (11:01 +0000)
  cases.

ext/date/lib/datetime.c
ext/date/lib/datetime.h
ext/date/lib/dow.c
ext/date/lib/parse_date.c
ext/date/lib/parse_date.re
ext/date/lib/parse_tz.c
ext/date/lib/resource/parse_date.re
ext/date/lib/timelib_structs.h
ext/date/lib/tm2unixtime.c

index 6aae277690a54dfea3abf11ca7e6c6efc9f972fe..905a94538a147c99b51b70411a9cc4764277d8e2 100644 (file)
@@ -38,7 +38,7 @@ timelib_time* timelib_time_ctor()
 
 void timelib_time_tz_abbr_update(timelib_time* tm, char* tz_abbr)
 {
-       int i;
+       unsigned int i;
        
        TIMELIB_TIME_FREE(tm->tz_abbr);
        tm->tz_abbr = strdup(tz_abbr);
@@ -141,7 +141,7 @@ signed long timelib_date_to_int(timelib_time *d, int *error)
        if (error) {
                *error = 0;
        }
-       return d->sse;
+       return (signed long) d->sse;
 }
 
 void timelib_dump_date(timelib_time *d, int options)
index 3cc4f2d11b3de04b014f79b65c5cc10b8ea3aff9..dd8320bdbfe55f9001571e7191ab190e8c24e9a9 100644 (file)
@@ -33,8 +33,8 @@
 
 
 /* From dow.c */
-int timelib_day_of_week(int y, int m, int d);
-int timelib_daynr_from_weeknr(int y, int w, int d);
+timelib_sll timelib_day_of_week(timelib_sll y, timelib_sll m, timelib_sll d);
+timelib_sll timelib_daynr_from_weeknr(timelib_sll y, timelib_sll w, timelib_sll d);
 
 /* From parse_date.re */
 timelib_time *timelib_strtotime(char *s);
index f0f08ad04bf856077b1a822578873afaff66cf97..4066d61b4cec2c0a0f0f7dbcec066e505a490647 100644 (file)
 static int m_table_common[13] = { -1, 0, 3, 3, 6, 1, 4, 6, 2, 5, 0, 3, 5 }; /* 1 = jan */
 static int m_table_leap[13] =   { -1, 6, 2, 3, 6, 1, 4, 6, 2, 5, 0, 3, 5 }; /* 1 = jan */
 
-static int century_value(int j)
+static timelib_sll century_value(timelib_sll j)
 {
-       int i = j - 17;
-       int c = (4 - i * 2 + (i + 1) / 4) % 7;
+       timelib_sll i = j - 17;
+       timelib_sll c = (4 - i * 2 + (i + 1) / 4) % 7;
 
        return c < 0 ? c + 7 : c;
 }
 
-int timelib_day_of_week(int y, int m, int d)
+timelib_sll timelib_day_of_week(timelib_sll y, timelib_sll m, timelib_sll d)
 {
-       int c1, y1, m1;
+       timelib_sll c1, y1, m1;
 
        /* Only valid for Gregorian calendar */
        if (y < 1753) {
@@ -45,9 +45,9 @@ int timelib_day_of_week(int y, int m, int d)
        return (c1 + y1 + m1 + (y1 / 4) + d) % 7;
 }
 
-int timelib_daynr_from_weeknr(int y, int w, int d)
+timelib_sll timelib_daynr_from_weeknr(timelib_sll y, timelib_sll w, timelib_sll d)
 {
-       int dow, day;
+       timelib_sll dow, day;
        
        /* Figure out the dayofweek for y-1-1 */
        dow = timelib_day_of_week(y, 1, 1);
index dd6f6d367c5e9120029256cd31428e1b75ab9a32..b89c4f6eacdbf2ae646058d9fb10996e1f02e5aa 100644 (file)
@@ -1,4 +1,4 @@
-/* Generated by re2c 0.9.8.dev on Wed Jun 15 11:08:32 2005 */
+/* Generated by re2c 0.9.8.dev on Wed Jun 15 12:56:03 2005 */
 #line 1 "parse_date.re"
 /*
    +----------------------------------------------------------------------+
@@ -69,7 +69,7 @@
 
 #define TIMELIB_RELATIVE       310
 
-#define ERROR    999
+#define TIMELIB_ERROR          999
 
 typedef unsigned char uchar;
 
@@ -85,13 +85,13 @@ typedef unsigned char uchar;
 
 #define timelib_string_free free
 
-#define TIMELIB_HAVE_TIME() { if (s->time->have_time) { return ERROR; } else { s->time->have_time = 1; s->time->h = 0; s->time->i = 0; s->time->s = 0; s->time->f = 0; } }
+#define TIMELIB_HAVE_TIME() { if (s->time->have_time) { return TIMELIB_ERROR; } else { s->time->have_time = 1; s->time->h = 0; s->time->i = 0; s->time->s = 0; s->time->f = 0; } }
 #define TIMELIB_UNHAVE_TIME() { s->time->have_time = 0; s->time->h = 0; s->time->i = 0; s->time->s = 0; s->time->f = 0; }
-#define TIMELIB_HAVE_DATE() { if (s->time->have_date) { return ERROR; } else { s->time->have_date = 1; } }
+#define TIMELIB_HAVE_DATE() { if (s->time->have_date) { return TIMELIB_ERROR; } else { s->time->have_date = 1; } }
 #define TIMELIB_UNHAVE_DATE() { s->time->have_date = 0; s->time->d = 0; s->time->m = 0; s->time->y = 0; }
 #define TIMELIB_HAVE_RELATIVE() { s->time->have_relative = 1; }
 #define TIMELIB_HAVE_WEEKDAY_RELATIVE() { s->time->have_weekday_relative = 1; }
-#define TIMELIB_HAVE_TZ() { s->cur = cursor; if (s->time->have_zone) { return ERROR; } else { s->time.have_zone = 1; } }
+#define TIMELIB_HAVE_TZ() { s->cur = cursor; if (s->time->have_zone) { return TIMELIB_ERROR; } else { s->time.have_zone = 1; } }
 
 #define TIMELIB_INIT  s->cur = cursor; str = timelib_string(s); ptr = str
 #define TIMELIB_DEINIT timelib_string_free(str)
@@ -151,7 +151,7 @@ typedef struct _timelib_relunit {
        int         multiplier;
 } timelib_relunit;
 
-#define HOUR(a) (a * 60)
+#define HOUR(a) (int)(a * 60)
 
 /* The timezone table. */
 static timelib_tz_lookup_table const timelib_timezone_lookup[] = {
@@ -402,9 +402,9 @@ uchar *fill(Scanner *s, uchar *cursor){
 }
 #endif
 
-static int timelib_meridian(char **ptr, int h)
+static timelib_sll timelib_meridian(char **ptr, timelib_sll h)
 {
-       int retval = 0;
+       timelib_sll retval = 0;
 
        while (!strchr("AaPp", **ptr)) {
                ++*ptr;
@@ -458,10 +458,10 @@ static timelib_sll timelib_get_nr(char **ptr, int max_length)
        return tmp_nr;
 }
 
-static float timelib_get_frac_nr(char **ptr, int max_length)
+static double timelib_get_frac_nr(char **ptr, int max_length)
 {
        char *begin, *end, *str;
-       float tmp_nr = -1;
+       double tmp_nr = -1;
        int len = 0;
 
        while ((**ptr != '.') && ((**ptr < '0') || (**ptr > '9'))) {
@@ -623,7 +623,7 @@ static const timelib_relunit* timelib_lookup_relunit(char **ptr)
        return value;
 }
 
-static void timelib_set_relative(char **ptr, long amount, Scanner *s)
+static void timelib_set_relative(char **ptr, timelib_ull amount, Scanner *s)
 {
        const timelib_relunit* relunit;
 
@@ -858,7 +858,7 @@ yy2:
 yy3:
        YYDEBUG(3, *YYCURSOR);
 
-#line 1262 "parse_date.re"
+#line 1263 "parse_date.re"
 {
                TIMELIB_INIT;
                s->time->z = timelib_get_zone((char **) &ptr, &s->time->dst, s->time);
@@ -934,7 +934,7 @@ yy6:
 yy7:
        YYDEBUG(7, *YYCURSOR);
 
-#line 1322 "parse_date.re"
+#line 1323 "parse_date.re"
 {
 /*             printf("unexpected character: #%d, %c\n", *s->tok, *s->tok); */
                goto std;
@@ -1673,7 +1673,7 @@ yy43:
 yy44:
        YYDEBUG(44, *YYCURSOR);
 
-#line 1311 "parse_date.re"
+#line 1312 "parse_date.re"
 {
                goto std;
        }
@@ -1685,7 +1685,7 @@ yy45:
 yy46:
        YYDEBUG(46, *YYCURSOR);
 
-#line 1316 "parse_date.re"
+#line 1317 "parse_date.re"
 {
                s->pos = cursor; s->line++;
                goto std;
@@ -2043,7 +2043,7 @@ yy80:
 yy81:
        YYDEBUG(81, *YYCURSOR);
 
-#line 1295 "parse_date.re"
+#line 1296 "parse_date.re"
 {
                timelib_ull i;
 
@@ -2681,7 +2681,7 @@ yy147:
 yy148:
        YYDEBUG(148, *YYCURSOR);
 
-#line 1257 "parse_date.re"
+#line 1258 "parse_date.re"
 {
                goto std;
        }
@@ -2727,7 +2727,7 @@ yy154:
 yy155:
        YYDEBUG(155, *YYCURSOR);
 
-#line 1241 "parse_date.re"
+#line 1242 "parse_date.re"
 {
                const timelib_relunit* relunit;
 
@@ -3126,7 +3126,7 @@ yy187:
 yy188:
        YYDEBUG(188, *YYCURSOR);
 
-#line 1225 "parse_date.re"
+#line 1226 "parse_date.re"
 {
                long i;
 
@@ -5287,7 +5287,7 @@ yy385:
 yy386:
        YYDEBUG(386, *YYCURSOR);
 
-#line 1098 "parse_date.re"
+#line 1099 "parse_date.re"
 {
                TIMELIB_INIT;
                TIMELIB_HAVE_DATE();
@@ -5368,7 +5368,7 @@ yy396:
 yy397:
        YYDEBUG(397, *YYCURSOR);
 
-#line 1074 "parse_date.re"
+#line 1075 "parse_date.re"
 {
                TIMELIB_INIT;
                TIMELIB_HAVE_DATE();
@@ -5422,7 +5422,7 @@ yy403:
 yy404:
        YYDEBUG(404, *YYCURSOR);
 
-#line 1171 "parse_date.re"
+#line 1172 "parse_date.re"
 {
                TIMELIB_INIT;
                TIMELIB_HAVE_DATE();
@@ -5569,7 +5569,7 @@ yy422:
 yy423:
        YYDEBUG(423, *YYCURSOR);
 
-#line 1270 "parse_date.re"
+#line 1271 "parse_date.re"
 {
                TIMELIB_INIT;
                TIMELIB_HAVE_DATE();
@@ -7256,7 +7256,7 @@ yy558:
 yy559:
        YYDEBUG(559, *YYCURSOR);
 
-#line 1211 "parse_date.re"
+#line 1212 "parse_date.re"
 {
                TIMELIB_INIT;
                s->time->relative.y = 0 - s->time->relative.y;
@@ -8903,7 +8903,7 @@ yy668:
 yy669:
        YYDEBUG(669, *YYCURSOR);
 
-#line 930 "parse_date.re"
+#line 931 "parse_date.re"
 {
                DEBUG_OUTPUT("timeshort24 | timelong24 | iso8601long");
                TIMELIB_INIT;
@@ -9051,7 +9051,7 @@ yy683:
 yy684:
        YYDEBUG(684, *YYCURSOR);
 
-#line 915 "parse_date.re"
+#line 916 "parse_date.re"
 {
                DEBUG_OUTPUT("timeshort12 | timelong12");
                TIMELIB_INIT;
@@ -9175,7 +9175,7 @@ yy696:
 yy697:
        YYDEBUG(697, *YYCURSOR);
 
-#line 1050 "parse_date.re"
+#line 1051 "parse_date.re"
 {
                TIMELIB_INIT;
                TIMELIB_HAVE_DATE();
@@ -9553,7 +9553,7 @@ yy755:
 yy756:
        YYDEBUG(756, *YYCURSOR);
 
-#line 1062 "parse_date.re"
+#line 1063 "parse_date.re"
 {
                TIMELIB_INIT;
                TIMELIB_HAVE_DATE();
@@ -9936,7 +9936,7 @@ yy800:
 yy801:
        YYDEBUG(801, *YYCURSOR);
 
-#line 1038 "parse_date.re"
+#line 1039 "parse_date.re"
 {
                TIMELIB_INIT;
                TIMELIB_HAVE_DATE();
@@ -9969,7 +9969,7 @@ yy804:
 yy805:
        YYDEBUG(805, *YYCURSOR);
 
-#line 1013 "parse_date.re"
+#line 1014 "parse_date.re"
 {
                TIMELIB_INIT;
                TIMELIB_HAVE_DATE();
@@ -10204,7 +10204,7 @@ yy837:
 yy838:
        YYDEBUG(838, *YYCURSOR);
 
-#line 1195 "parse_date.re"
+#line 1196 "parse_date.re"
 {
                TIMELIB_INIT;
                TIMELIB_HAVE_TIME();
@@ -10531,7 +10531,7 @@ yy877:
 yy878:
        YYDEBUG(878, *YYCURSOR);
 
-#line 1183 "parse_date.re"
+#line 1184 "parse_date.re"
 {
                TIMELIB_INIT;
                TIMELIB_HAVE_DATE();
@@ -10788,7 +10788,7 @@ yy897:
 yy898:
        YYDEBUG(898, *YYCURSOR);
 
-#line 1086 "parse_date.re"
+#line 1087 "parse_date.re"
 {
                TIMELIB_INIT;
                TIMELIB_HAVE_DATE();
@@ -10957,9 +10957,9 @@ yy918:
 yy919:
        YYDEBUG(919, *YYCURSOR);
 
-#line 1152 "parse_date.re"
+#line 1153 "parse_date.re"
 {
-               int w, d;
+               timelib_sll w, d;
 
                TIMELIB_INIT;
                TIMELIB_HAVE_DATE();
@@ -11008,7 +11008,7 @@ yy922:
 yy923:
        YYDEBUG(923, *YYCURSOR);
 
-#line 1140 "parse_date.re"
+#line 1141 "parse_date.re"
 {
                TIMELIB_INIT;
                TIMELIB_HAVE_DATE();
@@ -11095,7 +11095,7 @@ yy929:
 yy930:
        YYDEBUG(930, *YYCURSOR);
 
-#line 1110 "parse_date.re"
+#line 1111 "parse_date.re"
 {
                TIMELIB_INIT;
                TIMELIB_HAVE_DATE();
@@ -11173,7 +11173,7 @@ yy940:
 yy941:
        YYDEBUG(941, *YYCURSOR);
 
-#line 1121 "parse_date.re"
+#line 1122 "parse_date.re"
 {
                TIMELIB_INIT;
                TIMELIB_HAVE_TIME();
@@ -11872,7 +11872,7 @@ yy1034:
 yy1035:
        YYDEBUG(1035, *YYCURSOR);
 
-#line 1027 "parse_date.re"
+#line 1028 "parse_date.re"
 {
                TIMELIB_INIT;
                TIMELIB_HAVE_DATE();
@@ -12665,7 +12665,7 @@ yy1115:
 yy1116:
        YYDEBUG(1116, *YYCURSOR);
 
-#line 952 "parse_date.re"
+#line 953 "parse_date.re"
 {
                DEBUG_OUTPUT("gnunocolon");
                TIMELIB_INIT;
@@ -12680,7 +12680,7 @@ yy1116:
                                break;
                        default:
                                TIMELIB_DEINIT;
-                               return ERROR;
+                               return TIMELIB_ERROR;
                }
                s->time->have_time++;
                TIMELIB_DEINIT;
@@ -12759,7 +12759,7 @@ yy1123:
 yy1124:
        YYDEBUG(1124, *YYCURSOR);
 
-#line 997 "parse_date.re"
+#line 998 "parse_date.re"
 {
                DEBUG_OUTPUT("iso8601nocolon");
                TIMELIB_INIT;
@@ -12965,7 +12965,8 @@ yy1140:
                s->time->y = 1970;
                s->time->m = 1;
                s->time->d = 1;
-               s->time->h = s->time->i = s->time->s = s->time->f = 0;
+               s->time->h = s->time->i = s->time->s = 0;
+               s->time->f = 0.0;
                s->time->relative.s += i;
                s->time->is_localtime = 1;
                s->time->zone_type = TIMELIB_ZONETYPE_OFFSET;
@@ -12974,7 +12975,7 @@ yy1140:
                TIMELIB_DEINIT;
                return TIMELIB_RELATIVE;
        }
-#line 10670 "<stdout>"
+#line 10671 "<stdout>"
 yy1141:
        YYDEBUG(1141, *YYCURSOR);
        yych = *++YYCURSOR;
@@ -13033,7 +13034,7 @@ yy1149:
                TIMELIB_DEINIT;
                return TIMELIB_RELATIVE;
        }
-#line 10711 "<stdout>"
+#line 10712 "<stdout>"
 yy1150:
        YYDEBUG(1150, *YYCURSOR);
        yych = *++YYCURSOR;
@@ -13059,7 +13060,7 @@ yy1152:
                TIMELIB_DEINIT;
                return TIMELIB_RELATIVE;
        }
-#line 10731 "<stdout>"
+#line 10732 "<stdout>"
 yy1153:
        YYDEBUG(1153, *YYCURSOR);
        yych = *++YYCURSOR;
@@ -13090,7 +13091,7 @@ yy1155:
                TIMELIB_DEINIT;
                return TIMELIB_RELATIVE;
        }
-#line 10756 "<stdout>"
+#line 10757 "<stdout>"
 yy1156:
        YYDEBUG(1156, *YYCURSOR);
        yych = *++YYCURSOR;
@@ -13148,10 +13149,10 @@ yy1164:
                TIMELIB_DEINIT;
                return TIMELIB_RELATIVE;
        }
-#line 10796 "<stdout>"
+#line 10797 "<stdout>"
 }
 }
-#line 1326 "parse_date.re"
+#line 1327 "parse_date.re"
 
 }
 
index dd383e6c9a39b9400eda538312c33fc1b7495d41..4b072173cc9a4b20da61522e4969e8fca4b193fd 100644 (file)
@@ -67,7 +67,7 @@
 
 #define TIMELIB_RELATIVE       310
 
-#define ERROR    999
+#define TIMELIB_ERROR          999
 
 typedef unsigned char uchar;
 
@@ -83,13 +83,13 @@ typedef unsigned char uchar;
 
 #define timelib_string_free free
 
-#define TIMELIB_HAVE_TIME() { if (s->time->have_time) { return ERROR; } else { s->time->have_time = 1; s->time->h = 0; s->time->i = 0; s->time->s = 0; s->time->f = 0; } }
+#define TIMELIB_HAVE_TIME() { if (s->time->have_time) { return TIMELIB_ERROR; } else { s->time->have_time = 1; s->time->h = 0; s->time->i = 0; s->time->s = 0; s->time->f = 0; } }
 #define TIMELIB_UNHAVE_TIME() { s->time->have_time = 0; s->time->h = 0; s->time->i = 0; s->time->s = 0; s->time->f = 0; }
-#define TIMELIB_HAVE_DATE() { if (s->time->have_date) { return ERROR; } else { s->time->have_date = 1; } }
+#define TIMELIB_HAVE_DATE() { if (s->time->have_date) { return TIMELIB_ERROR; } else { s->time->have_date = 1; } }
 #define TIMELIB_UNHAVE_DATE() { s->time->have_date = 0; s->time->d = 0; s->time->m = 0; s->time->y = 0; }
 #define TIMELIB_HAVE_RELATIVE() { s->time->have_relative = 1; }
 #define TIMELIB_HAVE_WEEKDAY_RELATIVE() { s->time->have_weekday_relative = 1; }
-#define TIMELIB_HAVE_TZ() { s->cur = cursor; if (s->time->have_zone) { return ERROR; } else { s->time.have_zone = 1; } }
+#define TIMELIB_HAVE_TZ() { s->cur = cursor; if (s->time->have_zone) { return TIMELIB_ERROR; } else { s->time.have_zone = 1; } }
 
 #define TIMELIB_INIT  s->cur = cursor; str = timelib_string(s); ptr = str
 #define TIMELIB_DEINIT timelib_string_free(str)
@@ -149,7 +149,7 @@ typedef struct _timelib_relunit {
        int         multiplier;
 } timelib_relunit;
 
-#define HOUR(a) (a * 60)
+#define HOUR(a) (int)(a * 60)
 
 /* The timezone table. */
 static timelib_tz_lookup_table const timelib_timezone_lookup[] = {
@@ -400,9 +400,9 @@ uchar *fill(Scanner *s, uchar *cursor){
 }
 #endif
 
-static int timelib_meridian(char **ptr, int h)
+static timelib_sll timelib_meridian(char **ptr, timelib_sll h)
 {
-       int retval = 0;
+       timelib_sll retval = 0;
 
        while (!strchr("AaPp", **ptr)) {
                ++*ptr;
@@ -456,10 +456,10 @@ static timelib_sll timelib_get_nr(char **ptr, int max_length)
        return tmp_nr;
 }
 
-static float timelib_get_frac_nr(char **ptr, int max_length)
+static double timelib_get_frac_nr(char **ptr, int max_length)
 {
        char *begin, *end, *str;
-       float tmp_nr = -1;
+       double tmp_nr = -1;
        int len = 0;
 
        while ((**ptr != '.') && ((**ptr < '0') || (**ptr > '9'))) {
@@ -621,7 +621,7 @@ static const timelib_relunit* timelib_lookup_relunit(char **ptr)
        return value;
 }
 
-static void timelib_set_relative(char **ptr, long amount, Scanner *s)
+static void timelib_set_relative(char **ptr, timelib_ull amount, Scanner *s)
 {
        const timelib_relunit* relunit;
 
@@ -901,7 +901,8 @@ relativetext = (reltextnumber space reltextunit)+;
                s->time->y = 1970;
                s->time->m = 1;
                s->time->d = 1;
-               s->time->h = s->time->i = s->time->s = s->time->f = 0;
+               s->time->h = s->time->i = s->time->s = 0;
+               s->time->f = 0.0;
                s->time->relative.s += i;
                s->time->is_localtime = 1;
                s->time->zone_type = TIMELIB_ZONETYPE_OFFSET;
@@ -963,7 +964,7 @@ relativetext = (reltextnumber space reltextunit)+;
                                break;
                        default:
                                TIMELIB_DEINIT;
-                               return ERROR;
+                               return TIMELIB_ERROR;
                }
                s->time->have_time++;
                TIMELIB_DEINIT;
@@ -986,7 +987,7 @@ relativetext = (reltextnumber space reltextunit)+;
                                break;
                        default:
                                TIMELIB_DEINIT;
-                               return ERROR;
+                               return TIMELIB_ERROR;
                }
                s->time->have_time++;
                TIMELIB_DEINIT;
@@ -1150,7 +1151,7 @@ relativetext = (reltextnumber space reltextunit)+;
 
        isoweekday
        {
-               int w, d;
+               timelib_sll w, d;
 
                TIMELIB_INIT;
                TIMELIB_HAVE_DATE();
index 6e98a1b9d50e3fd1fd3b8a31f0e0a2edf3b05e0d..0bfdd2622bba3aa6178cbe68f4c38dabb6b7603f 100644 (file)
@@ -45,7 +45,8 @@ static void read_header(char **tzf, timelib_tzinfo *tz)
 
 static void read_transistions(char **tzf, timelib_tzinfo *tz)
 {
-       int32_t *buffer = NULL, i;
+       int32_t *buffer = NULL;
+       uint32_t i;
        unsigned char *cbuffer = NULL;
 
        if (tz->timecnt) {
@@ -219,7 +220,7 @@ timelib_tzinfo *timelib_parse_tzfile(char *timezone)
 
 static ttinfo* fetch_timezone_offset(timelib_tzinfo *tz, timelib_sll ts)
 {
-       int i;
+       uint32_t i;
 
        if (!tz->timecnt || !tz->trans) {
                return NULL;
index dd383e6c9a39b9400eda538312c33fc1b7495d41..4b072173cc9a4b20da61522e4969e8fca4b193fd 100644 (file)
@@ -67,7 +67,7 @@
 
 #define TIMELIB_RELATIVE       310
 
-#define ERROR    999
+#define TIMELIB_ERROR          999
 
 typedef unsigned char uchar;
 
@@ -83,13 +83,13 @@ typedef unsigned char uchar;
 
 #define timelib_string_free free
 
-#define TIMELIB_HAVE_TIME() { if (s->time->have_time) { return ERROR; } else { s->time->have_time = 1; s->time->h = 0; s->time->i = 0; s->time->s = 0; s->time->f = 0; } }
+#define TIMELIB_HAVE_TIME() { if (s->time->have_time) { return TIMELIB_ERROR; } else { s->time->have_time = 1; s->time->h = 0; s->time->i = 0; s->time->s = 0; s->time->f = 0; } }
 #define TIMELIB_UNHAVE_TIME() { s->time->have_time = 0; s->time->h = 0; s->time->i = 0; s->time->s = 0; s->time->f = 0; }
-#define TIMELIB_HAVE_DATE() { if (s->time->have_date) { return ERROR; } else { s->time->have_date = 1; } }
+#define TIMELIB_HAVE_DATE() { if (s->time->have_date) { return TIMELIB_ERROR; } else { s->time->have_date = 1; } }
 #define TIMELIB_UNHAVE_DATE() { s->time->have_date = 0; s->time->d = 0; s->time->m = 0; s->time->y = 0; }
 #define TIMELIB_HAVE_RELATIVE() { s->time->have_relative = 1; }
 #define TIMELIB_HAVE_WEEKDAY_RELATIVE() { s->time->have_weekday_relative = 1; }
-#define TIMELIB_HAVE_TZ() { s->cur = cursor; if (s->time->have_zone) { return ERROR; } else { s->time.have_zone = 1; } }
+#define TIMELIB_HAVE_TZ() { s->cur = cursor; if (s->time->have_zone) { return TIMELIB_ERROR; } else { s->time.have_zone = 1; } }
 
 #define TIMELIB_INIT  s->cur = cursor; str = timelib_string(s); ptr = str
 #define TIMELIB_DEINIT timelib_string_free(str)
@@ -149,7 +149,7 @@ typedef struct _timelib_relunit {
        int         multiplier;
 } timelib_relunit;
 
-#define HOUR(a) (a * 60)
+#define HOUR(a) (int)(a * 60)
 
 /* The timezone table. */
 static timelib_tz_lookup_table const timelib_timezone_lookup[] = {
@@ -400,9 +400,9 @@ uchar *fill(Scanner *s, uchar *cursor){
 }
 #endif
 
-static int timelib_meridian(char **ptr, int h)
+static timelib_sll timelib_meridian(char **ptr, timelib_sll h)
 {
-       int retval = 0;
+       timelib_sll retval = 0;
 
        while (!strchr("AaPp", **ptr)) {
                ++*ptr;
@@ -456,10 +456,10 @@ static timelib_sll timelib_get_nr(char **ptr, int max_length)
        return tmp_nr;
 }
 
-static float timelib_get_frac_nr(char **ptr, int max_length)
+static double timelib_get_frac_nr(char **ptr, int max_length)
 {
        char *begin, *end, *str;
-       float tmp_nr = -1;
+       double tmp_nr = -1;
        int len = 0;
 
        while ((**ptr != '.') && ((**ptr < '0') || (**ptr > '9'))) {
@@ -621,7 +621,7 @@ static const timelib_relunit* timelib_lookup_relunit(char **ptr)
        return value;
 }
 
-static void timelib_set_relative(char **ptr, long amount, Scanner *s)
+static void timelib_set_relative(char **ptr, timelib_ull amount, Scanner *s)
 {
        const timelib_relunit* relunit;
 
@@ -901,7 +901,8 @@ relativetext = (reltextnumber space reltextunit)+;
                s->time->y = 1970;
                s->time->m = 1;
                s->time->d = 1;
-               s->time->h = s->time->i = s->time->s = s->time->f = 0;
+               s->time->h = s->time->i = s->time->s = 0;
+               s->time->f = 0.0;
                s->time->relative.s += i;
                s->time->is_localtime = 1;
                s->time->zone_type = TIMELIB_ZONETYPE_OFFSET;
@@ -963,7 +964,7 @@ relativetext = (reltextnumber space reltextunit)+;
                                break;
                        default:
                                TIMELIB_DEINIT;
-                               return ERROR;
+                               return TIMELIB_ERROR;
                }
                s->time->have_time++;
                TIMELIB_DEINIT;
@@ -986,7 +987,7 @@ relativetext = (reltextnumber space reltextunit)+;
                                break;
                        default:
                                TIMELIB_DEINIT;
-                               return ERROR;
+                               return TIMELIB_ERROR;
                }
                s->time->have_time++;
                TIMELIB_DEINIT;
@@ -1150,7 +1151,7 @@ relativetext = (reltextnumber space reltextunit)+;
 
        isoweekday
        {
-               int w, d;
+               timelib_sll w, d;
 
                TIMELIB_INIT;
                TIMELIB_HAVE_DATE();
index 52dc21bf2145e2464c617ec427a4122dd1885403..b86b47352d67c96058df4dec241a0014ec28914f 100644 (file)
@@ -95,7 +95,7 @@ typedef struct timelib_time_offset {
 typedef struct timelib_time {
        timelib_sll      y, m, d;     /* Year, Month, Day */
        timelib_sll      h, i, s;     /* Hour, mInute, Second */
-       float            f;           /* Fraction */
+       double           f;           /* Fraction */
        int              z;           /* GMT offset in minutes */
        char            *tz_abbr;     /* Timezone abbreviation (display only) */
        timelib_tzinfo  *tz_info;     /* Timezone structure */
index 507465fac70b6482bebd8f56e5420019aea4d68d..a62dbb8a34e1b4ddc2ac8d519e0ac00471db5f2d 100644 (file)
@@ -51,10 +51,10 @@ static int do_range_limit(timelib_sll start, timelib_sll end, timelib_sll adj, t
 
 static int do_range_limit_days(timelib_sll *y, timelib_sll *m, timelib_sll *d)
 {
-       int leapyear;
-       int days_this_month;
-       int last_month, last_year;
-       int days_last_month;
+       timelib_sll leapyear;
+       timelib_sll days_this_month;
+       timelib_sll last_month, last_year;
+       timelib_sll days_last_month;
 
        do_range_limit(1, 13, 12, m, y);
 
@@ -86,7 +86,7 @@ static int do_range_limit_days(timelib_sll *y, timelib_sll *m, timelib_sll *d)
 
 static void do_adjust_for_weekday(timelib_time* time)
 {
-       int current_dow, difference;
+       timelib_sll current_dow, difference;
 
        current_dow = timelib_day_of_week(time->y, time->m, time->d);
        difference = time->relative.weekday - current_dow;
@@ -131,9 +131,9 @@ static void do_adjust_relative(timelib_time* time)
        memset(&(time->relative), 0, sizeof(time->relative));
 }
 
-static timelib_sll do_years(int year)
+static timelib_sll do_years(timelib_sll year)
 {
-       unsigned int i;
+       timelib_sll i;
        timelib_sll res = 0;
 
        if (year >= 1970) {
@@ -156,7 +156,7 @@ static timelib_sll do_years(int year)
        return res;
 }
 
-static timelib_sll do_months(unsigned int month, unsigned int year)
+static timelib_sll do_months(timelib_ull month, timelib_ull year)
 {
        if (is_leap(year)) {
                return ((month_tab_leap[month - 1] + 1) * SECS_PER_DAY);
@@ -165,12 +165,12 @@ static timelib_sll do_months(unsigned int month, unsigned int year)
        }
 }
 
-static timelib_sll do_days(unsigned int day)
+static timelib_sll do_days(timelib_ull day)
 {
        return ((day - 1) * SECS_PER_DAY);
 }
 
-static timelib_sll do_time(unsigned int hour, unsigned int minute, unsigned int second)
+static timelib_sll do_time(timelib_ull hour, timelib_ull minute, timelib_ull second)
 {
        timelib_sll res = 0;