ruby-changes:43419
From: nobu <ko1@a...>
Date: Fri, 24 Jun 2016 09:17:26 +0900 (JST)
Subject: [ruby-changes:43419] nobu:r55492 (trunk): Updating casefold.h
nobu 2016-06-24 09:17:17 +0900 (Fri, 24 Jun 2016) New Revision: 55492 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=55492 Log: 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. Modified files: trunk/ChangeLog trunk/common.mk trunk/enc/unicode/case-folding.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 55491) +++ ChangeLog (revision 55492) @@ -1,3 +1,15 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Fri Jun 24 09:17:15 2016 Nobuyoshi Nakada <nobu@r...> + + * 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. + Tue Jun 21 19:44:54 2016 Martin Duerst <duerst@i...> * test/ruby/enc/test_regex_casefold.rb: Add Windows-1251, KOI8-R, and Index: common.mk =================================================================== --- common.mk (revision 55491) +++ common.mk (revision 55492) @@ -807,6 +807,7 @@ all-incs: incs {$(VPATH)}encdb.h {$(VPAT https://github.com/ruby/ruby/blob/trunk/common.mk#L807 incs: $(INSNS) {$(VPATH)}node_name.inc {$(VPATH)}known_errors.inc \ {$(VPATH)}vm_call_iseq_optimized.inc $(srcdir)/revision.h \ $(REVISION_H) enc/unicode/name2ctype.h enc/jis/props.h \ + $(srcdir)/enc/unicode/casefold.h \ {$(VPATH)}id.h {$(VPATH)}probes.dmyh insns: $(INSNS) @@ -1051,9 +1052,11 @@ $(UNICODE_FILES): https://github.com/ruby/ruby/blob/trunk/common.mk#L1052 $(srcdir)/$(HAVE_BASERUBY:yes=lib/unicode_normalize/tables.rb): \ $(srcdir)/.unicode-tables.time +$(srcdir)/$(ALWAYS_UPDATE_UNICODE:yes=.unicode-tables.time): $(UNICODE_FILES) + $(srcdir)/.unicode-tables.time: $(srcdir)/tool/generic_erb.rb \ - $(UNICODE_FILES) \ $(srcdir)/template/unicode_norm_gen.tmpl + $(Q) $(ALWAYS_UPDATE_UNICODE:yes=exit &&) $(MAKE) $(MFLAGS) Q=$(Q) update-unicode $(Q) $(BASERUBY) $(srcdir)/tool/generic_erb.rb \ -c -t$@ -o $(srcdir)/lib/unicode_normalize/tables.rb \ -I $(srcdir) \ @@ -1063,12 +1066,17 @@ $(srcdir)/.unicode-tables.time: $(srcdir https://github.com/ruby/ruby/blob/trunk/common.mk#L1066 # the next non-comment line was: # $(srcdir)/enc/unicode/casefold.h: $(srcdir)/enc/unicode/case-folding.rb \ # but was changed to make sure CI works on systems that don't have gperf -unicode-up: $(srcdir)/enc/unicode/case-folding.rb \ +unicode-up: $(srcdir)/enc/unicode/casefold.h + +$(srcdir)/$(ALWAYS_UPDATE_UNICODE:yes=enc/unicode/casefold.h): \ $(UNICODE_SRC_DATA_DIR)/UnicodeData.txt \ $(UNICODE_SRC_DATA_DIR)/SpecialCasing.txt \ $(UNICODE_SRC_DATA_DIR)/CaseFolding.txt + +$(srcdir)/enc/unicode/casefold.h: $(srcdir)/enc/unicode/case-folding.rb + $(Q) $(ALWAYS_UPDATE_UNICODE:yes=exit &&) $(MAKE) $(MFLAGS) Q=$(Q) update-unicode $(Q) $(BASERUBY) $(srcdir)/enc/unicode/case-folding.rb \ - --output-file=$(srcdir)/enc/unicode/casefold.h \ + --output-file=$@ \ --mapping-data-directory=$(UNICODE_SRC_DATA_DIR) download-extlibs: Index: enc/unicode/case-folding.rb =================================================================== --- enc/unicode/case-folding.rb (revision 55491) +++ enc/unicode/case-folding.rb (revision 55492) @@ -1,4 +1,5 @@ https://github.com/ruby/ruby/blob/trunk/enc/unicode/case-folding.rb#L1 #!/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 https://github.com/ruby/ruby/blob/trunk/enc/unicode/case-folding.rb#L97 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__ https://github.com/ruby/ruby/blob/trunk/enc/unicode/case-folding.rb#L364 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 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/