From: Christoph Date: 2003-10-15T18:10:14+09:00 Subject: stringy range bug This is a multi-part message in MIME format. ------=_NextPart_000_0080_01C3930C.DC54EE30 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Hi, currently there is a bug in open ranges with identical boundaries strings. --- p ("a"..."a").to_a # ["a"] --- I also have a back log of old Range questions. Shouldn't a failure like --- class Class alias succ superclass end class A end (A..Object).each {} # raises ... `<=>' for nil:NilClass (NoMethodError) --- be fixed? (the patch should be straight forward) - and why isn't it possible to form ranges with incomparable boundaries - this would make ranges more usefull when iterating in trees - example -- class Class alias succ superclass end class A end class B end (A..B) # raises an argument error --- rather than raising an error we could iterate up to the ``least common successor'' - in our example this would be Object? /Christoph ------=_NextPart_000_0080_01C3930C.DC54EE30 Content-Type: application/octet-stream; name="string.diff" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="string.diff" --- string.c.1.176 2003-10-15 10:09:59.382163200 +0200=0A= +++ string.c 2003-10-15 10:09:25.347153600 +0200=0A= @@ -1174,9 +1174,12 @@=0A= {=0A= VALUE current, after_end;=0A= ID succ =3D rb_intern("succ");=0A= + int limits_cmp;=0A= =0A= StringValue(end);=0A= - if (rb_str_cmp(beg, end) > 0) return beg;=0A= + limits_cmp =3D rb_str_cmp(beg, end);=0A= +=0A= + if ((limits_cmp > 0) || (excl && limits_cmp =3D=3D 0)) return beg;=0A= after_end =3D rb_funcall(end, succ, 0, 0);=0A= current =3D beg;=0A= while (!rb_str_equal(current, after_end)) {=0A= ------=_NextPart_000_0080_01C3930C.DC54EE30--