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

ruby-changes:41759

From: duerst <ko1@a...>
Date: Mon, 15 Feb 2016 14:43:37 +0900 (JST)
Subject: [ruby-changes:41759] duerst:r53833 (trunk): * enc/unicode/case-folding.rb: Added debugging option

duerst	2016-02-15 14:43:55 +0900 (Mon, 15 Feb 2016)

  New Revision: 53833

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

  Log:
    * enc/unicode/case-folding.rb: Added debugging option
      (with Kimihito Matsui)

  Modified files:
    trunk/ChangeLog
    trunk/enc/unicode/case-folding.rb
Index: enc/unicode/case-folding.rb
===================================================================
--- enc/unicode/case-folding.rb	(revision 53832)
+++ enc/unicode/case-folding.rb	(revision 53833)
@@ -8,6 +8,7 @@ https://github.com/ruby/ruby/blob/trunk/enc/unicode/case-folding.rb#L8
 #   $ wget http://www.unicode.org/Public/UNIDATA/UnicodeData.txt
 #   $ wget http://www.unicode.org/Public/UNIDATA/SpecialCasing.txt
 #   $ ruby case-folding.rb -m . -o casefold.h
+# using -d or --debug will include UTF-8 characters in comments for debugging
 
 class CaseFolding
   module Util
@@ -20,7 +21,10 @@ class CaseFolding https://github.com/ruby/ruby/blob/trunk/enc/unicode/case-folding.rb#L21
     def print_table_1(dest, type, mapping_data, data)
       for k, v in data = data.sort
         sk = (Array === k and k.length > 1) ? "{#{hex_seq(k)}}" : ("0x%04x" % k)
-        dest.print("  {#{sk}, {#{v.length}#{mapping_data.flags(k, type, v)}, {#{hex_seq(v)}}}},\n")
+        ck = cv = ''
+        ck = ' /* ' + Array(k).pack("U*") + ' */' if @debug
+        cv = ' /* ' + Array(v).map{|c|[c].pack("U*")}.join(", ") + ' */' if @debug
+        dest.print("  {#{sk}#{ck}, {#{v.length}#{mapping_data.flags(k, type, v)}, {#{hex_seq(v)}#{cv}}}},\n")
       end
       data
     end
@@ -47,6 +51,7 @@ class CaseFolding https://github.com/ruby/ruby/blob/trunk/enc/unicode/case-folding.rb#L51
 
     @fold = fold = {}
     @unfold = unfold = [{}, {}, {}]
+    @debug = false
     turkic = []
 
     IO.foreach(filename) do |line|
@@ -172,6 +177,10 @@ class CaseFolding https://github.com/ruby/ruby/blob/trunk/enc/unicode/case-folding.rb#L177
     dest.print lookup_hash(name, "CodePointList2", data)
   end
 
+  def debug!
+    @debug = true
+  end
+
   def self.load(*args)
     new.load(*args)
   end
@@ -237,6 +246,7 @@ if $0 == __FILE__ https://github.com/ruby/ruby/blob/trunk/enc/unicode/case-folding.rb#L246
   dest = nil
   mapping_directory = nil
   mapping_data = nil
+  debug = false
   fold_1 = false
   ARGV.options do |opt|
     opt.banner << " [INPUT]"
@@ -246,6 +256,9 @@ if $0 == __FILE__ https://github.com/ruby/ruby/blob/trunk/enc/unicode/case-folding.rb#L256
     opt.on('--mapping-data-directory=DIRECTORY', '-m', 'data DIRECTORY of mapping files') { |directory|
       mapping_directory = directory
     }
+    opt.on('--debug', '-d') {
+      debug = true
+    }
     opt.parse!
     abort(opt.to_s) if ARGV.size > 1
   end
@@ -261,6 +274,7 @@ if $0 == __FILE__ https://github.com/ruby/ruby/blob/trunk/enc/unicode/case-folding.rb#L274
   mapping_data ||= CaseMappingDummy.new
 
   data = CaseFolding.load(filename)
+  data.debug! if debug
   if dest
     open(dest, "wb") do |f|
       data.display(f, mapping_data)
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 53832)
+++ ChangeLog	(revision 53833)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Mon Feb 15 14:43:28 2016  Martin Duerst  <duerst@i...>
+
+	* enc/unicode/case-folding.rb: Added debugging option
+	  (with Kimihito Matsui)
+
 Sun Feb 14 17:31:50 2016  Lars Kanis  <lars@g...>
 
 	* lib/mkmf.rb (with_{cpp,c,ld}flags): copy caller strings not to
@@ -87,7 +92,7 @@ Mon Feb  8 20:43:57 2016  Martin Duerst https://github.com/ruby/ruby/blob/trunk/ChangeLog#L92
 
 	* string.c, enc/unicode.c: Disassociating ONIGENC_CASE_FOLD flag from
 	  ONIGENC_CASE_DOWNCASE.
-	(with Kimihito Matsui)
+	  (with Kimihito Matsui)
 
 Mon Feb  8 13:00:17 2016  Martin Duerst  <duerst@i...>
 
@@ -133,7 +138,6 @@ Sun Feb  7 11:44:03 2016  Martin Duerst https://github.com/ruby/ruby/blob/trunk/ChangeLog#L138
 	  to pass as parameters; not yet implemented or used.
 	(with Kimihito Matsui)
 
-
 Sun Feb  7 11:16:00 2016  Martin Duerst  <duerst@i...>
 
 	* common.mk: using new option in recipe for enc/unicode/casefold.h

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

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