diff options
| author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2003-05-26 08:22:33 +0000 |
|---|---|---|
| committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2003-05-26 08:22:33 +0000 |
| commit | 77f1318878c194595d599ec7adf0b66d538af742 (patch) | |
| tree | 7d8e6794c8b14219eb3a1902d6538ea27a239065 /string.c | |
| parent | 4e004061014c11a5d0cb6a04d7930268d7713176 (diff) | |
| download | ruby-77f1318878c194595d599ec7adf0b66d538af742.tar.gz ruby-77f1318878c194595d599ec7adf0b66d538af742.tar.xz ruby-77f1318878c194595d599ec7adf0b66d538af742.zip | |
* eval.c (Init_Proc): Block/Proc separation. [huge change]
* eval.c (block_arity): returns exact arity number for Procs out
of methods. also gives 1 for {|a|..}.
* string.c (rb_str_match): revert use of String#index for
invocation like string =~ string.
* eval.c (rb_Array): move Object#to_a exclusion hack from
splat_value(). need to be in eval.c for a while.
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@3867 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'string.c')
| -rw-r--r-- | string.c | 11 |
1 files changed, 8 insertions, 3 deletions
@@ -1020,6 +1020,7 @@ static VALUE rb_str_match(x, y) VALUE x, y; { + VALUE reg; long start; switch (TYPE(y)) { @@ -1027,11 +1028,15 @@ rb_str_match(x, y) return rb_reg_match(y, x); case T_STRING: - start = rb_str_index(x, y, 0); +#if RUBY_VERSION_CODE < 181 + rb_warn("string =~ string will be obsolete; use explicit regexp"); +#endif + reg = rb_reg_regcomp(y); + start = rb_reg_search(reg, x, 0, 0); if (start == -1) { return Qnil; } - return LONG2NUM(start); + return INT2NUM(start); default: return rb_funcall(y, rb_intern("=~"), 1, x); @@ -1459,7 +1464,7 @@ get_pat(pat, quote) if (quote) { val = rb_reg_quote(pat); -#if RUBY_VERSION_CODE < 180 +#if RUBY_VERSION_CODE < 181 if (val != pat && rb_str_cmp(val, pat) != 0) { rb_warn("string pattern instead of regexp; metacharacters no longer effective"); } |
