Hi,

At Fri, 27 Jan 2006 01:58:12 +0900,
Paul Duncan wrote in [ruby-core:07220]:
> Most people would expect ['a', 'b', 'c, 'e', 'f'] there.  This could be
> "fixed" in a a couple of ways:
> 
> * Raise an exception if the receiver is modified during a scan (I don't
>   really like this option).
> * Attempt to hack in offset adjustment into string modification.  The
>   functions in question are rb_str_splice() and rb_str_aref(), although
>   I haven't investigated fully, so there may be other methods as well.
>   This is really my least-favorite option, because it doesn't handle the
>   case where someone modifies the receiver while keeping the length the
>   same.
> * Leave things as they are and add a big warning to the String#scan
>   documentation.  Personally, I prefer this option.

* Scan frozen shared string.


Index: string.c =================================================================== RCS file: /cvs/ruby/src/ruby/string.c,v retrieving revision 1.242 diff -p -U2 -r1.242 string.c --- string.c 29 Dec 2005 17:03:27 -0000 1.242 +++ string.c 27 Jan 2006 01:31:02 -0000 @@ -3844,4 +3844,5 @@ rb_str_scan(VALUE str, VALUE pat) pat = get_pat(pat, 1); + str = rb_str_new4(str); if (!rb_block_given_p()) { VALUE ary = rb_ary_new();
-- Nobu Nakada