aboutsummaryrefslogtreecommitdiffstats
path: root/string.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-02-18 12:06:20 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-02-18 12:06:20 +0000
commit43fd658c0c66db00ad60554d2f2af79b5e534da7 (patch)
treeb536a525ef19abb3416888c1348ad939ec32a224 /string.c
parent2654b8b85f9c4c8c20e8e2cdd914154ed0feb944 (diff)
downloadruby-43fd658c0c66db00ad60554d2f2af79b5e534da7.tar.gz
string.c: Symbol#match
* string.c (sym_match_m): delegate to String#match but not String#=~. [ruby-core:72864] [Bug #11991] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53866 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'string.c')
-rw-r--r--string.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/string.c b/string.c
index 7850bcd1d5..2782d28e52 100644
--- a/string.c
+++ b/string.c
@@ -9423,7 +9423,6 @@ sym_casecmp(VALUE sym, VALUE other)
/*
* call-seq:
* sym =~ obj -> fixnum or nil
- * sym.match(obj) -> fixnum or nil
*
* Returns <code>sym.to_s =~ obj</code>.
*/
@@ -9436,6 +9435,19 @@ sym_match(VALUE sym, VALUE other)
/*
* call-seq:
+ * sym.match(obj) -> MatchData or nil
+ *
+ * Returns <code>sym.to_s.match(obj)</code>.
+ */
+
+static VALUE
+sym_match_m(int argc, VALUE *argv, VALUE sym)
+{
+ return rb_str_match_m(argc, argv, rb_sym2str(sym));
+}
+
+/*
+ * call-seq:
* sym[idx] -> char
* sym[b, n] -> string
* sym.slice(idx) -> char
@@ -9763,7 +9775,7 @@ Init_String(void)
rb_define_method(rb_cSymbol, "length", sym_length, 0);
rb_define_method(rb_cSymbol, "size", sym_length, 0);
rb_define_method(rb_cSymbol, "empty?", sym_empty, 0);
- rb_define_method(rb_cSymbol, "match", sym_match, 1);
+ rb_define_method(rb_cSymbol, "match", sym_match_m, -1);
rb_define_method(rb_cSymbol, "upcase", sym_upcase, -1);
rb_define_method(rb_cSymbol, "downcase", sym_downcase, -1);