aboutsummaryrefslogtreecommitdiffstats
path: root/tool
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-12-08 05:51:19 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-12-08 05:51:19 +0000
commita4804fbdf503a9c2b550b877120ca4029c65cdb3 (patch)
tree2a354e79dbe773294347b7123701720a9b1bbb60 /tool
parentf8659dfd94d3f05f365996c68f2f1a78b1e7cbe3 (diff)
downloadruby-a4804fbdf503a9c2b550b877120ca4029c65cdb3.tar.gz
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] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61076 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'tool')
-rwxr-xr-xtool/enc-unicode.rb11
-rw-r--r--tool/gperf.sed22
2 files changed, 32 insertions, 1 deletions
diff --git a/tool/enc-unicode.rb b/tool/enc-unicode.rb
index 50fa07e7c9..2ba0b73606 100755
--- a/tool/enc-unicode.rb
+++ b/tool/enc-unicode.rb
@@ -449,7 +449,9 @@ struct uniname2ctype_struct {
};
#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
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
}
}
diff --git a/tool/gperf.sed b/tool/gperf.sed
new file mode 100644
index 0000000000..ed2196fee4
--- /dev/null
+++ b/tool/gperf.sed
@@ -0,0 +1,22 @@
+/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)/
+}