From: Florian Frank Date: 2003-06-23T08:26:22+09:00 Subject: Re: Range (String) Question --WhfpMioaduB5tiZL Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On 2003-06-23 07:20:13 +0900, D T wrote: [...] Sorry. Perhaps this patch is better to guard against infinite loops without throwing exceptions. -- Were it left to me to decide whether we should have government without newspapers or newspapers without government, I should not hesitate for a moment to prefer the latter. But I should mean that every man should receive those papers and be capable of reading them. -- Thomas Jefferson --WhfpMioaduB5tiZL Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="ruby-string.patch" Index: string.c =================================================================== RCS file: /src/ruby/string.c,v retrieving revision 1.156 diff -u -p -r1.156 string.c --- string.c 26 May 2003 08:22:28 -0000 1.156 +++ string.c 22 Jun 2003 23:24:01 -0000 @@ -1142,12 +1142,14 @@ rb_str_upto(beg, end, excl) VALUE beg, end; int excl; { - VALUE current; + VALUE current, after_end; ID succ = rb_intern("succ"); StringValue(end); + if (rb_str_cmp(beg, end) > 0) return beg; + after_end = rb_funcall(end, succ, 0, 0); current = beg; - while (rb_str_cmp(current, end) <= 0) { + while (!rb_str_equal(current, after_end)) { rb_yield(current); if (!excl && rb_str_equal(current, end)) break; current = rb_funcall(current, succ, 0, 0); --WhfpMioaduB5tiZL--