diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2001-10-29 05:07:26 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2001-10-29 05:07:26 +0000 |
commit | 88abd791f522c7097141753c3480a456340215f8 (patch) | |
tree | ac7f94b43697aed5cb9306aa19a904f08ab8a2d7 | |
parent | 429f7ed113dc862b121ab63c73170e4169853581 (diff) |
* parse.y (str_extend): shuould allow interpolation of $-x.
* variable.c (rb_cvar_set): empty iv_tbl may cause infinite loop.
* variable.c (rb_cvar_get): ditto.
* variable.c (cvar_override_check): ditto.
* bignum.c (rb_big_eq): convert Bignum to Float, instead of
reverse.
* time.c (time_localtime): getting tm should not be prohibited for
frozen time objects.
* time.c (time_gmtime): ditto.
* version.c (Init_version): freeze RUBY_VERSION,
RUBY_RELEASE_DATE, and RUBY_PLATFORM.
* file.c (Init_File): freeze File::SEPARATOR, ALT_SEPARATOR and
PATH_SEPARATOR.
* file.c (rb_stat_cmp): should check operand type before calling
get_stat().
* eval.c (rb_eval_cmd): should not invoke "call" with a block on
any occasion.
* numeric.c (fix_aref): idx may be a Bignum.
* numeric.c (num_remainder): a bug in Numeric#remainder.
* eval.c (rb_exec_end_proc): END might be called within END
block.
* class.c (rb_mod_clone): should not copy class name, since clone
should remain anonymous.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1800 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 47 | ||||
-rw-r--r-- | array.c | 2 | ||||
-rw-r--r-- | bignum.c | 3 | ||||
-rw-r--r-- | error.c | 4 | ||||
-rw-r--r-- | eval.c | 31 | ||||
-rw-r--r-- | ext/socket/socket.c | 2 | ||||
-rw-r--r-- | ext/tcltklib/tcltklib.c | 4 | ||||
-rw-r--r-- | ext/tk/lib/tk.rb | 17 | ||||
-rw-r--r-- | file.c | 25 | ||||
-rw-r--r-- | hash.c | 10 | ||||
-rw-r--r-- | intern.h | 2 | ||||
-rw-r--r-- | io.c | 3 | ||||
-rw-r--r-- | lib/tracer.rb | 4 | ||||
-rw-r--r-- | numeric.c | 28 | ||||
-rw-r--r-- | parse.y | 6 | ||||
-rw-r--r-- | ruby.h | 2 | ||||
-rw-r--r-- | time.c | 12 | ||||
-rw-r--r-- | variable.c | 39 | ||||
-rw-r--r-- | version.c | 6 | ||||
-rw-r--r-- | version.h | 4 |
20 files changed, 174 insertions, 77 deletions
@@ -1,3 +1,43 @@ +Mon Oct 29 07:57:31 2001 Yukihiro Matsumoto <matz@ruby-lang.org> + + * parse.y (str_extend): shuould allow interpolation of $-x. + + * variable.c (rb_cvar_set): empty iv_tbl may cause infinite loop. + + * variable.c (rb_cvar_get): ditto. + + * variable.c (cvar_override_check): ditto. + +Sat Oct 27 23:01:19 2001 Yukihiro Matsumoto <matz@ruby-lang.org> + + * bignum.c (rb_big_eq): convert Bignum to Float, instead of + reverse. + +Fri Oct 26 06:19:29 2001 Yukihiro Matsumoto <matz@ruby-lang.org> + + * time.c (time_localtime): getting tm should not be prohibited for + frozen time objects. + + * time.c (time_gmtime): ditto. + + * version.c (Init_version): freeze RUBY_VERSION, + RUBY_RELEASE_DATE, and RUBY_PLATFORM. + + * file.c (Init_File): freeze File::SEPARATOR, ALT_SEPARATOR and + PATH_SEPARATOR. + + * file.c (rb_stat_cmp): should check operand type before calling + get_stat(). + +Thu Oct 25 10:28:15 2001 Yukihiro Matsumoto <matz@ruby-lang.org> + + * eval.c (rb_eval_cmd): should not invoke "call" with a block on + any occasion. + +Wed Oct 24 03:25:31 2001 Yukihiro Matsumoto <matz@ruby-lang.org> + + * numeric.c (fix_aref): idx may be a Bignum. + Tue Oct 23 01:21:19 2001 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp> * eval.c (proc_invoke): fix self switching in Proc#call @@ -43,8 +83,15 @@ Tue Oct 23 01:15:43 2001 K.Kosako <kosako@sofnec.co.jp> * variable.c (rb_alias_variable): ditto. +Mon Oct 22 18:53:55 2001 Masahiro Tanaka <masa@stars.gsfc.nasa.gov> + + * numeric.c (num_remainder): a bug in Numeric#remainder. + Mon Oct 22 15:21:55 2001 Yukihiro Matsumoto <matz@ruby-lang.org> + * eval.c (rb_exec_end_proc): END might be called within END + block. + * class.c (rb_mod_clone): should not copy class name, since clone should remain anonymous. @@ -890,7 +890,7 @@ inspect_ensure(obj) VALUE rb_protect_inspect(func, obj, arg) - VALUE (*func)(); + VALUE (*func)(ANYARGS); VALUE obj, arg; { struct inspect_arg iarg; @@ -593,8 +593,7 @@ rb_big_eq(x, y) case T_BIGNUM: break; case T_FLOAT: - y = dbl2big(RFLOAT(y)->value); - break; + return (rb_big2dbl(x) == RFLOAT(y)->value)?Qtrue:Qfalse; default: return Qfalse; } @@ -734,14 +734,14 @@ rb_sys_fail(mesg) #ifdef __BEOS__ ee = get_syserr(n); if (!ee) { - char name[6]; + char name[12]; sprintf(name, "E%03d", n); ee = set_syserr(n, name); } #else if (n > sys_nerr || !syserr_list[n]) { - char name[6]; + char name[12]; sprintf(name, "E%03d", n); ee = set_syserr(n, name); @@ -1349,8 +1349,10 @@ rb_eval_cmd(cmd, arg) volatile int safe = ruby_safe_level; if (TYPE(cmd) != T_STRING) { - return rb_funcall2(cmd, rb_intern("call"), - RARRAY(arg)->len, RARRAY(arg)->ptr); + PUSH_ITER(ITER_NOT); + val = rb_funcall2(cmd, rb_intern("call"), RARRAY(arg)->len, RARRAY(arg)->ptr); + POP_ITER(); + return val; } saved_scope = ruby_scope; @@ -2736,7 +2738,7 @@ rb_eval(self, n) val = rb_funcall(val, node->nd_mid, 1, rb_eval(self, rval)); } argv[argc-1] = val; - val = rb_funcall2(recv, aset, argc, argv); + rb_funcall2(recv, aset, argc, argv); result = val; } break; @@ -3921,7 +3923,7 @@ assign(self, lhs, val, pcall) VALUE rb_iterate(it_proc, data1, bl_proc, data2) - VALUE (*it_proc)(), (*bl_proc)(); + VALUE (*it_proc) _((VALUE)), (*bl_proc)(ANYARGS); VALUE data1, data2; { int state; @@ -3995,10 +3997,10 @@ handle_rescue(self, node) VALUE #ifdef HAVE_STDARG_PROTOTYPES -rb_rescue2(VALUE (*b_proc)(), VALUE data1, VALUE (*r_proc)(), VALUE data2, ...) +rb_rescue2(VALUE (*b_proc)(ANYARGS), VALUE data1, VALUE (*r_proc)(ANYARGS), VALUE data2, ...) #else rb_rescue2(b_proc, data1, r_proc, data2, va_alist) - VALUE (*b_proc)(), (*r_proc)(); + VALUE (*b_proc)(ANYARGS), (*r_proc)(ANYARGS); VALUE data1, data2; va_dcl #endif @@ -4089,8 +4091,9 @@ rb_protect(proc, data, state) VALUE rb_ensure(b_proc, data1, e_proc, data2) VALUE (*b_proc)(); + VALUE data1; VALUE (*e_proc)(); - VALUE data1, data2; + VALUE data2; { int state; volatile VALUE result = Qnil; @@ -5959,12 +5962,20 @@ rb_f_at_exit() void rb_exec_end_proc() { - struct end_proc_data *link; + struct end_proc_data *link, *save; int status; - link = end_procs; + save = link = end_procs; while (link) { - rb_protect((VALUE(*)_((VALUE)))link->func, link->data, &status); + rb_protect((VALUE(*)())link->func, link->data, &status); + if (status) { + error_handle(status); + } + link = link->next; + } + link = end_procs; + while (link != save) { + rb_protect((VALUE(*)())link->func, link->data, &status); if (status) { error_handle(status); } diff --git a/ext/socket/socket.c b/ext/socket/socket.c index 8974096bbc..e1f84376aa 100644 --- a/ext/socket/socket.c +++ b/ext/socket/socket.c @@ -849,9 +849,11 @@ open_inet(class, remote_host, remote_serv, local_host, local_serv, type) continue; } if (type == INET_SERVER) { +#ifndef NT status = 1; setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (char*)&status, sizeof(status)); +#endif status = bind(fd, res->ai_addr, res->ai_addrlen); syscall = "bind(2)"; } diff --git a/ext/tcltklib/tcltklib.c b/ext/tcltklib/tcltklib.c index 6c95b42b37..e9c2b56fc1 100644 --- a/ext/tcltklib/tcltklib.c +++ b/ext/tcltklib/tcltklib.c @@ -157,7 +157,9 @@ ip_ruby(clientData, interp, argc, argv) DUMP2("rb_eval_string(%s)", arg); old_trapflg = rb_trap_immediate; rb_trap_immediate = 0; - res = rb_rescue(rb_eval_string, (VALUE)arg, ip_eval_rescue, (VALUE)&failed); + res = rb_rescue2(rb_eval_string, (VALUE)arg, + ip_eval_rescue, (VALUE)&failed, + rb_eStandardError, rb_eScriptError, 0); rb_trap_immediate = old_trapflg; Tcl_ResetResult(interp); diff --git a/ext/tk/lib/tk.rb b/ext/tk/lib/tk.rb index e64a6b3af7..967d185053 100644 --- a/ext/tk/lib/tk.rb +++ b/ext/tk/lib/tk.rb @@ -77,6 +77,9 @@ module TkComm def tk_split_list(str) return [] if str == "" idx = str.index('{') + while idx and idx > 0 and str[idx-1] == ?\\ + idx = str.index('{', idx+1) + end return tk_tcl2ruby(str) unless idx list = tk_tcl2ruby(str[0,idx]) @@ -90,6 +93,7 @@ module TkComm brace -= 1 if c == ?} break if brace == 0 } + p str[0,i] if str[0, i] == ' ' list.push ' ' else @@ -102,6 +106,9 @@ module TkComm def tk_split_simplelist(str) return [] if str == "" idx = str.index('{') + while idx and idx > 0 and str[idx-1] == ?\\ + idx = str.index('{', idx+1) + end return str.split unless idx list = str[0,idx].split @@ -467,7 +474,15 @@ module TkCore INTERP = TclTkIp.new - INTERP._invoke("proc", "rb_out", "args", "if {[set st [catch {ruby [format \"TkCore.callback %%Q!%s!\" $args]} ret]] != 0} {if {[regsub -all {!} $args {\\!} newargs] == 0} {return -code $st $ret} {if {[set st [catch {ruby [format \"TkCore.callback %%Q!%s!\" $newargs]} ret]] != 0} {return -code $st $ret} {return $ret}}} {return $ret}") + INTERP._invoke("proc", "rb_out", "args", <<-'EOL') + regsub -all {!} $args {\\!} args + regsub -all "{" $args "\\{" args + if {[set st [catch {ruby [format "TkCore.callback %%Q!%s!" $args]} ret]] != 0} { + return -code $st $ret + } { + return $ret + } + EOL def callback_break fail TkCallbackBreak, "Tk callback returns 'break' status" @@ -143,14 +143,17 @@ static VALUE rb_stat_cmp(self, other) VALUE self, other; { - time_t t1 = get_stat(self)->st_mtime; - time_t t2 = get_stat(other)->st_mtime; - if (t1 == t2) - return INT2FIX(0); - else if (t1 < t2) - return INT2FIX(-1); - else - return INT2FIX(1); + if (rb_obj_is_kind_of(other, rb_obj_class(self))) { + time_t t1 = get_stat(self)->st_mtime; + time_t t2 = get_stat(other)->st_mtime; + if (t1 == t2) + return INT2FIX(0); + else if (t1 < t2) + return INT2FIX(-1); + else + return INT2FIX(1); + } + rb_raise(rb_eTypeError, "operand is not File::Stat"); } static VALUE @@ -2492,18 +2495,18 @@ Init_File() rb_define_singleton_method(rb_cFile, "basename", rb_file_s_basename, -1); rb_define_singleton_method(rb_cFile, "dirname", rb_file_s_dirname, 1); - separator = rb_str_new2("/"); + separator = rb_obj_freeze(rb_str_new2("/")); rb_define_const(rb_cFile, "Separator", separator); rb_define_const(rb_cFile, "SEPARATOR", separator); rb_define_singleton_method(rb_cFile, "split", rb_file_s_split, 1); rb_define_singleton_method(rb_cFile, "join", rb_file_s_join, -2); #if defined DOSISH && !defined __CYGWIN__ - rb_define_const(rb_cFile, "ALT_SEPARATOR", rb_str_new2("\\")); + rb_define_const(rb_cFile, "ALT_SEPARATOR", rb_obj_freeze(rb_str_new2("\\"))); #else rb_define_const(rb_cFile, "ALT_SEPARATOR", Qnil); #endif - rb_define_const(rb_cFile, "PATH_SEPARATOR", rb_str_new2(PATH_SEP)); + rb_define_const(rb_cFile, "PATH_SEPARATOR", rb_obj_freeze(rb_str_new2(PATH_SEP))); rb_define_method(rb_cIO, "stat", rb_io_stat, 0); /* this is IO's method */ rb_define_method(rb_cFile, "lstat", rb_file_lstat, 0); @@ -1098,7 +1098,7 @@ ruby_unsetenv(name) } static VALUE -rb_f_setenv(obj, nm, val) +env_aset(obj, nm, val) VALUE obj, nm, val; { char *name, *value; @@ -1126,13 +1126,13 @@ rb_f_setenv(obj, nm, val) if (OBJ_TAINTED(val)) { /* already tainted, no check */ path_tainted = 1; - return Qtrue; + return val; } else { path_tainted_p(value); } } - return Qtrue; + return val; } static VALUE @@ -1499,8 +1499,8 @@ Init_Hash() rb_define_singleton_method(envtbl,"[]", rb_f_getenv, 1); rb_define_singleton_method(envtbl,"fetch", env_fetch, -1); - rb_define_singleton_method(envtbl,"[]=", rb_f_setenv, 2); - rb_define_singleton_method(envtbl,"store", rb_f_setenv, 2); + rb_define_singleton_method(envtbl,"[]=", env_aset, 2); + rb_define_singleton_method(envtbl,"store", env_aset, 2); rb_define_singleton_method(envtbl,"each", env_each, 0); rb_define_singleton_method(envtbl,"each_pair", env_each, 0); rb_define_singleton_method(envtbl,"each_key", env_each_key, 0); @@ -50,7 +50,7 @@ VALUE rb_ary_assoc _((VALUE, VALUE)); VALUE rb_ary_rassoc _((VALUE, VALUE)); VALUE rb_ary_includes _((VALUE, VALUE)); VALUE rb_ary_cmp _((VALUE, VALUE)); -VALUE rb_protect_inspect _((VALUE(*)(),VALUE,VALUE)); +VALUE rb_protect_inspect _((VALUE(*)(VALUE,VALUE),VALUE,VALUE)); VALUE rb_inspecting_p _((VALUE)); /* bignum.c */ VALUE rb_big_clone _((VALUE)); @@ -3531,7 +3531,8 @@ Init_IO() rb_output_fs = Qnil; rb_define_hooked_variable("$,", &rb_output_fs, 0, rb_str_setter); - rb_rs = rb_default_rs = rb_str_new2("\n"); rb_output_rs = Qnil; + rb_rs = rb_default_rs = rb_str_new2("\n"); + rb_output_rs = Qnil; rb_global_variable(&rb_default_rs); OBJ_FREEZE(rb_default_rs); /* avoid modifying RS_default */ rb_define_variable("$/", &rb_rs); diff --git a/lib/tracer.rb b/lib/tracer.rb index 54179dd193..dbe18eacc2 100644 --- a/lib/tracer.rb +++ b/lib/tracer.rb @@ -17,12 +17,12 @@ class Tracer @RCS_ID='-$Id: tracer.rb,v 1.8 1998/05/19 03:42:49 keiju Exp keiju $-' @stdout = STDOUT + @verbose = false class << self attr :verbose, true alias verbose? verbose attr :stdout, true end - verbose = true MY_FILE_NAME = caller(0)[0].scan(/^(.*):[0-9]+$/)[0][0] @@ -155,7 +155,7 @@ class Tracer end -LINES__ = {} unless defined? LINES__ +SCRIPT_LINES__ = {} unless defined? SCRIPT_LINES__ if caller(0).size == 1 if $0 == Tracer::MY_FILE_NAME @@ -153,10 +153,11 @@ num_remainder(x, y) { VALUE z = rb_funcall(x, '%', 1, y); - if ((RTEST(rb_funcall(x, '<', 1, INT2FIX(0))) && - RTEST(rb_funcall(y, '>', 1, INT2FIX(0)))) || - (RTEST(rb_funcall(x, '>', 1, INT2FIX(0))) && - RTEST(rb_funcall(y, '<', 1, INT2FIX(0))))) { + if ((!RTEST(rb_equal(z, INT2FIX(0)))) && + ((RTEST(rb_funcall(x, '<', 1, INT2FIX(0))) && + RTEST(rb_funcall(y, '>', 1, INT2FIX(0)))) || + (RTEST(rb_funcall(x, '>', 1, INT2FIX(0))) && + RTEST(rb_funcall(y, '<', 1, INT2FIX(0)))))) { return rb_funcall(z, '-', 1, y); } return z; @@ -1310,15 +1311,22 @@ fix_aref(fix, idx) VALUE fix, idx; { long val = FIX2LONG(fix); - int i = NUM2INT(idx); - if (i < 0 || sizeof(VALUE)*CHAR_BIT-1 < i) { - if (val < 0) return INT2FIX(1); + if (TYPE(idx) == T_BIGNUM) { + if (val >= 0) return INT2FIX(0); + return INT2FIX(1); + } + else { + int i = NUM2INT(idx); + + if (i < 0 || sizeof(VALUE)*CHAR_BIT-1 < i) { + if (val < 0) return INT2FIX(1); + return INT2FIX(0); + } + if (val & (1L<<i)) + return INT2FIX(1); return INT2FIX(0); } - if (val & (1L<<i)) - return INT2FIX(1); - return INT2FIX(0); } static VALUE @@ -3847,6 +3847,12 @@ str_extend(list, term) tokadd(c); goto fetch_id; + case '-': + tokadd(c); + c = nextc(); + tokadd(c); + goto fetch_id; + default: if (c == term) { list_append(list, NEW_STR(rb_str_new2("#$"))); @@ -488,7 +488,7 @@ void rb_warn __((const char*, ...)); /* reports always */ VALUE rb_each _((VALUE)); VALUE rb_yield _((VALUE)); int rb_block_given_p _((void)); -VALUE rb_iterate _((VALUE(*)(ANYARGS),VALUE,VALUE(*)(ANYARGS),VALUE)); +VALUE rb_iterate _((VALUE(*)(VALUE),VALUE,VALUE(*)(ANYARGS),VALUE)); VALUE rb_rescue _((VALUE(*)(ANYARGS),VALUE,VALUE(*)(ANYARGS),VALUE)); VALUE rb_rescue2 __((VALUE(*)(ANYARGS),VALUE,VALUE(*)(ANYARGS),VALUE,...)); VALUE rb_ensure _((VALUE(*)(ANYARGS),VALUE,VALUE(*)(ANYARGS),VALUE)); @@ -706,10 +706,10 @@ time_localtime(time) time_t t; GetTimeval(time, tobj); - if (tobj->tm_got && !tobj->gmt) { - return time; + if (tobj->tm_got) { + if (!tobj->gmt) return time; + time_modify(time); } - time_modify(time); t = tobj->tv.tv_sec; tm_tmp = localtime(&t); tobj->tm = *tm_tmp; @@ -727,10 +727,10 @@ time_gmtime(time) time_t t; GetTimeval(time, tobj); - if (tobj->tm_got && tobj->gmt) { - return time; + if (tobj->tm_got) { + if (tobj->gmt) return time; + time_modify(time); } - time_modify(time); t = tobj->tv.tv_sec; tm_tmp = gmtime(&t); tobj->tm = *tm_tmp; diff --git a/variable.c b/variable.c index bf2c2c918d..fc02f749f7 100644 --- a/variable.c +++ b/variable.c @@ -1425,11 +1425,12 @@ cvar_override_check(id, a, b) { a = RCLASS(a)->super; while (a) { - if (!RCLASS(a)->iv_tbl) continue; - if (st_lookup(RCLASS(a)->iv_tbl,id,0)) { - rb_warning("class variable %s of %s is overridden by %s", - rb_id2name(id), rb_class2name(a), - rb_class2name(b)); + if (RCLASS(a)->iv_tbl) { + if (st_lookup(RCLASS(a)->iv_tbl,id,0)) { + rb_warning("class variable %s of %s is overridden by %s", + rb_id2name(id), rb_class2name(a), + rb_class2name(b)); + } } a = RCLASS(a)->super; } @@ -1445,15 +1446,16 @@ rb_cvar_set(klass, id, val) tmp = klass; while (tmp) { - if (!RCLASS(tmp)->iv_tbl) continue; - if (st_lookup(RCLASS(tmp)->iv_tbl,id,0)) { - if (!OBJ_TAINTED(tmp) && rb_safe_level() >= 4) - rb_raise(rb_eSecurityError, "Insecure: can't modify class variable"); - st_insert(RCLASS(tmp)->iv_tbl,id,val); - if (ruby_verbose) { - cvar_override_check(id, tmp, klass); + if (RCLASS(tmp)->iv_tbl) { + if (st_lookup(RCLASS(tmp)->iv_tbl,id,0)) { + if (!OBJ_TAINTED(tmp) && rb_safe_level() >= 4) + rb_raise(rb_eSecurityError, "Insecure: can't modify class variable"); + st_insert(RCLASS(tmp)->iv_tbl,id,val); + if (ruby_verbose) { + cvar_override_check(id, tmp, klass); + } + return; } - return; } tmp = RCLASS(tmp)->super; } @@ -1500,12 +1502,13 @@ rb_cvar_get(klass, id) tmp = klass; while (tmp) { - if (!RCLASS(tmp)->iv_tbl) continue; - if (st_lookup(RCLASS(tmp)->iv_tbl,id,&value)) { - if (ruby_verbose) { - cvar_override_check(id, tmp, klass); + if (RCLASS(tmp)->iv_tbl) { + if (st_lookup(RCLASS(tmp)->iv_tbl,id,&value)) { + if (ruby_verbose) { + cvar_override_check(id, tmp, klass); + } + return value; } - return value; } tmp = RCLASS(tmp)->super; } @@ -17,9 +17,9 @@ void Init_version() { - VALUE v = rb_str_new2(RUBY_VERSION); - VALUE d = rb_str_new2(RUBY_RELEASE_DATE); - VALUE p = rb_str_new2(RUBY_PLATFORM); + VALUE v = rb_obj_freeze(rb_str_new2(RUBY_VERSION)); + VALUE d = rb_obj_freeze(rb_str_new2(RUBY_RELEASE_DATE)); + VALUE p = rb_obj_freeze(rb_str_new2(RUBY_PLATFORM)); rb_define_global_const("RUBY_VERSION", v); rb_define_global_const("RUBY_RELEASE_DATE", d); @@ -1,4 +1,4 @@ #define RUBY_VERSION "1.7.1" -#define RUBY_RELEASE_DATE "2001-10-22" +#define RUBY_RELEASE_DATE "2001-10-29" #define RUBY_VERSION_CODE 171 -#define RUBY_RELEASE_CODE 20011022 +#define RUBY_RELEASE_CODE 20011029 |