summaryrefslogtreecommitdiff
path: root/string.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-05-26 08:22:33 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-05-26 08:22:33 +0000
commitb4fd4d6018a8ad72f69912606c60ec42ee3b62b8 (patch)
tree7d8e6794c8b14219eb3a1902d6538ea27a239065 /string.c
parentea325deab0729bf17d3f366aa6369d93a4db54fd (diff)
* 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: svn+ssh://ci.ruby-lang.org/ruby/trunk@3867 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'string.c')
-rw-r--r--string.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/string.c b/string.c
index 852a7238f6..0bbd9f5513 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");
}