[前][次][番号順一覧][スレッド一覧]

ruby-changes:41690

From: duerst <ko1@a...>
Date: Sun, 7 Feb 2016 11:44:09 +0900 (JST)
Subject: [ruby-changes:41690] duerst:r53764 (trunk): * enc/unicode/case-folding.rb: New classes CaseMapping/CaseMappingDummy

duerst	2016-02-07 11:44:14 +0900 (Sun, 07 Feb 2016)

  New Revision: 53764

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=53764

  Log:
    * enc/unicode/case-folding.rb: New classes CaseMapping/CaseMappingDummy
      to pass as parameters; not yet implemented or used.
    (with Kimihito Matsui)

  Modified files:
    trunk/ChangeLog
    trunk/enc/unicode/case-folding.rb
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 53763)
+++ ChangeLog	(revision 53764)
@@ -1,8 +1,7 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
-Sun Feb  7 11:16:00 2016  Martin Duerst  <duerst@i...>
+Sun Feb  7 11:44:03 2016  Martin Duerst  <duerst@i...>
 
-	* 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  <duerst@i...>
Index: enc/unicode/case-folding.rb
===================================================================
--- enc/unicode/case-folding.rb	(revision 53763)
+++ enc/unicode/case-folding.rb	(revision 53764)
@@ -85,7 +85,7 @@ class CaseFolding https://github.com/ruby/ruby/blob/trunk/enc/unicode/case-folding.rb#L85
     "#{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 https://github.com/ruby/ruby/blob/trunk/enc/unicode/case-folding.rb#L140
     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 https://github.com/ruby/ruby/blob/trunk/enc/unicode/case-folding.rb#L150
     # 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 https://github.com/ruby/ruby/blob/trunk/enc/unicode/case-folding.rb#L175
   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__ https://github.com/ruby/ruby/blob/trunk/enc/unicode/case-folding.rb#L217
       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

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]