Skip to content

Commit

Permalink
* enc/*.c: add replicas and aliases.
Browse files Browse the repository at this point in the history
* enc/make_encdb.h: add duplicate and undefined check.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15028 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information
nurse committed Jan 13, 2008
1 parent 50bbc4e commit 5b46f99
Show file tree
Hide file tree
Showing 7 changed files with 84 additions and 10 deletions.
6 changes: 6 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
Mon Jan 14 05:44:44 2008 NARUSE, Yui <[email protected]>

* enc/*.c: add replicas and aliases.

* enc/make_encdb.h: add duplicate and undefined check.

Mon Jan 14 02:03:05 2008 NARUSE, Yui <[email protected]>

* include/ruby/oniguruma.h: remove ONIG_ENCODING_* and OnigEncoding*
Expand Down
44 changes: 44 additions & 0 deletions enc/ascii.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,47 @@ OnigEncodingDefine(ascii, ASCII) = {
onigenc_always_true_is_allowed_reverse_match
};
ENC_ALIAS("BINARY", "ASCII-8BIT");
ENC_REPLICATE("IBM437", "ASCII-8BIT");
ENC_ALIAS("CP437", "IBM437");
ENC_REPLICATE("IBM737", "ASCII-8BIT");
ENC_ALIAS("CP737", "IBM737");
ENC_REPLICATE("IBM775", "ASCII-8BIT");
ENC_ALIAS("CP775", "IBM775");
ENC_REPLICATE("CP850", "ASCII-8BIT");
ENC_ALIAS("CP850", "IBM850");
ENC_REPLICATE("IBM852", "ASCII-8BIT");
ENC_REPLICATE("CP852", "IBM852");
ENC_REPLICATE("IBM855", "ASCII-8BIT");
ENC_REPLICATE("CP855", "IBM855");
ENC_REPLICATE("IBM857", "ASCII-8BIT");
ENC_ALIAS("CP857", "IBM857");
ENC_REPLICATE("IBM860", "ASCII-8BIT");
ENC_ALIAS("CP860", "IBM860");
ENC_REPLICATE("IBM861", "ASCII-8BIT");
ENC_ALIAS("CP861", "IBM861");
ENC_REPLICATE("IBM862", "ASCII-8BIT");
ENC_ALIAS("CP862", "IBM862");
ENC_REPLICATE("IBM863", "ASCII-8BIT");
ENC_ALIAS("CP863", "IBM863");
ENC_REPLICATE("IBM864", "ASCII-8BIT");
ENC_ALIAS("CP864", "IBM864");
ENC_REPLICATE("IBM865", "ASCII-8BIT");
ENC_ALIAS("CP865", "IBM865");
ENC_REPLICATE("IBM866", "ASCII-8BIT");
ENC_ALIAS("CP866", "IBM866");
ENC_REPLICATE("IBM869", "ASCII-8BIT");
ENC_ALIAS("CP869", "IBM869");
ENC_REPLICATE("Windows-1258", "ASCII-8BIT");
ENC_ALIAS("CP1258", "Windows-1258");
ENC_REPLICATE("gb1988", "ASCII-8BIT");
ENC_REPLICATE("koi8-u", "ASCII-8BIT");
ENC_REPLICATE("macCentEuro", "ASCII-8BIT");
ENC_REPLICATE("macCroatian", "ASCII-8BIT");
ENC_REPLICATE("macCyrillic", "ASCII-8BIT");
ENC_REPLICATE("macGreek", "ASCII-8BIT");
ENC_REPLICATE("macIceland", "ASCII-8BIT");
ENC_REPLICATE("macRoman", "ASCII-8BIT");
ENC_REPLICATE("macRomania", "ASCII-8BIT");
ENC_REPLICATE("macThai", "ASCII-8BIT");
ENC_REPLICATE("macTurkish", "ASCII-8BIT");
ENC_REPLICATE("macUkraine", "ASCII-8BIT");
1 change: 1 addition & 0 deletions enc/big5.c
Original file line number Diff line number Diff line change
Expand Up @@ -162,3 +162,4 @@ OnigEncodingDefine(big5, BIG5) = {
big5_left_adjust_char_head,
big5_is_allowed_reverse_match
};
ENC_ALIAS("CP950", "BIG5");
3 changes: 2 additions & 1 deletion enc/iso_8859_11.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,5 +95,6 @@ OnigEncodingDefine(iso_8859_11, ISO_8859_11) = {
onigenc_always_true_is_allowed_reverse_match
};
ENC_ALIAS("ISO8859-11", "ISO-8859-11");
ENC_REPLICATE("TIS-620", "ISO-8859-11");
ENC_REPLICATE("Windows-874", "ISO-8859-11");
ENC_ALIAS("CP874", "ISO-8859-11");
ENC_ALIAS("CP874", "Windows-874");
36 changes: 28 additions & 8 deletions enc/make_encdb.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@
# ENC_ALIAS("CP932", "Windows-31J")
#

def check_duplication(encs, name, fn, line)
if encs.include?(name)
raise ArgumentError, "%s:%d: encoding %s is already registered" % [fn, line, name]
end
end

encodings = []
replicas = {}
aliases = {}
Expand All @@ -17,20 +23,34 @@
open(File.join(encdir,fn)) do |f|
orig = nil
name = nil
encs = []
f.each_line do |line|
break if /^OnigEncodingDefine/o =~ line
end
f.each_line do |line|
break if /"(.*?)"/ =~ line
end
encodings << $1 if $1
f.each_line do |line|
if /^ENC_REPLICATE\(\s*"([^"]+)"\s*,\s*"([^"]+)"/o =~ line
encodings << $1
replicas[$1] = $2
elsif /^ENC_ALIAS\(\s*"([^"]+)"\s*,\s*"([^"]+)"/o =~ line
encodings << $1
aliases[$1] = $2
if $1
check_duplication(encs, $1, fn, $.)
encs << $1.upcase
encodings << $1
f.each_line do |line|
if /^ENC_REPLICATE\(\s*"([^"]+)"\s*,\s*"([^"]+)"/o =~ line
raise ArgumentError,
'%s:%d: ENC_REPLICATE: %s is not defined yet. (replica %s)' %
[fn, $., $2, $1] unless encs.include?($2.upcase)
check_duplication(encs, $1, fn, $.)
encs << $1.upcase
encodings << $1
replicas[$1] = $2
elsif /^ENC_ALIAS\(\s*"([^"]+)"\s*,\s*"([^"]+)"/o =~ line
raise ArgumentError,
'%s:%d: ENC_ALIAS: %s is not defined yet. (alias %s)' %
[fn, $., $2, $1] unless encs.include?($2.upcase)
check_duplication(encs, $1, fn, $.)
encodings << $1
aliases[$1] = $2
end
end
end
end
Expand Down
2 changes: 2 additions & 0 deletions enc/shift_jis.c
Original file line number Diff line number Diff line change
Expand Up @@ -376,3 +376,5 @@ ENC_ALIAS("SJIS", "Shift_JIS");
ENC_REPLICATE("Windows-31J", "Shift_JIS");
ENC_ALIAS("CP932", "Windows-31J");
ENC_ALIAS("csWindows31J", "Windows-31J"); /* IANA. IE6 don't accept Windows-31J but csWindows31J. */
ENC_REPLICATE("MacJapanese", "Shift_JIS");
ENC_ALIAS("MacJapan", "MacJapanese");
2 changes: 1 addition & 1 deletion enc/windows_1251.c
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ cp1251_get_case_fold_codes_by_str(OnigCaseFoldType flag,
flag, p, end, items);
}

OnigEncodingType OnigEncodingCP1251 = {
OnigEncodingDefine(windows_1251, Windows_1251) = {
onigenc_single_byte_mbc_enc_len,
"Windows-1251", /* name */
1, /* max enc length */
Expand Down

0 comments on commit 5b46f99

Please sign in to comment.