[#32910] NKF,Kconv — Kazuhiro NISHIYAMA <zn@...>
西山和広です。
[#32913] openの"b"とencoding — Kazuhiro NISHIYAMA <zn@...>
西山和広です。
[#32922] SEGV by regexp match in while loop — Tanaka Akira <akr@...>
Debian GNU/Linux (sarge) の gcc-3.4 を使ってビルドした ruby
[#32935] queue and timeout — Tanaka Akira <akr@...>
timeout で Queue#pop に時間制限をつけた時、タイムアウト時に
まつもと ゆきひろです
[#32940] ripper cannot build on win32 — yukimi_sake <yukimi_sake@...>
雪見酒です。
[#32945] Shift_JIS variants and UTF-16 support — "U.Nakamura" <usa@...>
こんにちは、なかむら(う)です。
中村さん、こんにちは。
まつもと ゆきひろです
成瀬です。
まつもと ゆきひろです
こんにちは、なかむら(う)です。
成瀬です。
こんにちは、なかむら(う)です。
成瀬です。
こんにちは、なかむら(う)です。
まつもと ゆきひろです
[#32946] replica と alias の違い(encoding) — KIMURA Koichi <kimura.koichi@...>
木村です。
[#32987] error with open-uri (instance_eval?) — "U.Nakamura" <usa@...>
こんにちは、なかむら(う)です。
[#32988] Re: [ruby-cvs:22194] Ruby:r14957 (trunk): * encoding.c (rb_enc_init): UTF-{16,32}{BE,LE} are not builtin. — Yukihiro Matsumoto <matz@...>
まつもと ゆきひろです
[#32992] ASCII is alias of US-ASCII; replica of dummy encoding is not a dummy — "NARUSE, Yui" <naruse@...>
成瀬です。
まつもと ゆきひろです
At 18:13 08/01/09, Yukihiro Matsumoto wrote:
成瀬です。
まつもと ゆきひろです
成瀬です。
まつもと ゆきひろです
なかだです。
まつもと ゆきひろです
[#32996] binmode and ASCII-8BIT — Kazuhiro NISHIYAMA <zn@...>
西山和広です。
[#33069] Re: [ruby-cvs:22244] Ruby:r15007 (trunk): * enc/make_encdb.rb: added. search enc/*.c and make encoding database. — Yukihiro Matsumoto <matz@...>
まつもと ゆきひろです
まつもと ゆきひろです
[#33076] Encoding.compatible? and dummy encodings — sheepman <sheepman@...>
こんにちは sheepman です。
成瀬です。
まつもと ゆきひろです
[#33078] NEW REPLICA ENCODINGS AND ENCODING ALIASES — "NARUSE, Yui" <naruse@...>
成瀬です。
[#33101] String#valid_encoding? shoud be strict? — Masayoshi Takahashi <maki@...>
高橋征義です。1.9のエンコーディングとString#valid_encoding?について。
[#33139] Bignum#* might invoke GC parallelly? — "Yusuke ENDOH" <mame@...>
遠藤と申します。
[#33156] default script encoding and -K option — sheepman <sheepman@...>
こんばんは sheepman です。
こんにちは、なかむら(う)です。
まつもと ゆきひろです
[#33164] default encoding for Marshal.load — "Shugo Maeda" <shugo@...>
前田です。
まつもと ゆきひろです
[#33185] コンパイルの問題 (r15218) — Martin Duerst <duerst@...>
r15128 当たりで (実はもう少し前から) コンパイルできなくなりました。
[#33218] Re: Ruby1.9String バイト列へのインデックス アクセス — "Hisanori Kiryu" <hkiryu@...>
> ちなみに、byte のではなく bytes の方が妥当だと思います。
[#33224] printf "%0x" — Tanaka Akira <akr@...>
printf の %0x に負の整数を与えると、値によって .. がついたり
[#33226] [PATCH] warnings of enc/trans/utf_16_32.c — Nobuyoshi Nakada <nobu@...>
なかだです。
[#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>,
なかだです。
In article <20080121065650.55F60E0662@mail.bc9.jp>,
なかだです。
まつもと ゆきひろです
[#33247] requests to transcode — "U.Nakamura" <usa@...>
こんにちは、なかむら(う)です。
[#33303] Time#strftimeのエンコーディング — rubikitch@...
るびきちです。
まつもと ゆきひろです
なかだです。
西山和広です。
[#33368] summary of script encoding — "U.Nakamura" <usa@...>
こんにちは、なかむら(う)です。
まつもと ゆきひろです
こんにちは、なかむら(う)です。
まつもと ゆきひろです
永井@知能.九工大です.
[#33387] HashからStructを作る — rubikitch@...
るびきちです。
まつもと ゆきひろです
From: Yukihiro Matsumoto <matz@ruby-lang.org>
まつもと ゆきひろです
From: Yukihiro Matsumoto <matz@ruby-lang.org>
まつもと ゆきひろです
From: Yukihiro Matsumoto <matz@ruby-lang.org>
まつもと ゆきひろです
[#33399] regexp match /.../n against to UTF-8 string — Tanaka Akira <akr@...>
以下のように、つけてもいない正規表現の n オプションに関して
[#33400] /#{}/e.encoding — Tanaka Akira <akr@...>
以下のように /#{}/e の encoding が US-ASCII になります。
[#33403] wrapped String#gsub — "Park Ji-In" <tisphie@...>
こんにちは、朴 芝印です。
[#33417] コンパイルの問題 — Martin Duerst <duerst@...>
現在 (r15264 で) コンパイル使用とすると、エラーになります:
At 16:28 08/01/27, you wrote:
[#33433] Win32OLE: set encoding to OLE string — "U.Nakamura" <usa@...>
こんにちは、なかむら(う)です。
成瀬です。
助田です。
こんにちは、なかむら(う)です。
こんにちは、なかむら(う)です。
[#33452] enc/euc_kr.c (euckr_mbc_enc_len) euc_kr.c is also used by CP942 — "NARUSE, Yui" <naruse@...>
成瀬です。
まつもと ゆきひろです
成瀬です。
[#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
なかだです。
森田です。
なかだです。
森田です。
天野竜太郎と申します。
森田です。
天野です。
森田です。
天野です。
森田です。
天野です。
森田です。
天野です。
[#33488] 現在の script encoding の値を得る方法は? — Hidetoshi NAGAI <nagai@...>
永井@知能.九工大です.
まつもと ゆきひろです
永井@知能.九工大です.
成瀬です。
永井@知能.九工大です.
成瀬です。
永井@知能.九工大です.
成瀬です。
In article <47A00E86.4010701@airemix.com>,
成瀬です。
In article <47A03C9D.2090008@airemix.com>,
In article <87hcgvu1ng.fsf@fsij.org>,
[#33521] nkf の CP932 — Martin Duerst <duerst@...>
成瀬さん、皆さん、こんにちは。
[#33548] block parameter of String#gsub — "NARUSE, Yui" <naruse@...>
成瀬です。
まつもと ゆきひろです
[ruby-dev:33400] /#{}/e.encoding
以下のように /#{}/e の encoding が US-ASCII になります。
% ./ruby -ve 'p(/#{}/e.encoding)'
ruby 1.9.0 (2008-01-26 revision 15237) [i686-linux]
#<Encoding:US-ASCII>
正規表現のソースを構成する文字列の連結時に EUC-JP な
encoding が消えてしまうのが理由なようです。
もともとこの連結に単なる文字列連結を使うのは、エスケープされ
た中途半端な非 ASCII 文字が連結されて中途半端でないものにな
るのを検出できないという問題があります。なので、
Regexp.preprocess というメソッドを新設して、そこで連結を行い、
エンコーディングの伝播も以前同様ににされるようにしてみました。
Index: re.c
===================================================================
--- re.c (revision 15249)
+++ re.c (working copy)
@@ -1942,36 +1942,51 @@ rb_reg_check_preprocess(VALUE str)
return Qnil;
}
-#if 0
static VALUE
-rb_reg_preprocess_obj(VALUE str,
- rb_encoding **fixed_enc, onig_errmsg_buffer err)
+rb_reg_preprocess_m(int argc, VALUE *argv, VALUE klass)
{
- VALUE buf;
- char *p, *end;
- rb_encoding *enc;
+ rb_encoding *fixed_enc = 0;
+ onig_errmsg_buffer err = "";
+ int i;
+ VALUE result = 0;
- StringValue(str);
- p = RSTRING_PTR(str);
- end = p + RSTRING_LEN(str);
- enc = rb_enc_get(str);
+ if (argc == 0) {
+ rb_raise(rb_eArgError, "no arguments given");
+ }
- buf = rb_reg_preprocess(p, end, enc, fixed_enc, err);
- RB_GC_GUARD(str);
- return buf;
-}
+ for (i = 0; i < argc; i++) {
+ VALUE str = argv[i];
+ VALUE buf;
+ char *p, *end;
+ rb_encoding *enc;
+
+ StringValue(str);
+ p = RSTRING_PTR(str);
+ end = p + RSTRING_LEN(str);
+ enc = rb_enc_get(str);
+
+ buf = rb_reg_preprocess(p, end, enc, &fixed_enc, err);
+ RB_GC_GUARD(str);
+
+ if (buf == Qnil)
+ rb_raise(rb_eArgError, "%s", err);
+
+ if (i == 0) {
+ /* The encoding of the first fragment is the encoding
+ * given by the regexp option or script encoding. */
+ if (fixed_enc == 0) {
+ rb_enc_copy(buf, str);
+ }
+ }
-static VALUE
-rb_reg_preprocess_m(VALUE klass, VALUE obj)
-{
- rb_encoding *fixed_enc = 0;
- onig_errmsg_buffer err = "";
- VALUE str = rb_reg_preprocess_obj(obj, &fixed_enc, err);
- if (str == Qnil)
- rb_raise(rb_eArgError, "%s", err);
- return rb_assoc_new(str, fixed_enc ? Qtrue : Qfalse);
+ if (!result)
+ result = buf;
+ else
+ rb_str_buf_append(result, buf);
+ }
+
+ return result;
}
-#endif
static int
rb_reg_initialize(VALUE obj, const char *s, int len, rb_encoding *enc,
@@ -3035,9 +3050,7 @@ Init_Regexp(void)
rb_define_singleton_method(rb_cRegexp, "last_match", rb_reg_s_last_match, -1);
rb_define_singleton_method(rb_cRegexp, "try_convert", rb_reg_s_try_convert, 1);
-#if 0
- rb_define_singleton_method(rb_cRegexp, "preprocess", rb_reg_preprocess_m, 1);
-#endif
+ rb_define_singleton_method(rb_cRegexp, "preprocess", rb_reg_preprocess_m, -1);
rb_define_method(rb_cRegexp, "initialize", rb_reg_initialize_m, -1);
rb_define_method(rb_cRegexp, "initialize_copy", rb_reg_init_copy, 1);
Index: compile.c
===================================================================
--- compile.c (revision 15249)
+++ compile.c (working copy)
@@ -1848,7 +1848,7 @@ iseq_set_sequence_stackcaching(rb_iseq_t
static int
-compile_dstr(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node)
+compile_dstr_fragments(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int *cntp)
{
NODE *list = node->nd_next;
VALUE lit = node->nd_lit;
@@ -1862,12 +1862,31 @@ compile_dstr(rb_iseq_t *iseq, LINK_ANCHO
cnt++;
list = list->nd_next;
}
+ *cntp = cnt;
+
+ return COMPILE_OK;
+}
+static int
+compile_dstr(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node)
+{
+ int cnt;
+ compile_dstr_fragments(iseq, ret, node, &cnt);
ADD_INSN1(ret, nd_line(node), concatstrings, INT2FIX(cnt));
return COMPILE_OK;
}
static int
+compile_dregx(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node)
+{
+ int cnt;
+ ADD_INSN1(ret, nd_line(node), putobject, rb_cRegexp);
+ compile_dstr_fragments(iseq, ret, node, &cnt);
+ ADD_SEND(ret, nd_line(node), ID2SYM(rb_intern("preprocess")), INT2FIX(cnt));
+ return COMPILE_OK;
+}
+
+static int
compile_branch_condition(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * cond,
LABEL *then_label, LABEL *else_label)
{
@@ -4077,7 +4096,7 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_
break;
}
case NODE_DREGX:{
- compile_dstr(iseq, ret, node);
+ compile_dregx(iseq, ret, node);
ADD_INSN1(ret, nd_line(node), toregexp, INT2FIX(node->nd_cflag));
if (poped) {
@@ -4094,7 +4113,7 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_
ADD_INSN2(ret, nd_line(node), onceinlinecache, 0, lend);
ADD_INSN(ret, nd_line(node), pop);
- compile_dstr(iseq, ret, node);
+ compile_dregx(iseq, ret, node);
ADD_INSN1(ret, nd_line(node), toregexp, INT2FIX(node->nd_cflag));
ADD_INSN1(ret, nd_line(node), setinlinecache, lstart);
Index: test/ruby/test_m17n.rb
===================================================================
--- test/ruby/test_m17n.rb (revision 15249)
+++ test/ruby/test_m17n.rb (working copy)
@@ -428,14 +428,14 @@ class TestM17N < Test::Unit::TestCase
assert_raise(ArgumentError) { eval(s("/\#{r}\xc2\xa1/s")) }
r = /\xc2\xa1/e
- #assert_raise(ArgumentError) { eval(s("/\xc2\xa1\#{r}/s")) }
- #assert_raise(ArgumentError) { eval(s("/\#{r}\xc2\xa1/s")) }
+ assert_raise(ArgumentError) { eval(s("/\xc2\xa1\#{r}/s")) }
+ assert_raise(ArgumentError) { eval(s("/\#{r}\xc2\xa1/s")) }
r = eval(e("/\xc2\xa1/"))
- #assert_raise(ArgumentError) { /\xc2\xa1#{r}/s }
+ assert_raise(ArgumentError) { /\xc2\xa1#{r}/s }
r = /\xc2\xa1/e
- #assert_raise(ArgumentError) { /\xc2\xa1#{r}/s }
+ assert_raise(ArgumentError) { /\xc2\xa1#{r}/s }
end
def test_begin_end_offset
@@ -560,7 +560,7 @@ class TestM17N < Test::Unit::TestCase
}
assert_regexp_fixed_ascii8bit(/#{}\xc2\xa1/n)
assert_regexp_fixed_ascii8bit(/\xc2\xa1#{}/n)
- #assert_raise(SyntaxError) { s1, s2 = s('\xc2'), s('\xa1'); /#{s1}#{s2}/ }
+ assert_nothing_raised { s1, s2 = a('\xc2'), a('\xa1'); /#{s1}#{s2}/ }
end
def test_dynamic_eucjp_regexp
@@ -570,7 +570,7 @@ class TestM17N < Test::Unit::TestCase
assert_raise(SyntaxError) { eval('/\xc2#{}/e') }
assert_raise(SyntaxError) { eval('/#{}\xc2/e') }
assert_raise(SyntaxError) { eval('/\xc2#{}\xa1/e') }
- #assert_raise(SyntaxError) { s1, s2 = e('\xc2'), e('\xa1'); /#{s1}#{s2}/ }
+ assert_raise(ArgumentError) { s1, s2 = e('\xc2'), e('\xa1'); /#{s1}#{s2}/ }
end
def test_dynamic_sjis_regexp
@@ -580,7 +580,7 @@ class TestM17N < Test::Unit::TestCase
assert_raise(SyntaxError) { eval('/\x81#{}/s') }
assert_raise(SyntaxError) { eval('/#{}\x81/s') }
assert_raise(SyntaxError) { eval('/\x81#{}\xa1/s') }
- #assert_raise(SyntaxError) { s1, s2 = s('\x81'), s('\xa1'); /#{s1}#{s2}/ }
+ assert_raise(ArgumentError) { s1, s2 = s('\x81'), s('\xa1'); /#{s1}#{s2}/ }
end
def test_dynamic_utf8_regexp
@@ -590,7 +590,7 @@ class TestM17N < Test::Unit::TestCase
assert_raise(SyntaxError) { eval('/\xc2#{}/u') }
assert_raise(SyntaxError) { eval('/#{}\xc2/u') }
assert_raise(SyntaxError) { eval('/\xc2#{}\xa1/u') }
- #assert_raise(SyntaxError) { s1, s2 = u('\xc2'), u('\xa1'); /#{s1}#{s2}/ }
+ assert_raise(ArgumentError) { s1, s2 = u('\xc2'), u('\xa1'); /#{s1}#{s2}/ }
end
def test_regexp_unicode
--
[田中 哲][たなか あきら][Tanaka Akira]