From d1e2c50a0c4fc3d7b5688221b609aecc85caf29a Mon Sep 17 00:00:00 2001 From: nobu Date: Fri, 24 Jun 2016 00:17:17 +0000 Subject: 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 --- enc/unicode/case-folding.rb | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'enc/unicode/case-folding.rb') 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 -- cgit v1.2.3