1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

re.c: use name_to_backref_number

* re.c (match_backref_number): use name_to_backref_number for
  casts.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57110 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2016-12-18 11:43:51 +00:00
parent 86f229ec32
commit 9fc44b8790

9
re.c
View file

@ -1111,6 +1111,8 @@ match_size(VALUE match)
return INT2FIX(RMATCH_REGS(match)->num_regs);
}
static int name_to_backref_number(struct re_registers *, VALUE, const char*, const char*);
static int
match_backref_number(VALUE match, VALUE backref)
{
@ -1134,10 +1136,7 @@ match_backref_number(VALUE match, VALUE backref)
break;
}
num = onig_name_to_backref_number(RREGEXP_PTR(regexp),
(const unsigned char*)name,
(const unsigned char*)name + strlen(name),
regs);
num = name_to_backref_number(regs, regexp, name, name + strlen(name));
if (num < 1) {
rb_raise(rb_eIndexError, "undefined group name reference: %s", name);
@ -1819,7 +1818,7 @@ static int
name_to_backref_number(struct re_registers *regs, VALUE regexp, const char* name, const char* name_end)
{
return onig_name_to_backref_number(RREGEXP_PTR(regexp),
(const unsigned char* )name, (const unsigned char* )name_end, regs);
(const unsigned char *)name, (const unsigned char *)name_end, regs);
}
NORETURN(static void name_to_backref_error(VALUE name));