Hi,
Ruby 1.8.5p12
I noticed that "".upto("anything") causes an infinite loop, since
"".succ returns "".
Is this just a case of, "Don't do that", or do we want to handle empty
strings specially? Just thought I'd ask. If we do want to handle it
specially, I propose the following patch:
--- string.orig Mon Jul 31 00:34:10 2006
+++ string.c Mon Jan 8 09:37:18 2007
@@ -1460,7 +1460,7 @@
StringValue(current);
if (excl && rb_str_equal(current, end)) break;
StringValue(current);
- if (RSTRING(current)->len > RSTRING(end)->len)
+ if (RSTRING(current)->len > RSTRING(end)->len ||
RSTRING(current)->len == 0)
break;
}
This will yield an empty string *once* and then break.
Regards,
Dan