From: Nobuyoshi Nakada Date: 2006-11-29T12:09:05+09:00 Subject: [ruby-dev:29973] Re: BUG: Incorrect handling of Ignorecase matching (regex.c of 1.8.5) なかだです。 At Wed, 29 Nov 2006 10:30:01 +0900, KIMURA Koichi wrote in [ruby-dev:29972]: > > staticだとこれ以降のRegexpの生成時にまで影響してしまうのでは。 > > あーそうですね。 > かといって、casefold_onを見つけるたびにやるのは避けたいのですが > どうしたものでしょう? RE_MAY_IGNORECASE を使ってはどうでしょうか。 > > > + if (!found_casefold) { > > > + unsigned char *p = (unsigned char*)fastmap; > > > > なんで unsigned char * に? > > int ←→ char での型変換時に符号がらみで悩みたくなかったのです。 ここは悩む必要ないんじゃないかと思いますが。 Index: regex.c =================================================================== RCS file: /pub/cvs/ruby/Attic/regex.c,v retrieving revision 1.96.2.9 diff -U 2 -p -u -r1.96.2.9 regex.c --- regex.c 7 Aug 2006 03:43:42 -0000 1.96.2.9 +++ regex.c 29 Nov 2006 03:03:13 -0000 @@ -2835,4 +2835,12 @@ re_compile_fastmap(bufp) case casefold_on: + if (!(bufp->options & RE_MAY_IGNORECASE)) { + int i; + for (i = 0; i < (1< fastmap[j]) fastmap[j] = m; + } + } bufp->options |= RE_MAY_IGNORECASE; options |= RE_OPTION_IGNORECASE; @@ -2905,17 +2913,17 @@ re_compile_fastmap(bufp) case on_failure_jump: - EXTRACT_NUMBER_AND_INCR(j, p); - if (p + j < pend) { - if (stackp == stacke) { - EXPAND_FAIL_STACK(); + EXTRACT_NUMBER_AND_INCR(j, p); + if (p + j < pend) { + if (stackp == stacke) { + EXPAND_FAIL_STACK(); + } + *++stackp = p + j; /* push */ } - *++stackp = p + j; /* push */ - } - else { - bufp->can_be_null = 1; - } - if (is_a_succeed_n) - EXTRACT_NUMBER_AND_INCR(k, p); /* Skip the n. */ - continue; + else { + bufp->can_be_null = 1; + } + if (is_a_succeed_n) + EXTRACT_NUMBER_AND_INCR(k, p); /* Skip the n. */ + continue; case set_number_at: -- --- 僕の前にBugはない。 --- 僕の後ろにBugはできる。 中田 伸悦