summaryrefslogtreecommitdiff
path: root/enc/unicode
diff options
context:
space:
mode:
authorduerst <duerst@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-02-07 01:39:26 +0000
committerduerst <duerst@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-02-07 01:39:26 +0000
commit07ad033850328cf2f19a9e1521eb631b7059b5ed (patch)
tree5795d204af6de7c1667125d3fa7b040adec0231d /enc/unicode
parentb6d25f03a8a719975dbe8d8f87f7543706ca51c4 (diff)
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53759 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'enc/unicode')
-rwxr-xr-xenc/unicode/case-folding.rb18
1 files changed, 17 insertions, 1 deletions
diff --git a/enc/unicode/case-folding.rb b/enc/unicode/case-folding.rb
index d93de65..c514ab0 100755
--- a/enc/unicode/case-folding.rb
+++ b/enc/unicode/case-folding.rb
@@ -3,6 +3,9 @@
# Usage:
# $ wget http://www.unicode.org/Public/UNIDATA/CaseFolding.txt
# $ ruby case-folding.rb CaseFolding.txt -o casefold.h
+# or:
+# $ wget http://www.unicode.org/Public/UNIDATA/CaseFolding.txt
+# $ ruby case-folding.rb -m . -o casefold.h
class CaseFolding
module Util
@@ -175,16 +178,29 @@ end
if $0 == __FILE__
require 'optparse'
dest = nil
+ mapping_directory = nil
+ mapping_data = nil
fold_1 = false
ARGV.options do |opt|
opt.banner << " [INPUT]"
opt.on("--output-file=FILE", "-o", "output to the FILE instead of STDOUT") {|output|
dest = (output unless output == '-')
}
+ opt.on('--mapping-data-directory', '-m', 'data directory of mapping files') { |directory|
+ mapping_directory = directory
+ }
opt.parse!
abort(opt.to_s) if ARGV.size > 1
end
- filename = ARGV[0] || 'CaseFolding.txt'
+ if mapping_directory
+ if ARGV[0]
+ warn "Either specify directory or individual file, but not both."
+ exit
+ end
+ filename = File.expand_path("CaseFolding.txt", mapping_directory)
+ end
+ filename ||= ARGV[0] || 'CaseFolding.txt'
+
data = CaseFolding.load(filename)
if dest
open(dest, "wb") do |f|