mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* re.c (match_values_at): make #select to be alias to #values_at
to adapt RDoc description. [ruby-core:12588] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13683 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
7927f32a19
commit
ba9eb2c929
2 changed files with 9 additions and 41 deletions
|
@ -14,6 +14,11 @@ Fri Oct 12 12:44:11 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||||
* array.c (rb_ary_product): accessing out of memory bounds.
|
* array.c (rb_ary_product): accessing out of memory bounds.
|
||||||
condition fixed.
|
condition fixed.
|
||||||
|
|
||||||
|
Fri Oct 12 11:22:15 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||||
|
|
||||||
|
* re.c (match_values_at): make #select to be alias to #values_at
|
||||||
|
to adapt RDoc description. [ruby-core:12588]
|
||||||
|
|
||||||
Thu Oct 11 21:10:17 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
|
Thu Oct 11 21:10:17 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||||
|
|
||||||
* include/ruby/node.h (NOEX_LOCAL): remove unused local visibility.
|
* include/ruby/node.h (NOEX_LOCAL): remove unused local visibility.
|
||||||
|
|
45
re.c
45
re.c
|
@ -1339,8 +1339,8 @@ match_entry(VALUE match, long n)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
if (!OBJ_TAINTED(obj) && rb_safe_level() >= 4)
|
*
|
||||||
rb_raise(rb_eSecurityError, "Insecure: can't modify regexp");
|
* mtch.values_at([index]*) => array
|
||||||
* mtch.select([index]*) => array
|
* mtch.select([index]*) => array
|
||||||
*
|
*
|
||||||
* Uses each <i>index</i> to access the matching values, returning an array of
|
* Uses each <i>index</i> to access the matching values, returning an array of
|
||||||
|
@ -1348,7 +1348,7 @@ match_entry(VALUE match, long n)
|
||||||
*
|
*
|
||||||
* m = /(.)(.)(\d+)(\d)/.match("THX1138: The Movie")
|
* m = /(.)(.)(\d+)(\d)/.match("THX1138: The Movie")
|
||||||
* m.to_a #=> ["HX1138", "H", "X", "113", "8"]
|
* m.to_a #=> ["HX1138", "H", "X", "113", "8"]
|
||||||
* m.select(0, 2, -2) #=> ["HX1138", "X", "113"]
|
* m.values_at(0, 2, -2) #=> ["HX1138", "X", "113"]
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
|
@ -1358,43 +1358,6 @@ match_values_at(int argc, VALUE *argv, VALUE match)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* call-seq:
|
|
||||||
* mtch.select([index]*) => array
|
|
||||||
*
|
|
||||||
* Uses each <i>index</i> to access the matching values, returning an
|
|
||||||
* array of the corresponding matches.
|
|
||||||
*
|
|
||||||
* m = /(.)(.)(\d+)(\d)/.match("THX1138: The Movie")
|
|
||||||
* m.to_a #=> ["HX1138", "H", "X", "113", "8"]
|
|
||||||
* m.select(0, 2, -2) #=> ["HX1138", "X", "113"]
|
|
||||||
*/
|
|
||||||
|
|
||||||
static VALUE
|
|
||||||
match_select(int argc, VALUE *argv, VALUE match)
|
|
||||||
{
|
|
||||||
if (argc > 0) {
|
|
||||||
rb_raise(rb_eArgError, "wrong number of arguments (%d for 0)", argc);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
struct re_registers *regs = RMATCH(match)->regs;
|
|
||||||
VALUE target = RMATCH(match)->str;
|
|
||||||
VALUE result = rb_ary_new();
|
|
||||||
int i;
|
|
||||||
int taint = OBJ_TAINTED(match);
|
|
||||||
|
|
||||||
for (i=0; i<regs->num_regs; i++) {
|
|
||||||
VALUE str = rb_str_subseq(target, regs->beg[i], regs->end[i]-regs->beg[i]);
|
|
||||||
if (taint) OBJ_TAINT(str);
|
|
||||||
if (RTEST(rb_yield(str))) {
|
|
||||||
rb_ary_push(result, str);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* mtch.to_s => str
|
* mtch.to_s => str
|
||||||
|
@ -2453,8 +2416,8 @@ Init_Regexp(void)
|
||||||
rb_define_method(rb_cMatch, "to_a", match_to_a, 0);
|
rb_define_method(rb_cMatch, "to_a", match_to_a, 0);
|
||||||
rb_define_method(rb_cMatch, "[]", match_aref, -1);
|
rb_define_method(rb_cMatch, "[]", match_aref, -1);
|
||||||
rb_define_method(rb_cMatch, "captures", match_captures, 0);
|
rb_define_method(rb_cMatch, "captures", match_captures, 0);
|
||||||
rb_define_method(rb_cMatch, "select", match_select, -1);
|
|
||||||
rb_define_method(rb_cMatch, "values_at", match_values_at, -1);
|
rb_define_method(rb_cMatch, "values_at", match_values_at, -1);
|
||||||
|
rb_define_method(rb_cMatch, "select", match_values_at, -1);
|
||||||
rb_define_method(rb_cMatch, "pre_match", rb_reg_match_pre, 0);
|
rb_define_method(rb_cMatch, "pre_match", rb_reg_match_pre, 0);
|
||||||
rb_define_method(rb_cMatch, "post_match", rb_reg_match_post, 0);
|
rb_define_method(rb_cMatch, "post_match", rb_reg_match_post, 0);
|
||||||
rb_define_method(rb_cMatch, "to_s", match_to_s, 0);
|
rb_define_method(rb_cMatch, "to_s", match_to_s, 0);
|
||||||
|
|
Loading…
Reference in a new issue