Upgrade timelib to 2017.05beta9

This commit is contained in:
Derick Rethans 2017-09-04 22:45:34 +01:00
parent b2824629c2
commit c0383b5039
10 changed files with 80 additions and 90 deletions

View File

@ -100,12 +100,12 @@ timelib_time *timelib_add(timelib_time *old_time, timelib_rel_time *interval)
timelib_time *t = timelib_time_clone(old_time);
if (interval->have_weekday_relative || interval->have_special_relative) {
memcpy(&t->relative, interval, sizeof(struct timelib_rel_time));
memcpy(&t->relative, interval, sizeof(timelib_rel_time));
} else {
if (interval->invert) {
bias = -1;
}
memset(&t->relative, 0, sizeof(struct timelib_rel_time));
memset(&t->relative, 0, sizeof(timelib_rel_time));
t->relative.y = interval->y * bias;
t->relative.m = interval->m * bias;
t->relative.d = interval->d * bias;
@ -141,7 +141,7 @@ timelib_time *timelib_sub(timelib_time *old_time, timelib_rel_time *interval)
bias = -1;
}
memset(&t->relative, 0, sizeof(struct timelib_rel_time));
memset(&t->relative, 0, sizeof(timelib_rel_time));
t->relative.y = 0 - (interval->y * bias);
t->relative.m = 0 - (interval->m * bias);
t->relative.d = 0 - (interval->d * bias);

View File

