📄 parse_date.c.orig
字号:
{ int first_found = 0; const timelib_tz_lookup_table *tp, *first_found_elem = NULL; const timelib_tz_lookup_table *fmp; if (strcasecmp("utc", word) == 0 || strcasecmp("gmt", word) == 0) { return timelib_timezone_utc; } for (tp = timelib_timezone_lookup; tp->name; tp++) { if (strcasecmp(word, tp->name) == 0) { if (!first_found) { first_found = 1; first_found_elem = tp; if (gmtoffset == -1) { return tp; } } if (tp->gmtoffset == gmtoffset) { return tp; } } } if (first_found) { return first_found_elem; } /* Still didn't find anything, let's find the zone solely based on * offset/isdst then */ for (fmp = timelib_timezone_fallbackmap; fmp->name; fmp++) { if ((fmp->gmtoffset * 3600) == gmtoffset && fmp->type == isdst) { return fmp; } } return NULL;}static long timelib_lookup_zone(char **ptr, int *dst, char **tz_abbr, int *found){ char *word; char *begin = *ptr, *end; long value = 0; const timelib_tz_lookup_table *tp; while (**ptr != '\0' && **ptr != ')') { ++*ptr; } end = *ptr; word = calloc(1, end - begin + 1); memcpy(word, begin, end - begin); if ((tp = zone_search(word, -1, 0))) { value = -tp->gmtoffset / 60; *dst = tp->type; value += tp->type * 60; *found = 1; } else { *found = 0; } *tz_abbr = word; return value;}static long timelib_get_zone(char **ptr, int *dst, timelib_time *t, int *tz_not_found, const timelib_tzdb *tzdb){ timelib_tzinfo *res; long retval = 0; *tz_not_found = 0; while (**ptr == ' ' || **ptr == '\t' || **ptr == '(') { ++*ptr; } if (**ptr == '+') { ++*ptr; t->is_localtime = 1; t->zone_type = TIMELIB_ZONETYPE_OFFSET; *tz_not_found = 0; t->dst = 0; retval = -1 * timelib_parse_tz_cor(ptr); } else if (**ptr == '-') { ++*ptr; t->is_localtime = 1; t->zone_type = TIMELIB_ZONETYPE_OFFSET; *tz_not_found = 0; t->dst = 0; retval = timelib_parse_tz_cor(ptr); } else { int found = 0; long offset; char *tz_abbr; t->is_localtime = 1; offset = timelib_lookup_zone(ptr, dst, &tz_abbr, &found); if (found) { t->zone_type = TIMELIB_ZONETYPE_ABBR; }#if 0 /* If we found a TimeZone identifier, use it */ if (tz_name) { t->tz_info = timelib_parse_tzfile(tz_name); t->zone_type = TIMELIB_ZONETYPE_ID; }#endif /* If we have a TimeZone identifier to start with, use it */ if (strstr(tz_abbr, "/")) { if ((res = timelib_parse_tzfile(tz_abbr, tzdb)) != NULL) { t->tz_info = res; t->zone_type = TIMELIB_ZONETYPE_ID; found++; } } if (found && t->zone_type != TIMELIB_ZONETYPE_ID) { timelib_time_tz_abbr_update(t, tz_abbr); } free(tz_abbr); *tz_not_found = (found == 0); retval = offset; } while (**ptr == ')') { ++*ptr; } return retval;}#define timelib_split_free(arg) { \ int i; \ for (i = 0; i < arg.c; i++) { \ free(arg.v[i]); \ } \ if (arg.v) { \ free(arg.v); \ } \}static int scan(Scanner *s){ uchar *cursor = s->cur; char *str, *ptr = NULL; std: s->tok = cursor; s->len = 0;#line 879 "ext/date/lib/parse_date.re"{ static unsigned char yybm[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 208, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 208, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 64, 192, 0, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 32, 32, 32, 160, 32, 32, 32, 160, 32, 32, 32, 32, 32, 160, 32, 32, 32, 160, 160, 160, 32, 32, 32, 32, 32, 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, };#line 808 "ext/date/lib/parse_date.c" { YYCTYPE yych; unsigned int yyaccept = 0; YYDEBUG(0, *YYCURSOR); if((YYLIMIT - YYCURSOR) < 29) YYFILL(29); yych = *YYCURSOR; YYDEBUG(-1, yych); switch(yych) { case 0x00: case 0x0A: goto yy48; case 0x09: case ' ': goto yy45; case '(': goto yy42; case '+': case '-': goto yy41; case ',': case '.': goto yy47; case '0': goto yy13; case '1': goto yy14; case '2': goto yy15; case '3': goto yy16; case '4': case '5': case '6': case '7': case '8': case '9': goto yy17; case '@': goto yy11; case 'A': goto yy25; case 'B': case 'C': case 'G': case 'H': case 'K': case 'Q': case 'R': case 'U': case 'Z': goto yy43; case 'D': goto yy31; case 'E': goto yy35; case 'F': goto yy23; case 'I': goto yy18; case 'J': goto yy21; case 'L': goto yy37; case 'M': goto yy7; case 'N': goto yy5; case 'O': goto yy29; case 'P': goto yy39; case 'S': goto yy27; case 'T': goto yy9; case 'V': goto yy19; case 'W': goto yy33; case 'X': goto yy20; case 'Y': goto yy2; case 'a': goto yy26; case 'b': case 'c': case 'g': case 'h': case 'i': case 'k': case 'q': case 'r': case 'u': case 'v': case 'x': case 'z': goto yy44; case 'd': goto yy32; case 'e': goto yy36; case 'f': goto yy24; case 'j': goto yy22; case 'l': goto yy38; case 'm': goto yy8; case 'n': goto yy6; case 'o': goto yy30; case 'p': goto yy40; case 's': goto yy28; case 't': goto yy10; case 'w': goto yy34; case 'y': goto yy4; default: goto yy50; }yy2: YYDEBUG(2, *YYCURSOR); ++YYCURSOR; if((yych = *YYCURSOR) <= 'E') { if(yych <= ')') { if(yych >= ')') goto yy136; } else { if(yych <= '@') goto yy3; if(yych <= 'D') goto yy137; goto yy1371; } } else { if(yych <= 'd') { if(yych <= 'Z') goto yy137; if(yych >= 'a') goto yy142; } else { if(yych <= 'e') goto yy1380; if(yych <= 'z') goto yy142; } }yy3: YYDEBUG(3, *YYCURSOR);#line 1408 "ext/date/lib/parse_date.re" { int tz_not_found; DEBUG_OUTPUT("tzcorrection | tz"); TIMELIB_INIT; TIMELIB_HAVE_TZ(); s->time->z = timelib_get_zone((char **) &ptr, &s->time->dst, s->time, &tz_not_found, s->tzdb); if (tz_not_found) { add_error(s, "The timezone could not be found in the database"); } TIMELIB_DEINIT; return TIMELIB_TIMEZONE; }#line 927 "ext/date/lib/parse_date.c"yy4: YYDEBUG(4, *YYCURSOR); yych = *++YYCURSOR; if(yych <= 'E') { if(yych <= ')') { if(yych <= '(') goto yy3; goto yy136; } else { if(yych <= '@') goto yy3; if(yych <= 'D') goto yy137; goto yy1371; } } else { if(yych <= 'd') { if(yych <= 'Z') goto yy137; if(yych <= '`') goto yy3; goto yy137; } else { if(yych <= 'e') goto yy1371; if(yych <= 'z') goto yy137; goto yy3; } }yy5: YYDEBUG(5, *YYCURSOR); yych = *++YYCURSOR; if(yych <= 'O') { if(yych <= 'D') { if(yych == ')') goto yy136; if(yych <= '@') goto yy3; goto yy137; } else { if(yych <= 'H') { if(yych <= 'E') goto yy1342; goto yy137; } else { if(yych <= 'I') goto yy1343; if(yych <= 'N') goto yy137; goto yy1341; } } } else { if(yych <= 'h') { if(yych <= '`') { if(yych <= 'Z') goto yy137; goto yy3; } else { if(yych == 'e') goto yy1358; goto yy142; } } else { if(yych <= 'n') { if(yych <= 'i') goto yy1359; goto yy142; } else { if(yych <= 'o') goto yy1357; if(yych <= 'z') goto yy142; goto yy3; } } }yy6: YYDEBUG(6, *YYCURSOR); yych = *++YYCURSOR; if(yych <= 'O') { if(yych <= 'D') { if(yych == ')') goto yy136; if(yych <= '@') goto yy3; goto yy137; } else { if(yych <= 'H') { if(yych <= 'E') goto yy1342; goto yy137; } else { if(yych <= 'I') goto yy1343; if(yych <= 'N') goto yy137; goto yy1341; } } } else { if(yych <= 'h') { if(yych <= '`') { if(yych <= 'Z') goto yy137; goto yy3; } else { if(yych == 'e') goto yy1342; goto yy137; } } else { if(yych <= 'n') { if(yych <= 'i') goto yy1343; goto yy137; } else { if(yych <= 'o') goto yy1341; if(yych <= 'z') goto yy137; goto yy3; } } }yy7: YYDEBUG(7, *YYCURSOR); yych = *++YYCURSOR; if(yych <= 'O') { if(yych <= 'A') { if(yych == ')') goto yy136; if(yych <= '@') goto yy3; goto yy1311; } else { if(yych == 'I') goto yy1312; if(yych <= 'N') goto yy137; goto yy1313; } } else { if(yych <= 'h') { if(yych <= 'Z') goto yy137; if(yych <= '`') goto yy3; if(yych <= 'a') goto yy1326; goto yy142; } else { if(yych <= 'n') { if(yych <= 'i') goto yy1327; goto yy142; } else { if(yych <= 'o') goto yy1328; if(yych <= 'z') goto yy142; goto yy3; } } }yy8: YYDEBUG(8, *YYCURSOR); yych = *++YYCURSOR; if(yych <= 'O') { if(yych <= 'A') { if(yych == ')') goto yy136; if(yych <= '@') goto yy3; goto yy1311; } else { if(yych == 'I') goto yy1312; if(yych <= 'N') goto yy137; goto yy1313; } } else { if(yych <= 'h') { if(yych <= 'Z') goto yy137; if(yych <= '`') goto yy3; if(yych <= 'a') goto yy1311; goto yy137; } else { if(yych <= 'n') { if(yych <= 'i') goto yy1312; goto yy137; } else { if(yych <= 'o') goto yy1313; if(yych <= 'z') goto yy137; goto yy3; } } }yy9: YYDEBUG(9, *YYCURSOR); yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); YYDEBUG(-1, yych); switch(yych) { case ')': goto yy136; case '0': case '1': goto yy1243; case '2': goto yy1244; case '3': case '4': case '5': case '6': case '7': case '8': case '9': goto yy1245; case 'A': case 'B': case 'C': case 'D': case 'F': case 'G': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'V': case 'X': case 'Y': case 'Z': goto yy137; case 'E': goto yy1238; case 'H': goto yy1239; case 'O': goto yy1240; case 'U': goto yy1241; case 'W': goto yy1242; case 'a': case 'b': case 'c': case 'd': case 'f': case 'g': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'p': case 'q': case 'r': case 's': case 't': case 'v': case 'x': case 'y': case 'z': goto yy142; case 'e': goto yy1280; case 'h': goto yy1281; case 'o': goto yy1282; case 'u': goto yy1283; case 'w': goto yy1284; default: goto yy3; }yy10: YYDEBUG(10, *YYCURSOR); yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); YYDEBUG(-1, yych); switch(yych) { case ')': goto yy136; case '0': case '1': goto yy1243; case '2': goto yy1244; case '3': case '4': case '5': case '6': case '7': case '8': case '9': goto yy1245; case 'A': case 'B': case 'C': case 'D': case 'F': case 'G': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'V': case 'X': case 'Y': case 'Z': case 'a': case 'b': case 'c': case 'd': case 'f': case 'g': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'p': case 'q': case 'r': case 's': case 't': case 'v': case 'x': case 'y': case 'z': goto yy137; case 'E': case 'e': goto yy1238; case 'H': case 'h': goto yy1239; case 'O': case 'o': goto yy1240; case 'U': case 'u': goto yy1241; case 'W': case 'w': goto yy1242; default: goto yy3; }yy11: YYDEBUG(11, *YYCURSOR); yyaccept = 1; yych = *(YYMARKER = ++YYCURSOR); if(yych == '-') goto yy1234; if(yych <= '/') goto yy12; if(yych <= '9') goto yy1235;yy12: YYDEBUG(12, *YYCURSOR);#line 1503 "ext/date/lib/parse_date.re" { add_error(s, "Unexpected character"); goto std;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -