ruby-changes:48957
From: nobu <ko1@a...>
Date: Fri, 8 Dec 2017 14:51:25 +0900 (JST)
Subject: [ruby-changes:48957] nobu:r61076 (trunk): support gperf 3.1
nobu 2017-12-08 14:51:19 +0900 (Fri, 08 Dec 2017) New Revision: 61076 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=61076 Log: support gperf 3.1 * tool/gperf.sed: extracted sed commands to a script. ANSI-C code produced by gperf 3.1 declares length arguments as `size_t`. it causes conflict with existing declarations, and needs casts for a local variable and return statements. [Feature #13883] Added files: trunk/tool/gperf.sed Modified files: trunk/Makefile.in trunk/defs/keywords trunk/defs/lex.c.src trunk/enc/jis/props.h.blt trunk/enc/jis/props.kwd trunk/enc/jis/props.src trunk/enc/unicode/10.0.0/name2ctype.h trunk/ext/date/prereq.mk trunk/ext/date/zonetab.h trunk/ext/io/console/depend trunk/ext/io/console/win32_vk.inc trunk/ext/io/console/win32_vk.list trunk/lex.c.blt trunk/tool/enc-unicode.rb Index: tool/enc-unicode.rb =================================================================== --- tool/enc-unicode.rb (revision 61075) +++ tool/enc-unicode.rb (revision 61076) @@ -449,7 +449,9 @@ struct uniname2ctype_struct { https://github.com/ruby/ruby/blob/trunk/tool/enc-unicode.rb#L449 }; #define uniname2ctype_offset(str) offsetof(struct uniname2ctype_pool_t, uniname2ctype_pool_##str) +#if !(/*ANSI*/+0) static const struct uniname2ctype_struct *uniname2ctype_p(const char *, unsigned int); +#endif %} struct uniname2ctype_struct; %% @@ -536,10 +538,17 @@ if header https://github.com/ruby/ruby/blob/trunk/tool/enc-unicode.rb#L538 fds.each(&:close) IO.popen(%W[diff -DUSE_UNICODE_AGE_PROPERTIES #{fds[1].path} #{fds[0].path}], "r") {|age| IO.popen(%W[diff -DUSE_UNICODE_PROPERTIES #{fds[2].path} -], "r", in: age) {|f| + ansi = false f.each {|line| + if /ANSI-C code produced by gperf/ =~ line + ansi = true + end + line.sub!(/\/\*ANSI\*\//, '1') if ansi line.gsub!(/\(int\)\((?:long|size_t)\)&\(\(struct uniname2ctype_pool_t \*\)0\)->uniname2ctype_pool_(str\d+),\s+/, 'uniname2ctype_offset(\1), ') - line.sub!(/^(uniname2ctype_(hash|p) *\(.* )size_t /, '\1unsigned int ') + if (/^(uniname2ctype_hash) /=~line)..(/^\}/=~line) + line.sub!(/^( *(?:register\s+)?(.*\S)\s+hval\s*=\s*)(?=len;)/, '\1(\2)') + end puts line } } Index: tool/gperf.sed =================================================================== --- tool/gperf.sed (nonexistent) +++ tool/gperf.sed (revision 61076) @@ -0,0 +1,22 @@ https://github.com/ruby/ruby/blob/trunk/tool/gperf.sed#L1 +/ANSI-C code/{ + h + s/.*/ANSI:offset:/ + x +} +/^\/\*!ANSI\*\//{ + G + s/^\/\*!ANSI\*\/\(.*\)\nANSI:.*/\/\*\1\*\// +} +s/(int)([a-z_]*)&((struct \([a-zA-Z_0-9][a-zA-Z_0-9]*\)_t *\*)0)->\1_str\([1-9][0-9]*\),/gperf_offsetof(\1, \2),/g +/^#line/{ + G + x + s/:offset:/:/ + x + s/\(.*\)\(\n\).*:offset:.*/#define gperf_offsetof(s, n) (short)offsetof(struct s##_t, s##_str##n)\2\1/ + s/\n[^#].*// +} +/^[a-zA-Z_0-9]*hash/,/^}/{ + s/ hval = / hval = (unsigned int)/ + s/ return / return (unsigned int)/ +} Property changes on: tool/gperf.sed ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +LF \ No newline at end of property Index: Makefile.in =================================================================== --- Makefile.in (revision 61075) +++ Makefile.in (revision 61076) @@ -345,7 +345,7 @@ lex.c: defs/keywords https://github.com/ruby/ruby/blob/trunk/Makefile.in#L345 else \ [ $(Q) ] && echo generating $@ || set -x; \ gperf -C -P -p -j1 -i 1 -g -o -t -N rb_reserved_word -k1,3,$$ $? \ - | sed 's/(long)&((\(struct stringpool_t\) *\*)0)->\(stringpool_[a-z0-9]*\)/offsetof(\1, \2)/g' \ + | sed -f $(srcdir)/tool/gperf.sed \ > $@.tmp && \ $(MV) $@.tmp $@ && \ $(CP) $? $(srcdir)/defs/lex.c.src && \ @@ -363,7 +363,7 @@ $(srcdir)/enc/jis/props.h: enc/jis/props https://github.com/ruby/ruby/blob/trunk/Makefile.in#L363 else \ set -x; \ gperf $(JIS_PROPS_OPTIONS) $? | \ - sed 's/(int)(long)&((\([a-zA-Z_0-9 ]*[a-zA-Z_0-9]\) *\*)0)->\([a-zA-Z0-9_]*\),/(char)offsetof(\1, \2),/g' > $@ && \ + sed -f $(srcdir)/tool/gperf.sed > $@ && \ $(CP) $? $(?:.kwd=.src) && \ $(CP) $@ $(?:.kwd=.h.blt); \ fi Index: ext/date/zonetab.h =================================================================== --- ext/date/zonetab.h (revision 61075) +++ ext/date/zonetab.h (revision 61076) @@ -1,4 +1,4 @@ https://github.com/ruby/ruby/blob/trunk/ext/date/zonetab.h#L1 -/* C code produced by gperf version 3.0.4 */ +/* ANSI-C code produced by gperf version 3.1 */ /* Command-line: gperf -E -C -c -P -p -j1 -i 1 -g -o -t -N zonetab zonetab.list */ /* Computed positions: -k'1-4,$' */ @@ -26,9 +26,10 @@ https://github.com/ruby/ruby/blob/trunk/ext/date/zonetab.h#L26 && ('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...>." +#error "gperf generated tables don't work with this execution character set. Please report a bug to <bug-gperf@g...>." #endif +#define gperf_offsetof(s, n) (short)offsetof(struct s##_t, s##_str##n) #line 1 "zonetab.list" struct zone { @@ -40,15 +41,15 @@ static const struct zone *zonetab(); https://github.com/ruby/ruby/blob/trunk/ext/date/zonetab.h#L41 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__) +#ifdef __GNUC__ __inline +#else +#ifdef __cplusplus +inline +#endif #endif static unsigned int -hash (str, len) - register const char *str; - register unsigned int len; +hash (register const char *str, register size_t len) { static const unsigned short asso_values[] = { @@ -79,7 +80,7 @@ hash (str, len) https://github.com/ruby/ruby/blob/trunk/ext/date/zonetab.h#L80 439, 439, 439, 439, 439, 439, 439, 439, 439, 439, 439, 439, 439, 439, 439, 439, 439 }; - register int hval = len; + register unsigned int hval = (unsigned int)len; switch (hval) { @@ -96,7 +97,7 @@ hash (str, len) https://github.com/ruby/ruby/blob/trunk/ext/date/zonetab.h#L97 hval += asso_values[(unsigned char)str[0]+1]; break; } - return hval + asso_values[(unsigned char)str[len - 1]]; + return (unsigned int)hval + asso_values[(unsigned char)str[len - 1]]; } struct stringpool_t @@ -446,16 +447,8 @@ static const struct stringpool_t stringp https://github.com/ruby/ruby/blob/trunk/ext/date/zonetab.h#L447 "fiji" }; #define stringpool ((const char *) &stringpool_contents) -#ifdef __GNUC__ -__inline -#if defined __GNUC_STDC_INLINE__ || defined __GNUC_GNU_INLINE__ -__attribute__ ((__gnu_inline__)) -#endif -#endif const struct zone * -zonetab (str, len) - register const char *str; - register unsigned int len; +zonetab (register const char *str, register size_t len) { enum { @@ -470,398 +463,398 @@ zonetab (str, len) https://github.com/ruby/ruby/blob/trunk/ext/date/zonetab.h#L463 { {-1}, {-1}, {-1}, {-1}, {-1}, #line 37 "zonetab.list" - {offsetof(struct stringpool_t, stringpool_str5), -5*3600}, + {gperf_offsetof(stringpool, 5), -5*3600}, #line 38 "zonetab.list" - {offsetof(struct stringpool_t, stringpool_str6), -6*3600}, + {gperf_offsetof(stringpool, 6), -6*3600}, #line 24 "zonetab.list" - {offsetof(struct stringpool_t, stringpool_str7), 4*3600}, + {gperf_offsetof(stringpool, 7), 4*3600}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, #line 15 "zonetab.list" - {offsetof(struct stringpool_t, stringpool_str14), -6*3600}, + {gperf_offsetof(stringpool, 14), -6*3600}, #line 16 "zonetab.list" - {offsetof(struct stringpool_t, stringpool_str15), -5*3600}, + {gperf_offsetof(stringpool, 15), -5*3600}, #line 85 "zonetab.list" - {offsetof(struct stringpool_t, stringpool_str16), 2*3600}, + {gperf_offsetof(stringpool, 16), 2*3600}, #line 71 "zonetab.list" - {offsetof(struct stringpool_t, stringpool_str17), 1*3600}, + {gperf_offsetof(stringpool, 17), 1*3600}, #line 90 "zonetab.list" - {offsetof(struct stringpool_t, stringpool_str18), 4*3600}, + {gperf_offsetof(stringpool, 18), 4*3600}, #line 79 "zonetab.list" - {offsetof(struct stringpool_t, stringpool_str19), 2*3600}, + {gperf_offsetof(stringpool, 19), 2*3600}, #line 65 "zonetab.list" - {offsetof(struct stringpool_t, stringpool_str20),-10*3600}, + {gperf_offsetof(stringpool, 20),-10*3600}, {-1}, #line 17 "zonetab.list" - {offsetof(struct stringpool_t, stringpool_str22), -7*3600}, + {gperf_offsetof(stringpool, 22), -7*3600}, #line 18 "zonetab.list" - {offsetof(struct stringpool_t, stringpool_str23), -6*3600}, + {gperf_offsetof(stringpool, 23), -6*3600}, #line 84 "zonetab.list" - {offsetof(struct stringpool_t, stringpool_str24), 2*3600}, + {gperf_offsetof(stringpool, 24), 2*3600}, #line 73 "zonetab.list" - {offsetof(struct stringpool_t, stringpool_str25), 1*3600}, + {gperf_offsetof(stringpool, 25), 1*3600}, {-1}, #line 82 "zonetab.list" - {offsetof(struct stringpool_t, stringpool_str27), 2*3600}, + {gperf_offsetof(stringpool, 27), 2*3600}, {-1}, {-1}, #line 47 "zonetab.list" - {offsetof(struct stringpool_t, stringpool_str30), 0*3600}, + {gperf_offsetof(stringpool, 30), 0*3600}, #line 128 "zonetab.list" - {offsetof(struct stringpool_t, stringpool_str31), -43200}, + {gperf_offsetof(stringpool, 31), -43200}, #line 78 "zonetab.list" - {offsetof(struct stringpool_t, stringpool_str32), 1*3600}, + {gperf_offsetof(stringpool, 32), 1*3600}, #line 77 "zonetab.list" - {offsetof(struct stringpool_t, stringpool_str33), 1*3600}, + {gperf_offsetof(stringpool, 33), 1*3600}, {-1}, #line 95 "zonetab.list" - {offsetof(struct stringpool_t, stringpool_str35), 7*3600}, + {gperf_offsetof(stringpool, 35), 7*3600}, #line 98 "zonetab.list" - {offsetof(struct stringpool_t, stringpool_str36), 8*3600}, + {gperf_offsetof(stringpool, 36), 8*3600}, #line 25 "zonetab.list" - {offsetof(struct stringpool_t, stringpool_str37), 5*3600}, + {gperf_offsetof(stringpool, 37), 5*3600}, #line 123 "zonetab.list" - {offsetof(struct stringpool_t, stringpool_str38), 3600}, + {gperf_offsetof(stringpool, 38), 3600}, #line 122 "zonetab.list" - {offsetof(struct stringpool_t, stringpool_str39), 21600}, + {gperf_offsetof(stringpool, 39), 21600}, #line 178 "zonetab.list" - {offsetof(struct stringpool_t, stringpool_str40), 18000}, + {gperf_offsetof(stringpool, 40), 18000}, #line 120 "zonetab.list" - {offsetof(struct stringpool_t, stringpool_str41), 34200}, + {gperf_offsetof(stringpool, 41), 34200}, #line 121 "zonetab.list" - {offsetof(struct stringpool_t, stringpool_str42), -21600}, + {gperf_offsetof(stringpool, 42), -21600}, {-1}, #line 13 "zonetab.list" - {offsetof(struct stringpool_t, stringpool_str44), -5*3600}, + {gperf_offsetof(stringpool, 44), -5*3600}, #line 14 "zonetab.list" - {offsetof(struct stringpool_t, stringpool_str45), -4*3600}, + {gperf_offsetof(stringpool, 45), -4*3600}, #line 124 "zonetab.list" - {offsetof(struct stringpool_t, stringpool_str46), 3600}, + {gperf_offsetof(stringpool, 46), 3600}, #line 80 "zonetab.list" - {offsetof(struct stringpool_t, stringpool_str47), 2*3600}, + {gperf_offsetof(stringpool, 47), 2*3600}, #line 164 "zonetab.list" - {offsetof(struct stringpool_t, stringpool_str48), 25200}, + {gperf_offsetof(stringpool, 48), 25200}, #line 88 "zonetab.list" - {offsetof(struct stringpool_t, stringpool_str49), 3*3600}, + {gperf_offsetof(stringpool, 49), 3*3600}, #line 87 "zonetab.list" - {offsetof(struct stringpool_t, stringpool_str50), 3*3600}, + {gperf_offsetof(stringpool, 50), 3*3600}, #line 45 "zonetab.list" - {offsetof(struct stringpool_t, stringpool_str51), 0*3600}, + {gperf_offsetof(stringpool, 51), 0*3600}, #line 101 "zonetab.list" - {offsetof(struct stringpool_t, stringpool_str52),10*3600}, + {gperf_offsetof(stringpool, 52),10*3600}, #line 103 "zonetab.list" - {offsetof(struct stringpool_t, stringpool_str53),11*3600}, + {gperf_offsetof(stringpool, 53),11*3600}, #line 160 "zonetab.list" - {offsetof(struct stringpool_t, stringpool_str54), -10800}, + {gperf_offsetof(stringpool, 54), -10800}, #line 177 "zonetab.list" - {offsetof(struct stringpool_t, stringpool_str55), 3600}, + {gperf_offsetof(stringpool, 55), 3600}, #line 23 "zonetab.list" - {offsetof(struct stringpool_t, stringpool_str56), 3*3600}, + {gperf_offsetof(stringpool, 56), 3*3600}, #line 63 "zonetab.list" - {offsetof(struct stringpool_t, stringpool_str57), -9*3600}, + {gperf_offsetof(stringpool, 57), -9*3600}, #line 59 "zonetab.list" - {offsetof(struct stringpool_t, stringpool_str58), -8*3600}, + {gperf_offsetof(stringpool, 58), -8*3600}, #line 100 "zonetab.list" - {offsetof(struct stringpool_t, stringpool_str59), 9*3600}, + {gperf_offsetof(stringpool, 59), 9*3600}, #line 57 "zonetab.list" - {offsetof(struct stringpool_t, stringpool_str60), -4*3600}, + {gperf_offsetof(stringpool, 60), -4*3600}, #line 133 "zonetab.list" - {offsetof(struct stringpool_t, stringpool_str61), -18000}, + {gperf_offsetof(stringpool, 61), -18000}, #line 54 "zonetab.list" - {offsetof(struct stringpool_t, stringpool_str62),-3*3600}, + {gperf_offsetof(stringpool, 62),-3*3600}, #line 86 "zonetab.list" - {offsetof(struct stringpool_t, stringpool_str63), 3*3600}, + {gperf_offsetof(stringpool, 63), 3*3600}, #line 175 "zonetab.list" - {offsetof(struct stringpool_t, stringpool_str64), 28800}, + {gperf_offsetof(stringpool, 64), 28800}, #line 70 "zonetab.list" - {offsetof(struct stringpool_t, stringpool_str65), 1*3600}, + {gperf_offsetof(stringpool, 65), 1*3600}, #line 96 "zonetab.list" - {offsetof(struct stringpool_t, stringpool_str66), 8*3600}, + {gperf_offsetof(stringpool, 66), 8*3600}, #line 53 "zonetab.list" - {offsetof(struct stringpool_t, stringpool_str67), -3*3600}, + {gperf_offsetof(stringpool, 67), -3*3600}, {-1}, #line 49 "zonetab.list" - {offsetof(struct stringpool_t, stringpool_str69),-2*3600}, + {gperf_offsetof(stringpool, 69),-2*3600}, {-1}, #line 21 "zonetab.list" - {offsetof(struct stringpool_t, stringpool_str71), 1*3600}, + {gperf_offsetof(stringpool, 71), 1*3600}, #line 131 "zonetab.list" - {offsetof(struct stringpool_t, stringpool_str72), 7200}, + {gperf_offsetof(stringpool, 72), 7200}, #line 48 "zonetab.list" - {offsetof(struct stringpool_t, stringpool_str73), -2*3600}, + {gperf_offsetof(stringpool, 73), -2*3600}, #line 126 "zonetab.list" - {offsetof(struct stringpool_t, stringpool_str74), -21600}, + {gperf_offsetof(stringpool, 74), -21600}, #line 56 "zonetab.list" - {offsetof(struct stringpool_t, stringpool_str75), -4*3600}, + {gperf_offsetof(stringpool, 75), -4*3600}, #line 52 "zonetab.list" - {offsetof(struct stringpool_t, stringpool_str76), -3*3600}, + {gperf_offsetof(stringpool, 76), -3*3600}, #line 51 "zonetab.list" - {offsetof(struct stringpool_t, stringpool_str77), -3*3600}, + {gperf_offsetof(stringpool, 77), -3*3600}, #line 129 "zonetab.list" - {offsetof(struct stringpool_t, stringpool_str78), 10800}, + {gperf_offsetof(stringpool, 78), 10800}, #line 132 "zonetab.list" - {offsetof(struct stringpool_t, stringpool_str79), -10800}, + {gperf_offsetof(stringpool, 79), -10800}, #line 99 "zonetab.list" - {offsetof(struct stringpool_t, stringpool_str80), 9*3600}, + {gperf_offsetof(stringpool, 80), 9*3600}, #line 130 "zonetab.list" - {offsetof(struct stringpool_t, stringpool_str81), 36000}, + {gperf_offsetof(stringpool, 81), 36000}, #line 39 "zonetab.list" - {offsetof(struct stringpool_t, stringpool_str82), -7*3600}, + {gperf_offsetof(stringpool, 82), -7*3600}, #line 68 "zonetab.list" - {offsetof(struct stringpool_t, stringpool_str83), -11*3600}, + {gperf_offsetof(stringpool, 83), -11*3600}, #line 33 "zonetab.list" - {offsetof(struct stringpool_t, stringpool_str84), -1*3600}, + {gperf_offsetof(stringpool, 84), -1*3600}, #line 55 "zonetab.list" - {offsetof(struct stringpool_t, stringpool_str85), -(3*3600+1800)}, + {gperf_offsetof(stringpool, 85), -(3*3600+1800)}, #line 50 "zonetab.list" - {offsetof(struct stringpool_t, stringpool_str86), -(2*3600+1800)}, + {gperf_offsetof(stringpool, 86), -(2*3600+1800)}, #line 117 "zonetab.list" - {offsetof(struct stringpool_t, stringpool_str87), -21600}, + {gperf_offsetof(stringpool, 87), -21600}, #line 125 "zonetab.list" - {offsetof(struct stringpool_t, stringpool_str88), 39600}, + {gperf_offsetof(stringpool, 88), 39600}, #line 179 "zonetab.list" - {offsetof(struct stringpool_t, stringpool_str89), 36000}, + {gperf_offsetof(stringpool, 89), 36000}, #line 67 "zonetab.list" - {offsetof(struct stringpool_t, stringpool_str90),-10*3600}, + {gperf_offsetof(stringpool, 90),-10*3600}, #line 62 "zonetab.list" - {offsetof(struct stringpool_t, stringpool_str91), -9*3600}, + {gperf_offsetof(stringpool, 91), -9*3600}, {-1}, #line 165 "zonetab.list" - {offsetof(struct stringpool_t, stringpool_str93), 28800}, + {gperf_offsetof(stringpool, 93), 28800}, {-1}, #line 94 "zonetab.list" - {offsetof(struct stringpool_t, stringpool_str95), 6*3600}, + {gperf_offsetof(stringpool, 95), 6*3600}, {-1}, #line 159 "zonetab.list" - {offsetof(struct stringpool_t, stringpool_str97), 10800}, + {gperf_offsetof(stringpool, 97), 10800}, #line 66 "zonetab.list" - {offsetof(struct stringpool_t, stringpool_str98),-10*3600}, + {gperf_offsetof(stringpool, 98),-10*3600}, #line 61 "zonetab.list" - {offsetof(struct stringpool_t, stringpool_str99),-9*3600}, + {gperf_offsetof(stringpool, 99),-9*3600}, #line 102 "zonetab.list" - {offsetof(struct stringpool_t, stringpool_str100), 10*3600}, + {gperf_offsetof(stringpool, 100), 10*3600}, #line 92 "zonetab.list" - {offsetof(struct stringpool_t, stringpool_str101), 5*3600}, + {gperf_offsetof(stringpool, 101), 5*3600}, #line 93 "zonetab.list" - {offsetof(struct stringpool_t, stringpool_str102), (5*3600+1800)}, + {gperf_offsetof(stringpool, 102), (5*3600+1800)}, #line 76 "zonetab.list" - {offsetof(struct stringpool_t, stringpool_str103), 1*3600}, + {gperf_offsetof(stringpool, 103), 1*3600}, #line 42 "zonetab.list" - {offsetof(struct stringpool_t, stringpool_str104), -10*3600}, + {gperf_offsetof(stringpool, 104), -10*3600}, #line 91 "zonetab.list" - {offsetof(struct stringpool_t, stringpool_str105), 4*3600}, + {gperf_offsetof(stringpool, 105), 4*3600}, {-1}, #line 75 "zonetab.list" - {offsetof(struct stringpool_t, stringpool_str107), 1*3600}, + {gperf_offsetof(stringpool, 107), 1*3600}, #line 118 "zonetab.list" - {offsetof(struct stringpool_t, stringpool_str108), -3600}, + {gperf_offsetof(stringpool, 108), -3600}, #line 83 "zonetab.list" - {offsetof(struct stringpool_t, stringpool_str109), 2*3600}, + {gperf_offsetof(stringpool, 109), 2*3600}, #line 138 "zonetab.list" - {offsetof(struct stringpool_t, stringpool_str110), -10800}, + {gperf_offsetof(stringpool, 110), -10800}, {-1}, #line 43 "zonetab.list" - {offsetof(struct stringpool_t, stringpool_str112), -11*3600}, + {gperf_offsetof(stringpool, 112), -11*3600}, {-1}, #line 74 "zonetab.list" - {offsetof(struct stringpool_t, stringpool_ (... truncated) -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/