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

* re.c (rb_reg_search): should clear last_match if pos is out of

string range.

* string.c (rb_str_index_m): ditto.

* string.c (rb_str_rindex): ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_6@2224 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
matz 2002-03-19 09:02:04 +00:00
parent 892bbbf0bf
commit d1a3599bf7
5 changed files with 41 additions and 15 deletions

View file

@ -15,6 +15,15 @@ Mon Mar 18 10:55:03 2002 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
* parse.y (str_extend): handle multi-byte characters.
Sat Mar 16 15:30:40 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
* re.c (rb_reg_search): should clear last_match if pos is out of
string range.
* string.c (rb_str_index_m): ditto.
* string.c (rb_str_rindex): ditto.
Thu Mar 14 16:42:37 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
* class.c (rb_define_class): should handle autoload.

24
parse.y
View file

@ -380,7 +380,7 @@ stmt : kALIAS fitem {lex_state = EXPR_FNAME;} fitem
if (in_def || in_single) {
yyerror("BEGIN in method");
}
local_push(1);
local_push(0);
}
'{' compstmt '}'
{
@ -1249,7 +1249,7 @@ primary : literal
if (in_def || in_single)
yyerror("class definition in method body");
class_nest++;
local_push(1);
local_push(0);
$<num>$ = ruby_sourceline;
}
compstmt
@ -1270,7 +1270,7 @@ primary : literal
$<num>$ = in_single;
in_single = 0;
class_nest++;
local_push(1);
local_push(0);
}
compstmt
kEND
@ -1287,7 +1287,7 @@ primary : literal
if (in_def || in_single)
yyerror("module definition in method body");
class_nest++;
local_push(1);
local_push(0);
$<num>$ = ruby_sourceline;
}
compstmt
@ -1305,7 +1305,7 @@ primary : literal
$<id>$ = cur_mid;
cur_mid = $2;
in_def++;
local_push(1);
local_push(0);
}
f_arglist
compstmt
@ -1333,7 +1333,7 @@ primary : literal
{
value_expr($2);
in_single++;
local_push(1);
local_push(0);
lex_state = EXPR_END; /* force for args */
}
f_arglist
@ -4697,7 +4697,8 @@ static struct local_vars {
} *lvtbl;
static void
local_push(int dyna_init)
local_push(top)
int top;
{
struct local_vars *local;
@ -4709,8 +4710,11 @@ local_push(int dyna_init)
local->dlev = 0;
local->dyna_vars = ruby_dyna_vars;
lvtbl = local;
if (dyna_init) ruby_dyna_vars = (struct RVarmap* )0;
if (!top) {
/* preserve reference for GC, but link should be cut. */
rb_dvar_push(0, (VALUE)ruby_dyna_vars);
ruby_dyna_vars->next = 0;
}
}
static void
@ -4785,7 +4789,7 @@ local_id(id)
static void
top_local_init()
{
local_push(0);
local_push(1);
lvtbl->cnt = ruby_scope->local_tbl?ruby_scope->local_tbl[0]:0;
if (lvtbl->cnt > 0) {
lvtbl->tbl = ALLOC_N(ID, lvtbl->cnt+3);

5
re.c
View file

@ -595,7 +595,10 @@ rb_reg_search(re, str, pos, reverse)
static struct re_registers regs;
int range;
if (pos > RSTRING(str)->len) return -1;
if (pos > RSTRING(str)->len) {
rb_backref_set(Qnil);
return -1;
}
rb_reg_check(re);
if (may_need_recompile) rb_reg_prepare_re(re);

View file

@ -670,7 +670,12 @@ rb_str_index_m(argc, argv, str)
}
if (pos < 0) {
pos += RSTRING(str)->len;
if (pos < 0) return Qnil;
if (pos < 0) {
if (TYPE(sub) == T_REGEXP) {
rb_backref_set(Qnil);
}
return Qnil;
}
}
switch (TYPE(sub)) {
@ -719,7 +724,12 @@ rb_str_rindex(argc, argv, str)
pos = NUM2INT(position);
if (pos < 0) {
pos += RSTRING(str)->len;
if (pos < 0) return Qnil;
if (pos < 0) {
if (TYPE(sub) == T_REGEXP) {
rb_backref_set(Qnil);
}
return Qnil;
}
}
if (pos > RSTRING(str)->len) pos = RSTRING(str)->len;
}

View file

@ -1,4 +1,4 @@
#define RUBY_VERSION "1.6.7"
#define RUBY_RELEASE_DATE "2002-03-18"
#define RUBY_RELEASE_DATE "2002-03-19"
#define RUBY_VERSION_CODE 167
#define RUBY_RELEASE_CODE 20020318
#define RUBY_RELEASE_CODE 20020319