aboutsummaryrefslogtreecommitdiffstats
path: root/enc
diff options
context:
space:
mode:
Diffstat (limited to 'enc')
-rw-r--r--enc/ascii.c1
-rw-r--r--enc/euc_jp.c1
-rwxr-xr-xenc/make_encdb.rb65
-rw-r--r--enc/sjis.c4
-rw-r--r--enc/us_ascii.c3
5 files changed, 74 insertions, 0 deletions
diff --git a/enc/ascii.c b/enc/ascii.c
index f9a619d700..e79d93074f 100644
--- a/enc/ascii.c
+++ b/enc/ascii.c
@@ -47,3 +47,4 @@ OnigEncodingDefine(ascii, ASCII) = {
onigenc_single_byte_left_adjust_char_head,
onigenc_always_true_is_allowed_reverse_match
};
+ENC_ALIAS("BINARY", "ASCII-8BIT");
diff --git a/enc/euc_jp.c b/enc/euc_jp.c
index 8c0df7db4e..7040185558 100644
--- a/enc/euc_jp.c
+++ b/enc/euc_jp.c
@@ -361,3 +361,4 @@ OnigEncodingDefine(euc_jp, EUC_JP) = {
is_allowed_reverse_match,
0
};
+ENC_ALIAS("eucJP", "EUC-JP"); /* UI-OSF Application Platform Profile for Japanese Environment Version 1.1 */
diff --git a/enc/make_encdb.rb b/enc/make_encdb.rb
new file mode 100755
index 0000000000..2cd7699944
--- /dev/null
+++ b/enc/make_encdb.rb
@@ -0,0 +1,65 @@
+#! ./miniruby
+
+#
+# OnigEncodingDefine(foo, Foo) = {
+# ..
+# "Shift_JIS", /* Canonical Name */
+# ..
+# };
+# ENC_ALIAS("SJIS", "Shift_JIS")
+# ENC_REPLICATE("Windows-31J", "Shift_JIS")
+# ENC_ALIAS("CP932", "Windows-31J")
+#
+
+require 'mkmf'
+
+encodings = []
+replicas = {}
+aliases = {}
+Dir.open($srcdir) {|d| d.grep(/.+\.c\z/)}.each do |fn|
+ open(File.join($srcdir,fn)) do |f|
+ orig = nil
+ name = nil
+ 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
+ replicas[$1] = $2
+ elsif /^ENC_ALIAS\(\s*"([^"]+)"\s*,\s*"([^"]+)"/o =~ line
+ aliases[$1] = $2
+ end
+ end
+ end
+end
+open('encdb.h', 'wb') do |f|
+ f.puts 'static const char *enc_name_list[] = {'
+ encodings.each {|name| f.puts' "%s",' % name}
+ replicas.each_key {|name| f.puts' "%s",' % name}
+ f.puts(<<"_TEXT_")
+ NULL
+};
+static const int enc_name_list_size = #{encodings.length + replicas.length};
+static const int enc_aliases_size = #{aliases.length};
+static st_table *enc_table_replica_name;
+static st_table *enc_table_alias_name;
+
+static void enc_init_db(void)
+{
+ if (!enc_table_replica_name) {
+ enc_table_replica_name = st_init_strcasetable();
+ }
+ if (!enc_table_alias_name) {
+ enc_table_alias_name = st_init_strcasetable();
+ }
+_TEXT_
+ replicas.each_pair {|name, orig|
+ f.puts' st_insert(enc_table_replica_name, (st_data_t)"%s", (st_data_t)"%s");' % [name, orig]}
+ aliases.each_pair {|name, orig|
+ f.puts' st_insert(enc_table_alias_name, (st_data_t)"%s", (st_data_t)"%s");' % [name, orig]}
+ f.puts '}'
+end
diff --git a/enc/sjis.c b/enc/sjis.c
index 776940291d..dcf05bf86f 100644
--- a/enc/sjis.c
+++ b/enc/sjis.c
@@ -370,3 +370,7 @@ OnigEncodingDefine(sjis, SJIS) = {
is_allowed_reverse_match,
0
};
+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. */
diff --git a/enc/us_ascii.c b/enc/us_ascii.c
index df50e2d0d4..b3ac093425 100644
--- a/enc/us_ascii.c
+++ b/enc/us_ascii.c
@@ -26,3 +26,6 @@ OnigEncodingDefine(us_ascii, US_ASCII) = {
onigenc_single_byte_left_adjust_char_head,
onigenc_always_true_is_allowed_reverse_match
};
+ENC_ALIAS("ASCII", "US-ASCII");
+ENC_ALIAS("ANSI_X3.4-1986", "US-ASCII");
+