>>>>> "A" == Agnot Tok <agnot_tok / europe.com> writes:

A> Can anyone explain the behavior:

 Probably a problem in regex.c


    case on_failure_jump:
      EXTRACT_NUMBER_AND_INCR(mcnt, p);
      if (mcnt > 0) p += mcnt;
      if ((enum regexpcode)p[-3] == jump) {
	p -= 3;
	EXTRACT_NUMBER_AND_INCR(mcnt, p);
	if (mcnt > 0) p += mcnt;
      }
      break;

 if 'p[-3] == jump' then p must be decremented by 2 before trying to
extract the number, this mean that the line 1052 must be

       p -= 2;

 Someone can confirm ?

pigeon% diff -u regex.c~ regex.c
--- regex.c~    Sat Feb 10 18:33:35 2001
+++ regex.c     Sat Apr 14 15:46:43 2001
@@ -1049,7 +1049,7 @@
       EXTRACT_NUMBER_AND_INCR(mcnt, p);
       if (mcnt > 0) p += mcnt;
       if ((enum regexpcode)p[-3] == jump) {
-       p -= 3;
+       p -= 2;
        EXTRACT_NUMBER_AND_INCR(mcnt, p);
        if (mcnt > 0) p += mcnt;
       }
pigeon%

pigeon% cat b.rb
def cr(b,d,e)
   /^(#{b}(#{d})?#{e})|((#{b})?#{d}(#{e})?)/
end
 
# Why does
puts ("be" =~ cr("b", "d", "e"))
 
# match when
puts ("1e1" =~ cr('(\d(_*\d+)*)', '(\.\d(_*\d+)*)', '((e|E)-?(_*\d+)+)'))
pigeon% 

pigeon% ruby b.rb
0
0
pigeon% 


Guy Decoux