From 5cbe9fe5c4c1a8f9a077663cd3e754dc89b39b59 Mon Sep 17 00:00:00 2001 From: duerst Date: Sun, 7 Feb 2016 02:44:14 +0000 Subject: [PATCH] * enc/unicode/case-folding.rb: New classes CaseMapping/CaseMappingDummy to pass as parameters; not yet implemented or used. (with Kimihito Matsui) git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53764 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 7 +++---- enc/unicode/case-folding.rb | 37 +++++++++++++++++++++++++++++-------- 2 files changed, 32 insertions(+), 12 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5bb7d30863..3a17d0d99c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,8 +1,7 @@ -Sun Feb 7 11:16:00 2016 Martin Duerst +Sun Feb 7 11:44:03 2016 Martin Duerst - * common.mk: using new option in recipe for enc/unicode/casefold.h - - * enc/unicode/case-folding.rb: Correctly specify argument to new option. + * enc/unicode/case-folding.rb: New classes CaseMapping/CaseMappingDummy + to pass as parameters; not yet implemented or used. (with Kimihito Matsui) Sun Feb 7 10:43:27 2016 Martin Duerst diff --git a/enc/unicode/case-folding.rb b/enc/unicode/case-folding.rb index 6f801cca84..68275c7ad9 100755 --- a/enc/unicode/case-folding.rb +++ b/enc/unicode/case-folding.rb @@ -85,7 +85,7 @@ class CaseFolding "#{code} <= MAX_CODE_VALUE && #{code} >= MIN_CODE_VALUE" end - def lookup_hash(key, type, data) + def lookup_hash(key, type, data, mapping_data) hash = "onigenc_unicode_#{key}_hash" lookup = "onigenc_unicode_#{key}_lookup" arity = Array(data[0][0]).size @@ -140,7 +140,7 @@ class CaseFolding src end - def display(dest) + def display(dest, mapping_data) # print the header dest.print("/* DO NOT EDIT THIS FILE. */\n") dest.print("/* Generated by enc/unicode/case-folding.rb */\n\n") @@ -150,24 +150,24 @@ class CaseFolding # CaseFold + CaseFold_Locale name = "CaseFold_11" data = print_table(dest, name, "CaseFold"=>fold, "CaseFold_Locale"=>fold_locale) - dest.print lookup_hash(name, "CodePointList3", data) + dest.print lookup_hash(name, "CodePointList3", data, mapping_data) # print unfolding data # CaseUnfold_11 + CaseUnfold_11_Locale name = "CaseUnfold_11" data = print_table(dest, name, name=>unfold[0], "#{name}_Locale"=>unfold_locale[0]) - dest.print lookup_hash(name, "CodePointList3", data) + dest.print lookup_hash(name, "CodePointList3", data, mapping_data) # CaseUnfold_12 + CaseUnfold_12_Locale name = "CaseUnfold_12" data = print_table(dest, name, name=>unfold[1], "#{name}_Locale"=>unfold_locale[1]) - dest.print lookup_hash(name, "CodePointList2", data) + dest.print lookup_hash(name, "CodePointList2", data, mapping_data) # CaseUnfold_13 name = "CaseUnfold_13" data = print_table(dest, name, name=>unfold[2]) - dest.print lookup_hash(name, "CodePointList2", data) + dest.print lookup_hash(name, "CodePointList2", data, mapping_data) end def self.load(*args) @@ -175,6 +175,25 @@ class CaseFolding end end +class CaseMapping + def initialize (mapping_directory) + end + + def mapping_flags(from) + "" # preliminary implementation + end + + def self.load(*args) + new(*args) + end +end + +class CaseMappingDummy + def mapping_flags(from) + "" + end +end + if $0 == __FILE__ require 'optparse' dest = nil @@ -198,15 +217,17 @@ if $0 == __FILE__ exit end filename = File.expand_path("CaseFolding.txt", mapping_directory) + mapping_data = CaseMapping.load(mapping_directory) end filename ||= ARGV[0] || 'CaseFolding.txt' + mapping_data ||= CaseMappingDummy.new data = CaseFolding.load(filename) if dest open(dest, "wb") do |f| - data.display(f) + data.display(f, mapping_data) end else - data.display(STDOUT) + data.display(STDOUT, mapping_data) end end