ruby-changes:43246
From: nobu <ko1@a...>
Date: Wed, 8 Jun 2016 10:09:30 +0900 (JST)
Subject: [ruby-changes:43246] nobu:r55320 (trunk): ext/date/zonetab.list: gperf timezone names
nobu 2016-06-08 10:09:23 +0900 (Wed, 08 Jun 2016) New Revision: 55320 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=55320 Log: ext/date/zonetab.list: gperf timezone names Added files: trunk/ext/date/prereq.mk trunk/ext/date/zonetab.h trunk/ext/date/zonetab.list Modified files: trunk/common.mk trunk/ext/date/date_parse.c trunk/ext/date/depend Index: common.mk =================================================================== --- common.mk (revision 55319) +++ common.mk (revision 55320) @@ -788,7 +788,9 @@ EXT_SRCS = $(srcdir)/ext/ripper/ripper.c https://github.com/ruby/ruby/blob/trunk/common.mk#L788 srcs-ext: $(EXT_SRCS) -srcs-extra: $(srcdir)/ext/json/parser/parser.c +srcs-extra: $(srcdir)/ext/json/parser/parser.c \ + $(srcdir)/ext/date/zonetab.c \ + $(empty) LIB_SRCS = $(srcdir)/lib/unicode_normalize/tables.rb @@ -888,6 +890,11 @@ $(srcdir)/ext/json/parser/parser.c: $(sr https://github.com/ruby/ruby/blob/trunk/common.mk#L890 $(ECHO) generating $@ $(Q) $(CHDIR) $(@D) && $(exec) $(MAKE) -f prereq.mk $(MFLAGS) \ Q=$(Q) ECHO=$(ECHO) top_srcdir=../../.. srcdir=. VPATH=../../.. BASERUBY="$(BASERUBY)" + +$(srcdir)/ext/date/zonetab.c: $(srcdir)/ext/date/zonetab.list + $(ECHO) generating $@ + $(Q) $(CHDIR) $(@D) && $(exec) $(MAKE) -f prereq.mk $(MFLAGS) \ + Q=$(Q) ECHO=$(ECHO) top_srcdir=../../.. srcdir=. VPATH=../../.. BASERUBY="$(BASERUBY)" $(srcdir)/ext/rbconfig/sizeof/sizes.c: $(srcdir)/ext/rbconfig/sizeof/depend \ $(srcdir)/tool/generic_erb.rb $(srcdir)/template/sizes.c.tmpl $(srcdir)/configure.in Index: ext/date/zonetab.list =================================================================== --- ext/date/zonetab.list (revision 0) +++ ext/date/zonetab.list (revision 55320) @@ -0,0 +1,181 @@ https://github.com/ruby/ruby/blob/trunk/ext/date/zonetab.list#L1 +%{ +struct zone { + int name; + int offset; +}; +static inline const struct zone *zonetab(); +%} + +struct zone; +%% +ut, 0*3600 +gmt, 0*3600 +est, -5*3600 +edt, -4*3600 +cst, -6*3600 +cdt, -5*3600 +mst, -7*3600 +mdt, -6*3600 +pst, -8*3600 +pdt, -7*3600 +a, 1*3600 +b, 2*3600 +c, 3*3600 +d, 4*3600 +e, 5*3600 +f, 6*3600 +g, 7*3600 +h, 8*3600 +i, 9*3600 +k, 10*3600 +l, 11*3600 +m, 12*3600 +n, -1*3600 +o, -2*3600 +p, -3*3600 +q, -4*3600 +r, -5*3600 +s, -6*3600 +t, -7*3600 +u, -8*3600 +v, -9*3600 +w, -10*3600 +x, -11*3600 +y, -12*3600 +z, 0*3600 +utc, 0*3600 +wet, 0*3600 +at, -2*3600 +brst,-2*3600 +ndt, -(2*3600+1800) +art, -3*3600 +adt, -3*3600 +brt, -3*3600 +clst,-3*3600 +nst, -(3*3600+1800) +ast, -4*3600 +clt, -4*3600 +akdt,-8*3600 +ydt, -8*3600 +akst,-9*3600 +hadt,-9*3600 +hdt, -9*3600 +yst, -9*3600 +ahst,-10*3600 +cat,-10*3600 +hast,-10*3600 +hst,-10*3600 +nt, -11*3600 +idlw,-12*3600 +bst, 1*3600 +cet, 1*3600 +fwt, 1*3600 +met, 1*3600 +mewt, 1*3600 +mez, 1*3600 +swt, 1*3600 +wat, 1*3600 +west, 1*3600 +cest, 2*3600 +eet, 2*3600 +fst, 2*3600 +mest, 2*3600 +mesz, 2*3600 +sast, 2*3600 +sst, 2*3600 +bt, 3*3600 +eat, 3*3600 +eest, 3*3600 +msk, 3*3600 +msd, 4*3600 +zp4, 4*3600 +zp5, 5*3600 +ist, (5*3600+1800) +zp6, 6*3600 +wast, 7*3600 +cct, 8*3600 +sgt, 8*3600 +wadt, 8*3600 +jst, 9*3600 +kst, 9*3600 +east,10*3600 +gst, 10*3600 +eadt,11*3600 +idle,12*3600 +nzst,12*3600 +nzt, 12*3600 +nzdt,13*3600 +afghanistan, 16200 +alaskan, -32400 +arab, 10800 +arabian, 14400 +arabic, 10800 +atlantic, -14400 +aus central, 34200 +aus eastern, 36000 +azores, -3600 +canada central, -21600 +cape verde, -3600 +caucasus, 14400 +cen. australia, 34200 +central america, -21600 +central asia, 21600 +central europe, 3600 +central european, 3600 +central pacific, 39600 +central, -21600 +china, 28800 +dateline, -43200 +e. africa, 10800 +e. australia, 36000 +e. europe, 7200 +e. south america, -10800 +eastern, -18000 +egypt, 7200 +ekaterinburg, 18000 +fiji, 43200 +fle, 7200 +greenland, -10800 +greenwich, 0 +gtb, 7200 +hawaiian, -36000 +india, 19800 +iran, 12600 +jerusalem, 7200 +korea, 32400 +mexico, -21600 +mid-atlantic, -7200 +mountain, -25200 +myanmar, 23400 +n. central asia, 21600 +nepal, 20700 +new zealand, 43200 +newfoundland, -12600 +north asia east, 28800 +north asia, 25200 +pacific sa, -14400 +pacific, -28800 +romance, 3600 +russian, 10800 +sa eastern, -10800 +sa pacific, -18000 +sa western, -14400 +samoa, -39600 +se asia, 25200 +malay peninsula, 28800 +south africa, 7200 +sri lanka, 21600 +taipei, 28800 +tasmania, 36000 +tokyo, 32400 +tonga, 46800 +us eastern, -18000 +us mountain, -25200 +vladivostok, 36000 +w. australia, 28800 +w. central africa, 3600 +w. europe, 3600 +west asia, 18000 +west pacific, 36000 +yakutsk, 32400 +%% Property changes on: ext/date/zonetab.list ___________________________________________________________________ Added: svn:eol-style + LF Index: ext/date/depend =================================================================== --- ext/date/depend (revision 55319) +++ ext/date/depend (revision 55320) @@ -29,6 +29,7 @@ date_parse.o: $(hdrdir)/ruby/st.h https://github.com/ruby/ruby/blob/trunk/ext/date/depend#L29 date_parse.o: $(hdrdir)/ruby/subst.h date_parse.o: $(top_srcdir)/include/ruby.h date_parse.o: date_parse.c +date_parse.o: zonetab.h date_strftime.o: $(RUBY_EXTCONF_H) date_strftime.o: $(arch_hdrdir)/ruby/config.h date_strftime.o: $(hdrdir)/ruby/backward.h Index: ext/date/prereq.mk =================================================================== --- ext/date/prereq.mk (revision 0) +++ ext/date/prereq.mk (revision 55320) @@ -0,0 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ext/date/prereq.mk#L1 +.SUFFIXES: .list + +.list.h: + gperf -E -C -P -p -j1 -i 1 -g -o -t -N $(*F) $< \ + | sed 's/(int)(long)&((\(struct stringpool_t\) *\*)0)->\(stringpool_[a-z0-9]*\)/offsetof(\1, \2)/g' \ + > $(@F) + +zonetab.h: zonetab.list Property changes on: ext/date/prereq.mk ___________________________________________________________________ Added: svn:eol-style + LF Index: ext/date/date_parse.c =================================================================== --- ext/date/date_parse.c (revision 55319) +++ ext/date/date_parse.c (revision 55320) @@ -337,88 +337,7 @@ subx(VALUE str, VALUE rep, VALUE pat, VA https://github.com/ruby/ruby/blob/trunk/ext/date/date_parse.c#L337 } #endif -struct zone { - const char *name; - int offset; -}; - -static const struct zone zones_source[] = { - {"ut", 0*3600}, {"gmt", 0*3600}, {"est", -5*3600}, {"edt", -4*3600}, - {"cst", -6*3600}, {"cdt", -5*3600}, {"mst", -7*3600}, {"mdt", -6*3600}, - {"pst", -8*3600}, {"pdt", -7*3600}, - {"a", 1*3600}, {"b", 2*3600}, {"c", 3*3600}, {"d", 4*3600}, - {"e", 5*3600}, {"f", 6*3600}, {"g", 7*3600}, {"h", 8*3600}, - {"i", 9*3600}, {"k", 10*3600}, {"l", 11*3600}, {"m", 12*3600}, - {"n", -1*3600}, {"o", -2*3600}, {"p", -3*3600}, {"q", -4*3600}, - {"r", -5*3600}, {"s", -6*3600}, {"t", -7*3600}, {"u", -8*3600}, - {"v", -9*3600}, {"w", -10*3600}, {"x", -11*3600}, {"y", -12*3600}, - {"z", 0*3600}, - - {"utc", 0*3600}, {"wet", 0*3600}, - {"at", -2*3600}, {"brst",-2*3600}, {"ndt", -(2*3600+1800)}, - {"art", -3*3600}, {"adt", -3*3600}, {"brt", -3*3600}, {"clst",-3*3600}, - {"nst", -(3*3600+1800)}, - {"ast", -4*3600}, {"clt", -4*3600}, - {"akdt",-8*3600}, {"ydt", -8*3600}, - {"akst",-9*3600}, {"hadt",-9*3600}, {"hdt", -9*3600}, {"yst", -9*3600}, - {"ahst",-10*3600},{"cat",-10*3600}, {"hast",-10*3600},{"hst",-10*3600}, - {"nt", -11*3600}, - {"idlw",-12*3600}, - {"bst", 1*3600}, {"cet", 1*3600}, {"fwt", 1*3600}, {"met", 1*3600}, - {"mewt", 1*3600}, {"mez", 1*3600}, {"swt", 1*3600}, {"wat", 1*3600}, - {"west", 1*3600}, - {"cest", 2*3600}, {"eet", 2*3600}, {"fst", 2*3600}, {"mest", 2*3600}, - {"mesz", 2*3600}, {"sast", 2*3600}, {"sst", 2*3600}, - {"bt", 3*3600}, {"eat", 3*3600}, {"eest", 3*3600}, {"msk", 3*3600}, - {"msd", 4*3600}, {"zp4", 4*3600}, - {"zp5", 5*3600}, {"ist", (5*3600+1800)}, - {"zp6", 6*3600}, - {"wast", 7*3600}, - {"cct", 8*3600}, {"sgt", 8*3600}, {"wadt", 8*3600}, - {"jst", 9*3600}, {"kst", 9*3600}, - {"east",10*3600}, {"gst", 10*3600}, - {"eadt",11*3600}, - {"idle",12*3600}, {"nzst",12*3600}, {"nzt", 12*3600}, - {"nzdt",13*3600}, - - {"afghanistan", 16200}, {"alaskan", -32400}, - {"arab", 10800}, {"arabian", 14400}, - {"arabic", 10800}, {"atlantic", -14400}, - {"aus central", 34200}, {"aus eastern", 36000}, - {"azores", -3600}, {"canada central", -21600}, - {"cape verde", -3600}, {"caucasus", 14400}, - {"cen. australia", 34200}, {"central america", -21600}, - {"central asia", 21600}, {"central europe", 3600}, - {"central european", 3600}, {"central pacific", 39600}, - {"central", -21600}, {"china", 28800}, - {"dateline", -43200}, {"e. africa", 10800}, - {"e. australia", 36000}, {"e. europe", 7200}, - {"e. south america", -10800}, {"eastern", -18000}, - {"egypt", 7200}, {"ekaterinburg", 18000}, - {"fiji", 43200}, {"fle", 7200}, - {"greenland", -10800}, {"greenwich", 0}, - {"gtb", 7200}, {"hawaiian", -36000}, - {"india", 19800}, {"iran", 12600}, - {"jerusalem", 7200}, {"korea", 32400}, - {"mexico", -21600}, {"mid-atlantic", -7200}, - {"mountain", -25200}, {"myanmar", 23400}, - {"n. central asia", 21600}, {"nepal", 20700}, - {"new zealand", 43200}, {"newfoundland", -12600}, - {"north asia east", 28800}, {"north asia", 25200}, - {"pacific sa", -14400}, {"pacific", -28800}, - {"romance", 3600}, {"russian", 10800}, - {"sa eastern", -10800}, {"sa pacific", -18000}, - {"sa western", -14400}, {"samoa", -39600}, - {"se asia", 25200}, {"malay peninsula", 28800}, - {"south africa", 7200}, {"sri lanka", 21600}, - {"taipei", 28800}, {"tasmania", 36000}, - {"tokyo", 32400}, {"tonga", 46800}, - {"us eastern", -18000}, {"us mountain", -25200}, - {"vladivostok", 36000}, {"w. australia", 28800}, - {"w. central africa", 3600}, {"w. europe", 3600}, - {"west asia", 18000}, {"west pacific", 36000}, - {"yakutsk", 32400} -}; +#include "zonetab.h" VALUE date_zone_to_diff(VALUE str) @@ -491,24 +410,12 @@ date_zone_to_diff(VALUE str) https://github.com/ruby/ruby/blob/trunk/ext/date/date_parse.c#L410 #undef DST } { - static VALUE zones = Qnil; - - if (NIL_P(zones)) { - int i; - - zones = rb_hash_new(); - rb_gc_register_mark_object(zones); - for (i = 0; i < (int)sizeof_array(zones_source); i++) { - VALUE name = rb_str_new2(zones_source[i].name); - VALUE offset = INT2FIX(zones_source[i].offset); - rb_hash_aset(zones, name, offset); - } - } - - offset = f_aref(zones, str); - if (!NIL_P(offset)) { + const struct zone *z = zonetab(RSTRING_PTR(str), (unsigned int)RSTRING_LEN(str)); + if (z) { + int d = z->offset; if (dst) - offset = f_add(offset, INT2FIX(3600)); + d += 3600; + offset = INT2FIX(d); goto ok; } } Index: ext/date/zonetab.h =================================================================== --- ext/date/zonetab.h (revision 0) +++ ext/date/zonetab.h (revision 55320) @@ -0,0 +1,902 @@ https://github.com/ruby/ruby/blob/trunk/ext/date/zonetab.h#L1 +/* C code produced by gperf version 3.0.4 */ +/* Command-line: gperf -E -C -P -p -j1 -i 1 -g -o -t -N zonetab zonetab.list */ +/* Computed positions: -k'1-4,$' */ + +#if !((' ' == 32) && ('!' == 33) && ('"' == 34) && ('#' == 35) \ + && ('%' == 37) && ('&' == 38) && ('\'' == 39) && ('(' == 40) \ + && (')' == 41) && ('*' == 42) && ('+' == 43) && (',' == 44) \ + && ('-' == 45) && ('.' == 46) && ('/' == 47) && ('0' == 48) \ + && ('1' == 49) && ('2' == 50) && ('3' == 51) && ('4' == 52) \ + && ('5' == 53) && ('6' == 54) && ('7' == 55) && ('8' == 56) \ + && ('9' == 57) && (':' == 58) && (';' == 59) && ('<' == 60) \ + && ('=' == 61) && ('>' == 62) && ('?' == 63) && ('A' == 65) \ + && ('B' == 66) && ('C' == 67) && ('D' == 68) && ('E' == 69) \ + && ('F' == 70) && ('G' == 71) && ('H' == 72) && ('I' == 73) \ + && ('J' == 74) && ('K' == 75) && ('L' == 76) && ('M' == 77) \ + && ('N' == 78) && ('O' == 79) && ('P' == 80) && ('Q' == 81) \ + && ('R' == 82) && ('S' == 83) && ('T' == 84) && ('U' == 85) \ + && ('V' == 86) && ('W' == 87) && ('X' == 88) && ('Y' == 89) \ + && ('Z' == 90) && ('[' == 91) && ('\\' == 92) && (']' == 93) \ + && ('^' == 94) && ('_' == 95) && ('a' == 97) && ('b' == 98) \ + && ('c' == 99) && ('d' == 100) && ('e' == 101) && ('f' == 102) \ + && ('g' == 103) && ('h' == 104) && ('i' == 105) && ('j' == 106) \ + && ('k' == 107) && ('l' == 108) && ('m' == 109) && ('n' == 110) \ + && ('o' == 111) && ('p' == 112) && ('q' == 113) && ('r' == 114) \ + && ('s' == 115) && ('t' == 116) && ('u' == 117) && ('v' == 118) \ + && ('w' == 119) && ('x' == 120) && ('y' == 121) && ('z' == 122) \ + && ('{' == 123) && ('|' == 124) && ('}' == 125) && ('~' == 126)) +/* The character set is not based on ISO-646. */ +error "gperf generated tables don't work with this execution character set. Please report a bug to <bug-gnu-gperf@g...>." +#endif + +#line 1 "zonetab.list" + +struct zone { + int name; + int offset; +}; +static inline const struct zone *zonetab(); +#line 9 "zonetab.list" +struct zone; +/* maximum key range = 434, duplicates = 0 */ + +#if (defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || defined(__cplusplus) || defined(__GNUC_STDC_INLINE__) +inline +#elif defined(__GNUC__) +__inline +#endif +static unsigned int +hash (str, len) + register const char *str; + register unsigned int len; +{ + static const unsigned short asso_values[] = + { + 439, 439, 439, 439, 439, 439, 439, 439, 439, 439, + 439, 439, 439, 439, 439, 439, 439, 439, 439, 439, + 439, 439, 439, 439, 439, 439, 439, 439, 439, 439, + 439, 439, 19, 439, 439, 439, 439, 439, 439, 439, + 439, 439, 439, 439, 439, 2, 4, 439, 439, 439, + 439, 439, 8, 6, 3, 439, 439, 439, 439, 439, + 439, 439, 439, 439, 439, 439, 439, 439, 439, 439, + 439, 439, 439, 439, 439, 439, 439, 439, 439, 439, + 439, 439, 439, 439, 439, 439, 439, 439, 439, 439, + 439, 439, 439, 439, 439, 439, 439, 7, 63, 53, + 2, 4, 32, 110, 88, 78, 90, 68, 47, 108, + 10, 73, 81, 124, 3, 1, 4, 77, 116, 88, + 15, 96, 45, 5, 439, 439, 439, 439, 439, 439, + 439, 439, 439, 439, 439, 439, 439, 439, 439, 439, + 439, 439, 439, 439, 439, 439, 439, 439, 439, 439, + 439, 439, 439, 439, 439, 439, 439, 439, 439, 439, + 439, 439, 439, 439, 439, 439, 439, 439, 439, 439, + 439, 439, 439, 439, 439, 439, 439, 439, 439, 439, + 439, 439, 439, 439, 439, 439, 439, 439, 439, 439, + 439, 439, 439, 439, 439, 439, 439, 439, 439, 439, + 439, 439, 439, 439, 439, 439, 439, 439, 439, 439, + 439, 439, 439, 439, 439, 439, 439, 439, 439, 439, + 439, 439, 439, 439, 439, 439, 439, 439, 439, 439, + 439, 439, 439, 439, 439, 439, 439, 439, 439, 439, + 439, 439, 439, 439, 439, 439, 439, 439, 439, 439, + 439, 439, 439, 439, 439, 439, 439 + }; + register int hval = len; + + switch (hval) + { + default: + hval += asso_values[(unsigned char)str[3]]; + /*FALLTHROUGH*/ + case 3: + hval += asso_values[(unsigned char)str[2]]; + /*FALLTHROUGH*/ + case 2: + hval += asso_values[(unsigned char)str[1]]; + /*FALLTHROUGH*/ + case 1: + hval += asso_values[(unsigned char)str[0]+1]; + break; + } + return hval + asso_values[(unsigned char)str[len - 1]]; +} + +struct stringpool_t + { + char stringpool_str5[sizeof("r")]; + char stringpool_str6[sizeof("s")]; + char stringpool_str7[sizeof("d")]; + char stringpool_str14[sizeof("cst")]; + char stringpool_str15[sizeof("cdt")]; + char stringpool_str16[sizeof("sst")]; + char stringpool_str17[sizeof("cet")]; + char stringpool_str18[sizeof("msd")]; + char stringpool_str19[sizeof("cest")]; + char stringpool_str20[sizeof("cat")]; + char stringpool_str22[sizeof("mst")]; + char stringpool_str23[sizeof("mdt")]; + char stringpool_str24[sizeof("sast")]; + char stringpool_str25[sizeof("met")]; + char stringpool_str27[sizeof("mest")]; + char stringpool_str30[sizeof("wet")]; + char stringpool_str31[sizeof("dateline")]; + char stringpool_str32[sizeof("west")]; + char stringpool_str33[sizeof("wat")]; + char stringpool_str35[sizeof("wast")]; + char stringpool_str36[sizeof("wadt")]; + char stringpool_str37[sizeof("e")]; + char stringpool_str38[sizeof("central europe")]; + char stringpool_str39[sizeof("central asia")]; + char stringpool_str40[sizeof("west asia")]; + char stringpool_str41[sizeof("cen. australia")]; + char stringpool_str42[sizeof("central america")]; + char stringpool_str44[sizeof("est")]; + char stringpool_str45[sizeof("edt")]; + char stringpool_str46[sizeof("central european")]; + char stringpool_str47[sizeof("eet")]; + char stringpool_str48[sizeof("se asia")]; + char stringpool_str49[sizeof("eest")]; + char stringpool_str50[sizeof("eat")]; + char stringpool_str51[sizeof("z")]; + char stringpool_str52[sizeof("east")]; + char stringpool_str53[sizeof("eadt")]; + char stringpool_str54[sizeof("sa eastern")]; + char stringpool_str55[sizeof("w. europe")]; + char stringpool_str56[sizeof("c")]; + char stringpool_str57[sizeof("yst")]; + char stringpool_str58[sizeof("ydt")]; + char stringpool_str59[sizeof("kst")]; + char stringpool_str60[sizeof("clt")]; + char stringpool_str61[sizeof("eastern")]; + char stringpool_str62[sizeof("clst")]; + char stringpool_str63[sizeof("bt")]; + char stringpool_str64[sizeof("w. australia")]; + char stringpool_str65[sizeof("bst")]; + char stringpool_str66[sizeof("cct")]; + char stringpool_str67[sizeof("brt")]; + char stringpool_str69[sizeof("brst")]; + char stringpool_str71[sizeof("a")]; + char stringpool_str72[sizeof("e. europe")]; + char stringpool_str73[sizeof("at")]; + char stringpool_str74[sizeof("central")]; + char stringpool_str75[sizeof("ast")]; + char stringpool_str (... truncated) -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/