From 77f1318878c194595d599ec7adf0b66d538af742 Mon Sep 17 00:00:00 2001 From: matz Date: Mon, 26 May 2003 08:22:33 +0000 Subject: * 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 --- string.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'string.c') diff --git a/string.c b/string.c index 852a7238f..0bbd9f551 100644 --- a/string.c +++ b/string.c @@ -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"); } -- cgit