From 96d1d13d8758e38f6fb8dbca35cbb555249f061a Mon Sep 17 00:00:00 2001 From: Derick Rethans Date: Tue, 22 Sep 2015 08:59:45 +0100 Subject: [PATCH] Update timelib to 2015.02 --- ext/date/lib/parse_date.c | 262 ++++++++++++++-------------- ext/date/lib/parse_date.re | 64 +++---- ext/date/lib/parse_iso_intervals.c | 164 ++++------------- ext/date/lib/parse_iso_intervals.re | 26 +-- ext/date/lib/parse_tz.c | 42 ++--- ext/date/lib/timelib.c | 36 ++-- ext/date/lib/timelib.h | 12 +- ext/date/lib/tm2unixtime.c | 4 +- ext/date/lib/unixtime2tm.c | 10 +- 9 files changed, 264 insertions(+), 356 deletions(-) diff --git a/ext/date/lib/parse_date.c b/ext/date/lib/parse_date.c index 0230e45ca8..2907d2c745 100644 --- a/ext/date/lib/parse_date.c +++ b/ext/date/lib/parse_date.c @@ -1,5 +1,5 @@ -/* Generated by re2c 0.13.5 on Tue Sep 22 08:27:53 2015 */ -#line 1 "ext/date/lib/parse_date.re" +/* Generated by re2c 0.13.5 on Thu Aug 13 10:30:11 2015 */ +#line 1 "parse_date.re" /* * The MIT License (MIT) * @@ -112,7 +112,7 @@ typedef unsigned char uchar; #define RET(i) {s->cur = cursor; return i;} -#define timelib_string_free free +#define timelib_string_free timelib_free #define TIMELIB_HAVE_TIME() { if (s->time->have_time) { add_error(s, "Double time specification"); timelib_string_free(str); 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; } @@ -324,7 +324,7 @@ uchar *fill(Scanner *s, uchar *cursor){ s->lim -= cnt; } if((s->top - s->lim) < BSIZE){ - uchar *buf = (uchar*) malloc(((s->lim - s->bot) + BSIZE)*sizeof(uchar)); + uchar *buf = (uchar*) timelib_malloc(((s->lim - s->bot) + BSIZE)*sizeof(uchar)); memcpy(buf, s->tok, s->lim - s->tok); s->tok = buf; s->ptr = &buf[s->ptr - s->bot]; @@ -332,7 +332,7 @@ uchar *fill(Scanner *s, uchar *cursor){ s->pos = &buf[s->pos - s->bot]; s->lim = &buf[s->lim - s->bot]; s->top = &s->lim[BSIZE]; - free(s->bot); + timelib_free(s->bot); s->bot = buf; } if((cnt = read(s->fd, (char*) s->lim, BSIZE)) != BSIZE){ @@ -347,37 +347,37 @@ uchar *fill(Scanner *s, uchar *cursor){ static void add_warning(Scanner *s, char *error) { s->errors->warning_count++; - s->errors->warning_messages = realloc(s->errors->warning_messages, s->errors->warning_count * sizeof(timelib_error_message)); + s->errors->warning_messages = timelib_realloc(s->errors->warning_messages, s->errors->warning_count * sizeof(timelib_error_message)); s->errors->warning_messages[s->errors->warning_count - 1].position = s->tok ? s->tok - s->str : 0; s->errors->warning_messages[s->errors->warning_count - 1].character = s->tok ? *s->tok : 0; - s->errors->warning_messages[s->errors->warning_count - 1].message = strdup(error); + s->errors->warning_messages[s->errors->warning_count - 1].message = timelib_strdup(error); } static void add_error(Scanner *s, char *error) { s->errors->error_count++; - s->errors->error_messages = realloc(s->errors->error_messages, s->errors->error_count * sizeof(timelib_error_message)); + s->errors->error_messages = timelib_realloc(s->errors->error_messages, s->errors->error_count * sizeof(timelib_error_message)); s->errors->error_messages[s->errors->error_count - 1].position = s->tok ? s->tok - s->str : 0; s->errors->error_messages[s->errors->error_count - 1].character = s->tok ? *s->tok : 0; - s->errors->error_messages[s->errors->error_count - 1].message = strdup(error); + s->errors->error_messages[s->errors->error_count - 1].message = timelib_strdup(error); } static void add_pbf_warning(Scanner *s, char *error, char *sptr, char *cptr) { s->errors->warning_count++; - s->errors->warning_messages = realloc(s->errors->warning_messages, s->errors->warning_count * sizeof(timelib_error_message)); + s->errors->warning_messages = timelib_realloc(s->errors->warning_messages, s->errors->warning_count * sizeof(timelib_error_message)); s->errors->warning_messages[s->errors->warning_count - 1].position = cptr - sptr; s->errors->warning_messages[s->errors->warning_count - 1].character = *cptr; - s->errors->warning_messages[s->errors->warning_count - 1].message = strdup(error); + s->errors->warning_messages[s->errors->warning_count - 1].message = timelib_strdup(error); } static void add_pbf_error(Scanner *s, char *error, char *sptr, char *cptr) { s->errors->error_count++; - s->errors->error_messages = realloc(s->errors->error_messages, s->errors->error_count * sizeof(timelib_error_message)); + s->errors->error_messages = timelib_realloc(s->errors->error_messages, s->errors->error_count * sizeof(timelib_error_message)); s->errors->error_messages[s->errors->error_count - 1].position = cptr - sptr; s->errors->error_messages[s->errors->error_count - 1].character = *cptr; - s->errors->error_messages[s->errors->error_count - 1].message = strdup(error); + s->errors->error_messages[s->errors->error_count - 1].message = timelib_strdup(error); } static timelib_sll timelib_meridian(char **ptr, timelib_sll h) @@ -441,7 +441,7 @@ static timelib_sll timelib_meridian_with_check(char **ptr, timelib_sll h) static char *timelib_string(Scanner *s) { - char *tmp = calloc(1, s->cur - s->tok + 1); + char *tmp = timelib_calloc(1, s->cur - s->tok + 1); memcpy(tmp, s->tok, s->cur - s->tok); return tmp; @@ -468,10 +468,10 @@ static timelib_sll timelib_get_nr_ex(char **ptr, int max_length, int *scanned_le if (scanned_length) { *scanned_length = end - begin; } - str = calloc(1, end - begin + 1); + str = timelib_calloc(1, end - begin + 1); memcpy(str, begin, end - begin); tmp_nr = strtoll(str, NULL, 10); - free(str); + timelib_free(str); return tmp_nr; } @@ -508,13 +508,13 @@ static double timelib_get_frac_nr(char **ptr, int max_length) ++len; } end = *ptr; - str = calloc(1, end - begin + 1); + str = timelib_calloc(1, end - begin + 1); memcpy(str, begin, end - begin); if (str[0] == ':') { str[0] = '.'; } tmp_nr = strtod(str, NULL); - free(str); + timelib_free(str); return tmp_nr; } @@ -550,7 +550,7 @@ static timelib_sll timelib_lookup_relative_text(char **ptr, int *behavior) ++*ptr; } end = *ptr; - word = calloc(1, end - begin + 1); + word = timelib_calloc(1, end - begin + 1); memcpy(word, begin, end - begin); for (tp = timelib_reltext_lookup; tp->name; tp++) { @@ -560,7 +560,7 @@ static timelib_sll timelib_lookup_relative_text(char **ptr, int *behavior) } } - free(word); + timelib_free(word); return value; } @@ -583,7 +583,7 @@ static timelib_long timelib_lookup_month(char **ptr) ++*ptr; } end = *ptr; - word = calloc(1, end - begin + 1); + word = timelib_calloc(1, end - begin + 1); memcpy(word, begin, end - begin); for (tp = timelib_month_lookup; tp->name; tp++) { @@ -592,7 +592,7 @@ static timelib_long timelib_lookup_month(char **ptr) } } - free(word); + timelib_free(word); return value; } @@ -630,7 +630,7 @@ static const timelib_relunit* timelib_lookup_relunit(char **ptr) ++*ptr; } end = *ptr; - word = calloc(1, end - begin + 1); + word = timelib_calloc(1, end - begin + 1); memcpy(word, begin, end - begin); for (tp = timelib_relunit_lookup; tp->name; tp++) { @@ -640,7 +640,7 @@ static const timelib_relunit* timelib_lookup_relunit(char **ptr) } } - free(word); + timelib_free(word); return value; } @@ -725,7 +725,7 @@ static timelib_long timelib_lookup_abbr(char **ptr, int *dst, char **tz_abbr, in ++*ptr; } end = *ptr; - word = calloc(1, end - begin + 1); + word = timelib_calloc(1, end - begin + 1); memcpy(word, begin, end - begin); if ((tp = abbr_search(word, -1, 0))) { @@ -792,7 +792,7 @@ timelib_long timelib_parse_zone(char **ptr, int *dst, timelib_time *t, int *tz_n found++; } } - free(tz_abbr); + timelib_free(tz_abbr); *tz_not_found = (found == 0); retval = offset; } @@ -805,10 +805,10 @@ timelib_long timelib_parse_zone(char **ptr, int *dst, timelib_time *t, int *tz_n #define timelib_split_free(arg) { \ int i; \ for (i = 0; i < arg.c; i++) { \ - free(arg.v[i]); \ + timelib_free(arg.v[i]); \ } \ if (arg.v) { \ - free(arg.v); \ + timelib_free(arg.v); \ } \ } @@ -820,11 +820,11 @@ static int scan(Scanner *s, timelib_tz_get_wrapper tz_get_wrapper) std: s->tok = cursor; s->len = 0; -#line 946 "ext/date/lib/parse_date.re" +#line 946 "parse_date.re" -#line 828 "ext/date/lib/parse_date.c" +#line 828 "" { YYCTYPE yych; unsigned int yyaccept = 0; @@ -964,7 +964,7 @@ yy2: } yy3: YYDEBUG(3, *YYCURSOR); -#line 1626 "ext/date/lib/parse_date.re" +#line 1626 "parse_date.re" { int tz_not_found; DEBUG_OUTPUT("tzcorrection | tz"); @@ -977,7 +977,7 @@ yy3: TIMELIB_DEINIT; return TIMELIB_TIMEZONE; } -#line 981 "ext/date/lib/parse_date.c" +#line 981 "" yy4: YYDEBUG(4, *YYCURSOR); yych = *++YYCURSOR; @@ -1288,12 +1288,12 @@ yy11: if (yych <= '9') goto yy1385; yy12: YYDEBUG(12, *YYCURSOR); -#line 1721 "ext/date/lib/parse_date.re" +#line 1721 "parse_date.re" { add_error(s, "Unexpected character"); goto std; } -#line 1297 "ext/date/lib/parse_date.c" +#line 1297 "" yy13: YYDEBUG(13, *YYCURSOR); yych = *++YYCURSOR; @@ -2350,11 +2350,11 @@ yy48: if (yych <= '9') goto yy54; yy49: YYDEBUG(49, *YYCURSOR); -#line 1710 "ext/date/lib/parse_date.re" +#line 1710 "parse_date.re" { goto std; } -#line 2358 "ext/date/lib/parse_date.c" +#line 2358 "" yy50: YYDEBUG(50, *YYCURSOR); yych = *++YYCURSOR; @@ -2363,12 +2363,12 @@ yy51: YYDEBUG(51, *YYCURSOR); ++YYCURSOR; YYDEBUG(52, *YYCURSOR); -#line 1715 "ext/date/lib/parse_date.re" +#line 1715 "parse_date.re" { s->pos = cursor; s->line++; goto std; } -#line 2372 "ext/date/lib/parse_date.c" +#line 2372 "" yy53: YYDEBUG(53, *YYCURSOR); yych = *++YYCURSOR; @@ -2755,7 +2755,7 @@ yy71: if (yych == 's') goto yy73; yy72: YYDEBUG(72, *YYCURSOR); -#line 1694 "ext/date/lib/parse_date.re" +#line 1694 "parse_date.re" { timelib_ull i; DEBUG_OUTPUT("relative"); @@ -2770,7 +2770,7 @@ yy72: TIMELIB_DEINIT; return TIMELIB_RELATIVE; } -#line 2774 "ext/date/lib/parse_date.c" +#line 2774 "" yy73: YYDEBUG(73, *YYCURSOR); yych = *++YYCURSOR; @@ -3532,7 +3532,7 @@ yy165: } yy166: YYDEBUG(166, *YYCURSOR); -#line 1557 "ext/date/lib/parse_date.re" +#line 1557 "parse_date.re" { const timelib_relunit* relunit; DEBUG_OUTPUT("daytext"); @@ -3549,7 +3549,7 @@ yy166: TIMELIB_DEINIT; return TIMELIB_WEEKDAY; } -#line 3553 "ext/date/lib/parse_date.c" +#line 3553 "" yy167: YYDEBUG(167, *YYCURSOR); yych = *++YYCURSOR; @@ -4069,7 +4069,7 @@ yy192: } yy193: YYDEBUG(193, *YYCURSOR); -#line 1616 "ext/date/lib/parse_date.re" +#line 1616 "parse_date.re" { DEBUG_OUTPUT("monthtext"); TIMELIB_INIT; @@ -4078,7 +4078,7 @@ yy193: TIMELIB_DEINIT; return TIMELIB_DATE_TEXT; } -#line 4082 "ext/date/lib/parse_date.c" +#line 4082 "" yy194: YYDEBUG(194, *YYCURSOR); ++YYCURSOR; @@ -4129,7 +4129,7 @@ yy197: } yy198: YYDEBUG(198, *YYCURSOR); -#line 1362 "ext/date/lib/parse_date.re" +#line 1362 "parse_date.re" { int length = 0; DEBUG_OUTPUT("datetextual | datenoyear"); @@ -4142,7 +4142,7 @@ yy198: TIMELIB_DEINIT; return TIMELIB_DATE_TEXT; } -#line 4146 "ext/date/lib/parse_date.c" +#line 4146 "" yy199: YYDEBUG(199, *YYCURSOR); yyaccept = 6; @@ -4411,7 +4411,7 @@ yy221: } yy222: YYDEBUG(222, *YYCURSOR); -#line 1664 "ext/date/lib/parse_date.re" +#line 1664 "parse_date.re" { int tz_not_found; DEBUG_OUTPUT("dateshortwithtimeshort | dateshortwithtimelong | dateshortwithtimelongtz"); @@ -4440,7 +4440,7 @@ yy222: TIMELIB_DEINIT; return TIMELIB_SHORTDATE_WITH_TIME; } -#line 4444 "ext/date/lib/parse_date.c" +#line 4444 "" yy223: YYDEBUG(223, *YYCURSOR); yyaccept = 7; @@ -5138,7 +5138,7 @@ yy277: YYDEBUG(277, *YYCURSOR); ++YYCURSOR; YYDEBUG(278, *YYCURSOR); -#line 1640 "ext/date/lib/parse_date.re" +#line 1640 "parse_date.re" { DEBUG_OUTPUT("dateshortwithtimeshort12 | dateshortwithtimelong12"); TIMELIB_INIT; @@ -5161,7 +5161,7 @@ yy277: TIMELIB_DEINIT; return TIMELIB_SHORTDATE_WITH_TIME; } -#line 5165 "ext/date/lib/parse_date.c" +#line 5165 "" yy279: YYDEBUG(279, *YYCURSOR); yych = *++YYCURSOR; @@ -5339,7 +5339,7 @@ yy293: ++YYCURSOR; yy294: YYDEBUG(294, *YYCURSOR); -#line 1334 "ext/date/lib/parse_date.re" +#line 1334 "parse_date.re" { int length = 0; DEBUG_OUTPUT("datenoday"); @@ -5352,7 +5352,7 @@ yy294: TIMELIB_DEINIT; return TIMELIB_DATE_NO_DAY; } -#line 5356 "ext/date/lib/parse_date.c" +#line 5356 "" yy295: YYDEBUG(295, *YYCURSOR); yych = *++YYCURSOR; @@ -6572,7 +6572,7 @@ yy361: if (yych <= '9') goto yy364; yy363: YYDEBUG(363, *YYCURSOR); -#line 1478 "ext/date/lib/parse_date.re" +#line 1478 "parse_date.re" { int length = 0; DEBUG_OUTPUT("pgtextshort"); @@ -6585,7 +6585,7 @@ yy363: TIMELIB_DEINIT; return TIMELIB_PG_TEXT; } -#line 6589 "ext/date/lib/parse_date.c" +#line 6589 "" yy364: YYDEBUG(364, *YYCURSOR); yych = *++YYCURSOR; @@ -7223,7 +7223,7 @@ yy391: } yy392: YYDEBUG(392, *YYCURSOR); -#line 1536 "ext/date/lib/parse_date.re" +#line 1536 "parse_date.re" { DEBUG_OUTPUT("ago"); TIMELIB_INIT; @@ -7243,7 +7243,7 @@ yy392: TIMELIB_DEINIT; return TIMELIB_AGO; } -#line 7247 "ext/date/lib/parse_date.c" +#line 7247 "" yy393: YYDEBUG(393, *YYCURSOR); yyaccept = 5; @@ -8993,7 +8993,7 @@ yy453: ++YYCURSOR; yy454: YYDEBUG(454, *YYCURSOR); -#line 1239 "ext/date/lib/parse_date.re" +#line 1239 "parse_date.re" { DEBUG_OUTPUT("iso8601date4 | iso8601date2 | iso8601dateslash | dateslash"); TIMELIB_INIT; @@ -9004,7 +9004,7 @@ yy454: TIMELIB_DEINIT; return TIMELIB_ISO_DATE; } -#line 9008 "ext/date/lib/parse_date.c" +#line 9008 "" yy455: YYDEBUG(455, *YYCURSOR); yyaccept = 0; @@ -9564,7 +9564,7 @@ yy474: } yy475: YYDEBUG(475, *YYCURSOR); -#line 1376 "ext/date/lib/parse_date.re" +#line 1376 "parse_date.re" { DEBUG_OUTPUT("datenoyearrev"); TIMELIB_INIT; @@ -9575,7 +9575,7 @@ yy475: TIMELIB_DEINIT; return TIMELIB_DATE_TEXT; } -#line 9579 "ext/date/lib/parse_date.c" +#line 9579 "" yy476: YYDEBUG(476, *YYCURSOR); yyaccept = 10; @@ -9716,7 +9716,7 @@ yy487: YYDEBUG(487, *YYCURSOR); ++YYCURSOR; YYDEBUG(488, *YYCURSOR); -#line 1094 "ext/date/lib/parse_date.re" +#line 1094 "parse_date.re" { DEBUG_OUTPUT("timetiny12 | timeshort12 | timelong12"); TIMELIB_INIT; @@ -9732,7 +9732,7 @@ yy487: TIMELIB_DEINIT; return TIMELIB_TIME12; } -#line 9736 "ext/date/lib/parse_date.c" +#line 9736 "" yy489: YYDEBUG(489, *YYCURSOR); yyaccept = 11; @@ -9745,7 +9745,7 @@ yy489: } yy490: YYDEBUG(490, *YYCURSOR); -#line 1131 "ext/date/lib/parse_date.re" +#line 1131 "parse_date.re" { int tz_not_found; DEBUG_OUTPUT("timeshort24 | timelong24 | iso8601long"); @@ -9770,7 +9770,7 @@ yy490: TIMELIB_DEINIT; return TIMELIB_TIME24_WITH_ZONE; } -#line 9774 "ext/date/lib/parse_date.c" +#line 9774 "" yy491: YYDEBUG(491, *YYCURSOR); yyaccept = 11; @@ -10080,7 +10080,7 @@ yy522: YYDEBUG(522, *YYCURSOR); ++YYCURSOR; YYDEBUG(523, *YYCURSOR); -#line 1111 "ext/date/lib/parse_date.re" +#line 1111 "parse_date.re" { DEBUG_OUTPUT("mssqltime"); TIMELIB_INIT; @@ -10099,7 +10099,7 @@ yy522: TIMELIB_DEINIT; return TIMELIB_TIME24_WITH_ZONE; } -#line 10103 "ext/date/lib/parse_date.c" +#line 10103 "" yy524: YYDEBUG(524, *YYCURSOR); yyaccept = 11; @@ -10205,7 +10205,7 @@ yy533: if (yych <= '9') goto yy540; yy534: YYDEBUG(534, *YYCURSOR); -#line 1293 "ext/date/lib/parse_date.re" +#line 1293 "parse_date.re" { int length = 0; DEBUG_OUTPUT("datefull"); @@ -10219,7 +10219,7 @@ yy534: TIMELIB_DEINIT; return TIMELIB_DATE_FULL; } -#line 10223 "ext/date/lib/parse_date.c" +#line 10223 "" yy535: YYDEBUG(535, *YYCURSOR); yych = *++YYCURSOR; @@ -10956,7 +10956,7 @@ yy604: YYDEBUG(605, *YYCURSOR); ++YYCURSOR; YYDEBUG(606, *YYCURSOR); -#line 1308 "ext/date/lib/parse_date.re" +#line 1308 "parse_date.re" { DEBUG_OUTPUT("pointed date YYYY"); TIMELIB_INIT; @@ -10967,7 +10967,7 @@ yy604: TIMELIB_DEINIT; return TIMELIB_DATE_FULL_POINTED; } -#line 10971 "ext/date/lib/parse_date.c" +#line 10971 "" yy607: YYDEBUG(607, *YYCURSOR); yyaccept = 11; @@ -11003,7 +11003,7 @@ yy610: if (yych <= '9') goto yy604; yy611: YYDEBUG(611, *YYCURSOR); -#line 1320 "ext/date/lib/parse_date.re" +#line 1320 "parse_date.re" { int length = 0; DEBUG_OUTPUT("pointed date YY"); @@ -11016,7 +11016,7 @@ yy611: TIMELIB_DEINIT; return TIMELIB_DATE_FULL_POINTED; } -#line 11020 "ext/date/lib/parse_date.c" +#line 11020 "" yy612: YYDEBUG(612, *YYCURSOR); yyaccept = 11; @@ -11657,7 +11657,7 @@ yy655: } yy656: YYDEBUG(656, *YYCURSOR); -#line 1279 "ext/date/lib/parse_date.re" +#line 1279 "parse_date.re" { int length = 0; DEBUG_OUTPUT("gnudateshort"); @@ -11670,7 +11670,7 @@ yy656: TIMELIB_DEINIT; return TIMELIB_ISO_DATE; } -#line 11674 "ext/date/lib/parse_date.c" +#line 11674 "" yy657: YYDEBUG(657, *YYCURSOR); yyaccept = 13; @@ -11776,7 +11776,7 @@ yy665: } yy666: YYDEBUG(666, *YYCURSOR); -#line 1223 "ext/date/lib/parse_date.re" +#line 1223 "parse_date.re" { int length = 0; DEBUG_OUTPUT("americanshort | american"); @@ -11791,7 +11791,7 @@ yy666: TIMELIB_DEINIT; return TIMELIB_AMERICAN; } -#line 11795 "ext/date/lib/parse_date.c" +#line 11795 "" yy667: YYDEBUG(667, *YYCURSOR); yyaccept = 14; @@ -12024,7 +12024,7 @@ yy699: if (yych <= ':') goto yy703; yy700: YYDEBUG(700, *YYCURSOR); -#line 1506 "ext/date/lib/parse_date.re" +#line 1506 "parse_date.re" { int tz_not_found; DEBUG_OUTPUT("clf"); @@ -12044,7 +12044,7 @@ yy700: TIMELIB_DEINIT; return TIMELIB_CLF; } -#line 12048 "ext/date/lib/parse_date.c" +#line 12048 "" yy701: YYDEBUG(701, *YYCURSOR); yych = *++YYCURSOR; @@ -12596,7 +12596,7 @@ yy762: } yy763: YYDEBUG(763, *YYCURSOR); -#line 1251 "ext/date/lib/parse_date.re" +#line 1251 "parse_date.re" { int length = 0; DEBUG_OUTPUT("iso8601date2"); @@ -12609,7 +12609,7 @@ yy763: TIMELIB_DEINIT; return TIMELIB_ISO_DATE; } -#line 12613 "ext/date/lib/parse_date.c" +#line 12613 "" yy764: YYDEBUG(764, *YYCURSOR); yych = *++YYCURSOR; @@ -12648,7 +12648,7 @@ yy770: YYDEBUG(770, *YYCURSOR); ++YYCURSOR; YYDEBUG(771, *YYCURSOR); -#line 1492 "ext/date/lib/parse_date.re" +#line 1492 "parse_date.re" { int length = 0; DEBUG_OUTPUT("pgtextreverse"); @@ -12661,7 +12661,7 @@ yy770: TIMELIB_DEINIT; return TIMELIB_PG_TEXT; } -#line 12665 "ext/date/lib/parse_date.c" +#line 12665 "" yy772: YYDEBUG(772, *YYCURSOR); yych = *++YYCURSOR; @@ -12799,7 +12799,7 @@ yy782: } yy783: YYDEBUG(783, *YYCURSOR); -#line 1527 "ext/date/lib/parse_date.re" +#line 1527 "parse_date.re" { DEBUG_OUTPUT("year4"); TIMELIB_INIT; @@ -12807,7 +12807,7 @@ yy783: TIMELIB_DEINIT; return TIMELIB_CLF; } -#line 12811 "ext/date/lib/parse_date.c" +#line 12811 "" yy784: YYDEBUG(784, *YYCURSOR); yych = *++YYCURSOR; @@ -12958,7 +12958,7 @@ yy792: } yy793: YYDEBUG(793, *YYCURSOR); -#line 1348 "ext/date/lib/parse_date.re" +#line 1348 "parse_date.re" { int length = 0; DEBUG_OUTPUT("datenodayrev"); @@ -12971,7 +12971,7 @@ yy793: TIMELIB_DEINIT; return TIMELIB_DATE_NO_DAY; } -#line 12975 "ext/date/lib/parse_date.c" +#line 12975 "" yy794: YYDEBUG(794, *YYCURSOR); yych = *++YYCURSOR; @@ -13186,7 +13186,7 @@ yy813: if (yych <= '7') goto yy816; yy814: YYDEBUG(814, *YYCURSOR); -#line 1459 "ext/date/lib/parse_date.re" +#line 1459 "parse_date.re" { timelib_sll w, d; DEBUG_OUTPUT("isoweek"); @@ -13204,7 +13204,7 @@ yy814: TIMELIB_DEINIT; return TIMELIB_ISO_WEEK; } -#line 13208 "ext/date/lib/parse_date.c" +#line 13208 "" yy815: YYDEBUG(815, *YYCURSOR); yych = *++YYCURSOR; @@ -13214,7 +13214,7 @@ yy816: YYDEBUG(816, *YYCURSOR); ++YYCURSOR; YYDEBUG(817, *YYCURSOR); -#line 1440 "ext/date/lib/parse_date.re" +#line 1440 "parse_date.re" { timelib_sll w, d; DEBUG_OUTPUT("isoweekday"); @@ -13232,7 +13232,7 @@ yy816: TIMELIB_DEINIT; return TIMELIB_ISO_WEEK; } -#line 13236 "ext/date/lib/parse_date.c" +#line 13236 "" yy818: YYDEBUG(818, *YYCURSOR); yych = *++YYCURSOR; @@ -13296,7 +13296,7 @@ yy820: } yy821: YYDEBUG(821, *YYCURSOR); -#line 1426 "ext/date/lib/parse_date.re" +#line 1426 "parse_date.re" { int length = 0; DEBUG_OUTPUT("pgydotd"); @@ -13309,7 +13309,7 @@ yy821: TIMELIB_DEINIT; return TIMELIB_PG_YEARDAY; } -#line 13313 "ext/date/lib/parse_date.c" +#line 13313 "" yy822: YYDEBUG(822, *YYCURSOR); yych = *++YYCURSOR; @@ -13412,7 +13412,7 @@ yy841: ++YYCURSOR; yy842: YYDEBUG(842, *YYCURSOR); -#line 1400 "ext/date/lib/parse_date.re" +#line 1400 "parse_date.re" { int tz_not_found; DEBUG_OUTPUT("xmlrpc | xmlrpcnocolon | soap | wddx | exif"); @@ -13437,7 +13437,7 @@ yy842: TIMELIB_DEINIT; return TIMELIB_XMLRPC_SOAP; } -#line 13441 "ext/date/lib/parse_date.c" +#line 13441 "" yy843: YYDEBUG(843, *YYCURSOR); yych = *++YYCURSOR; @@ -13699,7 +13699,7 @@ yy847: } yy848: YYDEBUG(848, *YYCURSOR); -#line 1388 "ext/date/lib/parse_date.re" +#line 1388 "parse_date.re" { DEBUG_OUTPUT("datenocolon"); TIMELIB_INIT; @@ -13710,7 +13710,7 @@ yy848: TIMELIB_DEINIT; return TIMELIB_DATE_NOCOLON; } -#line 13714 "ext/date/lib/parse_date.c" +#line 13714 "" yy849: YYDEBUG(849, *YYCURSOR); yych = *++YYCURSOR; @@ -14630,7 +14630,7 @@ yy972: if (yych <= '9') goto yy995; yy973: YYDEBUG(973, *YYCURSOR); -#line 1265 "ext/date/lib/parse_date.re" +#line 1265 "parse_date.re" { int length = 0; DEBUG_OUTPUT("gnudateshorter"); @@ -14643,7 +14643,7 @@ yy973: TIMELIB_DEINIT; return TIMELIB_ISO_DATE; } -#line 14647 "ext/date/lib/parse_date.c" +#line 14647 "" yy974: YYDEBUG(974, *YYCURSOR); yyaccept = 22; @@ -15652,7 +15652,7 @@ yy1065: } yy1067: YYDEBUG(1067, *YYCURSOR); -#line 1157 "ext/date/lib/parse_date.re" +#line 1157 "parse_date.re" { DEBUG_OUTPUT("gnunocolon"); TIMELIB_INIT; @@ -15674,7 +15674,7 @@ yy1067: TIMELIB_DEINIT; return TIMELIB_GNU_NOCOLON; } -#line 15678 "ext/date/lib/parse_date.c" +#line 15678 "" yy1068: YYDEBUG(1068, *YYCURSOR); yych = *++YYCURSOR; @@ -15766,7 +15766,7 @@ yy1074: } yy1075: YYDEBUG(1075, *YYCURSOR); -#line 1203 "ext/date/lib/parse_date.re" +#line 1203 "parse_date.re" { int tz_not_found; DEBUG_OUTPUT("iso8601nocolon"); @@ -15785,7 +15785,7 @@ yy1075: TIMELIB_DEINIT; return TIMELIB_ISO_NOCOLON; } -#line 15789 "ext/date/lib/parse_date.c" +#line 15789 "" yy1076: YYDEBUG(1076, *YYCURSOR); yyaccept = 25; @@ -16683,7 +16683,7 @@ yy1116: } yy1117: YYDEBUG(1117, *YYCURSOR); -#line 1599 "ext/date/lib/parse_date.re" +#line 1599 "parse_date.re" { timelib_sll i; int behavior = 0; @@ -16699,7 +16699,7 @@ yy1117: TIMELIB_DEINIT; return TIMELIB_RELATIVE; } -#line 16703 "ext/date/lib/parse_date.c" +#line 16703 "" yy1118: YYDEBUG(1118, *YYCURSOR); ++YYCURSOR; @@ -16750,7 +16750,7 @@ yy1125: YYDEBUG(1125, *YYCURSOR); ++YYCURSOR; YYDEBUG(1126, *YYCURSOR); -#line 1072 "ext/date/lib/parse_date.re" +#line 1072 "parse_date.re" { timelib_sll i; int behavior = 0; @@ -16771,7 +16771,7 @@ yy1125: TIMELIB_DEINIT; return TIMELIB_WEEK_DAY_OF_MONTH; } -#line 16775 "ext/date/lib/parse_date.c" +#line 16775 "" yy1127: YYDEBUG(1127, *YYCURSOR); yyaccept = 26; @@ -16879,7 +16879,7 @@ yy1140: } yy1141: YYDEBUG(1141, *YYCURSOR); -#line 1575 "ext/date/lib/parse_date.re" +#line 1575 "parse_date.re" { timelib_sll i; int behavior = 0; @@ -16902,7 +16902,7 @@ yy1141: TIMELIB_DEINIT; return TIMELIB_RELATIVE; } -#line 16906 "ext/date/lib/parse_date.c" +#line 16906 "" yy1142: YYDEBUG(1142, *YYCURSOR); yych = *++YYCURSOR; @@ -19579,7 +19579,7 @@ yy1293: goto yy1297; yy1294: YYDEBUG(1294, *YYCURSOR); -#line 1049 "ext/date/lib/parse_date.re" +#line 1049 "parse_date.re" { DEBUG_OUTPUT("backof | frontof"); TIMELIB_INIT; @@ -19601,7 +19601,7 @@ yy1294: TIMELIB_DEINIT; return TIMELIB_LF_DAY_OF_MONTH; } -#line 19605 "ext/date/lib/parse_date.c" +#line 19605 "" yy1295: YYDEBUG(1295, *YYCURSOR); yyaccept = 28; @@ -19862,7 +19862,7 @@ yy1315: YYDEBUG(1315, *YYCURSOR); ++YYCURSOR; YYDEBUG(1316, *YYCURSOR); -#line 1032 "ext/date/lib/parse_date.re" +#line 1032 "parse_date.re" { DEBUG_OUTPUT("firstdayof | lastdayof"); TIMELIB_INIT; @@ -19878,7 +19878,7 @@ yy1315: TIMELIB_DEINIT; return TIMELIB_LF_DAY_OF_MONTH; } -#line 19882 "ext/date/lib/parse_date.c" +#line 19882 "" yy1317: YYDEBUG(1317, *YYCURSOR); yyaccept = 0; @@ -21309,7 +21309,7 @@ yy1385: if (yych <= '9') goto yy1385; yy1387: YYDEBUG(1387, *YYCURSOR); -#line 1006 "ext/date/lib/parse_date.re" +#line 1006 "parse_date.re" { timelib_ull i; @@ -21334,7 +21334,7 @@ yy1387: TIMELIB_DEINIT; return TIMELIB_RELATIVE; } -#line 21338 "ext/date/lib/parse_date.c" +#line 21338 "" yy1388: YYDEBUG(1388, *YYCURSOR); yych = *++YYCURSOR; @@ -21770,7 +21770,7 @@ yy1416: ++YYCURSOR; yy1417: YYDEBUG(1417, *YYCURSOR); -#line 994 "ext/date/lib/parse_date.re" +#line 994 "parse_date.re" { DEBUG_OUTPUT("tomorrow"); TIMELIB_INIT; @@ -21781,7 +21781,7 @@ yy1417: TIMELIB_DEINIT; return TIMELIB_RELATIVE; } -#line 21785 "ext/date/lib/parse_date.c" +#line 21785 "" yy1418: YYDEBUG(1418, *YYCURSOR); yych = *++YYCURSOR; @@ -21816,7 +21816,7 @@ yy1419: } yy1420: YYDEBUG(1420, *YYCURSOR); -#line 984 "ext/date/lib/parse_date.re" +#line 984 "parse_date.re" { DEBUG_OUTPUT("midnight | today"); TIMELIB_INIT; @@ -21825,7 +21825,7 @@ yy1420: TIMELIB_DEINIT; return TIMELIB_RELATIVE; } -#line 21829 "ext/date/lib/parse_date.c" +#line 21829 "" yy1421: YYDEBUG(1421, *YYCURSOR); yych = *++YYCURSOR; @@ -23837,7 +23837,7 @@ yy1499: } yy1500: YYDEBUG(1500, *YYCURSOR); -#line 963 "ext/date/lib/parse_date.re" +#line 963 "parse_date.re" { DEBUG_OUTPUT("now"); TIMELIB_INIT; @@ -23845,7 +23845,7 @@ yy1500: TIMELIB_DEINIT; return TIMELIB_RELATIVE; } -#line 23849 "ext/date/lib/parse_date.c" +#line 23849 "" yy1501: YYDEBUG(1501, *YYCURSOR); yych = *++YYCURSOR; @@ -23984,7 +23984,7 @@ yy1507: } yy1508: YYDEBUG(1508, *YYCURSOR); -#line 972 "ext/date/lib/parse_date.re" +#line 972 "parse_date.re" { DEBUG_OUTPUT("noon"); TIMELIB_INIT; @@ -23995,7 +23995,7 @@ yy1508: TIMELIB_DEINIT; return TIMELIB_RELATIVE; } -#line 23999 "ext/date/lib/parse_date.c" +#line 23999 "" yy1509: YYDEBUG(1509, *YYCURSOR); yyaccept = 0; @@ -24528,7 +24528,7 @@ yy1530: ++YYCURSOR; yy1531: YYDEBUG(1531, *YYCURSOR); -#line 951 "ext/date/lib/parse_date.re" +#line 951 "parse_date.re" { DEBUG_OUTPUT("yesterday"); TIMELIB_INIT; @@ -24539,7 +24539,7 @@ yy1531: TIMELIB_DEINIT; return TIMELIB_RELATIVE; } -#line 24543 "ext/date/lib/parse_date.c" +#line 24543 "" yy1532: YYDEBUG(1532, *YYCURSOR); yyaccept = 0; @@ -24712,7 +24712,7 @@ yy1537: goto yy1531; } } -#line 1725 "ext/date/lib/parse_date.re" +#line 1725 "parse_date.re" } @@ -24725,7 +24725,7 @@ timelib_time* timelib_strtotime(char *s, size_t len, struct timelib_error_contai char *e = s + len - 1; memset(&in, 0, sizeof(in)); - in.errors = malloc(sizeof(struct timelib_error_container)); + in.errors = timelib_malloc(sizeof(struct timelib_error_container)); in.errors->warning_count = 0; in.errors->warning_messages = NULL; in.errors->error_count = 0; @@ -24753,7 +24753,7 @@ timelib_time* timelib_strtotime(char *s, size_t len, struct timelib_error_contai } e++; - in.str = malloc((e - s) + YYMAXFILL); + in.str = timelib_malloc((e - s) + YYMAXFILL); memset(in.str, 0, (e - s) + YYMAXFILL); memcpy(in.str, s, (e - s)); in.lim = in.str + (e - s) + YYMAXFILL; @@ -24789,7 +24789,7 @@ timelib_time* timelib_strtotime(char *s, size_t len, struct timelib_error_contai add_warning(&in, "The parsed date was invalid"); } - free(in.str); + timelib_free(in.str); if (errors) { *errors = in.errors; } else { @@ -24840,7 +24840,7 @@ timelib_time *timelib_parse_from_format(char *format, char *string, size_t len, int allow_extra = 0; memset(&in, 0, sizeof(in)); - in.errors = malloc(sizeof(struct timelib_error_container)); + in.errors = timelib_malloc(sizeof(struct timelib_error_container)); in.errors->warning_count = 0; in.errors->warning_messages = NULL; in.errors->error_count = 0; @@ -25183,14 +25183,14 @@ void timelib_fill_holes(timelib_time *parsed, timelib_time *now, int options) if (parsed->dst == TIMELIB_UNSET) parsed->dst = now->dst != TIMELIB_UNSET ? now->dst : 0; if (!parsed->tz_abbr) { - parsed->tz_abbr = now->tz_abbr ? strdup(now->tz_abbr) : NULL; + parsed->tz_abbr = now->tz_abbr ? timelib_strdup(now->tz_abbr) : NULL; } if (!parsed->tz_info) { parsed->tz_info = now->tz_info ? (!(options & TIMELIB_NO_CLONE) ? timelib_tzinfo_clone(now->tz_info) : now->tz_info) : NULL; } if (parsed->zone_type == 0 && now->zone_type != 0) { parsed->zone_type = now->zone_type; -/* parsed->tz_abbr = now->tz_abbr ? strdup(now->tz_abbr) : NULL; +/* parsed->tz_abbr = now->tz_abbr ? timelib_strdup(now->tz_abbr) : NULL; parsed->tz_info = now->tz_info ? timelib_tzinfo_clone(now->tz_info) : NULL; */ parsed->is_localtime = 1; } diff --git a/ext/date/lib/parse_date.re b/ext/date/lib/parse_date.re index 56f054b28c..3ff00bec3e 100644 --- a/ext/date/lib/parse_date.re +++ b/ext/date/lib/parse_date.re @@ -110,7 +110,7 @@ typedef unsigned char uchar; #define RET(i) {s->cur = cursor; return i;} -#define timelib_string_free free +#define timelib_string_free timelib_free #define TIMELIB_HAVE_TIME() { if (s->time->have_time) { add_error(s, "Double time specification"); timelib_string_free(str); 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; } @@ -322,7 +322,7 @@ uchar *fill(Scanner *s, uchar *cursor){ s->lim -= cnt; } if((s->top - s->lim) < BSIZE){ - uchar *buf = (uchar*) malloc(((s->lim - s->bot) + BSIZE)*sizeof(uchar)); + uchar *buf = (uchar*) timelib_malloc(((s->lim - s->bot) + BSIZE)*sizeof(uchar)); memcpy(buf, s->tok, s->lim - s->tok); s->tok = buf; s->ptr = &buf[s->ptr - s->bot]; @@ -330,7 +330,7 @@ uchar *fill(Scanner *s, uchar *cursor){ s->pos = &buf[s->pos - s->bot]; s->lim = &buf[s->lim - s->bot]; s->top = &s->lim[BSIZE]; - free(s->bot); + timelib_free(s->bot); s->bot = buf; } if((cnt = read(s->fd, (char*) s->lim, BSIZE)) != BSIZE){ @@ -345,37 +345,37 @@ uchar *fill(Scanner *s, uchar *cursor){ static void add_warning(Scanner *s, char *error) { s->errors->warning_count++; - s->errors->warning_messages = realloc(s->errors->warning_messages, s->errors->warning_count * sizeof(timelib_error_message)); + s->errors->warning_messages = timelib_realloc(s->errors->warning_messages, s->errors->warning_count * sizeof(timelib_error_message)); s->errors->warning_messages[s->errors->warning_count - 1].position = s->tok ? s->tok - s->str : 0; s->errors->warning_messages[s->errors->warning_count - 1].character = s->tok ? *s->tok : 0; - s->errors->warning_messages[s->errors->warning_count - 1].message = strdup(error); + s->errors->warning_messages[s->errors->warning_count - 1].message = timelib_strdup(error); } static void add_error(Scanner *s, char *error) { s->errors->error_count++; - s->errors->error_messages = realloc(s->errors->error_messages, s->errors->error_count * sizeof(timelib_error_message)); + s->errors->error_messages = timelib_realloc(s->errors->error_messages, s->errors->error_count * sizeof(timelib_error_message)); s->errors->error_messages[s->errors->error_count - 1].position = s->tok ? s->tok - s->str : 0; s->errors->error_messages[s->errors->error_count - 1].character = s->tok ? *s->tok : 0; - s->errors->error_messages[s->errors->error_count - 1].message = strdup(error); + s->errors->error_messages[s->errors->error_count - 1].message = timelib_strdup(error); } static void add_pbf_warning(Scanner *s, char *error, char *sptr, char *cptr) { s->errors->warning_count++; - s->errors->warning_messages = realloc(s->errors->warning_messages, s->errors->warning_count * sizeof(timelib_error_message)); + s->errors->warning_messages = timelib_realloc(s->errors->warning_messages, s->errors->warning_count * sizeof(timelib_error_message)); s->errors->warning_messages[s->errors->warning_count - 1].position = cptr - sptr; s->errors->warning_messages[s->errors->warning_count - 1].character = *cptr; - s->errors->warning_messages[s->errors->warning_count - 1].message = strdup(error); + s->errors->warning_messages[s->errors->warning_count - 1].message = timelib_strdup(error); } static void add_pbf_error(Scanner *s, char *error, char *sptr, char *cptr) { s->errors->error_count++; - s->errors->error_messages = realloc(s->errors->error_messages, s->errors->error_count * sizeof(timelib_error_message)); + s->errors->error_messages = timelib_realloc(s->errors->error_messages, s->errors->error_count * sizeof(timelib_error_message)); s->errors->error_messages[s->errors->error_count - 1].position = cptr - sptr; s->errors->error_messages[s->errors->error_count - 1].character = *cptr; - s->errors->error_messages[s->errors->error_count - 1].message = strdup(error); + s->errors->error_messages[s->errors->error_count - 1].message = timelib_strdup(error); } static timelib_sll timelib_meridian(char **ptr, timelib_sll h) @@ -439,7 +439,7 @@ static timelib_sll timelib_meridian_with_check(char **ptr, timelib_sll h) static char *timelib_string(Scanner *s) { - char *tmp = calloc(1, s->cur - s->tok + 1); + char *tmp = timelib_calloc(1, s->cur - s->tok + 1); memcpy(tmp, s->tok, s->cur - s->tok); return tmp; @@ -466,10 +466,10 @@ static timelib_sll timelib_get_nr_ex(char **ptr, int max_length, int *scanned_le if (scanned_length) { *scanned_length = end - begin; } - str = calloc(1, end - begin + 1); + str = timelib_calloc(1, end - begin + 1); memcpy(str, begin, end - begin); tmp_nr = strtoll(str, NULL, 10); - free(str); + timelib_free(str); return tmp_nr; } @@ -506,13 +506,13 @@ static double timelib_get_frac_nr(char **ptr, int max_length) ++len; } end = *ptr; - str = calloc(1, end - begin + 1); + str = timelib_calloc(1, end - begin + 1); memcpy(str, begin, end - begin); if (str[0] == ':') { str[0] = '.'; } tmp_nr = strtod(str, NULL); - free(str); + timelib_free(str); return tmp_nr; } @@ -548,7 +548,7 @@ static timelib_sll timelib_lookup_relative_text(char **ptr, int *behavior) ++*ptr; } end = *ptr; - word = calloc(1, end - begin + 1); + word = timelib_calloc(1, end - begin + 1); memcpy(word, begin, end - begin); for (tp = timelib_reltext_lookup; tp->name; tp++) { @@ -558,7 +558,7 @@ static timelib_sll timelib_lookup_relative_text(char **ptr, int *behavior) } } - free(word); + timelib_free(word); return value; } @@ -581,7 +581,7 @@ static timelib_long timelib_lookup_month(char **ptr) ++*ptr; } end = *ptr; - word = calloc(1, end - begin + 1); + word = timelib_calloc(1, end - begin + 1); memcpy(word, begin, end - begin); for (tp = timelib_month_lookup; tp->name; tp++) { @@ -590,7 +590,7 @@ static timelib_long timelib_lookup_month(char **ptr) } } - free(word); + timelib_free(word); return value; } @@ -628,7 +628,7 @@ static const timelib_relunit* timelib_lookup_relunit(char **ptr) ++*ptr; } end = *ptr; - word = calloc(1, end - begin + 1); + word = timelib_calloc(1, end - begin + 1); memcpy(word, begin, end - begin); for (tp = timelib_relunit_lookup; tp->name; tp++) { @@ -638,7 +638,7 @@ static const timelib_relunit* timelib_lookup_relunit(char **ptr) } } - free(word); + timelib_free(word); return value; } @@ -723,7 +723,7 @@ static timelib_long timelib_lookup_abbr(char **ptr, int *dst, char **tz_abbr, in ++*ptr; } end = *ptr; - word = calloc(1, end - begin + 1); + word = timelib_calloc(1, end - begin + 1); memcpy(word, begin, end - begin); if ((tp = abbr_search(word, -1, 0))) { @@ -790,7 +790,7 @@ timelib_long timelib_parse_zone(char **ptr, int *dst, timelib_time *t, int *tz_n found++; } } - free(tz_abbr); + timelib_free(tz_abbr); *tz_not_found = (found == 0); retval = offset; } @@ -803,10 +803,10 @@ timelib_long timelib_parse_zone(char **ptr, int *dst, timelib_time *t, int *tz_n #define timelib_split_free(arg) { \ int i; \ for (i = 0; i < arg.c; i++) { \ - free(arg.v[i]); \ + timelib_free(arg.v[i]); \ } \ if (arg.v) { \ - free(arg.v); \ + timelib_free(arg.v); \ } \ } @@ -1734,7 +1734,7 @@ timelib_time* timelib_strtotime(char *s, size_t len, struct timelib_error_contai char *e = s + len - 1; memset(&in, 0, sizeof(in)); - in.errors = malloc(sizeof(struct timelib_error_container)); + in.errors = timelib_malloc(sizeof(struct timelib_error_container)); in.errors->warning_count = 0; in.errors->warning_messages = NULL; in.errors->error_count = 0; @@ -1762,7 +1762,7 @@ timelib_time* timelib_strtotime(char *s, size_t len, struct timelib_error_contai } e++; - in.str = malloc((e - s) + YYMAXFILL); + in.str = timelib_malloc((e - s) + YYMAXFILL); memset(in.str, 0, (e - s) + YYMAXFILL); memcpy(in.str, s, (e - s)); in.lim = in.str + (e - s) + YYMAXFILL; @@ -1798,7 +1798,7 @@ timelib_time* timelib_strtotime(char *s, size_t len, struct timelib_error_contai add_warning(&in, "The parsed date was invalid"); } - free(in.str); + timelib_free(in.str); if (errors) { *errors = in.errors; } else { @@ -1849,7 +1849,7 @@ timelib_time *timelib_parse_from_format(char *format, char *string, size_t len, int allow_extra = 0; memset(&in, 0, sizeof(in)); - in.errors = malloc(sizeof(struct timelib_error_container)); + in.errors = timelib_malloc(sizeof(struct timelib_error_container)); in.errors->warning_count = 0; in.errors->warning_messages = NULL; in.errors->error_count = 0; @@ -2192,14 +2192,14 @@ void timelib_fill_holes(timelib_time *parsed, timelib_time *now, int options) if (parsed->dst == TIMELIB_UNSET) parsed->dst = now->dst != TIMELIB_UNSET ? now->dst : 0; if (!parsed->tz_abbr) { - parsed->tz_abbr = now->tz_abbr ? strdup(now->tz_abbr) : NULL; + parsed->tz_abbr = now->tz_abbr ? timelib_strdup(now->tz_abbr) : NULL; } if (!parsed->tz_info) { parsed->tz_info = now->tz_info ? (!(options & TIMELIB_NO_CLONE) ? timelib_tzinfo_clone(now->tz_info) : now->tz_info) : NULL; } if (parsed->zone_type == 0 && now->zone_type != 0) { parsed->zone_type = now->zone_type; -/* parsed->tz_abbr = now->tz_abbr ? strdup(now->tz_abbr) : NULL; +/* parsed->tz_abbr = now->tz_abbr ? timelib_strdup(now->tz_abbr) : NULL; parsed->tz_info = now->tz_info ? timelib_tzinfo_clone(now->tz_info) : NULL; */ parsed->is_localtime = 1; } diff --git a/ext/date/lib/parse_iso_intervals.c b/ext/date/lib/parse_iso_intervals.c index 5798ad4b08..55e8d1f124 100644 --- a/ext/date/lib/parse_iso_intervals.c +++ b/ext/date/lib/parse_iso_intervals.c @@ -1,5 +1,5 @@ -/* Generated by re2c 0.13.5 on Tue Sep 22 08:27:59 2015 */ -#line 1 "ext/date/lib/parse_iso_intervals.re" +/* Generated by re2c 0.13.5 on Thu Aug 13 10:30:12 2015 */ +#line 1 "parse_iso_intervals.re" /* * The MIT License (MIT) * @@ -77,7 +77,7 @@ typedef unsigned char uchar; #define RET(i) {s->cur = cursor; return i;} -#define timelib_string_free free +#define timelib_string_free timelib_free #define TIMELIB_INIT s->cur = cursor; str = timelib_string(s); ptr = str #define TIMELIB_DEINIT timelib_string_free(str) @@ -113,24 +113,24 @@ typedef struct Scanner { static void add_warning(Scanner *s, char *error) { s->errors->warning_count++; - s->errors->warning_messages = realloc(s->errors->warning_messages, s->errors->warning_count * sizeof(timelib_error_message)); + s->errors->warning_messages = timelib_realloc(s->errors->warning_messages, s->errors->warning_count * sizeof(timelib_error_message)); s->errors->warning_messages[s->errors->warning_count - 1].position = s->tok ? s->tok - s->str : 0; s->errors->warning_messages[s->errors->warning_count - 1].character = s->tok ? *s->tok : 0; - s->errors->warning_messages[s->errors->warning_count - 1].message = strdup(error); + s->errors->warning_messages[s->errors->warning_count - 1].message = timelib_strdup(error); } static void add_error(Scanner *s, char *error) { s->errors->error_count++; - s->errors->error_messages = realloc(s->errors->error_messages, s->errors->error_count * sizeof(timelib_error_message)); + s->errors->error_messages = timelib_realloc(s->errors->error_messages, s->errors->error_count * sizeof(timelib_error_message)); s->errors->error_messages[s->errors->error_count - 1].position = s->tok ? s->tok - s->str : 0; s->errors->error_messages[s->errors->error_count - 1].character = s->tok ? *s->tok : 0; - s->errors->error_messages[s->errors->error_count - 1].message = strdup(error); + s->errors->error_messages[s->errors->error_count - 1].message = timelib_strdup(error); } static char *timelib_string(Scanner *s) { - char *tmp = calloc(1, s->cur - s->tok + 1); + char *tmp = timelib_calloc(1, s->cur - s->tok + 1); memcpy(tmp, s->tok, s->cur - s->tok); return tmp; @@ -154,10 +154,10 @@ static timelib_sll timelib_get_nr(char **ptr, int max_length) ++len; } end = *ptr; - str = calloc(1, end - begin + 1); + str = timelib_calloc(1, end - begin + 1); memcpy(str, begin, end - begin); tmp_nr = strtoll(str, NULL, 10); - free(str); + timelib_free(str); return tmp_nr; } @@ -234,10 +234,10 @@ static timelib_long timelib_get_zone(char **ptr, int *dst, timelib_time *t, int #define timelib_split_free(arg) { \ int i; \ for (i = 0; i < arg.c; i++) { \ - free(arg.v[i]); \ + timelib_free(arg.v[i]); \ } \ if (arg.v) { \ - free(arg.v); \ + timelib_free(arg.v); \ } \ } @@ -254,11 +254,11 @@ static int scan(Scanner *s) std: s->tok = cursor; s->len = 0; -#line 282 "ext/date/lib/parse_iso_intervals.re" +#line 282 "parse_iso_intervals.re" -#line 262 "ext/date/lib/parse_iso_intervals.c" +#line 262 "" { YYCTYPE yych; unsigned int yyaccept = 0; @@ -297,7 +297,6 @@ std: 0, 0, 0, 0, 0, 0, 0, 0, }; - YYDEBUG(0, *YYCURSOR); if ((YYLIMIT - YYCURSOR) < 20) YYFILL(20); yych = *YYCURSOR; if (yych <= ',') { @@ -322,35 +321,30 @@ std: if (yych != 'R') goto yy11; } } - YYDEBUG(2, *YYCURSOR); ++YYCURSOR; if ((yych = *YYCURSOR) <= '/') goto yy3; if (yych <= '9') goto yy98; yy3: - YYDEBUG(3, *YYCURSOR); -#line 395 "ext/date/lib/parse_iso_intervals.re" +#line 395 "parse_iso_intervals.re" { add_error(s, "Unexpected character"); goto std; } -#line 337 "ext/date/lib/parse_iso_intervals.c" +#line 334 "" yy4: - YYDEBUG(4, *YYCURSOR); yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); if (yych <= '/') goto yy3; if (yych <= '9') goto yy59; goto yy3; yy5: - YYDEBUG(5, *YYCURSOR); yyaccept = 1; yych = *(YYMARKER = ++YYCURSOR); if (yych <= '/') goto yy6; if (yych <= '9') goto yy12; if (yych == 'T') goto yy14; yy6: - YYDEBUG(6, *YYCURSOR); -#line 322 "ext/date/lib/parse_iso_intervals.re" +#line 322 "parse_iso_intervals.re" { timelib_sll nr; int in_time = 0; @@ -391,32 +385,26 @@ yy6: TIMELIB_DEINIT; return TIMELIB_PERIOD; } -#line 395 "ext/date/lib/parse_iso_intervals.c" +#line 389 "" yy7: - YYDEBUG(7, *YYCURSOR); ++YYCURSOR; - YYDEBUG(8, *YYCURSOR); -#line 384 "ext/date/lib/parse_iso_intervals.re" +#line 384 "parse_iso_intervals.re" { goto std; } -#line 404 "ext/date/lib/parse_iso_intervals.c" +#line 396 "" yy9: - YYDEBUG(9, *YYCURSOR); ++YYCURSOR; - YYDEBUG(10, *YYCURSOR); -#line 389 "ext/date/lib/parse_iso_intervals.re" +#line 389 "parse_iso_intervals.re" { s->pos = cursor; s->line++; goto std; } -#line 414 "ext/date/lib/parse_iso_intervals.c" +#line 404 "" yy11: - YYDEBUG(11, *YYCURSOR); yych = *++YYCURSOR; goto yy3; yy12: - YYDEBUG(12, *YYCURSOR); yych = *++YYCURSOR; if (yych <= 'L') { if (yych <= '9') { @@ -433,7 +421,6 @@ yy12: } } yy13: - YYDEBUG(13, *YYCURSOR); YYCURSOR = YYMARKER; if (yyaccept <= 0) { goto yy3; @@ -441,7 +428,6 @@ yy13: goto yy6; } yy14: - YYDEBUG(14, *YYCURSOR); yyaccept = 1; yych = *(YYMARKER = ++YYCURSOR); if (yybm[0+yych] & 128) { @@ -449,11 +435,9 @@ yy14: } goto yy6; yy15: - YYDEBUG(15, *YYCURSOR); ++YYCURSOR; if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2); yych = *YYCURSOR; - YYDEBUG(16, *YYCURSOR); if (yybm[0+yych] & 128) { goto yy15; } @@ -465,28 +449,23 @@ yy15: if (yych != 'S') goto yy13; } yy17: - YYDEBUG(17, *YYCURSOR); yych = *++YYCURSOR; goto yy6; yy18: - YYDEBUG(18, *YYCURSOR); yyaccept = 1; yych = *(YYMARKER = ++YYCURSOR); if (yych <= '/') goto yy6; if (yych <= '9') goto yy22; goto yy6; yy19: - YYDEBUG(19, *YYCURSOR); yyaccept = 1; yych = *(YYMARKER = ++YYCURSOR); if (yych <= '/') goto yy6; if (yych >= ':') goto yy6; yy20: - YYDEBUG(20, *YYCURSOR); ++YYCURSOR; if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2); yych = *YYCURSOR; - YYDEBUG(21, *YYCURSOR); if (yych <= 'L') { if (yych <= '/') goto yy13; if (yych <= '9') goto yy20; @@ -497,22 +476,18 @@ yy20: goto yy13; } yy22: - YYDEBUG(22, *YYCURSOR); ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); yych = *YYCURSOR; - YYDEBUG(23, *YYCURSOR); if (yych <= '/') goto yy13; if (yych <= '9') goto yy22; if (yych == 'S') goto yy17; goto yy13; yy24: - YYDEBUG(24, *YYCURSOR); yych = *++YYCURSOR; if (yych == 'T') goto yy14; goto yy6; yy25: - YYDEBUG(25, *YYCURSOR); yych = *++YYCURSOR; if (yych <= 'L') { if (yych <= '9') { @@ -532,7 +507,6 @@ yy25: } } yy26: - YYDEBUG(26, *YYCURSOR); yyaccept = 1; yych = *(YYMARKER = ++YYCURSOR); if (yych <= '/') goto yy6; @@ -540,7 +514,6 @@ yy26: if (yych == 'T') goto yy14; goto yy6; yy27: - YYDEBUG(27, *YYCURSOR); yyaccept = 1; yych = *(YYMARKER = ++YYCURSOR); if (yych <= '/') goto yy6; @@ -548,7 +521,6 @@ yy27: if (yych == 'T') goto yy14; goto yy6; yy28: - YYDEBUG(28, *YYCURSOR); yyaccept = 1; yych = *(YYMARKER = ++YYCURSOR); if (yych <= '/') goto yy6; @@ -556,11 +528,9 @@ yy28: if (yych == 'T') goto yy14; goto yy6; yy29: - YYDEBUG(29, *YYCURSOR); ++YYCURSOR; if ((YYLIMIT - YYCURSOR) < 3) YYFILL(3); yych = *YYCURSOR; - YYDEBUG(30, *YYCURSOR); if (yych <= 'D') { if (yych <= '/') goto yy13; if (yych <= '9') goto yy29; @@ -576,11 +546,9 @@ yy29: } } yy31: - YYDEBUG(31, *YYCURSOR); ++YYCURSOR; if ((YYLIMIT - YYCURSOR) < 3) YYFILL(3); yych = *YYCURSOR; - YYDEBUG(32, *YYCURSOR); if (yych <= 'C') { if (yych <= '/') goto yy13; if (yych <= '9') goto yy31; @@ -591,17 +559,14 @@ yy31: goto yy13; } yy33: - YYDEBUG(33, *YYCURSOR); ++YYCURSOR; if ((YYLIMIT - YYCURSOR) < 3) YYFILL(3); yych = *YYCURSOR; - YYDEBUG(34, *YYCURSOR); if (yych <= '/') goto yy13; if (yych <= '9') goto yy33; if (yych == 'D') goto yy24; goto yy13; yy35: - YYDEBUG(35, *YYCURSOR); yych = *++YYCURSOR; if (yych <= 'L') { if (yych <= '9') { @@ -620,22 +585,18 @@ yy35: goto yy13; } } - YYDEBUG(36, *YYCURSOR); yych = *++YYCURSOR; if (yych != '-') goto yy39; - YYDEBUG(37, *YYCURSOR); yych = *++YYCURSOR; if (yych <= '/') goto yy13; if (yych <= '0') goto yy40; if (yych <= '1') goto yy41; goto yy13; yy38: - YYDEBUG(38, *YYCURSOR); ++YYCURSOR; if ((YYLIMIT - YYCURSOR) < 3) YYFILL(3); yych = *YYCURSOR; yy39: - YYDEBUG(39, *YYCURSOR); if (yych <= 'L') { if (yych <= '9') { if (yych <= '/') goto yy13; @@ -655,21 +616,17 @@ yy39: } } yy40: - YYDEBUG(40, *YYCURSOR); yych = *++YYCURSOR; if (yych <= '/') goto yy13; if (yych <= '9') goto yy42; goto yy13; yy41: - YYDEBUG(41, *YYCURSOR); yych = *++YYCURSOR; if (yych <= '/') goto yy13; if (yych >= '3') goto yy13; yy42: - YYDEBUG(42, *YYCURSOR); yych = *++YYCURSOR; if (yych != '-') goto yy13; - YYDEBUG(43, *YYCURSOR); yych = *++YYCURSOR; if (yych <= '/') goto yy13; if (yych <= '0') goto yy44; @@ -677,70 +634,55 @@ yy42: if (yych <= '3') goto yy46; goto yy13; yy44: - YYDEBUG(44, *YYCURSOR); yych = *++YYCURSOR; if (yych <= '/') goto yy13; if (yych <= '9') goto yy47; goto yy13; yy45: - YYDEBUG(45, *YYCURSOR); yych = *++YYCURSOR; if (yych <= '/') goto yy13; if (yych <= '9') goto yy47; goto yy13; yy46: - YYDEBUG(46, *YYCURSOR); yych = *++YYCURSOR; if (yych <= '/') goto yy13; if (yych >= '2') goto yy13; yy47: - YYDEBUG(47, *YYCURSOR); yych = *++YYCURSOR; if (yych != 'T') goto yy13; - YYDEBUG(48, *YYCURSOR); yych = *++YYCURSOR; if (yych <= '/') goto yy13; if (yych <= '1') goto yy49; if (yych <= '2') goto yy50; goto yy13; yy49: - YYDEBUG(49, *YYCURSOR); yych = *++YYCURSOR; if (yych <= '/') goto yy13; if (yych <= '9') goto yy51; goto yy13; yy50: - YYDEBUG(50, *YYCURSOR); yych = *++YYCURSOR; if (yych <= '/') goto yy13; if (yych >= '5') goto yy13; yy51: - YYDEBUG(51, *YYCURSOR); yych = *++YYCURSOR; if (yych != ':') goto yy13; - YYDEBUG(52, *YYCURSOR); yych = *++YYCURSOR; if (yych <= '/') goto yy13; if (yych >= '6') goto yy13; - YYDEBUG(53, *YYCURSOR); yych = *++YYCURSOR; if (yych <= '/') goto yy13; if (yych >= ':') goto yy13; - YYDEBUG(54, *YYCURSOR); yych = *++YYCURSOR; if (yych != ':') goto yy13; - YYDEBUG(55, *YYCURSOR); yych = *++YYCURSOR; if (yych <= '/') goto yy13; if (yych >= '6') goto yy13; - YYDEBUG(56, *YYCURSOR); yych = *++YYCURSOR; if (yych <= '/') goto yy13; if (yych >= ':') goto yy13; - YYDEBUG(57, *YYCURSOR); ++YYCURSOR; - YYDEBUG(58, *YYCURSOR); -#line 364 "ext/date/lib/parse_iso_intervals.re" +#line 364 "parse_iso_intervals.re" { DEBUG_OUTPUT("combinedrep"); TIMELIB_INIT; @@ -759,17 +701,14 @@ yy51: TIMELIB_DEINIT; return TIMELIB_PERIOD; } -#line 763 "ext/date/lib/parse_iso_intervals.c" +#line 705 "" yy59: - YYDEBUG(59, *YYCURSOR); yych = *++YYCURSOR; if (yych <= '/') goto yy13; if (yych >= ':') goto yy13; - YYDEBUG(60, *YYCURSOR); yych = *++YYCURSOR; if (yych <= '/') goto yy13; if (yych >= ':') goto yy13; - YYDEBUG(61, *YYCURSOR); yych = *++YYCURSOR; if (yych <= '/') { if (yych == '-') goto yy64; @@ -780,40 +719,33 @@ yy59: goto yy13; } yy62: - YYDEBUG(62, *YYCURSOR); yych = *++YYCURSOR; if (yych <= '0') goto yy13; if (yych <= '9') goto yy85; goto yy13; yy63: - YYDEBUG(63, *YYCURSOR); yych = *++YYCURSOR; if (yych <= '/') goto yy13; if (yych <= '2') goto yy85; goto yy13; yy64: - YYDEBUG(64, *YYCURSOR); yych = *++YYCURSOR; if (yych <= '/') goto yy13; if (yych <= '0') goto yy65; if (yych <= '1') goto yy66; goto yy13; yy65: - YYDEBUG(65, *YYCURSOR); yych = *++YYCURSOR; if (yych <= '0') goto yy13; if (yych <= '9') goto yy67; goto yy13; yy66: - YYDEBUG(66, *YYCURSOR); yych = *++YYCURSOR; if (yych <= '/') goto yy13; if (yych >= '3') goto yy13; yy67: - YYDEBUG(67, *YYCURSOR); yych = *++YYCURSOR; if (yych != '-') goto yy13; - YYDEBUG(68, *YYCURSOR); yych = *++YYCURSOR; if (yych <= '/') goto yy13; if (yych <= '0') goto yy69; @@ -821,74 +753,58 @@ yy67: if (yych <= '3') goto yy71; goto yy13; yy69: - YYDEBUG(69, *YYCURSOR); yych = *++YYCURSOR; if (yych <= '0') goto yy13; if (yych <= '9') goto yy72; goto yy13; yy70: - YYDEBUG(70, *YYCURSOR); yych = *++YYCURSOR; if (yych <= '/') goto yy13; if (yych <= '9') goto yy72; goto yy13; yy71: - YYDEBUG(71, *YYCURSOR); yych = *++YYCURSOR; if (yych <= '/') goto yy13; if (yych >= '2') goto yy13; yy72: - YYDEBUG(72, *YYCURSOR); yych = *++YYCURSOR; if (yych != 'T') goto yy13; - YYDEBUG(73, *YYCURSOR); yych = *++YYCURSOR; if (yych <= '/') goto yy13; if (yych <= '1') goto yy74; if (yych <= '2') goto yy75; goto yy13; yy74: - YYDEBUG(74, *YYCURSOR); yych = *++YYCURSOR; if (yych <= '/') goto yy13; if (yych <= '9') goto yy76; goto yy13; yy75: - YYDEBUG(75, *YYCURSOR); yych = *++YYCURSOR; if (yych <= '/') goto yy13; if (yych >= '5') goto yy13; yy76: - YYDEBUG(76, *YYCURSOR); yych = *++YYCURSOR; if (yych != ':') goto yy13; - YYDEBUG(77, *YYCURSOR); yych = *++YYCURSOR; if (yych <= '/') goto yy13; if (yych >= '6') goto yy13; - YYDEBUG(78, *YYCURSOR); yych = *++YYCURSOR; if (yych <= '/') goto yy13; if (yych >= ':') goto yy13; - YYDEBUG(79, *YYCURSOR); yych = *++YYCURSOR; if (yych != ':') goto yy13; - YYDEBUG(80, *YYCURSOR); yych = *++YYCURSOR; if (yych <= '/') goto yy13; if (yych >= '6') goto yy13; - YYDEBUG(81, *YYCURSOR); yych = *++YYCURSOR; if (yych <= '/') goto yy13; if (yych >= ':') goto yy13; - YYDEBUG(82, *YYCURSOR); yych = *++YYCURSOR; if (yych != 'Z') goto yy13; yy83: - YYDEBUG(83, *YYCURSOR); ++YYCURSOR; - YYDEBUG(84, *YYCURSOR); -#line 298 "ext/date/lib/parse_iso_intervals.re" +#line 298 "parse_iso_intervals.re" { timelib_time *current; @@ -911,9 +827,8 @@ yy83: TIMELIB_DEINIT; return TIMELIB_ISO_DATE; } -#line 915 "ext/date/lib/parse_iso_intervals.c" +#line 831 "" yy85: - YYDEBUG(85, *YYCURSOR); yych = *++YYCURSOR; if (yych <= '/') goto yy13; if (yych <= '0') goto yy86; @@ -921,75 +836,60 @@ yy85: if (yych <= '3') goto yy88; goto yy13; yy86: - YYDEBUG(86, *YYCURSOR); yych = *++YYCURSOR; if (yych <= '0') goto yy13; if (yych <= '9') goto yy89; goto yy13; yy87: - YYDEBUG(87, *YYCURSOR); yych = *++YYCURSOR; if (yych <= '/') goto yy13; if (yych <= '9') goto yy89; goto yy13; yy88: - YYDEBUG(88, *YYCURSOR); yych = *++YYCURSOR; if (yych <= '/') goto yy13; if (yych >= '2') goto yy13; yy89: - YYDEBUG(89, *YYCURSOR); yych = *++YYCURSOR; if (yych != 'T') goto yy13; - YYDEBUG(90, *YYCURSOR); yych = *++YYCURSOR; if (yych <= '/') goto yy13; if (yych <= '1') goto yy91; if (yych <= '2') goto yy92; goto yy13; yy91: - YYDEBUG(91, *YYCURSOR); yych = *++YYCURSOR; if (yych <= '/') goto yy13; if (yych <= '9') goto yy93; goto yy13; yy92: - YYDEBUG(92, *YYCURSOR); yych = *++YYCURSOR; if (yych <= '/') goto yy13; if (yych >= '5') goto yy13; yy93: - YYDEBUG(93, *YYCURSOR); yych = *++YYCURSOR; if (yych <= '/') goto yy13; if (yych >= '6') goto yy13; - YYDEBUG(94, *YYCURSOR); yych = *++YYCURSOR; if (yych <= '/') goto yy13; if (yych >= ':') goto yy13; - YYDEBUG(95, *YYCURSOR); yych = *++YYCURSOR; if (yych <= '/') goto yy13; if (yych >= '6') goto yy13; - YYDEBUG(96, *YYCURSOR); yych = *++YYCURSOR; if (yych <= '/') goto yy13; if (yych >= ':') goto yy13; - YYDEBUG(97, *YYCURSOR); yych = *++YYCURSOR; if (yych == 'Z') goto yy83; goto yy13; yy98: - YYDEBUG(98, *YYCURSOR); ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); yych = *YYCURSOR; - YYDEBUG(99, *YYCURSOR); if (yych <= '/') goto yy100; if (yych <= '9') goto yy98; yy100: - YYDEBUG(100, *YYCURSOR); -#line 287 "ext/date/lib/parse_iso_intervals.re" +#line 287 "parse_iso_intervals.re" { DEBUG_OUTPUT("recurrences"); TIMELIB_INIT; @@ -999,9 +899,9 @@ yy100: s->have_recurrences = 1; return TIMELIB_PERIOD; } -#line 1003 "ext/date/lib/parse_iso_intervals.c" +#line 903 "" } -#line 399 "ext/date/lib/parse_iso_intervals.re" +#line 399 "parse_iso_intervals.re" } #ifdef PHP_WIN32 @@ -1020,7 +920,7 @@ void timelib_strtointerval(char *s, size_t len, char *e = s + len - 1; memset(&in, 0, sizeof(in)); - in.errors = malloc(sizeof(struct timelib_error_container)); + in.errors = timelib_malloc(sizeof(struct timelib_error_container)); in.errors->warning_count = 0; in.errors->warning_messages = NULL; in.errors->error_count = 0; @@ -1046,7 +946,7 @@ void timelib_strtointerval(char *s, size_t len, e++; /* init cursor */ - in.str = malloc((e - s) + YYMAXFILL); + in.str = timelib_malloc((e - s) + YYMAXFILL); memset(in.str, 0, (e - s) + YYMAXFILL); memcpy(in.str, s, (e - s)); in.lim = in.str + (e - s) + YYMAXFILL; @@ -1100,7 +1000,7 @@ void timelib_strtointerval(char *s, size_t len, #endif } while(t != EOI); - free(in.str); + timelib_free(in.str); if (errors) { *errors = in.errors; } else { diff --git a/ext/date/lib/parse_iso_intervals.re b/ext/date/lib/parse_iso_intervals.re index 52450138b3..6f23bb16f2 100644 --- a/ext/date/lib/parse_iso_intervals.re +++ b/ext/date/lib/parse_iso_intervals.re @@ -75,7 +75,7 @@ typedef unsigned char uchar; #define RET(i) {s->cur = cursor; return i;} -#define timelib_string_free free +#define timelib_string_free timelib_free #define TIMELIB_INIT s->cur = cursor; str = timelib_string(s); ptr = str #define TIMELIB_DEINIT timelib_string_free(str) @@ -111,24 +111,24 @@ typedef struct Scanner { static void add_warning(Scanner *s, char *error) { s->errors->warning_count++; - s->errors->warning_messages = realloc(s->errors->warning_messages, s->errors->warning_count * sizeof(timelib_error_message)); + s->errors->warning_messages = timelib_realloc(s->errors->warning_messages, s->errors->warning_count * sizeof(timelib_error_message)); s->errors->warning_messages[s->errors->warning_count - 1].position = s->tok ? s->tok - s->str : 0; s->errors->warning_messages[s->errors->warning_count - 1].character = s->tok ? *s->tok : 0; - s->errors->warning_messages[s->errors->warning_count - 1].message = strdup(error); + s->errors->warning_messages[s->errors->warning_count - 1].message = timelib_strdup(error); } static void add_error(Scanner *s, char *error) { s->errors->error_count++; - s->errors->error_messages = realloc(s->errors->error_messages, s->errors->error_count * sizeof(timelib_error_message)); + s->errors->error_messages = timelib_realloc(s->errors->error_messages, s->errors->error_count * sizeof(timelib_error_message)); s->errors->error_messages[s->errors->error_count - 1].position = s->tok ? s->tok - s->str : 0; s->errors->error_messages[s->errors->error_count - 1].character = s->tok ? *s->tok : 0; - s->errors->error_messages[s->errors->error_count - 1].message = strdup(error); + s->errors->error_messages[s->errors->error_count - 1].message = timelib_strdup(error); } static char *timelib_string(Scanner *s) { - char *tmp = calloc(1, s->cur - s->tok + 1); + char *tmp = timelib_calloc(1, s->cur - s->tok + 1); memcpy(tmp, s->tok, s->cur - s->tok); return tmp; @@ -152,10 +152,10 @@ static timelib_sll timelib_get_nr(char **ptr, int max_length) ++len; } end = *ptr; - str = calloc(1, end - begin + 1); + str = timelib_calloc(1, end - begin + 1); memcpy(str, begin, end - begin); tmp_nr = strtoll(str, NULL, 10); - free(str); + timelib_free(str); return tmp_nr; } @@ -232,10 +232,10 @@ static timelib_long timelib_get_zone(char **ptr, int *dst, timelib_time *t, int #define timelib_split_free(arg) { \ int i; \ for (i = 0; i < arg.c; i++) { \ - free(arg.v[i]); \ + timelib_free(arg.v[i]); \ } \ if (arg.v) { \ - free(arg.v); \ + timelib_free(arg.v); \ } \ } @@ -414,7 +414,7 @@ void timelib_strtointerval(char *s, size_t len, char *e = s + len - 1; memset(&in, 0, sizeof(in)); - in.errors = malloc(sizeof(struct timelib_error_container)); + in.errors = timelib_malloc(sizeof(struct timelib_error_container)); in.errors->warning_count = 0; in.errors->warning_messages = NULL; in.errors->error_count = 0; @@ -440,7 +440,7 @@ void timelib_strtointerval(char *s, size_t len, e++; /* init cursor */ - in.str = malloc((e - s) + YYMAXFILL); + in.str = timelib_malloc((e - s) + YYMAXFILL); memset(in.str, 0, (e - s) + YYMAXFILL); memcpy(in.str, s, (e - s)); in.lim = in.str + (e - s) + YYMAXFILL; @@ -494,7 +494,7 @@ void timelib_strtointerval(char *s, size_t len, #endif } while(t != EOI); - free(in.str); + timelib_free(in.str); if (errors) { *errors = in.errors; } else { diff --git a/ext/date/lib/parse_tz.c b/ext/date/lib/parse_tz.c index 0589b22f67..20d7eeac19 100644 --- a/ext/date/lib/parse_tz.c +++ b/ext/date/lib/parse_tz.c @@ -107,7 +107,7 @@ static void read_transistions(const unsigned char **tzf, timelib_tzinfo *tz) unsigned char *cbuffer = NULL; if (tz->bit32.timecnt) { - buffer = (int32_t*) malloc(tz->bit32.timecnt * sizeof(int32_t)); + buffer = (int32_t*) timelib_malloc(tz->bit32.timecnt * sizeof(int32_t)); if (!buffer) { return; } @@ -117,9 +117,9 @@ static void read_transistions(const unsigned char **tzf, timelib_tzinfo *tz) buffer[i] = timelib_conv_int(buffer[i]); } - cbuffer = (unsigned char*) malloc(tz->bit32.timecnt * sizeof(unsigned char)); + cbuffer = (unsigned char*) timelib_malloc(tz->bit32.timecnt * sizeof(unsigned char)); if (!cbuffer) { - free(buffer); + timelib_free(buffer); return; } memcpy(cbuffer, *tzf, sizeof(unsigned char) * tz->bit32.timecnt); @@ -151,16 +151,16 @@ static void read_types(const unsigned char **tzf, timelib_tzinfo *tz) int32_t *leap_buffer; unsigned int i, j; - buffer = (unsigned char*) malloc(tz->bit32.typecnt * sizeof(unsigned char) * 6); + buffer = (unsigned char*) timelib_malloc(tz->bit32.typecnt * sizeof(unsigned char) * 6); if (!buffer) { return; } memcpy(buffer, *tzf, sizeof(unsigned char) * 6 * tz->bit32.typecnt); *tzf += sizeof(unsigned char) * 6 * tz->bit32.typecnt; - tz->type = (ttinfo*) malloc(tz->bit32.typecnt * sizeof(struct ttinfo)); + tz->type = (ttinfo*) timelib_malloc(tz->bit32.typecnt * sizeof(struct ttinfo)); if (!tz->type) { - free(buffer); + timelib_free(buffer); return; } @@ -170,9 +170,9 @@ static void read_types(const unsigned char **tzf, timelib_tzinfo *tz) tz->type[i].isdst = buffer[j + 4]; tz->type[i].abbr_idx = buffer[j + 5]; } - free(buffer); + timelib_free(buffer); - tz->timezone_abbr = (char*) malloc(tz->bit32.charcnt); + tz->timezone_abbr = (char*) timelib_malloc(tz->bit32.charcnt); if (!tz->timezone_abbr) { return; } @@ -180,27 +180,27 @@ static void read_types(const unsigned char **tzf, timelib_tzinfo *tz) *tzf += sizeof(char) * tz->bit32.charcnt; if (tz->bit32.leapcnt) { - leap_buffer = (int32_t *) malloc(tz->bit32.leapcnt * 2 * sizeof(int32_t)); + leap_buffer = (int32_t *) timelib_malloc(tz->bit32.leapcnt * 2 * sizeof(int32_t)); if (!leap_buffer) { return; } memcpy(leap_buffer, *tzf, sizeof(int32_t) * tz->bit32.leapcnt * 2); *tzf += sizeof(int32_t) * tz->bit32.leapcnt * 2; - tz->leap_times = (tlinfo*) malloc(tz->bit32.leapcnt * sizeof(tlinfo)); + tz->leap_times = (tlinfo*) timelib_malloc(tz->bit32.leapcnt * sizeof(tlinfo)); if (!tz->leap_times) { - free(leap_buffer); + timelib_free(leap_buffer); return; } for (i = 0; i < tz->bit32.leapcnt; i++) { tz->leap_times[i].trans = timelib_conv_int(leap_buffer[i * 2]); tz->leap_times[i].offset = timelib_conv_int(leap_buffer[i * 2 + 1]); } - free(leap_buffer); + timelib_free(leap_buffer); } if (tz->bit32.ttisstdcnt) { - buffer = (unsigned char*) malloc(tz->bit32.ttisstdcnt * sizeof(unsigned char)); + buffer = (unsigned char*) timelib_malloc(tz->bit32.ttisstdcnt * sizeof(unsigned char)); if (!buffer) { return; } @@ -210,11 +210,11 @@ static void read_types(const unsigned char **tzf, timelib_tzinfo *tz) for (i = 0; i < tz->bit32.ttisstdcnt; i++) { tz->type[i].isstdcnt = buffer[i]; } - free(buffer); + timelib_free(buffer); } if (tz->bit32.ttisgmtcnt) { - buffer = (unsigned char*) malloc(tz->bit32.ttisgmtcnt * sizeof(unsigned char)); + buffer = (unsigned char*) timelib_malloc(tz->bit32.ttisgmtcnt * sizeof(unsigned char)); if (!buffer) { return; } @@ -224,7 +224,7 @@ static void read_types(const unsigned char **tzf, timelib_tzinfo *tz) for (i = 0; i < tz->bit32.ttisgmtcnt; i++) { tz->type[i].isgmtcnt = buffer[i]; } - free(buffer); + timelib_free(buffer); } } @@ -253,7 +253,7 @@ static void read_location(const unsigned char **tzf, timelib_tzinfo *tz) comments_len = timelib_conv_int(buffer[2]); *tzf += sizeof(buffer); - tz->location.comments = malloc(comments_len + 1); + tz->location.comments = timelib_malloc(comments_len + 1); memcpy(tz->location.comments, *tzf, comments_len); tz->location.comments[comments_len] = '\0'; *tzf += comments_len; @@ -310,7 +310,7 @@ static int seek_to_tz_position(const unsigned char **tzf, char *timezone, const tmp = setlocale(LC_CTYPE, NULL); if (tmp) { - cur_locale = strdup(tmp); + cur_locale = timelib_strdup(tmp); } setlocale(LC_CTYPE, "C"); #endif @@ -327,7 +327,7 @@ static int seek_to_tz_position(const unsigned char **tzf, char *timezone, const (*tzf) = &(tzdb->data[tzdb->index[mid].pos]); #ifdef HAVE_SETLOCALE setlocale(LC_CTYPE, cur_locale); - if (cur_locale) free(cur_locale); + if (cur_locale) timelib_free(cur_locale); #endif return 1; } @@ -336,7 +336,7 @@ static int seek_to_tz_position(const unsigned char **tzf, char *timezone, const #ifdef HAVE_SETLOCALE setlocale(LC_CTYPE, cur_locale); - if (cur_locale) free(cur_locale); + if (cur_locale) timelib_free(cur_locale); #endif return 0; } @@ -503,7 +503,7 @@ timelib_time_offset *timelib_get_time_zone_info(timelib_sll ts, timelib_tzinfo * tmp->offset = offset; tmp->leap_secs = leap_secs; - tmp->abbr = abbr ? strdup(abbr) : strdup("GMT"); + tmp->abbr = abbr ? timelib_strdup(abbr) : timelib_strdup("GMT"); return tmp; } diff --git a/ext/date/lib/timelib.c b/ext/date/lib/timelib.c index 6ee457b950..73cdfa2d85 100644 --- a/ext/date/lib/timelib.c +++ b/ext/date/lib/timelib.c @@ -28,7 +28,7 @@ #define TIMELIB_TIME_FREE(m) \ if (m) { \ - free(m); \ + timelib_free(m); \ m = NULL; \ } \ @@ -39,7 +39,7 @@ timelib_time* timelib_time_ctor(void) { timelib_time *t; - t = calloc(1, sizeof(timelib_time)); + t = timelib_calloc(1, sizeof(timelib_time)); return t; } @@ -47,7 +47,7 @@ timelib_time* timelib_time_ctor(void) timelib_rel_time* timelib_rel_time_ctor(void) { timelib_rel_time *t; - t = calloc(1, sizeof(timelib_rel_time)); + t = timelib_calloc(1, sizeof(timelib_rel_time)); return t; } @@ -57,7 +57,7 @@ timelib_time* timelib_time_clone(timelib_time *orig) timelib_time *tmp = timelib_time_ctor(); memcpy(tmp, orig, sizeof(timelib_time)); if (orig->tz_abbr) { - tmp->tz_abbr = strdup(orig->tz_abbr); + tmp->tz_abbr = timelib_strdup(orig->tz_abbr); } if (orig->tz_info) { tmp->tz_info = orig->tz_info; @@ -78,7 +78,7 @@ void timelib_time_tz_abbr_update(timelib_time* tm, char* tz_abbr) size_t tz_abbr_len = strlen(tz_abbr); TIMELIB_TIME_FREE(tm->tz_abbr); - tm->tz_abbr = strdup(tz_abbr); + tm->tz_abbr = timelib_strdup(tz_abbr); for (i = 0; i < tz_abbr_len; i++) { tm->tz_abbr[i] = toupper(tz_abbr[i]); } @@ -98,7 +98,7 @@ void timelib_rel_time_dtor(timelib_rel_time* t) timelib_time_offset* timelib_time_offset_ctor(void) { timelib_time_offset *t; - t = calloc(1, sizeof(timelib_time_offset)); + t = timelib_calloc(1, sizeof(timelib_time_offset)); return t; } @@ -112,8 +112,8 @@ void timelib_time_offset_dtor(timelib_time_offset* t) timelib_tzinfo* timelib_tzinfo_ctor(char *name) { timelib_tzinfo *t; - t = calloc(1, sizeof(timelib_tzinfo)); - t->name = strdup(name); + t = timelib_calloc(1, sizeof(timelib_tzinfo)); + t->name = timelib_strdup(name); return t; } @@ -128,18 +128,18 @@ timelib_tzinfo *timelib_tzinfo_clone(timelib_tzinfo *tz) tmp->bit32.typecnt = tz->bit32.typecnt; tmp->bit32.charcnt = tz->bit32.charcnt; - tmp->trans = (int32_t *) malloc(tz->bit32.timecnt * sizeof(int32_t)); - tmp->trans_idx = (unsigned char*) malloc(tz->bit32.timecnt * sizeof(unsigned char)); + tmp->trans = (int32_t *) timelib_malloc(tz->bit32.timecnt * sizeof(int32_t)); + tmp->trans_idx = (unsigned char*) timelib_malloc(tz->bit32.timecnt * sizeof(unsigned char)); memcpy(tmp->trans, tz->trans, tz->bit32.timecnt * sizeof(int32_t)); memcpy(tmp->trans_idx, tz->trans_idx, tz->bit32.timecnt * sizeof(unsigned char)); - tmp->type = (ttinfo*) malloc(tz->bit32.typecnt * sizeof(struct ttinfo)); + tmp->type = (ttinfo*) timelib_malloc(tz->bit32.typecnt * sizeof(struct ttinfo)); memcpy(tmp->type, tz->type, tz->bit32.typecnt * sizeof(struct ttinfo)); - tmp->timezone_abbr = (char*) malloc(tz->bit32.charcnt); + tmp->timezone_abbr = (char*) timelib_malloc(tz->bit32.charcnt); memcpy(tmp->timezone_abbr, tz->timezone_abbr, tz->bit32.charcnt); - tmp->leap_times = (tlinfo*) malloc(tz->bit32.leapcnt * sizeof(tlinfo)); + tmp->leap_times = (tlinfo*) timelib_malloc(tz->bit32.leapcnt * sizeof(tlinfo)); memcpy(tmp->leap_times, tz->leap_times, tz->bit32.leapcnt * sizeof(tlinfo)); return tmp; @@ -171,14 +171,14 @@ void timelib_error_container_dtor(timelib_error_container *errors) int i; for (i = 0; i < errors->warning_count; i++) { - free(errors->warning_messages[i].message); + timelib_free(errors->warning_messages[i].message); } - free(errors->warning_messages); + timelib_free(errors->warning_messages); for (i = 0; i < errors->error_count; i++) { - free(errors->error_messages[i].message); + timelib_free(errors->error_messages[i].message); } - free(errors->error_messages); - free(errors); + timelib_free(errors->error_messages); + timelib_free(errors); } timelib_long timelib_date_to_int(timelib_time *d, int *error) diff --git a/ext/date/lib/timelib.h b/ext/date/lib/timelib.h index a23b2ab314..125b8b21ad 100644 --- a/ext/date/lib/timelib.h +++ b/ext/date/lib/timelib.h @@ -30,8 +30,16 @@ #include #endif -#define TIMELIB_VERSION 201501 -#define TIMELIB_ASCII_VERSION "2015.01" +#ifndef timelib_malloc +# define timelib_malloc malloc +# define timelib_realloc realloc +# define timelib_calloc calloc +# define timelib_strdup strdup +# define timelib_free free +#endif + +#define TIMELIB_VERSION 201502 +#define TIMELIB_ASCII_VERSION "2015.02" #define TIMELIB_NONE 0x00 #define TIMELIB_OVERRIDE_TIME 0x01 diff --git a/ext/date/lib/tm2unixtime.c b/ext/date/lib/tm2unixtime.c index b88131e84b..414cf13082 100644 --- a/ext/date/lib/tm2unixtime.c +++ b/ext/date/lib/tm2unixtime.c @@ -427,9 +427,9 @@ static timelib_sll do_adjust_timezone(timelib_time *tz, timelib_tzinfo *tzi) tz->dst = gmt_offset->is_dst; if (tz->tz_abbr) { - free(tz->tz_abbr); + timelib_free(tz->tz_abbr); } - tz->tz_abbr = strdup(gmt_offset->abbr); + tz->tz_abbr = timelib_strdup(gmt_offset->abbr); timelib_time_offset_dtor(gmt_offset); } return tmp; diff --git a/ext/date/lib/unixtime2tm.c b/ext/date/lib/unixtime2tm.c index a640d0875c..a9b71662ea 100644 --- a/ext/date/lib/unixtime2tm.c +++ b/ext/date/lib/unixtime2tm.c @@ -221,7 +221,7 @@ void timelib_unixtime2local(timelib_time *tm, timelib_sll ts) void timelib_set_timezone_from_offset(timelib_time *t, timelib_sll utc_offset) { if (t->tz_abbr) { - free(t->tz_abbr); + timelib_free(t->tz_abbr); } t->tz_abbr = NULL; @@ -235,9 +235,9 @@ void timelib_set_timezone_from_offset(timelib_time *t, timelib_sll utc_offset) void timelib_set_timezone_from_abbr(timelib_time *t, timelib_abbr_info abbr_info) { if (t->tz_abbr) { - free(t->tz_abbr); + timelib_free(t->tz_abbr); } - t->tz_abbr = strdup(abbr_info.abbr); + t->tz_abbr = timelib_strdup(abbr_info.abbr); t->z = abbr_info.utc_offset; t->have_zone = 1; @@ -261,9 +261,9 @@ void timelib_set_timezone(timelib_time *t, timelib_tzinfo *tz) t->dst = gmt_offset->is_dst; t->tz_info = tz; if (t->tz_abbr) { - free(t->tz_abbr); + timelib_free(t->tz_abbr); } - t->tz_abbr = strdup(gmt_offset->abbr); + t->tz_abbr = timelib_strdup(gmt_offset->abbr); timelib_time_offset_dtor(gmt_offset); t->have_zone = 1; -- 2.50.1