mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* enc/unicode.c: Shortened macros for enc/unicode/casefold.h to
single-letter; use flags in casefold.h for logic. * enc/unicode/case-folding.rb: Added flag for case folding. Changed parameter passing. * enc/unicode/casefold.h: New flags added. (with Kimihito Matsui) git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53775 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
1bea5a6127
commit
8f10a72d90
4 changed files with 1355 additions and 1338 deletions
11
ChangeLog
11
ChangeLog
|
@ -1,3 +1,14 @@
|
|||
Mon Feb 8 13:00:17 2016 Martin Duerst <duerst@it.aoyama.ac.jp>
|
||||
|
||||
* enc/unicode.c: Shortened macros for enc/unicode/casefold.h to
|
||||
single-letter; use flags in casefold.h for logic.
|
||||
|
||||
* enc/unicode/case-folding.rb: Added flag for case folding.
|
||||
Changed parameter passing.
|
||||
|
||||
* enc/unicode/casefold.h: New flags added.
|
||||
(with Kimihito Matsui)
|
||||
|
||||
Mon Feb 8 10:30:10 2016 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* ruby.c (feature_option): raise a runtime error if ambiguous
|
||||
|
|
|
@ -73,6 +73,7 @@ static const unsigned short EncUNICODE_ISO_8859_1_CtypeTable[256] = {
|
|||
|
||||
/* use bottom bytes for actual code point count; 3 bits is more than enough */
|
||||
#define OnigCodePointCount(n) ((n)&0x7)
|
||||
#define OnigCaseFoldFlags(n) ((n)&~0x7)
|
||||
|
||||
typedef struct {
|
||||
int n;
|
||||
|
@ -140,17 +141,17 @@ code3_equal(const OnigCodePoint *x, const OnigCodePoint *y)
|
|||
return 1;
|
||||
}
|
||||
|
||||
#define UP ONIGENC_CASE_UPCASE
|
||||
#define DOWN ONIGENC_CASE_DOWNCASE
|
||||
#define TITLE ONIGENC_CASE_TITLECASE
|
||||
#define FOLD ONIGENC_CASE_FOLD
|
||||
#define U ONIGENC_CASE_UPCASE
|
||||
#define D ONIGENC_CASE_DOWNCASE
|
||||
#define T ONIGENC_CASE_TITLECASE
|
||||
#define F ONIGENC_CASE_FOLD
|
||||
|
||||
#include "enc/unicode/casefold.h"
|
||||
|
||||
#undef UP
|
||||
#undef DOWN
|
||||
#undef TITLE
|
||||
#undef FOLD
|
||||
#undef U
|
||||
#undef D
|
||||
#undef T
|
||||
#undef F
|
||||
|
||||
#include "enc/unicode/name2ctype.h"
|
||||
|
||||
|
@ -676,9 +677,9 @@ onigenc_unicode_case_map(OnigCaseFoldType* flagP,
|
|||
code = 0x0049; MODIFIED;
|
||||
}
|
||||
else if ((folded = onigenc_unicode_fold_lookup(code)) != 0) {
|
||||
if (flags&ONIGENC_CASE_FOLD) {
|
||||
const OnigCodePoint *next = folded->code;
|
||||
if (flags&OnigCaseFoldFlags(folded->n)) {
|
||||
int count = OnigCodePointCount(folded->n);
|
||||
const OnigCodePoint *next = folded->code;
|
||||
MODIFIED;
|
||||
if (count==1)
|
||||
code = *next;
|
||||
|
|
|
@ -17,10 +17,10 @@ class CaseFolding
|
|||
v.map {|i| "0x%04x" % i}.join(", ")
|
||||
end
|
||||
|
||||
def print_table_1(dest, mapping_data, data)
|
||||
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)}, {#{hex_seq(v)}}}},\n")
|
||||
dest.print(" {#{sk}, {#{v.length}#{mapping_data.flags(k, type)}, {#{hex_seq(v)}}}},\n")
|
||||
end
|
||||
data
|
||||
end
|
||||
|
@ -31,7 +31,7 @@ class CaseFolding
|
|||
ret = data.inject([]) do |a, (n, d)|
|
||||
dest.print("#define #{n} (*(#{type}_Type (*)[#{d.size}])(#{type}_Table+#{i}))\n")
|
||||
i += d.size
|
||||
a.concat(print_table_1(dest, mapping_data, d))
|
||||
a.concat(print_table_1(dest, type, mapping_data, d))
|
||||
end
|
||||
dest.print("};\n\n")
|
||||
ret
|
||||
|
@ -205,9 +205,14 @@ class CaseMapping
|
|||
# IO.readlines(File.expand_path('SpecialCasing.txt', mapping_directory))
|
||||
end
|
||||
|
||||
def flags(from)
|
||||
to = @mappings[from]
|
||||
to ? to.flags : ""
|
||||
def flags(from, type)
|
||||
# types: CaseFold_11, CaseUnfold_11, CaseUnfold_12, CaseUnfold_13
|
||||
flags = ""
|
||||
flags += '|F' if type=='CaseFold_11'
|
||||
|
||||
#to = @mappings[from]
|
||||
#to ? to.flags : ""
|
||||
flags
|
||||
end
|
||||
|
||||
def self.load(*args)
|
||||
|
@ -216,7 +221,7 @@ class CaseMapping
|
|||
end
|
||||
|
||||
class CaseMappingDummy
|
||||
def flags(from)
|
||||
def flags(from, type)
|
||||
""
|
||||
end
|
||||
end
|
||||
|
|
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue