Merge branch 'PHP-5.5' into PHP-5.6

This commit is contained in:
Derick Rethans 2015-04-28 15:57:35 +01:00
commit 43c69443bb
9 changed files with 67 additions and 67 deletions

View File

@ -115,7 +115,7 @@ static double astro_GMST0(double d)
/* time, imposing no runtime or code overhead. */ /* time, imposing no runtime or code overhead. */
sidtim0 = astro_revolution((180.0 + 356.0470 + 282.9404) + (0.9856002585 + 4.70935E-5) * d); sidtim0 = astro_revolution((180.0 + 356.0470 + 282.9404) + (0.9856002585 + 4.70935E-5) * d);
return sidtim0; return sidtim0;
} }
/* This function computes the Sun's position at any instant */ /* This function computes the Sun's position at any instant */
@ -177,32 +177,32 @@ static void astro_sun_RA_dec(double d, double *RA, double *dec, double *r)
/** /**
* Note: timestamp = unixtimestamp (NEEDS to be 00:00:00 UT) * Note: timestamp = unixtimestamp (NEEDS to be 00:00:00 UT)
* Eastern longitude positive, Western longitude negative * Eastern longitude positive, Western longitude negative
* Northern latitude positive, Southern latitude negative * Northern latitude positive, Southern latitude negative
* The longitude value IS critical in this function! * The longitude value IS critical in this function!
* altit = the altitude which the Sun should cross * altit = the altitude which the Sun should cross
* Set to -35/60 degrees for rise/set, -6 degrees * Set to -35/60 degrees for rise/set, -6 degrees
* for civil, -12 degrees for nautical and -18 * for civil, -12 degrees for nautical and -18
* degrees for astronomical twilight. * degrees for astronomical twilight.
* upper_limb: non-zero -> upper limb, zero -> center * upper_limb: non-zero -> upper limb, zero -> center
* Set to non-zero (e.g. 1) when computing rise/set * Set to non-zero (e.g. 1) when computing rise/set
* times, and to zero when computing start/end of * times, and to zero when computing start/end of
* twilight. * twilight.
* *rise = where to store the rise time * *rise = where to store the rise time
* *set = where to store the set time * *set = where to store the set time
* Both times are relative to the specified altitude, * Both times are relative to the specified altitude,
* and thus this function can be used to compute * and thus this function can be used to compute
* various twilight times, as well as rise/set times * various twilight times, as well as rise/set times
* Return value: 0 = sun rises/sets this day, times stored at * Return value: 0 = sun rises/sets this day, times stored at
* *trise and *tset. * *trise and *tset.
* +1 = sun above the specified "horizon" 24 hours. * +1 = sun above the specified "horizon" 24 hours.
* *trise set to time when the sun is at south, * *trise set to time when the sun is at south,
* minus 12 hours while *tset is set to the south * minus 12 hours while *tset is set to the south
* time plus 12 hours. "Day" length = 24 hours * time plus 12 hours. "Day" length = 24 hours
* -1 = sun is below the specified "horizon" 24 hours * -1 = sun is below the specified "horizon" 24 hours
* "Day" length = 0 hours, *trise and *tset are * "Day" length = 0 hours, *trise and *tset are
* both set to the time when the sun is at south. * both set to the time when the sun is at south.
* *
*/ */
int timelib_astro_rise_set_altitude(timelib_time *t_loc, double lon, double lat, double altit, int upper_limb, double *h_rise, double *h_set, timelib_sll *ts_rise, timelib_sll *ts_set, timelib_sll *ts_transit) int timelib_astro_rise_set_altitude(timelib_time *t_loc, double lon, double lat, double altit, int upper_limb, double *h_rise, double *h_set, timelib_sll *ts_rise, timelib_sll *ts_set, timelib_sll *ts_transit)
{ {

View File

@ -136,7 +136,7 @@ void timelib_isoweek_from_date(timelib_sll y, timelib_sll m, timelib_sll d, time
timelib_sll timelib_daynr_from_weeknr(timelib_sll y, timelib_sll w, timelib_sll d) timelib_sll timelib_daynr_from_weeknr(timelib_sll y, timelib_sll w, timelib_sll d)
{ {
timelib_sll dow, day; timelib_sll dow, day;
/* Figure out the dayofweek for y-1-1 */ /* Figure out the dayofweek for y-1-1 */
dow = timelib_day_of_week(y, 1, 1); dow = timelib_day_of_week(y, 1, 1);
/* then use that to figure out the offset for day 1 of week 1 */ /* then use that to figure out the offset for day 1 of week 1 */

View File

@ -677,7 +677,7 @@ const static timelib_tz_lookup_table* abbr_search(const char *word, long gmtoffs
if (strcasecmp("utc", word) == 0 || strcasecmp("gmt", word) == 0) { if (strcasecmp("utc", word) == 0 || strcasecmp("gmt", word) == 0) {
return timelib_timezone_utc; return timelib_timezone_utc;
} }
for (tp = timelib_timezone_lookup; tp->name; tp++) { for (tp = timelib_timezone_lookup; tp->name; tp++) {
if (strcasecmp(word, tp->name) == 0) { if (strcasecmp(word, tp->name) == 0) {
if (!first_found) { if (!first_found) {
@ -808,7 +808,7 @@ static int scan(Scanner *s, timelib_tz_get_wrapper tz_get_wrapper)
{ {
uchar *cursor = s->cur; uchar *cursor = s->cur;
char *str, *ptr = NULL; char *str, *ptr = NULL;
std: std:
s->tok = cursor; s->tok = cursor;
s->len = 0; s->len = 0;
@ -1437,7 +1437,7 @@ weekdayof = (reltextnumber|reltexttext) space (dayfull|dayabbr) space 'of
TIMELIB_INIT; TIMELIB_INIT;
TIMELIB_HAVE_DATE(); TIMELIB_HAVE_DATE();
TIMELIB_HAVE_RELATIVE(); TIMELIB_HAVE_RELATIVE();
s->time->y = timelib_get_nr((char **) &ptr, 4); s->time->y = timelib_get_nr((char **) &ptr, 4);
w = timelib_get_nr((char **) &ptr, 2); w = timelib_get_nr((char **) &ptr, 2);
d = timelib_get_nr((char **) &ptr, 1); d = timelib_get_nr((char **) &ptr, 1);
@ -1456,7 +1456,7 @@ weekdayof = (reltextnumber|reltexttext) space (dayfull|dayabbr) space 'of
TIMELIB_INIT; TIMELIB_INIT;
TIMELIB_HAVE_DATE(); TIMELIB_HAVE_DATE();
TIMELIB_HAVE_RELATIVE(); TIMELIB_HAVE_RELATIVE();
s->time->y = timelib_get_nr((char **) &ptr, 4); s->time->y = timelib_get_nr((char **) &ptr, 4);
w = timelib_get_nr((char **) &ptr, 2); w = timelib_get_nr((char **) &ptr, 2);
d = 1; d = 1;
@ -1560,7 +1560,7 @@ weekdayof = (reltextnumber|reltexttext) space (dayfull|dayabbr) space 'of
if (s->time->relative.weekday_behavior != 2) { if (s->time->relative.weekday_behavior != 2) {
s->time->relative.weekday_behavior = 1; s->time->relative.weekday_behavior = 1;
} }
TIMELIB_DEINIT; TIMELIB_DEINIT;
return TIMELIB_WEEKDAY; return TIMELIB_WEEKDAY;
} }
@ -1877,7 +1877,7 @@ timelib_time *timelib_parse_from_format(char *format, char *string, int len, tim
add_pbf_error(s, "A textual day could not be found", string, begin); add_pbf_error(s, "A textual day could not be found", string, begin);
break; break;
} else { } else {
in.time->have_relative = 1; in.time->have_relative = 1;
in.time->relative.have_weekday_relative = 1; in.time->relative.have_weekday_relative = 1;
in.time->relative.weekday = tmprel->multiplier; in.time->relative.weekday = tmprel->multiplier;
in.time->relative.weekday_behavior = 1; in.time->relative.weekday_behavior = 1;
@ -2148,13 +2148,13 @@ timelib_time *timelib_parse_from_format(char *format, char *string, int len, tim
/* do funky checking whether the parsed time was valid time */ /* do funky checking whether the parsed time was valid time */
if (s->time->h != TIMELIB_UNSET && s->time->i != TIMELIB_UNSET && if (s->time->h != TIMELIB_UNSET && s->time->i != TIMELIB_UNSET &&
s->time->s != TIMELIB_UNSET && s->time->s != TIMELIB_UNSET &&
!timelib_valid_time( s->time->h, s->time->i, s->time->s)) { !timelib_valid_time( s->time->h, s->time->i, s->time->s)) {
add_pbf_warning(s, "The parsed time was invalid", string, ptr); add_pbf_warning(s, "The parsed time was invalid", string, ptr);
} }
/* do funky checking whether the parsed date was valid date */ /* do funky checking whether the parsed date was valid date */
if (s->time->y != TIMELIB_UNSET && s->time->m != TIMELIB_UNSET && if (s->time->y != TIMELIB_UNSET && s->time->m != TIMELIB_UNSET &&
s->time->d != TIMELIB_UNSET && s->time->d != TIMELIB_UNSET &&
!timelib_valid_date( s->time->y, s->time->m, s->time->d)) { !timelib_valid_date( s->time->y, s->time->m, s->time->d)) {
add_pbf_warning(s, "The parsed date was invalid", string, ptr); add_pbf_warning(s, "The parsed date was invalid", string, ptr);
} }
@ -2227,7 +2227,7 @@ int main(void)
printf ("%04d-%02d-%02d %02d:%02d:%02d.%-5d %+04d %1d", printf ("%04d-%02d-%02d %02d:%02d:%02d.%-5d %+04d %1d",
time.y, time.m, time.d, time.h, time.i, time.s, time.f, time.z, time.dst); time.y, time.m, time.d, time.h, time.i, time.s, time.f, time.z, time.dst);
if (time.have_relative) { if (time.have_relative) {
printf ("%3dY %3dM %3dD / %3dH %3dM %3dS", printf ("%3dY %3dM %3dD / %3dH %3dM %3dS",
time.relative.y, time.relative.m, time.relative.d, time.relative.h, time.relative.i, time.relative.s); time.relative.y, time.relative.m, time.relative.d, time.relative.h, time.relative.i, time.relative.s);
} }
if (time.have_weekday_relative) { if (time.have_weekday_relative) {
@ -2236,7 +2236,7 @@ int main(void)
if (time.have_weeknr_day) { if (time.have_weeknr_day) {
printf(" / %dW%d", time.relative.weeknr_day.weeknr, time.relative.weeknr_day.dayofweek); printf(" / %dW%d", time.relative.weeknr_day.weeknr, time.relative.weeknr_day.dayofweek);
} }
return 0; return 0;
} }
#endif #endif

View File

@ -242,7 +242,7 @@ static int scan(Scanner *s)
{ {
uchar *cursor = s->cur; uchar *cursor = s->cur;
char *str, *ptr = NULL; char *str, *ptr = NULL;
std: std:
s->tok = cursor; s->tok = cursor;
s->len = 0; s->len = 0;
@ -336,11 +336,11 @@ isoweek = year4 "-"? "W" weekofyear;
case 'D': s->period->d = nr; break; case 'D': s->period->d = nr; break;
case 'H': s->period->h = nr; break; case 'H': s->period->h = nr; break;
case 'S': s->period->s = nr; break; case 'S': s->period->s = nr; break;
case 'M': case 'M':
if (in_time) { if (in_time) {
s->period->i = nr; s->period->i = nr;
} else { } else {
s->period->m = nr; s->period->m = nr;
} }
break; break;
default: default:
@ -398,9 +398,9 @@ isoweek = year4 "-"? "W" weekofyear;
/*!max:re2c */ /*!max:re2c */
void timelib_strtointerval(char *s, int len, void timelib_strtointerval(char *s, int len,
timelib_time **begin, timelib_time **end, timelib_time **begin, timelib_time **end,
timelib_rel_time **period, int *recurrences, timelib_rel_time **period, int *recurrences,
struct timelib_error_container **errors) struct timelib_error_container **errors)
{ {
Scanner in; Scanner in;

View File

@ -36,7 +36,7 @@
#if (defined(__APPLE__) || defined(__APPLE_CC__)) && (defined(__BIG_ENDIAN__) || defined(__LITTLE_ENDIAN__)) #if (defined(__APPLE__) || defined(__APPLE_CC__)) && (defined(__BIG_ENDIAN__) || defined(__LITTLE_ENDIAN__))
# if defined(__LITTLE_ENDIAN__) # if defined(__LITTLE_ENDIAN__)
# undef WORDS_BIGENDIAN # undef WORDS_BIGENDIAN
# else # else
# if defined(__BIG_ENDIAN__) # if defined(__BIG_ENDIAN__)
# define WORDS_BIGENDIAN # define WORDS_BIGENDIAN
# endif # endif
@ -56,7 +56,7 @@ static int read_preamble(const unsigned char **tzf, timelib_tzinfo *tz)
/* read ID */ /* read ID */
version = (*tzf)[3] - '0'; version = (*tzf)[3] - '0';
*tzf += 4; *tzf += 4;
/* read BC flag */ /* read BC flag */
tz->bc = (**tzf == '\1'); tz->bc = (**tzf == '\1');
*tzf += 1; *tzf += 1;
@ -119,7 +119,7 @@ static void read_transistions(const unsigned char **tzf, timelib_tzinfo *tz)
memcpy(cbuffer, *tzf, sizeof(unsigned char) * tz->timecnt); memcpy(cbuffer, *tzf, sizeof(unsigned char) * tz->timecnt);
*tzf += sizeof(unsigned char) * tz->timecnt; *tzf += sizeof(unsigned char) * tz->timecnt;
} }
tz->trans = buffer; tz->trans = buffer;
tz->trans_idx = cbuffer; tz->trans_idx = cbuffer;
} }
@ -307,7 +307,7 @@ static int seek_to_tz_position(const unsigned char **tzf, char *timezone, const
cur_locale = strdup(tmp); cur_locale = strdup(tmp);
} }
setlocale(LC_CTYPE, "C"); setlocale(LC_CTYPE, "C");
#endif #endif
do { do {
int mid = ((unsigned)left + right) >> 1; int mid = ((unsigned)left + right) >> 1;
@ -322,7 +322,7 @@ static int seek_to_tz_position(const unsigned char **tzf, char *timezone, const
#ifdef HAVE_SETLOCALE #ifdef HAVE_SETLOCALE
setlocale(LC_CTYPE, cur_locale); setlocale(LC_CTYPE, cur_locale);
if (cur_locale) free(cur_locale); if (cur_locale) free(cur_locale);
#endif #endif
return 1; return 1;
} }
@ -331,7 +331,7 @@ static int seek_to_tz_position(const unsigned char **tzf, char *timezone, const
#ifdef HAVE_SETLOCALE #ifdef HAVE_SETLOCALE
setlocale(LC_CTYPE, cur_locale); setlocale(LC_CTYPE, cur_locale);
if (cur_locale) free(cur_locale); if (cur_locale) free(cur_locale);
#endif #endif
return 0; return 0;
} }
@ -449,7 +449,7 @@ int timelib_timestamp_is_in_dst(timelib_sll ts, timelib_tzinfo *tz)
{ {
ttinfo *to; ttinfo *to;
timelib_sll dummy; timelib_sll dummy;
if ((to = fetch_timezone_offset(tz, ts, &dummy))) { if ((to = fetch_timezone_offset(tz, ts, &dummy))) {
return to->isdst; return to->isdst;
} }
@ -492,12 +492,12 @@ timelib_sll timelib_get_current_offset(timelib_time *t)
{ {
timelib_time_offset *gmt_offset; timelib_time_offset *gmt_offset;
timelib_sll retval; timelib_sll retval;
switch (t->zone_type) { switch (t->zone_type) {
case TIMELIB_ZONETYPE_ABBR: case TIMELIB_ZONETYPE_ABBR:
case TIMELIB_ZONETYPE_OFFSET: case TIMELIB_ZONETYPE_OFFSET:
return (t->z + t->dst) * -60; return (t->z + t->dst) * -60;
case TIMELIB_ZONETYPE_ID: case TIMELIB_ZONETYPE_ID:
gmt_offset = timelib_get_time_zone_info(t->sse, t->tz_info); gmt_offset = timelib_get_time_zone_info(t->sse, t->tz_info);
retval = gmt_offset->offset; retval = gmt_offset->offset;

View File

@ -122,7 +122,7 @@ timelib_tzinfo *timelib_tzinfo_clone(timelib_tzinfo *tz)
tmp->timecnt = tz->timecnt; tmp->timecnt = tz->timecnt;
tmp->typecnt = tz->typecnt; tmp->typecnt = tz->typecnt;
tmp->charcnt = tz->charcnt; tmp->charcnt = tz->charcnt;
tmp->trans = (int32_t *) malloc(tz->timecnt * sizeof(int32_t)); tmp->trans = (int32_t *) malloc(tz->timecnt * sizeof(int32_t));
tmp->trans_idx = (unsigned char*) malloc(tz->timecnt * sizeof(unsigned char)); tmp->trans_idx = (unsigned char*) malloc(tz->timecnt * sizeof(unsigned char));
memcpy(tmp->trans, tz->trans, tz->timecnt * sizeof(int32_t)); memcpy(tmp->trans, tz->trans, tz->timecnt * sizeof(int32_t));
@ -236,7 +236,7 @@ void timelib_dump_date(timelib_time *d, int options)
if ((options & 1) == 1) { if ((options & 1) == 1) {
if (d->have_relative) { if (d->have_relative) {
printf("%3lldY %3lldM %3lldD / %3lldH %3lldM %3lldS", printf("%3lldY %3lldM %3lldD / %3lldH %3lldM %3lldS",
d->relative.y, d->relative.m, d->relative.d, d->relative.h, d->relative.i, d->relative.s); d->relative.y, d->relative.m, d->relative.d, d->relative.h, d->relative.i, d->relative.s);
if (d->relative.first_last_day_of != 0) { if (d->relative.first_last_day_of != 0) {
switch (d->relative.first_last_day_of) { switch (d->relative.first_last_day_of) {
@ -271,7 +271,7 @@ void timelib_dump_date(timelib_time *d, int options)
void timelib_dump_rel_time(timelib_rel_time *d) void timelib_dump_rel_time(timelib_rel_time *d)
{ {
printf("%3lldY %3lldM %3lldD / %3lldH %3lldM %3lldS (days: %lld)%s", printf("%3lldY %3lldM %3lldD / %3lldH %3lldM %3lldS (days: %lld)%s",
d->y, d->m, d->d, d->h, d->i, d->s, d->days, d->invert ? " inverted" : ""); d->y, d->m, d->d, d->h, d->i, d->s, d->days, d->invert ? " inverted" : "");
if (d->first_last_day_of != 0) { if (d->first_last_day_of != 0) {
switch (d->first_last_day_of) { switch (d->first_last_day_of) {

View File

@ -80,8 +80,8 @@ long timelib_parse_tz_cor(char**);
/* From parse_iso_intervals.re */ /* From parse_iso_intervals.re */
void timelib_strtointerval(char *s, int len, void timelib_strtointerval(char *s, int len,
timelib_time **begin, timelib_time **end, timelib_time **begin, timelib_time **end,
timelib_rel_time **period, int *recurrences, timelib_rel_time **period, int *recurrences,
struct timelib_error_container **errors); struct timelib_error_container **errors);

View File

@ -106,7 +106,7 @@ static int do_range_limit_days(timelib_sll *y, timelib_sll *m, timelib_sll *d)
timelib_sll days_this_month; timelib_sll days_this_month;
timelib_sll last_month, last_year; timelib_sll last_month, last_year;
timelib_sll days_last_month; timelib_sll days_last_month;
/* can jump an entire leap year period quickly */ /* can jump an entire leap year period quickly */
if (*d >= DAYS_PER_LYEAR_PERIOD || *d <= -DAYS_PER_LYEAR_PERIOD) { if (*d >= DAYS_PER_LYEAR_PERIOD || *d <= -DAYS_PER_LYEAR_PERIOD) {
*y += YEARS_PER_LYEAR_PERIOD * (*d / DAYS_PER_LYEAR_PERIOD); *y += YEARS_PER_LYEAR_PERIOD * (*d / DAYS_PER_LYEAR_PERIOD);
@ -396,7 +396,7 @@ static timelib_sll do_adjust_timezone(timelib_time *tz, timelib_tzinfo *tzi)
timelib_time_offset *before, *after; timelib_time_offset *before, *after;
timelib_sll tmp; timelib_sll tmp;
int in_transistion; int in_transistion;
tz->is_localtime = 1; tz->is_localtime = 1;
before = timelib_get_time_zone_info(tz->sse, tzi); before = timelib_get_time_zone_info(tz->sse, tzi);
after = timelib_get_time_zone_info(tz->sse - before->offset, tzi); after = timelib_get_time_zone_info(tz->sse - before->offset, tzi);
@ -406,7 +406,7 @@ static timelib_sll do_adjust_timezone(timelib_time *tz, timelib_tzinfo *tzi)
((tz->sse - after->offset) >= (after->transistion_time + (before->offset - after->offset))) && ((tz->sse - after->offset) >= (after->transistion_time + (before->offset - after->offset))) &&
((tz->sse - after->offset) < after->transistion_time) ((tz->sse - after->offset) < after->transistion_time)
); );
if ((before->offset != after->offset) && !in_transistion) { if ((before->offset != after->offset) && !in_transistion) {
tmp = -after->offset; tmp = -after->offset;
} else { } else {
@ -464,7 +464,7 @@ int main(void)
printf ("%04d-%02d-%02d %02d:%02d:%02d.%-5d %+04d %1d", printf ("%04d-%02d-%02d %02d:%02d:%02d.%-5d %+04d %1d",
time.y, time.m, time.d, time.h, time.i, time.s, time.f, time.z, time.dst); time.y, time.m, time.d, time.h, time.i, time.s, time.f, time.z, time.dst);
if (time.have_relative) { if (time.have_relative) {
printf ("%3dY %3dM %3dD / %3dH %3dM %3dS", printf ("%3dY %3dM %3dD / %3dH %3dM %3dS",
time.relative.y, time.relative.m, time.relative.d, time.relative.h, time.relative.i, time.relative.s); time.relative.y, time.relative.m, time.relative.d, time.relative.h, time.relative.i, time.relative.s);
} }
if (time.have_weekday_relative) { if (time.have_weekday_relative) {

View File

@ -141,7 +141,7 @@ void timelib_update_from_sse(timelib_time *tm)
signed int dst = tm->dst; signed int dst = tm->dst;
sse = tm->sse; sse = tm->sse;
switch (tm->zone_type) { switch (tm->zone_type) {
case TIMELIB_ZONETYPE_ABBR: case TIMELIB_ZONETYPE_ABBR:
case TIMELIB_ZONETYPE_OFFSET: { case TIMELIB_ZONETYPE_OFFSET: {
@ -152,11 +152,11 @@ void timelib_update_from_sse(timelib_time *tm)
case TIMELIB_ZONETYPE_ID: { case TIMELIB_ZONETYPE_ID: {
timelib_time_offset *gmt_offset; timelib_time_offset *gmt_offset;
gmt_offset = timelib_get_time_zone_info(tm->sse, tm->tz_info); gmt_offset = timelib_get_time_zone_info(tm->sse, tm->tz_info);
timelib_unixtime2gmt(tm, tm->sse + gmt_offset->offset); timelib_unixtime2gmt(tm, tm->sse + gmt_offset->offset);
timelib_time_offset_dtor(gmt_offset); timelib_time_offset_dtor(gmt_offset);
goto cleanup; goto cleanup;
} }
@ -182,7 +182,7 @@ void timelib_unixtime2local(timelib_time *tm, timelib_sll ts)
case TIMELIB_ZONETYPE_OFFSET: { case TIMELIB_ZONETYPE_OFFSET: {
int z = tm->z; int z = tm->z;
signed int dst = tm->dst; signed int dst = tm->dst;
timelib_unixtime2gmt(tm, ts - (tm->z * 60) + (tm->dst * 3600)); timelib_unixtime2gmt(tm, ts - (tm->z * 60) + (tm->dst * 3600));
tm->z = z; tm->z = z;
@ -195,7 +195,7 @@ void timelib_unixtime2local(timelib_time *tm, timelib_sll ts)
timelib_unixtime2gmt(tm, ts + gmt_offset->offset); timelib_unixtime2gmt(tm, ts + gmt_offset->offset);
/* we need to reset the sse here as unixtime2gmt modifies it */ /* we need to reset the sse here as unixtime2gmt modifies it */
tm->sse = ts; tm->sse = ts;
tm->dst = gmt_offset->is_dst; tm->dst = gmt_offset->is_dst;
tm->z = gmt_offset->offset; tm->z = gmt_offset->offset;
tm->tz_info = tz; tm->tz_info = tz;