@ -1,4 +1,4 @@
/* Generated by re2c 0.15.3 on Mon Aug 14 16:35:21 2017 */
/* Generated by re2c 0.15.3 on Mon Sep 4 22:44:17 2017 */
#line 1 "ext/date/lib/parse_date.re"
/*
* The MIT License (MIT)
@ -127,18 +127,18 @@ typedef unsigned char uchar;
#define YYDEBUG(s,c)
#endif
typedef struct timelib_elems {
typedef struct _timelib_elems {
unsigned int c; /* Number of elements */
char **v; /* Values */
} timelib_elems;
typedef struct Scanner {
typedef struct _Scanner {
int fd;
uchar *lim, *str, *ptr, *cur, *tok, *pos;
unsigned int line, len;
struct timelib_error_container *errors;
timelib_error_container *errors;
struct timelib_time *time;
timelib_time *time;
const timelib_tzdb *tzdb;
} Scanner;
@ -24896,14 +24896,14 @@ yy1537:
#define YYMAXFILL 33
timelib_time* timelib_strtotime(char *s, size_t len, struct timelib_error_container **errors, const timelib_tzdb *tzdb, timelib_tz_get_wrapper tz_get_wrapper)
timelib_time* timelib_strtotime(char *s, size_t len, timelib_error_container **errors, const timelib_tzdb *tzdb, timelib_tz_get_wrapper tz_get_wrapper)
{
Scanner in;
int t;
char *e = s + len - 1;
memset(&in, 0, sizeof(in));
in.errors = timelib_malloc(sizeof(struct timelib_error_container));
in.errors = timelib_malloc(sizeof(timelib_error_container));
in.errors->warning_count = 0;
in.errors->warning_messages = NULL;
in.errors->error_count = 0;
@ -25023,7 +25023,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 = timelib_malloc(sizeof(struct timelib_error_container));
in.errors = timelib_malloc(sizeof(timelib_error_container));
in.errors->warning_count = 0;
in.errors->warning_messages = NULL;
in.errors->error_count = 0;

View File

@ -125,18 +125,18 @@ typedef unsigned char uchar;
#define YYDEBUG(s,c)
#endif
typedef struct timelib_elems {
typedef struct _timelib_elems {
unsigned int c; /* Number of elements */
char **v; /* Values */
} timelib_elems;
typedef struct Scanner {
typedef struct _Scanner {
int fd;
uchar *lim, *str, *ptr, *cur, *tok, *pos;
unsigned int line, len;
struct timelib_error_container *errors;
timelib_error_container *errors;
struct timelib_time *time;
timelib_time *time;
const timelib_tzdb *tzdb;
} Scanner;
@ -1790,14 +1790,14 @@ weekdayof = (reltextnumber|reltexttext) space (dayfull|dayabbr) space 'of
/*!max:re2c */
timelib_time* timelib_strtotime(char *s, size_t len, struct timelib_error_container **errors, const timelib_tzdb *tzdb, timelib_tz_get_wrapper tz_get_wrapper)
timelib_time* timelib_strtotime(char *s, size_t len, timelib_error_container **errors, const timelib_tzdb *tzdb, timelib_tz_get_wrapper tz_get_wrapper)
{
Scanner in;
int t;
char *e = s + len - 1;
memset(&in, 0, sizeof(in));
in.errors = timelib_malloc(sizeof(struct timelib_error_container));
in.errors = timelib_malloc(sizeof(timelib_error_container));
in.errors->warning_count = 0;
in.errors->warning_messages = NULL;
in.errors->error_count = 0;
@ -1917,7 +1917,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 = timelib_malloc(sizeof(struct timelib_error_container));
in.errors = timelib_malloc(sizeof(timelib_error_container));
in.errors->warning_count = 0;
in.errors->warning_messages = NULL;
in.errors->error_count = 0;

View File

@ -1,4 +1,4 @@
/* Generated by re2c 0.15.3 on Mon Aug 14 13:00:14 2017 */
/* Generated by re2c 0.15.3 on Mon Sep 4 22:44:07 2017 */
#line 1 "ext/date/lib/parse_iso_intervals.re"
/*
* The MIT License (MIT)
@ -72,16 +72,16 @@ typedef unsigned char uchar;
#define YYDEBUG(s,c)
#endif
typedef struct Scanner {
typedef struct _Scanner {
int fd;
uchar *lim, *str, *ptr, *cur, *tok, *pos;
unsigned int line, len;
struct timelib_error_container *errors;
timelib_error_container *errors;
struct timelib_time *begin;
struct timelib_time *end;
struct timelib_rel_time *period;
int recurrences;
timelib_time *begin;
timelib_time *end;
timelib_rel_time *period;
int recurrences;
int have_period;
int have_recurrences;
@ -934,14 +934,14 @@ yy100:
void timelib_strtointerval(char *s, size_t len,
timelib_time **begin, timelib_time **end,
timelib_rel_time **period, int *recurrences,
struct timelib_error_container **errors)
timelib_error_container **errors)
{
Scanner in;
int t;
char *e = s + len - 1;
memset(&in, 0, sizeof(in));
in.errors = timelib_malloc(sizeof(struct timelib_error_container));
in.errors = timelib_malloc(sizeof(timelib_error_container));
in.errors->warning_count = 0;
in.errors->warning_messages = NULL;
in.errors->error_count = 0;

View File

@ -70,16 +70,16 @@ typedef unsigned char uchar;
#define YYDEBUG(s,c)
#endif
typedef struct Scanner {
typedef struct _Scanner {
int fd;
uchar *lim, *str, *ptr, *cur, *tok, *pos;
unsigned int line, len;
struct timelib_error_container *errors;
timelib_error_container *errors;
struct timelib_time *begin;
struct timelib_time *end;
struct timelib_rel_time *period;
int recurrences;
timelib_time *begin;
timelib_time *end;
timelib_rel_time *period;
int recurrences;
int have_period;
int have_recurrences;
@ -329,14 +329,14 @@ isoweek = year4 "-"? "W" weekofyear;
void timelib_strtointerval(char *s, size_t len,
timelib_time **begin, timelib_time **end,
timelib_rel_time **period, int *recurrences,
struct timelib_error_container **errors)
timelib_error_container **errors)
{
Scanner in;
int t;
char *e = s + len - 1;
memset(&in, 0, sizeof(in));
in.errors = timelib_malloc(sizeof(struct timelib_error_container));
in.errors = timelib_malloc(sizeof(timelib_error_container));
in.errors->warning_count = 0;
in.errors->warning_messages = NULL;
in.errors->error_count = 0;

View File

@ -218,7 +218,7 @@ static int read_types(const unsigned char **tzf, timelib_tzinfo *tz)
memcpy(buffer, *tzf, sizeof(unsigned char) * 6 * tz->bit32.typecnt);
*tzf += sizeof(unsigned char) * 6 * tz->bit32.typecnt;
tz->type = (ttinfo*) timelib_malloc(tz->bit32.typecnt * sizeof(struct ttinfo));
tz->type = (ttinfo*) timelib_malloc(tz->bit32.typecnt * sizeof(ttinfo));
if (!tz->type) {
timelib_free(buffer);
return TIMELIB_ERROR_CANNOT_ALLOCATE;
@ -558,8 +558,8 @@ timelib_tzinfo *timelib_tzinfo_clone(timelib_tzinfo *tz)
memcpy(tmp->trans_idx, tz->trans_idx, tz->bit32.timecnt * sizeof(unsigned char));
}
tmp->type = (ttinfo*) timelib_malloc(tz->bit32.typecnt * sizeof(struct ttinfo));
memcpy(tmp->type, tz->type, tz->bit32.typecnt * sizeof(struct ttinfo));
tmp->type = (ttinfo*) timelib_malloc(tz->bit32.typecnt * sizeof(ttinfo));
memcpy(tmp->type, tz->type, tz->bit32.typecnt * sizeof(ttinfo));
tmp->timezone_abbr = (char*) timelib_malloc(tz->bit32.charcnt);
memcpy(tmp->timezone_abbr, tz->timezone_abbr, tz->bit32.charcnt);

View File

@ -131,10 +131,10 @@ typedef signed long long timelib_sll;
# define TIMELIB_LL_CONST(n) n ## ll
#endif
typedef struct ttinfo ttinfo;
typedef struct tlinfo tlinfo;
typedef struct _ttinfo ttinfo;
typedef struct _tlinfo tlinfo;
typedef struct tlocinfo
typedef struct _tlocinfo
{
char country_code[3];
double latitude;
@ -142,7 +142,7 @@ typedef struct tlocinfo
char *comments;
} tlocinfo;
typedef struct timelib_tzinfo
typedef struct _timelib_tzinfo
{
char *name;
struct {
@ -173,7 +173,7 @@ typedef struct timelib_tzinfo
tlocinfo location;
} timelib_tzinfo;
typedef struct timelib_rel_time {
typedef struct _timelib_rel_time {
timelib_sll y, m, d; /* Years, Months and Days */
timelib_sll h, i, s; /* Hours, mInutes and Seconds */
timelib_sll us; /* Microseconds */
@ -193,7 +193,7 @@ typedef struct timelib_rel_time {
unsigned int have_weekday_relative, have_special_relative;
} timelib_rel_time;
typedef struct timelib_time_offset {
typedef struct _timelib_time_offset {
int32_t offset;
unsigned int leap_secs;
unsigned int is_dst;
@ -201,7 +201,7 @@ typedef struct timelib_time_offset {
timelib_sll transition_time;
} timelib_time_offset;
typedef struct timelib_time {
typedef struct _timelib_time {
timelib_sll y, m, d; /* Year, Month, Day */
timelib_sll h, i, s; /* Hour, mInute, Second */
timelib_sll us; /* Microseconds */
@ -223,7 +223,7 @@ typedef struct timelib_time {
* 2 TimeZone abbreviation */
} timelib_time;
typedef struct timelib_abbr_info {
typedef struct _timelib_abbr_info {
timelib_sll utc_offset;
char *abbr;
int dst;
@ -269,18 +269,18 @@ typedef struct timelib_abbr_info {
#define TIMELIB_ZONETYPE_ABBR 2
#define TIMELIB_ZONETYPE_ID 3
typedef struct timelib_error_message {
typedef struct _timelib_error_message {
int error_code;
int position;
char character;
char *message;
} timelib_error_message;
typedef struct timelib_error_container {
struct timelib_error_message *error_messages;
struct timelib_error_message *warning_messages;
int error_count;
int warning_count;
typedef struct _timelib_error_container {
timelib_error_message *error_messages;
timelib_error_message *warning_messages;
int error_count;
int warning_count;
} timelib_error_container;
typedef struct _timelib_tz_lookup_table {
@ -311,7 +311,8 @@ typedef struct _timelib_tzdb {
#endif
#define TIMELIB_VERSION 201705
#define TIMELIB_ASCII_VERSION "2017.05beta7"
#define TIMELIB_EXTENDED_VERSION 20170509
#define TIMELIB_ASCII_VERSION "2017.05beta9"
#define TIMELIB_NONE 0x00
#define TIMELIB_OVERRIDE_TIME 0x01
@ -488,7 +489,7 @@ timelib_long timelib_parse_zone(char **ptr, int *dst, timelib_time *t, int *tz_n
void timelib_strtointerval(char *s, size_t len,
timelib_time **begin, timelib_time **end,
timelib_rel_time **period, int *recurrences,
struct timelib_error_container **errors);
timelib_error_container **errors);
/* From tm2unixtime.c */

View File

@ -115,7 +115,7 @@
m = NULL; \
}
struct ttinfo
struct _ttinfo
{
int32_t offset;
int isdst;
@ -125,7 +125,7 @@ struct ttinfo
unsigned int isgmtcnt;
};
struct tlinfo
struct _tlinfo
{
int32_t trans;
int32_t offset;

View File

@ -48,12 +48,17 @@ void timelib_unixtime2gmt(timelib_time* tm, timelib_sll ts)
if (ts >= 0) {
tmp_days = days + 1;
} else {
tmp_days = days;
}
if (tmp_days > DAYS_PER_LYEAR_PERIOD || tmp_days <= -DAYS_PER_LYEAR_PERIOD) {
cur_year += YEARS_PER_LYEAR_PERIOD * (tmp_days / DAYS_PER_LYEAR_PERIOD);
tmp_days -= DAYS_PER_LYEAR_PERIOD * (tmp_days / DAYS_PER_LYEAR_PERIOD);
}
if (tmp_days > DAYS_PER_LYEAR_PERIOD || tmp_days <= -DAYS_PER_LYEAR_PERIOD) {
cur_year += YEARS_PER_LYEAR_PERIOD * (tmp_days / DAYS_PER_LYEAR_PERIOD);
tmp_days -= DAYS_PER_LYEAR_PERIOD * (tmp_days / DAYS_PER_LYEAR_PERIOD);
}
TIMELIB_DEBUG(printf("tmp_days=%lld, year=%lld\n", tmp_days, cur_year););
if (ts >= 0) {
while (tmp_days >= DAYS_PER_LYEAR) {
cur_year++;
if (timelib_is_leap(cur_year)) {
@ -61,33 +66,17 @@ void timelib_unixtime2gmt(timelib_time* tm, timelib_sll ts)
} else {
tmp_days -= DAYS_PER_YEAR;
}
TIMELIB_DEBUG(printf("tmp_days=%lld, year=%lld\n", tmp_days, cur_year););
}
} else {
tmp_days = days;
/* Guess why this might be for, it has to do with a pope ;-). It's also
* only valid for Great Brittain and it's colonies. It needs fixing for
* other locales. *sigh*, why is this crap so complex! */
/*
if (ts <= TIMELIB_LL_CONST(-6857352000)) {
tmp_days -= 11;
}
*/
while (tmp_days <= 0) {
if (tmp_days < -1460970) {
cur_year -= 4000;
TIMELIB_DEBUG(printf("tmp_days=%lld, year=%lld\n", tmp_days, cur_year););
tmp_days += 1460970;
cur_year--;
if (timelib_is_leap(cur_year)) {
tmp_days += DAYS_PER_LYEAR;
} else {
cur_year--;
TIMELIB_DEBUG(printf("tmp_days=%lld, year=%lld\n", tmp_days, cur_year););
if (timelib_is_leap(cur_year)) {
tmp_days += DAYS_PER_LYEAR;
} else {
tmp_days += DAYS_PER_YEAR;
}
tmp_days += DAYS_PER_YEAR;
}
TIMELIB_DEBUG(printf("tmp_days=%lld, year=%lld\n", tmp_days, cur_year););
}
remainder += SECS_PER_DAY;
}

View File

@ -1481,7 +1481,7 @@ PHP_FUNCTION(strtotime)
{
zend_string *times;
int error1, error2;
struct timelib_error_container *error;
timelib_error_container *error;
zend_long preset_ts = 0, ts;
timelib_time *t, *now;
timelib_tzinfo *tzi;
@ -3017,7 +3017,7 @@ PHP_FUNCTION(date_get_last_errors)
}
/* }}} */
void php_date_do_return_parsed_time(INTERNAL_FUNCTION_PARAMETERS, timelib_time *parsed_time, struct timelib_error_container *error) /* {{{ */
void php_date_do_return_parsed_time(INTERNAL_FUNCTION_PARAMETERS, timelib_time *parsed_time, timelib_error_container *error) /* {{{ */
{
zval element;
@ -3097,7 +3097,7 @@ void php_date_do_return_parsed_time(INTERNAL_FUNCTION_PARAMETERS, timelib_time *
PHP_FUNCTION(date_parse)
{
zend_string *date;
struct timelib_error_container *error;
timelib_error_container *error;
timelib_time *parsed_time;
ZEND_PARSE_PARAMETERS_START(1, 1)
@ -3115,7 +3115,7 @@ PHP_FUNCTION(date_parse)
PHP_FUNCTION(date_parse_from_format)
{
zend_string *date, *format;
struct timelib_error_container *error;
timelib_error_container *error;
timelib_time *parsed_time;
ZEND_PARSE_PARAMETERS_START(2, 2)
@ -3172,7 +3172,7 @@ static int php_date_modify(zval *object, char *modify, size_t modify_len) /* {{{
return 0;
}
memcpy(&dateobj->time->relative, &tmp_time->relative, sizeof(struct timelib_rel_time));
memcpy(&dateobj->time->relative, &tmp_time->relative, sizeof(timelib_rel_time));
dateobj->time->have_relative = tmp_time->have_relative;
dateobj->time->sse_uptodate = 0;
@ -4096,7 +4096,7 @@ static int date_interval_initialize(timelib_rel_time **rt, /*const*/ char *forma
timelib_rel_time *p = NULL;
int r = 0;
int retval = 0;
struct timelib_error_container *errors;
timelib_error_container *errors;
timelib_strtointerval(format, format_length, &b, &e, &p, &r, &errors);
@ -4497,7 +4497,7 @@ static int date_period_initialize(timelib_time **st, timelib_time **et, timelib_
timelib_rel_time *p = NULL;
int r = 0;
int retval = 0;
struct timelib_error_container *errors;
timelib_error_container *errors;
timelib_strtointerval(format, format_length, &b, &e, &p, &r, &errors);
@ -4723,7 +4723,7 @@ PHP_FUNCTION(timezone_identifiers_list)
}
tzdb = DATE_TIMEZONEDB;
table = timelib_timezone_identifiers_list(tzdb, &item_count);
table = timelib_timezone_identifiers_list((timelib_tzdb*) tzdb, &item_count);
array_init(return_value);