Kouhei Sutou
null+****@clear*****
Sat Dec 5 20:26:34 JST 2015
Kouhei Sutou 2015-12-05 20:26:34 +0900 (Sat, 05 Dec 2015) New Revision: 68b21953ecf60b55e7898324b7a335e312bf7479 https://github.com/groonga/groonga/commit/68b21953ecf60b55e7898324b7a335e312bf7479 Message: nfkc: add Unicode version as suffix Modified files: lib/icudump.c lib/nfkc.rb Modified: lib/icudump.c (+6 -2) =================================================================== --- lib/icudump.c 2015-12-05 19:49:04 +0900 (f15a96c) +++ lib/icudump.c 2015-12-05 20:26:34 +0900 (233aef7) @@ -259,12 +259,13 @@ struct option options[] = { {"nfkc", 0, NULL, 'C'}, {"cc", 0, NULL, 'o'}, {"gc", 0, NULL, 'g'}, + {"version", 0, NULL, 'v'}, }; int main(int argc, char **argv) { - switch (getopt_long(argc, argv, "bdDcCog", options, NULL)) { + switch (getopt_long(argc, argv, "bdDcCogv", options, NULL)) { case 'b' : blockcode(); break; @@ -286,8 +287,11 @@ main(int argc, char **argv) case 'g' : gcdump(); break; + case 'v' : + printf("%s\n", U_UNICODE_VERSION); + break; default : - fputs("usage: icudump --[bc|nfd|nfkd|nfc|nfkc|cc|gc]\n", stderr); + fputs("usage: icudump --[bc|nfd|nfkd|nfc|nfkc|cc|gc|version]\n", stderr); break; } return 0; Modified: lib/nfkc.rb (+22 -19) =================================================================== --- lib/nfkc.rb 2015-12-05 19:49:04 +0900 (9d2b8b5) +++ lib/nfkc.rb 2015-12-05 20:26:34 +0900 (ec8d074) @@ -333,9 +333,26 @@ def generate_map2(file, map2) gen_map2_sub(file, suffix, 0) end +######## main ####### + +ARGV.each{|arg| + case arg + when /-*c/i + $case_sensitive = true + when /-*s/i + $keep_space = true + end +} + +STDERR.puts('compiling icudump') +system('cc -Wall -O3 -o icudump -I/tmp/local/include -L/tmp/local/lib icudump.c -licuuc -licui18n') + +STDERR.puts('getting Unicode version') +unicode_version = `./icudump --version`.strip.gsub(".", "") + template = <<END /* -*- c-basic-offset: 2 -*- */ -/* Copyright(C) 2010 Brazil +/* Copyright(C) 2010-2015 Brazil This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public @@ -359,19 +376,19 @@ don't edit this file by hand. it generated automatically by nfkc.rb #ifdef GRN_WITH_NFKC grn_char_type -grn_nfkc_char_type(const unsigned char *str) +grn_nfkc#{unicode_version}_char_type(const unsigned char *str) { % return -1; } const char * -grn_nfkc_map1(const unsigned char *str) +grn_nfkc#{unicode_version}_map1(const unsigned char *str) { % return 0; } const char * -grn_nfkc_map2(const unsigned char *prefix, const unsigned char *suffix) +grn_nfkc#{unicode_version}_map2(const unsigned char *prefix, const unsigned char *suffix) { % return 0; } @@ -380,27 +397,13 @@ grn_nfkc_map2(const unsigned char *prefix, const unsigned char *suffix) END -######## main ####### - -ARGV.each{|arg| - case arg - when /-*c/i - $case_sensitive = true - when /-*s/i - $keep_space = true - end -} - -STDERR.puts('compiling icudump') -system('cc -Wall -O3 -o icudump icudump.c -licui18n') - STDERR.puts('creating map1..') map1 = create_map1() STDERR.puts('creating map2..') map2 = create_map2(map1) -outf = open('nfkc.c', 'w') +outf = open("nfkc#{unicode_version}.c", 'w') tmps = template.split(/%/) -------------- next part -------------- HTML����������������������������... Download