[#32945] Shift_JIS variants and UTF-16 support — "U.Nakamura" <usa@...>

こんにちは、なかむら(う)です。

22 messages 2008/01/07
[#32953] Re: Shift_JIS variants and UTF-16 support — Martin Duerst <duerst@...> 2008/01/07

中村さん、こんにちは。

[#32955] Re: Shift_JIS variants and UTF-16 support — Yukihiro Matsumoto <matz@...> 2008/01/07

まつもと ゆきひろです

[#32959] Re: Shift_JIS variants and UTF-16 support — "NARUSE, Yui" <naruse@...> 2008/01/07

成瀬です。

[#32960] Re: Shift_JIS variants and UTF-16 support — Yukihiro Matsumoto <matz@...> 2008/01/07

まつもと ゆきひろです

[#32992] ASCII is alias of US-ASCII; replica of dummy encoding is not a dummy — "NARUSE, Yui" <naruse@...>

成瀬です。

18 messages 2008/01/08
[#32994] Re: ASCII is alias of US-ASCII; replica of dummy encoding is not a dummy — Yukihiro Matsumoto <matz@...> 2008/01/09

まつもと ゆきひろです

[#32995] Re: ASCII is alias of US-ASCII; replica of dummy encoding is not a dummy — Martin Duerst <duerst@...> 2008/01/09

At 18:13 08/01/09, Yukihiro Matsumoto wrote:

[#33011] Re: ASCII is alias of US-ASCII; replica of dummy encoding is not a dummy — "NARUSE, Yui" <naruse@...> 2008/01/11

成瀬です。

[#33012] Re: ASCII is alias of US-ASCII; replica of dummy encoding is not a dummy — Yukihiro Matsumoto <matz@...> 2008/01/11

まつもと ゆきひろです

[#33014] Re: ASCII is alias of US-ASCII; replica of dummy encoding is not a dummy — "NARUSE, Yui" <naruse@...> 2008/01/11

成瀬です。

[#33015] Re: ASCII is alias of US-ASCII; replica of dummy encoding is not a dummy — Yukihiro Matsumoto <matz@...> 2008/01/11

まつもと ゆきひろです

[#33239] Re: [ruby-cvs:22386] Ruby:r15149 (trunk): * string.c (rb_str_each_char): move forward. — Tanaka Akira <akr@...>

In article <200801210259.m0L2x3CW017171@ci.ruby-lang.org>,

11 messages 2008/01/21
[#33240] Re: [ruby-cvs:22386] Ruby:r15149 (trunk): * string.c (rb_str_each_char): move forward. — Nobuyoshi Nakada <nobu@...> 2008/01/21

なかだです。

[#33303] Time#strftimeのエンコーディング — rubikitch@...

るびきちです。

13 messages 2008/01/23
[#33305] Re: Time#strftimeのエンコーディング — Yukihiro Matsumoto <matz@...> 2008/01/23

まつもと ゆきひろです

[#33368] summary of script encoding — "U.Nakamura" <usa@...>

こんにちは、なかむら(う)です。

22 messages 2008/01/25
[#33375] Re: summary of script encoding — Yukihiro Matsumoto <matz@...> 2008/01/25

まつもと ゆきひろです

[#33376] Re: summary of script encoding — "U.Nakamura" <usa@...> 2008/01/25

こんにちは、なかむら(う)です。

[#33387] HashからStructを作る — rubikitch@...

るびきちです。

19 messages 2008/01/25
[#33455] Re: HashからStructを作る — Yukihiro Matsumoto <matz@...> 2008/01/28

まつもと ゆきひろです

[#33505] Re: HashからStructを作る — rubikitch@... 2008/01/29

From: Yukihiro Matsumoto <matz@ruby-lang.org>

[#33507] Re: HashからStructを作る — Yukihiro Matsumoto <matz@...> 2008/01/29

まつもと ゆきひろです

[#33508] Re: HashからStructを作る — rubikitch@... 2008/01/29

From: Yukihiro Matsumoto <matz@ruby-lang.org>

[#33433] Win32OLE: set encoding to OLE string — "U.Nakamura" <usa@...>

こんにちは、なかむら(う)です。

16 messages 2008/01/28

[#33461] Failed to make ruby-1.8.6-p111 on MacOSX 10.5(Leopard) — MORITA Hideyuki <h-morita@...>

=1B$B?9ED$H?=3D$7$^$9!#=1B(B

19 messages 2008/01/28
[#33473] Re: Failed to make ruby-1.8.6-p111 on MacOSX 10.5(Leopard) — Nobuyoshi Nakada <nobu@...> 2008/01/28

なかだです。

[#33503] Re: Failed to make ruby-1.8.6-p111 on MacOSX 10.5(Leopard) — MORITA Hideyuki <h-morita@...> 2008/01/29

森田です。

[#33514] Re: Failed to make ruby-1.8.6-p111 on MacOSX 10.5(Leopard) — Nobuyoshi Nakada <nobu@...> 2008/01/29

なかだです。

[#33518] Re: Failed to make ruby-1.8.6-p111 on MacOSX 10.5(Leopard) — MORITA Hideyuki <h-morita@...> 2008/01/30

森田です。

[#33545] Re: Failed to make ruby-1.8.6-p111 on MacOSX 10.5(Leopard) — Ryutaro Amano <wn9r-amn@...> 2008/01/31

天野竜太郎と申します。

[#33546] Re: Failed to make ruby-1.8.6-p111 on MacOSX 10.5(Leopard) — MORITA Hideyuki <h-morita@...> 2008/01/31

森田です。

[#33547] Re: Failed to make ruby-1.8.6-p111 on MacOSX 10.5(Leopard) — Ryutaro Amano <wn9r-amn@...> 2008/01/31

天野です。

[#33551] Re: Failed to make ruby-1.8.6-p111 on MacOSX 10.5(Leopard) — MORITA Hideyuki <h-morita@...> 2008/01/31

森田です。

[#33488] 現在の script encoding の値を得る方法は? — Hidetoshi NAGAI <nagai@...>

永井@知能.九工大です.

20 messages 2008/01/29
[#33491] Re: 現在の script encoding の値を得る方法は? — Yukihiro Matsumoto <matz@...> 2008/01/29

まつもと ゆきひろです

[#33500] Re: 現在の script encoding の値を得る方法は? — Hidetoshi NAGAI <nagai@...> 2008/01/29

永井@知能.九工大です.

[#33501] Re: 現在の script encoding の値を得る方法は? — "NARUSE, Yui" <naruse@...> 2008/01/29

成瀬です。

[#33515] Re: 現在の script encoding の値を得る方法は? — Hidetoshi NAGAI <nagai@...> 2008/01/30

永井@知能.九工大です.

[#33516] Re: 現在の script encoding の値を得る方法は? — "NARUSE, Yui" <naruse@...> 2008/01/30

成瀬です。

[#33519] Re: 現在の script encoding の値を得る方法は? — Hidetoshi NAGAI <nagai@...> 2008/01/30

永井@知能.九工大です.

[#33522] Re: 現在の script encoding の値を得る方法は? — "NARUSE, Yui" <naruse@...> 2008/01/30

成瀬です。

[ruby-dev:33011] Re: ASCII is alias of US-ASCII; replica of dummy encoding is not a dummy

From: "NARUSE, Yui" <naruse@...>
Date: 2008-01-11 00:36:52 UTC
List: ruby-dev #33011
成瀬です。

Martin Duerst wrote:
> At 18:13 08/01/09, Yukihiro Matsumoto wrote:
>> まつもと ゆきひろです
>>
>> In message "Re: [ruby-dev:32992] ASCII is alias of US-ASCII; replica of 
>> dummy encoding is not a dummy"
>>    on Wed, 9 Jan 2008 03:36:27 +0900, "NARUSE, Yui" <naruse@airemix.com> writes:
>>
>> |= ASCII is alias of US-ASCII
>> |
>> |UTF-{16,32}{BE,LE} が組み込まれた絡みで、NKF を修正していて気付いたので
>> |すが、今 ASCII は ASCII-8BIT の alias なのですね。IANA Charaset では
>> |US-ASCII の alias なのですが、少々まずくありませんか。
>>
>> きっと誰も気付かないと思うけど。この点は積極的に意見を持つ人
>> にお任せします。
> 
> 気がつかなかったかと思いますが、気をつかれたので、
> IANA Charset Registry の Secondary Expert Reviewer の立場として(http://www.iana.org/numbers.html#C 参考) 是非直していただきたいです。
> 「そちらで直して見ろ」と言われたらこちらでもやります。

というわけで、修正案です。
US-ASCII はビルトインではないので、alias だけ登録しておいて、呼ばれた時
に本体を読み込む仕組み (lazy alias) を作りました。名前も含めてこの方向で
よろしいでしょうか。

Index: encoding.c
===================================================================
--- encoding.c  (revision 14981)
+++ encoding.c  (working copy)
@@ -29,6 +29,7 @@ static struct rb_encoding_entry *enc_tab
 static int enc_table_count;
 static int enc_table_size;
 static st_table *enc_table_alias;
+static st_table *enc_table_lazy_alias;

 #define ENC_UNINITIALIZED (&rb_cEncoding)
 #define enc_initialized_p(enc) ((enc)->auxiliary_data != &rb_cEncoding)
@@ -174,6 +175,7 @@ rb_enc_register(const char *name, rb_enc
        if (STRCASECMP(name, rb_enc_name(oldenc))) {
            st_data_t key = (st_data_t)name, alias;
            st_delete(enc_table_alias, &key, &alias);
+           st_delete(enc_table_lazy_alias, &key, &alias);
            index = enc_register(name, encoding);
        }
        else if (enc_initialized_p(oldenc) &&

@@ -289,6 +291,21 @@ rb_enc_alias(const char *alias, const ch
     return enc_alias(alias, orig);
 }

+static int
+enc_lazy_alias(const char *alias, const char *orig)
+{
+    int idx;
+
+    if (!enc_table_lazy_alias) {
+       enc_table_lazy_alias = st_init_strcasetable();
+    }
+    idx = rb_enc_registered(alias);
+    if (idx < 0) {
+       st_insert(enc_table_lazy_alias, (st_data_t)alias, (st_data_t)orig);
+    }
+    return idx;
+}
+
 enum {
     ENCINDEX_ASCII,
     ENCINDEX_EUC_JP,
@@ -307,7 +324,7 @@ rb_enc_init(void)
     ENC_REGISTER(SJIS);
     ENC_REGISTER(UTF8);
 #undef ENC_REGISTER
-    enc_alias("ASCII", rb_enc_name(ONIG_ENCODING_ASCII));
+    enc_lazy_alias("ASCII", "US-ASCII");
     enc_alias("BINARY", rb_enc_name(ONIG_ENCODING_ASCII));
     enc_alias("eucJP", rb_enc_name(ONIG_ENCODING_EUC_JP)); /* UI-OSF
Application Platform Profile f
or Japanese Environment Version 1.1 */
     enc_alias("SJIS", rb_enc_name(ONIG_ENCODING_SJIS));
@@ -371,8 +388,14 @@ rb_enc_find_index(const char *name)
            ++s;
        }
        OBJ_FREEZE(enclib);
-       if (RTEST(rb_protect(require_enc, enclib, 0)))
+       if (RTEST(rb_protect(require_enc, enclib, 0))) {
            i = rb_enc_registered(name);
+       } else {
+           st_data_t orig;
+           if (st_lookup(enc_table_lazy_alias, (st_data_t)name, &orig)) {
+               i = rb_enc_alias(name, (char *)orig);
+           }
+       }
        rb_set_errinfo(Qnil);
     }
     return i;


-- 
NARUSE, Yui  <naruse@airemix.com>
DBDB A476 FDBD 9450 02CD 0EFC BCE3 C388 472E C1EA

In This Thread