Browse Source

- Replaced // by /* .. */ comments.

experimental/first_unicode_implementation
Derick Rethans 18 years ago
parent
commit
a339c57e1d
  1. 64
      ext/date/lib/parse_date.c
  2. 62
      ext/date/lib/parse_date.re
  3. 2
      ext/date/lib/parse_iso_intervals.c
  4. 30
      ext/date/lib/tm2unixtime.c
  5. 12
      ext/date/php_date.c

64
ext/date/lib/parse_date.c

@ -1,4 +1,4 @@
/* Generated by re2c 0.13.4 on Sun May 4 22:48:05 2008 */
/* Generated by re2c 0.13.4 on Tue Jul 8 19:51:01 2008 */
#line 1 "ext/date/lib/parse_date.re"
/*
+----------------------------------------------------------------------+
@ -19051,7 +19051,7 @@ yy1283:
TIMELIB_INIT;
TIMELIB_HAVE_RELATIVE();
// skip "last day of" or "first day of"
/* skip "last day of" or "first day of" */
if (*ptr == 'l') {
s->time->relative.first_last_day_of = 2;
} else {
@ -23398,17 +23398,17 @@ timelib_time *timelib_parse_from_format(char *format, char *string, int len, tim
while (*fptr && *ptr) {
begin = ptr;
switch (*fptr) {
case 'd': // two digit day, with leading zero
case 'j': // two digit day, without leading zero
case 'd': /* two digit day, with leading zero */
case 'j': /* two digit day, without leading zero */
TIMELIB_CHECK_NUMBER;
if ((s->time->d = timelib_get_nr((char **) &ptr, 2)) == TIMELIB_UNSET) {
add_pbf_error(s, "A two digit day could not be found", string, begin);
}
break;
case 'S': // day suffix, ignored, nor checked
case 'S': /* day suffix, ignored, nor checked */
timelib_skip_day_suffix((char **) &ptr);
break;
case 'z': // day of year - resets month (0 based)
case 'z': /* day of year - resets month (0 based) */
TIMELIB_CHECK_NUMBER;
if ((tmp = timelib_get_nr((char **) &ptr, 3)) == TIMELIB_UNSET) {
add_pbf_error(s, "A three digit day-of-year could not be found", string, begin);
@ -23418,15 +23418,15 @@ timelib_time *timelib_parse_from_format(char *format, char *string, int len, tim
}
break;
case 'm': // two digit month, with leading zero
case 'n': // two digit month, without leading zero
case 'm': /* two digit month, with leading zero */
case 'n': /* two digit month, without leading zero */
TIMELIB_CHECK_NUMBER;
if ((s->time->m = timelib_get_nr((char **) &ptr, 2)) == TIMELIB_UNSET) {
add_pbf_error(s, "A two digit month could not be found", string, begin);
}
break;
case 'M': // three letter month
case 'F': // full month
case 'M': /* three letter month */
case 'F': /* full month */
tmp = timelib_lookup_month((char **) &ptr);
if (!tmp) {
add_pbf_error(s, "A textual month could not be found", string, begin);
@ -23434,21 +23434,21 @@ timelib_time *timelib_parse_from_format(char *format, char *string, int len, tim
s->time->m = tmp;
}
break;
case 'y': // two digit year
case 'y': /* two digit year */
TIMELIB_CHECK_NUMBER;
if ((s->time->y = timelib_get_nr((char **) &ptr, 2)) == TIMELIB_UNSET) {
add_pbf_error(s, "A two digit year could not be found", string, begin);
}
TIMELIB_PROCESS_YEAR(s->time->y);
break;
case 'Y': // four digit year
case 'Y': /* four digit year */
TIMELIB_CHECK_NUMBER;
if ((s->time->y = timelib_get_nr((char **) &ptr, 4)) == TIMELIB_UNSET) {
add_pbf_error(s, "A four digit year could not be found", string, begin);
}
break;
case 'g': // two digit hour, with leading zero
case 'h': // two digit hour, without leading zero
case 'g': /* two digit hour, with leading zero */
case 'h': /* two digit hour, without leading zero */
TIMELIB_CHECK_NUMBER;
if ((s->time->h = timelib_get_nr((char **) &ptr, 2)) == TIMELIB_UNSET) {
add_pbf_error(s, "A two digit hour could not be found", string, begin);
@ -23457,15 +23457,15 @@ timelib_time *timelib_parse_from_format(char *format, char *string, int len, tim
add_pbf_error(s, "Hour can not be higher than 12", string, begin);
}
break;
case 'G': // two digit hour, with leading zero
case 'H': // two digit hour, without leading zero
case 'G': /* two digit hour, with leading zero */
case 'H': /* two digit hour, without leading zero */
TIMELIB_CHECK_NUMBER;
if ((s->time->h = timelib_get_nr((char **) &ptr, 2)) == TIMELIB_UNSET) {
add_pbf_error(s, "A two digit hour could not be found", string, begin);
}
break;
case 'a': // am/pm/a.m./p.m.
case 'A': // AM/PM/A.M./P.M.
case 'a': /* am/pm/a.m./p.m. */
case 'A': /* AM/PM/A.M./P.M. */
if (s->time->h == TIMELIB_UNSET) {
add_pbf_error(s, "Meridian can only come after an hour has been found", string, begin);
} else if ((tmp = timelib_meridian_with_check((char **) &ptr, s->time->h)) == TIMELIB_UNSET) {
@ -23474,28 +23474,28 @@ timelib_time *timelib_parse_from_format(char *format, char *string, int len, tim
s->time->h += tmp;
}
break;
case 'i': // two digit minute, with leading zero
case 'i': /* two digit minute, with leading zero */
TIMELIB_CHECK_NUMBER;
if ((s->time->i = timelib_get_nr((char **) &ptr, 2)) == TIMELIB_UNSET) {
add_pbf_error(s, "A two digit minute could not be found", string, begin);
}
break;
case 's': // two digit second, with leading zero
case 's': /* two digit second, with leading zero */
TIMELIB_CHECK_NUMBER;
if ((s->time->s = timelib_get_nr((char **) &ptr, 2)) == TIMELIB_UNSET) {
add_pbf_error(s, "A two digit second could not be found", string, begin);
}
break;
case 'u': // five digit millisecond, with leading zero
case 'u': /* five digit millisecond, with leading zero */
TIMELIB_CHECK_NUMBER;
if ((s->time->f = timelib_get_nr((char **) &ptr, 5)) == TIMELIB_UNSET) {
add_pbf_error(s, "A five digit millisecond could not be found", string, begin);
}
break;
case ' ': // any sort of whitespace (' ' and \t)
case ' ': /* any sort of whitespace (' ' and \t) */
timelib_eat_spaces((char **) &ptr);
break;
case 'U': // epoch seconds
case 'U': /* epoch seconds */
TIMELIB_CHECK_NUMBER;
TIMELIB_HAVE_RELATIVE();
tmp = timelib_get_unsigned_nr((char **) &ptr, 24);
@ -23510,7 +23510,7 @@ timelib_time *timelib_parse_from_format(char *format, char *string, int len, tim
s->time->z = 0;
break;
case 'e': // timezone
case 'e': /* timezone */
{
int tz_not_found;
s->time->z = timelib_get_zone((char **) &ptr, &s->time->dst, s->time, &tz_not_found, s->tzdb);
@ -23520,7 +23520,7 @@ timelib_time *timelib_parse_from_format(char *format, char *string, int len, tim
}
break;
case '#': // separation symbol
case '#': /* separation symbol */
if (*ptr == ';' || *ptr == ':' || *ptr == '/' || *ptr == '.' || *ptr == ',' || *ptr == '-') {
++ptr;
} else {
@ -23541,16 +23541,16 @@ timelib_time *timelib_parse_from_format(char *format, char *string, int len, tim
}
break;
case '!': // reset all fields to default
case '!': /* reset all fields to default */
s->time->y = 1970;
s->time->m = 1;
s->time->d = 1;
s->time->h = s->time->i = s->time->s = 0;
s->time->f = 0.0;
s->time->tz_info = NULL;
break; // break intentionally not missing
break; /* break intentionally not missing */
case '|': // reset all fields to default when not set
case '|': /* reset all fields to default when not set */
if (s->time->y == TIMELIB_UNSET ) s->time->y = 1970;
if (s->time->m == TIMELIB_UNSET ) s->time->m = 1;
if (s->time->d == TIMELIB_UNSET ) s->time->d = 1;
@ -23559,13 +23559,13 @@ timelib_time *timelib_parse_from_format(char *format, char *string, int len, tim
if (s->time->s == TIMELIB_UNSET ) s->time->s = 0;
if (s->time->f == TIMELIB_UNSET ) s->time->f = 0.0;
break; // break intentionally not missing
break; /* break intentionally not missing */
case '?': // random char
case '?': /* random char */
++ptr;
break;
case '*': // random chars until a separator or number ([ \t.,:;/-0123456789])
case '*': /* random chars until a separator or number ([ \t.,:;/-0123456789]) */
timelib_eat_until_separator((char **) &ptr);
break;
@ -23584,7 +23584,7 @@ timelib_time *timelib_parse_from_format(char *format, char *string, int len, tim
add_pbf_error(s, "Data missing", string, ptr);
}
// clean up a bit
/* clean up a bit */
if (s->time->h != TIMELIB_UNSET || s->time->i != TIMELIB_UNSET || s->time->s != TIMELIB_UNSET) {
if (s->time->h == TIMELIB_UNSET ) {
s->time->h = 0;

62
ext/date/lib/parse_date.re

@ -1049,7 +1049,7 @@ weekdayof = (reltextnumber|reltexttext) space (dayfull|dayabbr) ' of';
TIMELIB_INIT;
TIMELIB_HAVE_RELATIVE();
// skip "last day of" or "first day of"
/* skip "last day of" or "first day of" */
if (*ptr == 'l') {
s->time->relative.first_last_day_of = 2;
} else {
@ -1818,17 +1818,17 @@ timelib_time *timelib_parse_from_format(char *format, char *string, int len, tim
while (*fptr && *ptr) {
begin = ptr;
switch (*fptr) {
case 'd': // two digit day, with leading zero
case 'j': // two digit day, without leading zero
case 'd': /* two digit day, with leading zero */
case 'j': /* two digit day, without leading zero */
TIMELIB_CHECK_NUMBER;
if ((s->time->d = timelib_get_nr((char **) &ptr, 2)) == TIMELIB_UNSET) {
add_pbf_error(s, "A two digit day could not be found", string, begin);
}
break;
case 'S': // day suffix, ignored, nor checked
case 'S': /* day suffix, ignored, nor checked */
timelib_skip_day_suffix((char **) &ptr);
break;
case 'z': // day of year - resets month (0 based)
case 'z': /* day of year - resets month (0 based) */
TIMELIB_CHECK_NUMBER;
if ((tmp = timelib_get_nr((char **) &ptr, 3)) == TIMELIB_UNSET) {
add_pbf_error(s, "A three digit day-of-year could not be found", string, begin);
@ -1838,15 +1838,15 @@ timelib_time *timelib_parse_from_format(char *format, char *string, int len, tim
}
break;
case 'm': // two digit month, with leading zero
case 'n': // two digit month, without leading zero
case 'm': /* two digit month, with leading zero */
case 'n': /* two digit month, without leading zero */
TIMELIB_CHECK_NUMBER;
if ((s->time->m = timelib_get_nr((char **) &ptr, 2)) == TIMELIB_UNSET) {
add_pbf_error(s, "A two digit month could not be found", string, begin);
}
break;
case 'M': // three letter month
case 'F': // full month
case 'M': /* three letter month */
case 'F': /* full month */
tmp = timelib_lookup_month((char **) &ptr);
if (!tmp) {
add_pbf_error(s, "A textual month could not be found", string, begin);
@ -1854,21 +1854,21 @@ timelib_time *timelib_parse_from_format(char *format, char *string, int len, tim
s->time->m = tmp;
}
break;
case 'y': // two digit year
case 'y': /* two digit year */
TIMELIB_CHECK_NUMBER;
if ((s->time->y = timelib_get_nr((char **) &ptr, 2)) == TIMELIB_UNSET) {
add_pbf_error(s, "A two digit year could not be found", string, begin);
}
TIMELIB_PROCESS_YEAR(s->time->y);
break;
case 'Y': // four digit year
case 'Y': /* four digit year */
TIMELIB_CHECK_NUMBER;
if ((s->time->y = timelib_get_nr((char **) &ptr, 4)) == TIMELIB_UNSET) {
add_pbf_error(s, "A four digit year could not be found", string, begin);
}
break;
case 'g': // two digit hour, with leading zero
case 'h': // two digit hour, without leading zero
case 'g': /* two digit hour, with leading zero */
case 'h': /* two digit hour, without leading zero */
TIMELIB_CHECK_NUMBER;
if ((s->time->h = timelib_get_nr((char **) &ptr, 2)) == TIMELIB_UNSET) {
add_pbf_error(s, "A two digit hour could not be found", string, begin);
@ -1877,15 +1877,15 @@ timelib_time *timelib_parse_from_format(char *format, char *string, int len, tim
add_pbf_error(s, "Hour can not be higher than 12", string, begin);
}
break;
case 'G': // two digit hour, with leading zero
case 'H': // two digit hour, without leading zero
case 'G': /* two digit hour, with leading zero */
case 'H': /* two digit hour, without leading zero */
TIMELIB_CHECK_NUMBER;
if ((s->time->h = timelib_get_nr((char **) &ptr, 2)) == TIMELIB_UNSET) {
add_pbf_error(s, "A two digit hour could not be found", string, begin);
}
break;
case 'a': // am/pm/a.m./p.m.
case 'A': // AM/PM/A.M./P.M.
case 'a': /* am/pm/a.m./p.m. */
case 'A': /* AM/PM/A.M./P.M. */
if (s->time->h == TIMELIB_UNSET) {
add_pbf_error(s, "Meridian can only come after an hour has been found", string, begin);
} else if ((tmp = timelib_meridian_with_check((char **) &ptr, s->time->h)) == TIMELIB_UNSET) {
@ -1894,28 +1894,28 @@ timelib_time *timelib_parse_from_format(char *format, char *string, int len, tim
s->time->h += tmp;
}
break;
case 'i': // two digit minute, with leading zero
case 'i': /* two digit minute, with leading zero */
TIMELIB_CHECK_NUMBER;
if ((s->time->i = timelib_get_nr((char **) &ptr, 2)) == TIMELIB_UNSET) {
add_pbf_error(s, "A two digit minute could not be found", string, begin);
}
break;
case 's': // two digit second, with leading zero
case 's': /* two digit second, with leading zero */
TIMELIB_CHECK_NUMBER;
if ((s->time->s = timelib_get_nr((char **) &ptr, 2)) == TIMELIB_UNSET) {
add_pbf_error(s, "A two digit second could not be found", string, begin);
}
break;
case 'u': // five digit millisecond, with leading zero
case 'u': /* five digit millisecond, with leading zero */
TIMELIB_CHECK_NUMBER;
if ((s->time->f = timelib_get_nr((char **) &ptr, 5)) == TIMELIB_UNSET) {
add_pbf_error(s, "A five digit millisecond could not be found", string, begin);
}
break;
case ' ': // any sort of whitespace (' ' and \t)
case ' ': /* any sort of whitespace (' ' and \t) */
timelib_eat_spaces((char **) &ptr);
break;
case 'U': // epoch seconds
case 'U': /* epoch seconds */
TIMELIB_CHECK_NUMBER;
TIMELIB_HAVE_RELATIVE();
tmp = timelib_get_unsigned_nr((char **) &ptr, 24);
@ -1930,7 +1930,7 @@ timelib_time *timelib_parse_from_format(char *format, char *string, int len, tim
s->time->z = 0;
break;
case 'e': // timezone
case 'e': /* timezone */
{
int tz_not_found;
s->time->z = timelib_get_zone((char **) &ptr, &s->time->dst, s->time, &tz_not_found, s->tzdb);
@ -1940,7 +1940,7 @@ timelib_time *timelib_parse_from_format(char *format, char *string, int len, tim
}
break;
case '#': // separation symbol
case '#': /* separation symbol */
if (*ptr == ';' || *ptr == ':' || *ptr == '/' || *ptr == '.' || *ptr == ',' || *ptr == '-') {
++ptr;
} else {
@ -1961,16 +1961,16 @@ timelib_time *timelib_parse_from_format(char *format, char *string, int len, tim
}
break;
case '!': // reset all fields to default
case '!': /* reset all fields to default */
s->time->y = 1970;
s->time->m = 1;
s->time->d = 1;
s->time->h = s->time->i = s->time->s = 0;
s->time->f = 0.0;
s->time->tz_info = NULL;
break; // break intentionally not missing
break; /* break intentionally not missing */
case '|': // reset all fields to default when not set
case '|': /* reset all fields to default when not set */
if (s->time->y == TIMELIB_UNSET ) s->time->y = 1970;
if (s->time->m == TIMELIB_UNSET ) s->time->m = 1;
if (s->time->d == TIMELIB_UNSET ) s->time->d = 1;
@ -1979,13 +1979,13 @@ timelib_time *timelib_parse_from_format(char *format, char *string, int len, tim
if (s->time->s == TIMELIB_UNSET ) s->time->s = 0;
if (s->time->f == TIMELIB_UNSET ) s->time->f = 0.0;
break; // break intentionally not missing
break; /* break intentionally not missing */
case '?': // random char
case '?': /* random char */
++ptr;
break;
case '*': // random chars until a separator or number ([ \t.,:;/-0123456789])
case '*': /* random chars until a separator or number ([ \t.,:;/-0123456789]) */
timelib_eat_until_separator((char **) &ptr);
break;
@ -2004,7 +2004,7 @@ timelib_time *timelib_parse_from_format(char *format, char *string, int len, tim
add_pbf_error(s, "Data missing", string, ptr);
}
// clean up a bit
/* clean up a bit */
if (s->time->h != TIMELIB_UNSET || s->time->i != TIMELIB_UNSET || s->time->s != TIMELIB_UNSET) {
if (s->time->h == TIMELIB_UNSET ) {
s->time->h = 0;

2
ext/date/lib/parse_iso_intervals.c

@ -1,4 +1,4 @@
/* Generated by re2c 0.13.4 on Sun May 4 11:58:27 2008 */
/* Generated by re2c 0.13.4 on Tue Jul 8 19:51:01 2008 */
#line 1 "ext/date/lib/parse_iso_intervals.re"
/*
+----------------------------------------------------------------------+

30
ext/date/lib/tm2unixtime.c

@ -184,10 +184,10 @@ static void do_adjust_relative(timelib_time* time)
time->y += time->relative.y;
}
switch (time->relative.first_last_day_of) {
case 1: // first
case 1: /* first */
time->d = 1;
break;
case 2: // last
case 2: /* last */
time->d = 0;
time->m++;
break;
@ -203,43 +203,43 @@ static void do_adjust_special_weekday(timelib_time* time)
current_dow = timelib_day_of_week(time->y, time->m, time->d);
if (count == 0) {
// skip over saturday and sunday
/* skip over saturday and sunday */
if (current_dow == 6) {
time->d += 2;
}
// skip over sunday
/* skip over sunday */
if (current_dow == 0) {
time->d += 1;
}
} else if (count > 0) {
// skip over saturday and sunday
/* skip over saturday and sunday */
if (current_dow == 5) {
time->d += 2;
}
// skip over sunday
/* skip over sunday */
if (current_dow == 6) {
time->d += 1;
}
// add increments of 5 weekdays as a week
/* add increments of 5 weekdays as a week */
time->d += (count / 5) * 7;
// if current DOW plus the remainder > 5, add two days
/* if current DOW plus the remainder > 5, add two days */
current_dow = timelib_day_of_week(time->y, time->m, time->d);
time->d += (count % 5);
if ((count % 5) + current_dow > 5) {
time->d += 2;
}
} else if (count < 0) {
// skip over sunday and saturday
/* skip over sunday and saturday */
if (current_dow == 1) {
time->d -= 2;
}
// skip over satruday
/* skip over satruday */
if (current_dow == 0 ) {
time->d -= 1;
}
// subtract increments of 5 weekdays as a week
/* subtract increments of 5 weekdays as a week */
time->d += (count / 5) * 7;
// if current DOW minus the remainder < 0, subtract two days
/* if current DOW minus the remainder < 0, subtract two days */
current_dow = timelib_day_of_week(time->y, time->m, time->d);
time->d += (count % 5);
if ((count % 5) + current_dow < 1) {
@ -285,10 +285,10 @@ static timelib_sll do_years(timelib_sll year)
timelib_sll res = 0;
timelib_sll eras;
eras = (year - 1970) / 400;
eras = (year - 1970) / 40000;
if (eras != 0) {
year = year - (eras * 400);
res += (SECS_PER_ERA * eras);
year = year - (eras * 40000);
res += (SECS_PER_ERA * eras * 100);
}
if (year >= 1970) {

12
ext/date/php_date.c

@ -310,9 +310,9 @@ struct _php_timezone_obj {
int initialized;
int type;
union {
timelib_tzinfo *tz; // TIMELIB_ZONETYPE_ID;
timelib_sll utc_offset; // TIMELIB_ZONETYPE_OFFSET
struct // TIMELIB_ZONETYPE_ABBR
timelib_tzinfo *tz; /* TIMELIB_ZONETYPE_ID; */
timelib_sll utc_offset; /* TIMELIB_ZONETYPE_OFFSET */
struct /* TIMELIB_ZONETYPE_ABBR */
{
timelib_sll utc_offset;
char *abbr;
@ -2001,7 +2001,7 @@ static HashTable *date_object_get_properties(zval *object TSRMLS_DC)
return props;
}
// first we add the date and time in ISO format
/* first we add the date and time in ISO format */
str = date_format("Y-m-d H:i:s", 12, &return_len, dateobj->time, 1, 0 TSRMLS_CC);
MAKE_STD_ZVAL(zv);
if (UG(unicode)) {
@ -2011,7 +2011,7 @@ static HashTable *date_object_get_properties(zval *object TSRMLS_DC)
}
zend_hash_update(props, "date", 5, &zv, sizeof(zval), NULL);
// then we add the timezone name (or similar)
/* then we add the timezone name (or similar) */
if (dateobj->time->is_localtime) {
MAKE_STD_ZVAL(zv);
ZVAL_LONG(zv, dateobj->time->zone_type);
@ -2264,7 +2264,7 @@ static int date_initialize(php_date_obj *dateobj, /*const*/ char *time_str, int
dateobj->time = timelib_strtotime(time_str_len ? time_str : "now", time_str_len ? time_str_len : sizeof("now") -1, &err, DATE_TIMEZONEDB);
}
// update last errors and warnings
/* update last errors and warnings */
update_errors_warnings(err TSRMLS_CC);

Loading…
Cancel
Save