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.

* class.c (rb_define_class): should handle autoload.

* class.c (rb_define_module): ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2225 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
matz 2002-03-19 09:03:11 +00:00
parent 7632b48a7d
commit 6d2e56ce7c
10 changed files with 86 additions and 20 deletions

View file

@ -63,6 +63,15 @@ Sat Mar 16 22:43:53 2002 WATANABE Hirofumi <eban@ruby-lang.org>
* missing/fileblocks.c: add for autoconf.
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.
Sat Mar 16 09:04:58 2002 Koji Arai <JCA02266@nifty.ne.jp>
* enum.c (enum_inject): use the first iterated element as the
@ -96,6 +105,12 @@ Thu Mar 14 22:17:45 2002 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
* ext/iconv: imported.
Thu Mar 14 16:42:37 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
* class.c (rb_define_class): should handle autoload.
* class.c (rb_define_module): ditto.
Thu Mar 14 16:18:12 2002 WATANABE Hirofumi <eban@ruby-lang.org>
* configure.in: autoconf 2.53 support. use AC_LIBOBJ.

View file

@ -184,6 +184,9 @@ rb_define_class(name, super)
ID id;
id = rb_intern(name);
if (rb_autoload_defined(id)) {
rb_autoload_load(id);
}
if (rb_const_defined(rb_cObject, id)) {
klass = rb_const_get(rb_cObject, id);
if (TYPE(klass) != T_CLASS) {
@ -270,6 +273,9 @@ rb_define_module(name)
ID id;
id = rb_intern(name);
if (rb_autoload_defined(id)) {
rb_autoload_load(id);
}
if (rb_const_defined(rb_cObject, id)) {
module = rb_const_get(rb_cObject, id);
if (TYPE(module) == T_MODULE)

View file

@ -1,3 +1,11 @@
: IO
64bit off_t support by Janathan Baker.
: abort()
optional terminate message argument.
: iconv module
Imported. Wrapper library of (({iconv})).

View file

@ -434,14 +434,14 @@ rb_name_error(id, fmt, va_alist)
}
static VALUE
name_name(self)
name_err_name(self)
VALUE self;
{
return rb_iv_get(self, "name");
}
static VALUE
nometh_args(self)
nometh_err_args(self)
VALUE self;
{
return rb_iv_get(self, "args");
@ -633,9 +633,9 @@ Init_Exception()
rb_eIndexError = rb_define_class("IndexError", rb_eStandardError);
rb_eRangeError = rb_define_class("RangeError", rb_eStandardError);
rb_eNameError = rb_define_class("NameError", rb_eStandardError);
rb_define_method(rb_eNameError, "name", name_name, 0);
rb_define_method(rb_eNameError, "name", name_err_name, 0);
rb_eNoMethodError = rb_define_class("NoMethodError", rb_eNameError);
rb_define_method(rb_eNoMethodError, "args", nometh_args, 0);
rb_define_method(rb_eNoMethodError, "args", nometh_err_args, 0);
rb_eScriptError = rb_define_class("ScriptError", rb_eException);
rb_eSyntaxError = rb_define_class("SyntaxError", rb_eScriptError);

4
eval.c
View file

@ -698,7 +698,7 @@ dvar_asgn_internal(id, value, curr)
}
}
static void
static inline void
dvar_asgn(id, value)
ID id;
VALUE value;
@ -706,7 +706,7 @@ dvar_asgn(id, value)
dvar_asgn_internal(id, value, 0);
}
static void
static inline void
dvar_asgn_curr(id, value)
ID id;
VALUE value;

30
parse.y
View file

@ -394,7 +394,7 @@ stmt : kALIAS fitem {lex_state = EXPR_FNAME;} fitem
if (in_def || in_single) {
yyerror("BEGIN in method");
}
local_push();
local_push(0);
}
'{' compstmt '}'
{
@ -1382,7 +1382,7 @@ primary : literal
if (in_def || in_single)
yyerror("class definition in method body");
class_nest++;
local_push();
local_push(0);
$<num>$ = ruby_sourceline;
}
compstmt
@ -1403,7 +1403,7 @@ primary : literal
$<num>$ = in_single;
in_single = 0;
class_nest++;
local_push();
local_push(0);
}
compstmt
kEND
@ -1420,7 +1420,7 @@ primary : literal
if (in_def || in_single)
yyerror("module definition in method body");
class_nest++;
local_push();
local_push(0);
$<num>$ = ruby_sourceline;
}
compstmt
@ -1438,7 +1438,7 @@ primary : literal
$<id>$ = cur_mid;
cur_mid = $2;
in_def++;
local_push();
local_push(0);
}
f_arglist
compstmt
@ -1465,7 +1465,7 @@ primary : literal
| kDEF singleton dot_or_colon {lex_state = EXPR_FNAME;} fname
{
in_single++;
local_push();
local_push(0);
lex_state = EXPR_END; /* force for args */
}
f_arglist
@ -4927,11 +4927,13 @@ static struct local_vars {
int nofree;
int cnt;
int dlev;
struct RVarmap* dyna_vars;
struct local_vars *prev;
} *lvtbl;
static void
local_push()
local_push(top)
int top;
{
struct local_vars *local;
@ -4941,7 +4943,13 @@ local_push()
local->cnt = 0;
local->tbl = 0;
local->dlev = 0;
local->dyna_vars = ruby_dyna_vars;
lvtbl = local;
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
@ -4953,6 +4961,7 @@ local_pop()
if (!lvtbl->nofree) free(lvtbl->tbl);
else lvtbl->tbl[0] = lvtbl->cnt;
}
ruby_dyna_vars = lvtbl->dyna_vars;
free(lvtbl);
lvtbl = local;
}
@ -5012,10 +5021,12 @@ local_id(id)
return Qfalse;
}
static VALUE last_dyna_vars = 0;
static void
top_local_init()
{
local_push();
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);
@ -5176,7 +5187,8 @@ Init_sym()
{
sym_tbl = st_init_strtable_with_size(200);
sym_rev_tbl = st_init_numtable_with_size(200);
rb_global_variable((VALUE*)&lex_lastline);
rb_global_variable(&lex_lastline);
rb_global_variable(&last_dyna_vars);
}
static ID last_id = LAST_TOKEN;

5
re.c
View file

@ -613,7 +613,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 || pos < 0) {
rb_backref_set(Qnil);
return -1;
}
rb_reg_check(re);
if (may_need_recompile) rb_reg_prepare_re(re);

View file

@ -999,6 +999,18 @@ proc{
}.call
test_ok(!defined?(iii)) # out of scope
loop{iii=5; test_ok(eval("defined? iii")); break}
loop {|iii|
iii = 10
def dyna_var_check
loop {
test_ok(!defined?(iii))
break
}
end
dyna_var_check
break
}
$x=0
$proc.call(5)
$proc2.call

View file

@ -887,7 +887,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)) {
@ -936,7 +941,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.7.2"
#define RUBY_RELEASE_DATE "2002-03-18"
#define RUBY_RELEASE_DATE "2002-03-19"
#define RUBY_VERSION_CODE 172
#define RUBY_RELEASE_CODE 20020318
#define RUBY_RELEASE_CODE 20020319