diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-06-24 00:17:17 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-06-24 00:17:17 +0000 |
commit | d1e2c50a0c4fc3d7b5688221b609aecc85caf29a (patch) | |
tree | 2bb4b62f1d0c08ab4f27bf54141d185bb76525bd /enc/unicode | |
parent | 6cfe8b0e22fa15cbc04ad290b23ffe207076669e (diff) |
Updating casefold.h
* common.mk (lib/unicode_normalize/tables.rb): should not depend
on Unicode data files unless ALWAYS_UPDATE_UNICODE=yes, to get
rid of downloading Unicode data unnecessary. [ruby-dev:49681]
* common.mk (enc/unicode/casefold.h): update Unicode files in a
sub-make, not to let the header depend on the files always.
* enc/unicode/case-folding.rb: if gperf is not usable, assume the
existing file is OK.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55492 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'enc/unicode')
-rwxr-xr-x | enc/unicode/case-folding.rb | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/enc/unicode/case-folding.rb b/enc/unicode/case-folding.rb index 433ce74dfe..f6aff0b321 100755 --- a/enc/unicode/case-folding.rb +++ b/enc/unicode/case-folding.rb @@ -1,4 +1,5 @@ #!/usr/bin/ruby +require 'stringio' # Usage (for case folding only): # $ wget http://www.unicode.org/Public/UNIDATA/CaseFolding.txt @@ -96,7 +97,7 @@ class CaseFolding hash = "onigenc_unicode_#{key}_hash" lookup = "onigenc_unicode_#{key}_lookup" arity = Array(data[0][0]).size - gperf = %W"gperf -7 -k#{[*1..(arity*3)].join(",")} -F,-1 -c -j1 -i1 -t -T -E -C -H #{hash} -N #{lookup} -n" + gperf = %W"gperf -7 -k#{[*1..(arity*3)].join(',')} -F,-1 -c -j1 -i1 -t -T -E -C -H #{hash} -N #{lookup} -n" argname = arity > 1 ? "codes" : "code" argdecl = "const OnigCodePoint #{arity > 1 ? "*": ""}#{argname}" n = 7 @@ -363,11 +364,21 @@ if $0 == __FILE__ data.debug! mapping_data.debug! end + f = StringIO.new + begin + data.display(f, mapping_data) + rescue Errno::ENOENT => e + raise unless /gperf/ =~ e.message + warn e.message + exit dest && File.file?(dest) # assume existing file is OK + else + s = f.string + end if dest open(dest, "wb") do |f| - data.display(f, mapping_data) + f.print(s) end else - data.display(STDOUT, mapping_data) + STDOUT.print(s) end end |