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>
|
Mon Feb 8 10:30:10 2016 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
* ruby.c (feature_option): raise a runtime error if ambiguous
|
* 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 */
|
/* use bottom bytes for actual code point count; 3 bits is more than enough */
|
||||||
#define OnigCodePointCount(n) ((n)&0x7)
|
#define OnigCodePointCount(n) ((n)&0x7)
|
||||||
|
#define OnigCaseFoldFlags(n) ((n)&~0x7)
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int n;
|
int n;
|
||||||
|
@ -140,17 +141,17 @@ code3_equal(const OnigCodePoint *x, const OnigCodePoint *y)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define UP ONIGENC_CASE_UPCASE
|
#define U ONIGENC_CASE_UPCASE
|
||||||
#define DOWN ONIGENC_CASE_DOWNCASE
|
#define D ONIGENC_CASE_DOWNCASE
|
||||||
#define TITLE ONIGENC_CASE_TITLECASE
|
#define T ONIGENC_CASE_TITLECASE
|
||||||
#define FOLD ONIGENC_CASE_FOLD
|
#define F ONIGENC_CASE_FOLD
|
||||||
|
|
||||||
#include "enc/unicode/casefold.h"
|
#include "enc/unicode/casefold.h"
|
||||||
|
|
||||||
#undef UP
|
#undef U
|
||||||
#undef DOWN
|
#undef D
|
||||||
#undef TITLE
|
#undef T
|
||||||
#undef FOLD
|
#undef F
|
||||||
|
|
||||||
#include "enc/unicode/name2ctype.h"
|
#include "enc/unicode/name2ctype.h"
|
||||||
|
|
||||||
|
@ -676,9 +677,9 @@ onigenc_unicode_case_map(OnigCaseFoldType* flagP,
|
||||||
code = 0x0049; MODIFIED;
|
code = 0x0049; MODIFIED;
|
||||||
}
|
}
|
||||||
else if ((folded = onigenc_unicode_fold_lookup(code)) != 0) {
|
else if ((folded = onigenc_unicode_fold_lookup(code)) != 0) {
|
||||||
if (flags&ONIGENC_CASE_FOLD) {
|
if (flags&OnigCaseFoldFlags(folded->n)) {
|
||||||
const OnigCodePoint *next = folded->code;
|
|
||||||
int count = OnigCodePointCount(folded->n);
|
int count = OnigCodePointCount(folded->n);
|
||||||
|
const OnigCodePoint *next = folded->code;
|
||||||
MODIFIED;
|
MODIFIED;
|
||||||
if (count==1)
|
if (count==1)
|
||||||
code = *next;
|
code = *next;
|
||||||
|
|
|
@ -17,10 +17,10 @@ class CaseFolding
|
||||||
v.map {|i| "0x%04x" % i}.join(", ")
|
v.map {|i| "0x%04x" % i}.join(", ")
|
||||||
end
|
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
|
for k, v in data = data.sort
|
||||||
sk = (Array === k and k.length > 1) ? "{#{hex_seq(k)}}" : ("0x%04x" % k)
|
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
|
end
|
||||||
data
|
data
|
||||||
end
|
end
|
||||||
|
@ -31,7 +31,7 @@ class CaseFolding
|
||||||
ret = data.inject([]) do |a, (n, d)|
|
ret = data.inject([]) do |a, (n, d)|
|
||||||
dest.print("#define #{n} (*(#{type}_Type (*)[#{d.size}])(#{type}_Table+#{i}))\n")
|
dest.print("#define #{n} (*(#{type}_Type (*)[#{d.size}])(#{type}_Table+#{i}))\n")
|
||||||
i += d.size
|
i += d.size
|
||||||
a.concat(print_table_1(dest, mapping_data, d))
|
a.concat(print_table_1(dest, type, mapping_data, d))
|
||||||
end
|
end
|
||||||
dest.print("};\n\n")
|
dest.print("};\n\n")
|
||||||
ret
|
ret
|
||||||
|
@ -205,9 +205,14 @@ class CaseMapping
|
||||||
# IO.readlines(File.expand_path('SpecialCasing.txt', mapping_directory))
|
# IO.readlines(File.expand_path('SpecialCasing.txt', mapping_directory))
|
||||||
end
|
end
|
||||||
|
|
||||||
def flags(from)
|
def flags(from, type)
|
||||||
to = @mappings[from]
|
# types: CaseFold_11, CaseUnfold_11, CaseUnfold_12, CaseUnfold_13
|
||||||
to ? to.flags : ""
|
flags = ""
|
||||||
|
flags += '|F' if type=='CaseFold_11'
|
||||||
|
|
||||||
|
#to = @mappings[from]
|
||||||
|
#to ? to.flags : ""
|
||||||
|
flags
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.load(*args)
|
def self.load(*args)
|
||||||
|
@ -216,7 +221,7 @@ class CaseMapping
|
||||||
end
|
end
|
||||||
|
|
||||||
class CaseMappingDummy
|
class CaseMappingDummy
|
||||||
def flags(from)
|
def flags(from, type)
|
||||||
""
|
""
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue