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2006-11-28 23:31:32.274500000 +0900
@@ -2836,6 +2836,20 @@ re_compile_fastmap(bufp)
case casefold_on:
bufp->options |= RE_MAY_IGNORECASE;
options |= RE_OPTION_IGNORECASE;

  •      {
    
  •          static found_casefold = 0;
    
  •          if (!found_casefold) {
    
  •              unsigned char *p = (unsigned char*)fastmap;
    
  •              int i;
    
  •              for (i=0; i<=(1<<BYTEWIDTH); i++) {
    
  •                  if (p[i]) {
    
  •                      /* p[i] = 0; Do we need this line?*/
    
  •                      p[translate[i]] = 1;
    
  •                  }
    
  •              }
    
  •              found_casefold = 1;
    
  •          }
    
  •      }
     continue;
    
    case casefold_off:

e$BLZB<$G$9!#e(B

On Wed, 29 Nov 2006 10:13:24 +0900
“Nobuyoshi N.” [email protected] wrote:

e$B$J$+$@$G$9!#e(B

At Wed, 29 Nov 2006 00:29:02 +0900,
e$B$-$`$i$3$&$$$Ae(B wrote in [ruby-dev:29970]:

  •      {
    
  •          static found_casefold = 0;
    

e$B7?L>$,$J$$$N$O$5$F$*$-e(B

e$B$9$_$^$;$s!#e(B
e$B7Y9p%l%Y%k$r>e$2$F$J$+$C$?$N$G5$$,IU$-$^$;$s$G$7$?!#e(B

statice$B$@$H$3$l0J9_$Ne(BRegexpe$B$N@8@.;~$K$^$G1F6A$7$F$7$^$&$N$G$O!#e(B

e$B$"!<$=$&$G$9$M!#e(B
e$B$+$H$$$C$F!"e(Bcasefold_one$B$r8+$D$1$k$?$S$K$d$k$N$OHr$1$?$$$N$G$9$,e(B
e$B$I$&$7$?$b$N$G$7$g$&e(B?

  •          if (!found_casefold) {
    
  •              unsigned char *p = (unsigned char*)fastmap;
    

e$B$J$s$Ge(B unsigned char * e$B$Ke(B?

int e$B"+"*e(B char
e$B$G$N7?JQ49;~$KId9f$,$i$$GG:$$?$/$J$+$C$?$N$G$9!#e(B

e$B%Q%C%A$K$D$$$F$O$A$g$C$H9M$(D>$7$^$9!#e(B
e$BL5O@B>$NJ}$,:n@.$5$l$F$b0l8~$K9=$$$^$;$s!#$o$?$7$O$=$l$[$I9-$$HO0O$Ge(B
Rubye$B$N%=!<%9$rGD0.$7$F$$$k$H$O1>$($J$$$H;W$$$^$9$N$G!#e(B

e$B$J$+$@$G$9!#e(B

At Wed, 29 Nov 2006 00:29:02 +0900,
e$B$-$`$i$3$&$$$Ae(B wrote in [ruby-dev:29970]:

  •      {
    
  •          static found_casefold = 0;
    

e$B7?L>$,$J$$$N$O$5$F$*$-e(B

statice$B$@$H$3$l0J9_$Ne(BRegexpe$B$N@8@.;~$K$^$G1F6A$7$F$7$^$&$N$G$O!#e(B

  •          if (!found_casefold) {
    
  •              unsigned char *p = (unsigned char*)fastmap;
    

e$B$J$s$Ge(B unsigned char * e$B$Ke(B?

e$B$J$+$@$G$9!#e(B

At Wed, 29 Nov 2006 10:30:01 +0900,
KIMURA Koichi wrote in [ruby-dev:29972]:

statice$B$@$H$3$l0J9_$Ne(BRegexpe$B$N@8@.;~$K$^$G1F6A$7$F$7$^$&$N$G$O!#e(B

e$B$"!<$=$&$G$9$M!#e(B
e$B$+$H$$$C$F!"e(Bcasefold_one$B$r8+$D$1$k$?$S$K$d$k$N$OHr$1$?$$$N$G$9$,e(B
e$B$I$&$7$?$b$N$G$7$g$&e(B?

RE_MAY_IGNORECASE e$B$r;H$C$F$O$I$&$G$7$g$&$+!#e(B

  •          if (!found_casefold) {
    
  •              unsigned char *p = (unsigned char*)fastmap;
    

e$B$J$s$Ge(B unsigned char * e$B$Ke(B?

int e$B"+"*e(B char e$B$G$N7?JQ49;~$KId9f$,$i$$GG:$$?$/$J$+$C$?$N$G$9!#e(B

e$B$3$3$OG:$`I,MW$J$$$s$8$c$J$$$+$H;W$$$^$9$,!#e(B

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<<BYTEWIDTH); i++) {
    
  •   char m = fastmap[i];
    
  •   j = translate[i];
    
  •   if (m > 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:

e$B$^$D$b$He(B e$B$f$-$R$m$G$9e(B

In message “Re: [ruby-dev:29974] Re: BUG: Incorrect handling of
Ignorecase matching (regex.c of 1.8.5)”
on Wed, 29 Nov 2006 12:22:04 +0900, KIMURA Koichi
[email protected] writes:

|> e$B%Q%C%A$K$D$$$F$O$A$g$C$H9M$(D>$7$^$9!#e(B
|
|e$B:n$jD>$7$^$7$?!#e(B
|
|re_compile_fastmap e$B$O!“0l$D$N%Q%?!<%s$rFbItI=8=$KJQ49$9$k$H$-$K0l2s$@$1e(B
|e$B8F$P$l$k$b$N$J$N$G!“Nc$N%U%i%0$O4X?t$Ne(Bauto e$BJQ?t$H$7$FJ];}$7$F$bBg>fIW$@e(B
|e$B$H;W$$$^$9!#e(B
|
|e$B$”$He(Bfastmape$B$K3JG<$5$l$kFbMF$,e(B1,2e$B$Ne(B2e$BDL$j$”$k$N$G!"$=$l$rDY$5$J$$$h$&$Ke(B
|e$B$7$^$7$?!#e(B
|
|#e$B$H$3$3$^$G=q$$$?$i!"Kb?@$+$i%Q%C%A$,=P$F$7$^$C$?!#e(B

e$B$I$C$A$,NI$$$N$+H=CG$9$k$N$,Fq$7$$$G$9$M$(!#$J$+$@$5$s$NJ}$Oe(B
e$B$h$/$o$+$i$J$+$C$?$N$@$1$I!“$b$7$+$7$F#2HVL$Ne(Bchunke$B$O%9%Z!<e(B
e$B%9$,$:$l$F$k$@$1!)e(B e$B$@$H$9$k$H!”$=$C$A$NJ}$,%3%s%Q%/%H$G$+$Ce(B
e$B$3$$$$$+$J$"!#e(B

e$BLZB<$G$9!#e(B

On Wed, 29 Nov 2006 10:30:01 +0900
KIMURA Koichi [email protected] wrote:

e$B%Q%C%A$K$D$$$F$O$A$g$C$H9M$(D>$7$^$9!#e(B

e$B:n$jD>$7$^$7$?!#e(B

re_compile_fastmap
e$B$O!"0l$D$N%Q%?!<%s$rFbItI=8=$KJQ49$9$k$H$-$K0l2s$@$1e(B
e$B8F$P$l$k$b$N$J$N$G!"Nc$N%U%i%0$O4X?t$Ne(Bauto
e$BJQ?t$H$7$FJ];}$7$F$bBg>fIW$@e(B
e$B$H;W$$$^$9!#e(B

e$B$“$He(Bfastmape$B$K3JG<$5$l$kFbMF$,e(B1,2e$B$Ne(B2e$BDL$j$”$k$N$G!"$=$l$rDY$5$J$$$h$&$Ke(B
e$B$7$^$7$?!#e(B

#e$B$H$3$3$^$G=q$$$?$i!"Kb?@$+$i%Q%C%A$,=P$F$7$^$C$?!#e(B

— regex.c.orig 2006-08-07 12:43:42.000000000 +0900
+++ regex.c 2006-11-29 11:43:49.524937500 +0900
@@ -2788,6 +2788,8 @@ re_compile_fastmap(bufp)
unsigned char **stacke = stackb + NFAILURES;
int options = bufp->options;

  • int found_casefold = 0;

  • memset(fastmap, 0, (1 << BYTEWIDTH));
    bufp->fastmap_accurate = 1;
    bufp->can_be_null = 0;
    @@ -2836,6 +2838,19 @@ re_compile_fastmap(bufp)
    case casefold_on:
    bufp->options |= RE_MAY_IGNORECASE;
    options |= RE_OPTION_IGNORECASE;

  •      {
    
  •          if (!found_casefold) {
    
  •              char *p = fastmap;
    
  •              int i;
    
  •              for (i=0; i<=(1<<BYTEWIDTH); i++) {
    
  •                  if (p[i]!=0) {
    
  •                      p[translate[i]] = p[i];
    
  •                      /* p[i] = 0; Do we need this line?*/
    
  •                  }
    
  •              }
    
  •              found_casefold = 1;
    
  •          }
    
  •      }
    

    continue;

     case casefold_off:
    

e$B$J$+$@$G$9!#e(B

At Wed, 29 Nov 2006 12:54:24 +0900,
Yukihiro M. wrote in [ruby-dev:29975]:

e$B$I$C$A$,NI$$$N$+H=CG$9$k$N$,Fq$7$$$G$9$M$(!#$J$+$@$5$s$NJ}$Oe(B
e$B$h$/$o$+$i$J$+$C$?$N$@$1$I!"$b$7$+$7$F#2HVL$Ne(Bchunke$B$O%9%Z!<e(B
e$B%9$,$:$l$F$k$@$1!)e(B e$B$@$H$9$k$H!"$=$C$A$NJ}$,%3%s%Q%/%H$G$+$Ce(B
e$B$3$$$$$+$J$"!#e(B

e$B$G$9!#e(B

e$B$I$C$A$G$b$$$$$G$9$,!"$-$`$i$5$s$N%Q%C%A$K$9$k$J$i!"e(B for
e$B$N>r7o$Oe(B <=
e$B$G$O$J$/e(B < e$B$K$7$J$$$H$^$:$$$G$7$g$&!#e(B

e$BLZB<$G$9!#e(B

e$B4{$K0lEYJL$N%Q%C%A$GL>A0$,;D$C$F$$$^$9$N$G!":NMQ$5$l$k$3$H$K$3$@$o$j$Oe(B
e$B$"$j$^$;$s!#e(Boff-by-one error
e$B$K$O5$$r$D$1$F$$$?$N$G$9$,H4$+$j$^$7$?e(B
(1<<BYTEWIDTH + 1 e$B%P%$%H3NJ]$5$l$F$$$k$H;W$C$?$i$7$$e(B)e$B!#e(B

e$B$H$$$&$3$H$G$J$+$@$5$s$N$b$N$K0lI<$G$9!#e(B

On Wed, 29 Nov 2006 15:35:00 +0900

At Wed, 29 Nov 2006 15:35:00 +0900,
matz wrote:

e$B$(!<$H!“e(B1.8e$B$K$D$$$F$Oe(Bknue$B$5$s$,!VEv$F$F$/$@$5$$!W$H8@$&$Y$-$Je(B
e$B$N$+$7$i$s!#;d$H$7$F$OL@$i$+$J%P%0$J$N$GEv$F$F$[$7$$$N$G$9$,!#e(B
e$B$I$C$A$G$b$$$$$1$I!”%3%s%Q%/%H$5$G$J$+$@$5$s$N$+$J!#e(B

e$B!!$O$$!";d$b$=$A$i$K0lI<!#e(B

e$B!!$^$@;d$,e(B [ruby-dev:29919]
e$B$GDs<($7$?%V%i%s%A%]%j%7!<0F$K$D$$$Fe(B
e$B==J,$K0U8+$rD:$$$?$H$$$&46$8$O$"$j$^$;$s$,!“FC$KH?BP$b$J$$$N$G!“e(B
e$B$H$j$”$($:$3$l$G1?MQ$7$^$9!#2K$r8+$F1QLu$7!”<~CN$r?^$j$^$9!#e(B


/
/__ __ Akinori.org / MUSHA.org
/ ) ) ) ) / FreeBSD.org / Ruby-lang.org
Akinori MUSHA aka / (_ / ( (__( @ iDaemons.org / and.or.jp

“Different eyes see different things,
Different hearts beat on different strings –
But there are times for you and me when all such things agree”

e$BKNIt$G$9!#e(B

e$B$-$`$i$3$&$$$Ae(B wrote:

e$BLZB<$G$9!#e(B

e$B#2$A$c$s$M$k$Ne(BRubye$B%9%l$GJs9p$5$l$F$$$?$N$G$9$,!“e(B1.8e$B0JA0$Ne(Bregex
e$B%k!<%A%s$Ne(B (?i) e$B%U%i%0$N=hM}$KLdBj$,$”$j$^$9!#$?$H$($Pe(B

/(B|(?i)c)/ =~ ‘B’

e$B$G%^%C%A$K<:GT$7$^$9!#e(B

e$B$3$N7o$G$9$,e(B1.8.5e$B$K$b=$@5F~$l$k$Y$-$G$7$g$&$+e(B?
e$B%P%0$O%P%0$J$N$G$9$,=$@5$9$k$H8eJ}8_49@-$,<:$o$l$k$N$G$I$&$7$?$b$N$+e(B
e$B$He(B…e$B$3$s$JHyL/$J5sF0$K0MB8$7$?%9%/%j%W%H$OAaHU6nC$5$l$k$Y$-$@$H$O;W$$e(B e$B$^$9$,!"5U$K;EMM$H8@$$@Z$C$F$7$^$C$F$b$"$^$j:$$i$J$$N$N%P%0$J5$$b$7$J$/e(B
e$B$b$J$$$?$a!"<c43G:$s$G$$$^$9!#e(B

e$B$^$D$b$He(B e$B$f$-$R$m$G$9e(B

In message “Re: [ruby-dev:29976] Re: BUG: Incorrect handling of
Ignorecase matching (regex.c of 1.8.5)”
on Wed, 29 Nov 2006 15:28:17 +0900, “Nobuyoshi N.”
[email protected] writes:

|At Wed, 29 Nov 2006 12:54:24 +0900,
|Yukihiro M. wrote in [ruby-dev:29975]:
|> e$B$I$C$A$,NI$$$N$+H=CG$9$k$N$,Fq$7$$$G$9$M$(!#$J$+$@$5$s$NJ}$Oe(B
|> e$B$h$/$o$+$i$J$+$C$?$N$@$1$I!“$b$7$+$7$F#2HVL$Ne(Bchunke$B$O%9%Z!<e(B
|> e$B%9$,$:$l$F$k$@$1!)e(B e$B$@$H$9$k$H!”$=$C$A$NJ}$,%3%s%Q%/%H$G$+$Ce(B
|> e$B$3$$$$$+$J$“!#e(B
|
|e$B$G$9!#e(B
|
|e$B$I$C$A$G$b$$$$$G$9$,!”$-$`$i$5$s$N%Q%C%A$K$9$k$J$i!"e(B for e$B$N>r7o$Oe(B <=
|e$B$G$O$J$/e(B < e$B$K$7$J$$$H$^$:$$$G$7$g$&!#e(B

e$B$(!<$H!“e(B1.8e$B$K$D$$$F$Oe(Bknue$B$5$s$,!VEv$F$F$/$@$5$$!W$H8@$&$Y$-$Je(B
e$B$N$+$7$i$s!#;d$H$7$F$OL@$i$+$J%P%0$J$N$GEv$F$F$[$7$$$N$G$9$,!#e(B
e$B$I$C$A$G$b$$$$$1$I!”%3%s%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%g%s$X$N0\9Te(B
e$B$^$G%P%0$N2sHr%3!<%I$r0z$-$:$k$3$H$r6/$$$k$N$OK>$^$7$/$J$$$H9M$($ke(B
e$B$+$i$G$9!#e(B


/
/__ __ Akinori.org / MUSHA.org
/ ) ) ) ) / FreeBSD.org / Ruby-lang.org
Akinori MUSHA aka / (_ / ( (__( @ iDaemons.org / and.or.jp

“Different eyes see different things,
Different hearts beat on different strings –
But there are times for you and me when all such things agree”

e$B$J$+$@$G$9!#e(B

At Mon, 4 Dec 2006 18:15:58 +0900,
Urabe S. wrote in [ruby-dev:29985]:

e$B$3$N7o$G$9$,e(B1.8.5e$B$K$b=$@5F~$l$k$Y$-$G$7$g$&$+e(B?
e$B%P%0$O%P%0$J$N$G$9$,=$@5$9$k$H8eJ}8_49@-$,<:$o$l$k$N$G$I$&$7$?$b$N$+e(B
e$B$He(B…e$B$3$s$JHyL/$J5sF0$K0MB8$7$?%9%/%j%W%H$OAaHU6nC$5$l$k$Y$-$@$H$O;W$$e(B e$B$^$9$,!"5U$K;EMM$H8@$$@Z$C$F$7$^$C$F$b$"$^$j:$$i$J$$N$N%P%0$J5$$b$7$J$/e(B
e$B$b$J$$$?$a!"<c43G:$s$G$$$^$9!#e(B

e$B;EMM$H$$$&$N$ODq93$,$"$k$N$G!"e(BKnown
bugse$B$H$7$F$I$3$+$K=q$$$F$*e(B
e$B$/$N$O$I$&$G$7$g$&$+!#e(B

At Mon, 4 Dec 2006 20:21:44 +0900,
Urabe S. wrote in [ruby-dev:29987]:

e$B$H$3$m$G$U$H;W$C$?$N$G$9$,$3$N%P%0$C$F%9%/%j%W%HB&$+$i2sHr2DG=$J$s$G$9$+$M!#e(B
e$B%9%/%j%W%HB&$G1*2s$G$-$k$b$N$G8eJ}8_49$,B;$J$o$l$k=$@5$Oe(Bruby_1_8_5e$B$K$OF~e(B
e$B$l$J$$J}$,$$$$5$$,$7$F$-$^$7$?!#e(B

e$B4JC1$JJ}K!$O=g=x$rJQ$($k$3$H$G$7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}$,$$$$5$$,$7$F$-$^$7$?!#e(B

e$BLZB<$G$9!#e(B

e$B$J$+$@$5$s$N%Q%C%A$,Ev$?$C$F$$$J$$>uBV$G$N2sHr:v$r;n$7$F$$$F!“e(B
e$B=$@5$,IT==J,$G$”$k$3$H$,$o$+$j$^$7$?!#e(B

e$B$J$+$@$5$s$N%Q%C%A$,Ev$?$C$?>uBV$G$be(B

E:\ruby-stable>ruby185 -ve “p(/(?-i:A)/i =~ ‘A’)”
ruby 1.8.5 (2006-08-25) [i386-mswin32]
nil

E:\ruby-stable>ruby185 -ve “p(/(?:i(?-i:A))/ =~ ‘A’)”
ruby 1.8.5 (2006-08-25) [i386-mswin32]
nil

e$B$N$h$&$JNc$G!"%^%C%A$9$Y$-$J$N$K%^%C%A$K<:GT$7$^$9!#e(B
e$B860x$O@h$N$b$N$HF1:,$G$9!#e(B

 case exactn:
   if (p[1] == 0xff) {
     if (TRANSLATE_P())
       fastmap[translate[p[2]]] = 2;
     else
       fastmap[p[2]] = 2;
     bufp->options |= RE_OPTIMIZE_BMATCH;
   }
   else if (TRANSLATE_P())
     fastmap[translate[p[1]]] = 1;
   else
     fastmap[p[1]] = 1;
   break;

re_compile_fastmape$BCf$N>e5-$NItJ,$G!"e(BTRANSLATE_P()e$B$K$h$C$FH=Dj$7$F$$$^$9$,!"e(B
e$B$=$NDj5A$Oe(B

#define TRANSLATE_P() ((options&RE_OPTION_IGNORECASE) && translate)

e$B$H$J$C$F$$$Fe(B (?:-i)
e$B$r8+$D$1$?$H$3$m$G$3$N%S%C%H$rMn$H$7$F$7$^$&$N$Ge(B
translatee$B$J$7$Ne(Belsee$B@a$rDL$k$N$G$9$,<B:]$Ke(Bre_searche$B$G%^%C%A0LCV$rC5$9$H$-$K$Oe(B
translatee$B$"$j$NJ}$r;H$C$F$7$^$&$N$G!"@h$N%P%0$HF1$87k2L$H$J$j$^$9!#e(B

e$B:,K\E*$J=$@5$O=$@52U=j$,J#?t$K$J$k$J$I$NM}M3$GFq$7$$$H;W$$$^$9$,!"e(B
e$B;29M$^$G$K;n$7$?%Q%C%A$G$9!#e(B
e$B$J$+$@$5$s$N%Q%C%A$,Ev$?$C$F$J$$%=!<%9$+$i$N:9J,$G$9!#e(B

e$B$H$j$"$($:!!e(Bknown
buge$B$H$7$F%Z%s%G%#%s%0$7$F$*$/$+$I$&$+$J$I$O$*G$$;$7$^$9!#e(B

— regex.c.orig 2006-08-07 12:43:42.000000000 +0900
+++ regex.c 2006-12-06 15:05:27.649250000 +0900
@@ -3104,6 +3104,16 @@ re_compile_fastmap(bufp)
else
break;
}
+

  • if (bufp->options & (RE_OPTION_IGNORECASE|RE_MAY_IGNORECASE)) {
  • int i;
  • for (i = 0; i < (1<<BYTEWIDTH); i++) {
  •  char m = fastmap[i];
    
  •  j = translate[i];
    
  •  if (m > fastmap[j]) fastmap[j] = m;
    
  • }
  • }
  • FREE_AND_RETURN_VOID(stackb);
    }