* 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
This commit is contained in:
matz 2001-10-29 05:07:26 +00:00
parent 429f7ed113
commit 88abd791f5
20 changed files with 174 additions and 77 deletions

View File

@ -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> Tue Oct 23 01:21:19 2001 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
* eval.c (proc_invoke): fix self switching in Proc#call * 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. * 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> 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 * class.c (rb_mod_clone): should not copy class name, since clone
should remain anonymous. should remain anonymous.

View File

@ -890,7 +890,7 @@ inspect_ensure(obj)
VALUE VALUE
rb_protect_inspect(func, obj, arg) rb_protect_inspect(func, obj, arg)
VALUE (*func)(); VALUE (*func)(ANYARGS);
VALUE obj, arg; VALUE obj, arg;
{ {
struct inspect_arg iarg; struct inspect_arg iarg;

View File

@ -593,8 +593,7 @@ rb_big_eq(x, y)
case T_BIGNUM: case T_BIGNUM:
break; break;
case T_FLOAT: case T_FLOAT:
y = dbl2big(RFLOAT(y)->value); return (rb_big2dbl(x) == RFLOAT(y)->value)?Qtrue:Qfalse;
break;
default: default:
return Qfalse; return Qfalse;
} }

View File

@ -734,14 +734,14 @@ rb_sys_fail(mesg)
#ifdef __BEOS__ #ifdef __BEOS__
ee = get_syserr(n); ee = get_syserr(n);
if (!ee) { if (!ee) {
char name[6]; char name[12];
sprintf(name, "E%03d", n); sprintf(name, "E%03d", n);
ee = set_syserr(n, name); ee = set_syserr(n, name);
} }
#else #else
if (n > sys_nerr || !syserr_list[n]) { if (n > sys_nerr || !syserr_list[n]) {
char name[6]; char name[12];
sprintf(name, "E%03d", n); sprintf(name, "E%03d", n);
ee = set_syserr(n, name); ee = set_syserr(n, name);

31
eval.c
View File

@ -1349,8 +1349,10 @@ rb_eval_cmd(cmd, arg)
volatile int safe = ruby_safe_level; volatile int safe = ruby_safe_level;
if (TYPE(cmd) != T_STRING) { if (TYPE(cmd) != T_STRING) {
return rb_funcall2(cmd, rb_intern("call"), PUSH_ITER(ITER_NOT);
RARRAY(arg)->len, RARRAY(arg)->ptr); val = rb_funcall2(cmd, rb_intern("call"), RARRAY(arg)->len, RARRAY(arg)->ptr);
POP_ITER();
return val;
} }
saved_scope = ruby_scope; saved_scope = ruby_scope;
@ -2736,7 +2738,7 @@ rb_eval(self, n)
val = rb_funcall(val, node->nd_mid, 1, rb_eval(self, rval)); val = rb_funcall(val, node->nd_mid, 1, rb_eval(self, rval));
} }
argv[argc-1] = val; argv[argc-1] = val;
val = rb_funcall2(recv, aset, argc, argv); rb_funcall2(recv, aset, argc, argv);
result = val; result = val;
} }
break; break;
@ -3921,7 +3923,7 @@ assign(self, lhs, val, pcall)
VALUE VALUE
rb_iterate(it_proc, data1, bl_proc, data2) rb_iterate(it_proc, data1, bl_proc, data2)
VALUE (*it_proc)(), (*bl_proc)(); VALUE (*it_proc) _((VALUE)), (*bl_proc)(ANYARGS);
VALUE data1, data2; VALUE data1, data2;
{ {
int state; int state;
@ -3995,10 +3997,10 @@ handle_rescue(self, node)
VALUE VALUE
#ifdef HAVE_STDARG_PROTOTYPES #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 #else
rb_rescue2(b_proc, data1, r_proc, data2, va_alist) 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; VALUE data1, data2;
va_dcl va_dcl
#endif #endif
@ -4089,8 +4091,9 @@ rb_protect(proc, data, state)
VALUE VALUE
rb_ensure(b_proc, data1, e_proc, data2) rb_ensure(b_proc, data1, e_proc, data2)
VALUE (*b_proc)(); VALUE (*b_proc)();
VALUE data1;
VALUE (*e_proc)(); VALUE (*e_proc)();
VALUE data1, data2; VALUE data2;
{ {
int state; int state;
volatile VALUE result = Qnil; volatile VALUE result = Qnil;
@ -5959,12 +5962,20 @@ rb_f_at_exit()
void void
rb_exec_end_proc() rb_exec_end_proc()
{ {
struct end_proc_data *link; struct end_proc_data *link, *save;
int status; int status;
link = end_procs; save = link = end_procs;
while (link) { 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) { if (status) {
error_handle(status); error_handle(status);
} }

View File

@ -849,9 +849,11 @@ open_inet(class, remote_host, remote_serv, local_host, local_serv, type)
continue; continue;
} }
if (type == INET_SERVER) { if (type == INET_SERVER) {
#ifndef NT
status = 1; status = 1;
setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, setsockopt(fd, SOL_SOCKET, SO_REUSEADDR,
(char*)&status, sizeof(status)); (char*)&status, sizeof(status));
#endif
status = bind(fd, res->ai_addr, res->ai_addrlen); status = bind(fd, res->ai_addr, res->ai_addrlen);
syscall = "bind(2)"; syscall = "bind(2)";
} }

View File

@ -157,7 +157,9 @@ ip_ruby(clientData, interp, argc, argv)
DUMP2("rb_eval_string(%s)", arg); DUMP2("rb_eval_string(%s)", arg);
old_trapflg = rb_trap_immediate; old_trapflg = rb_trap_immediate;
rb_trap_immediate = 0; 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; rb_trap_immediate = old_trapflg;
Tcl_ResetResult(interp); Tcl_ResetResult(interp);

View File

@ -77,6 +77,9 @@ module TkComm
def tk_split_list(str) def tk_split_list(str)
return [] if str == "" return [] if str == ""
idx = str.index('{') idx = str.index('{')
while idx and idx > 0 and str[idx-1] == ?\\
idx = str.index('{', idx+1)
end
return tk_tcl2ruby(str) unless idx return tk_tcl2ruby(str) unless idx
list = tk_tcl2ruby(str[0,idx]) list = tk_tcl2ruby(str[0,idx])
@ -90,6 +93,7 @@ module TkComm
brace -= 1 if c == ?} brace -= 1 if c == ?}
break if brace == 0 break if brace == 0
} }
p str[0,i]
if str[0, i] == ' ' if str[0, i] == ' '
list.push ' ' list.push ' '
else else
@ -102,6 +106,9 @@ module TkComm
def tk_split_simplelist(str) def tk_split_simplelist(str)
return [] if str == "" return [] if str == ""
idx = str.index('{') idx = str.index('{')
while idx and idx > 0 and str[idx-1] == ?\\
idx = str.index('{', idx+1)
end
return str.split unless idx return str.split unless idx
list = str[0,idx].split list = str[0,idx].split
@ -467,7 +474,15 @@ module TkCore
INTERP = TclTkIp.new 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 def callback_break
fail TkCallbackBreak, "Tk callback returns 'break' status" fail TkCallbackBreak, "Tk callback returns 'break' status"

25
file.c
View File

@ -143,14 +143,17 @@ static VALUE
rb_stat_cmp(self, other) rb_stat_cmp(self, other)
VALUE self, other; VALUE self, other;
{ {
time_t t1 = get_stat(self)->st_mtime; if (rb_obj_is_kind_of(other, rb_obj_class(self))) {
time_t t2 = get_stat(other)->st_mtime; time_t t1 = get_stat(self)->st_mtime;
if (t1 == t2) time_t t2 = get_stat(other)->st_mtime;
return INT2FIX(0); if (t1 == t2)
else if (t1 < t2) return INT2FIX(0);
return INT2FIX(-1); else if (t1 < t2)
else return INT2FIX(-1);
return INT2FIX(1); else
return INT2FIX(1);
}
rb_raise(rb_eTypeError, "operand is not File::Stat");
} }
static VALUE 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, "basename", rb_file_s_basename, -1);
rb_define_singleton_method(rb_cFile, "dirname", rb_file_s_dirname, 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_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, "split", rb_file_s_split, 1);
rb_define_singleton_method(rb_cFile, "join", rb_file_s_join, -2); rb_define_singleton_method(rb_cFile, "join", rb_file_s_join, -2);
#if defined DOSISH && !defined __CYGWIN__ #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 #else
rb_define_const(rb_cFile, "ALT_SEPARATOR", Qnil); rb_define_const(rb_cFile, "ALT_SEPARATOR", Qnil);
#endif #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_cIO, "stat", rb_io_stat, 0); /* this is IO's method */
rb_define_method(rb_cFile, "lstat", rb_file_lstat, 0); rb_define_method(rb_cFile, "lstat", rb_file_lstat, 0);

10
hash.c
View File

@ -1098,7 +1098,7 @@ ruby_unsetenv(name)
} }
static VALUE static VALUE
rb_f_setenv(obj, nm, val) env_aset(obj, nm, val)
VALUE obj, nm, val; VALUE obj, nm, val;
{ {
char *name, *value; char *name, *value;
@ -1126,13 +1126,13 @@ rb_f_setenv(obj, nm, val)
if (OBJ_TAINTED(val)) { if (OBJ_TAINTED(val)) {
/* already tainted, no check */ /* already tainted, no check */
path_tainted = 1; path_tainted = 1;
return Qtrue; return val;
} }
else { else {
path_tainted_p(value); path_tainted_p(value);
} }
} }
return Qtrue; return val;
} }
static VALUE static VALUE
@ -1499,8 +1499,8 @@ Init_Hash()
rb_define_singleton_method(envtbl,"[]", rb_f_getenv, 1); rb_define_singleton_method(envtbl,"[]", rb_f_getenv, 1);
rb_define_singleton_method(envtbl,"fetch", env_fetch, -1); rb_define_singleton_method(envtbl,"fetch", env_fetch, -1);
rb_define_singleton_method(envtbl,"[]=", rb_f_setenv, 2); rb_define_singleton_method(envtbl,"[]=", env_aset, 2);
rb_define_singleton_method(envtbl,"store", rb_f_setenv, 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", env_each, 0);
rb_define_singleton_method(envtbl,"each_pair", env_each, 0); rb_define_singleton_method(envtbl,"each_pair", env_each, 0);
rb_define_singleton_method(envtbl,"each_key", env_each_key, 0); rb_define_singleton_method(envtbl,"each_key", env_each_key, 0);

View File

@ -50,7 +50,7 @@ VALUE rb_ary_assoc _((VALUE, VALUE));
VALUE rb_ary_rassoc _((VALUE, VALUE)); VALUE rb_ary_rassoc _((VALUE, VALUE));
VALUE rb_ary_includes _((VALUE, VALUE)); VALUE rb_ary_includes _((VALUE, VALUE));
VALUE rb_ary_cmp _((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)); VALUE rb_inspecting_p _((VALUE));
/* bignum.c */ /* bignum.c */
VALUE rb_big_clone _((VALUE)); VALUE rb_big_clone _((VALUE));

3
io.c
View File

@ -3531,7 +3531,8 @@ Init_IO()
rb_output_fs = Qnil; rb_output_fs = Qnil;
rb_define_hooked_variable("$,", &rb_output_fs, 0, rb_str_setter); 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); rb_global_variable(&rb_default_rs);
OBJ_FREEZE(rb_default_rs); /* avoid modifying RS_default */ OBJ_FREEZE(rb_default_rs); /* avoid modifying RS_default */
rb_define_variable("$/", &rb_rs); rb_define_variable("$/", &rb_rs);

View File

@ -17,12 +17,12 @@ class Tracer
@RCS_ID='-$Id: tracer.rb,v 1.8 1998/05/19 03:42:49 keiju Exp keiju $-' @RCS_ID='-$Id: tracer.rb,v 1.8 1998/05/19 03:42:49 keiju Exp keiju $-'
@stdout = STDOUT @stdout = STDOUT
@verbose = false
class << self class << self
attr :verbose, true attr :verbose, true
alias verbose? verbose alias verbose? verbose
attr :stdout, true attr :stdout, true
end end
verbose = true
MY_FILE_NAME = caller(0)[0].scan(/^(.*):[0-9]+$/)[0][0] MY_FILE_NAME = caller(0)[0].scan(/^(.*):[0-9]+$/)[0][0]
@ -155,7 +155,7 @@ class Tracer
end end
LINES__ = {} unless defined? LINES__ SCRIPT_LINES__ = {} unless defined? SCRIPT_LINES__
if caller(0).size == 1 if caller(0).size == 1
if $0 == Tracer::MY_FILE_NAME if $0 == Tracer::MY_FILE_NAME

View File

@ -153,10 +153,11 @@ num_remainder(x, y)
{ {
VALUE z = rb_funcall(x, '%', 1, y); VALUE z = rb_funcall(x, '%', 1, y);
if ((RTEST(rb_funcall(x, '<', 1, INT2FIX(0))) && if ((!RTEST(rb_equal(z, INT2FIX(0)))) &&
RTEST(rb_funcall(y, '>', 1, INT2FIX(0)))) || ((RTEST(rb_funcall(x, '<', 1, INT2FIX(0))) &&
(RTEST(rb_funcall(x, '>', 1, INT2FIX(0))) && RTEST(rb_funcall(y, '>', 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 rb_funcall(z, '-', 1, y);
} }
return z; return z;
@ -1310,15 +1311,22 @@ fix_aref(fix, idx)
VALUE fix, idx; VALUE fix, idx;
{ {
long val = FIX2LONG(fix); long val = FIX2LONG(fix);
int i = NUM2INT(idx);
if (i < 0 || sizeof(VALUE)*CHAR_BIT-1 < i) { if (TYPE(idx) == T_BIGNUM) {
if (val < 0) return INT2FIX(1); 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); return INT2FIX(0);
} }
if (val & (1L<<i))
return INT2FIX(1);
return INT2FIX(0);
} }
static VALUE static VALUE

View File

@ -3847,6 +3847,12 @@ str_extend(list, term)
tokadd(c); tokadd(c);
goto fetch_id; goto fetch_id;
case '-':
tokadd(c);
c = nextc();
tokadd(c);
goto fetch_id;
default: default:
if (c == term) { if (c == term) {
list_append(list, NEW_STR(rb_str_new2("#$"))); list_append(list, NEW_STR(rb_str_new2("#$")));

2
ruby.h
View File

@ -488,7 +488,7 @@ void rb_warn __((const char*, ...)); /* reports always */
VALUE rb_each _((VALUE)); VALUE rb_each _((VALUE));
VALUE rb_yield _((VALUE)); VALUE rb_yield _((VALUE));
int rb_block_given_p _((void)); 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_rescue _((VALUE(*)(ANYARGS),VALUE,VALUE(*)(ANYARGS),VALUE));
VALUE rb_rescue2 __((VALUE(*)(ANYARGS),VALUE,VALUE(*)(ANYARGS),VALUE,...)); VALUE rb_rescue2 __((VALUE(*)(ANYARGS),VALUE,VALUE(*)(ANYARGS),VALUE,...));
VALUE rb_ensure _((VALUE(*)(ANYARGS),VALUE,VALUE(*)(ANYARGS),VALUE)); VALUE rb_ensure _((VALUE(*)(ANYARGS),VALUE,VALUE(*)(ANYARGS),VALUE));

12
time.c
View File

@ -706,10 +706,10 @@ time_localtime(time)
time_t t; time_t t;
GetTimeval(time, tobj); GetTimeval(time, tobj);
if (tobj->tm_got && !tobj->gmt) { if (tobj->tm_got) {
return time; if (!tobj->gmt) return time;
time_modify(time);
} }
time_modify(time);
t = tobj->tv.tv_sec; t = tobj->tv.tv_sec;
tm_tmp = localtime(&t); tm_tmp = localtime(&t);
tobj->tm = *tm_tmp; tobj->tm = *tm_tmp;
@ -727,10 +727,10 @@ time_gmtime(time)
time_t t; time_t t;
GetTimeval(time, tobj); GetTimeval(time, tobj);
if (tobj->tm_got && tobj->gmt) { if (tobj->tm_got) {
return time; if (tobj->gmt) return time;
time_modify(time);
} }
time_modify(time);
t = tobj->tv.tv_sec; t = tobj->tv.tv_sec;
tm_tmp = gmtime(&t); tm_tmp = gmtime(&t);
tobj->tm = *tm_tmp; tobj->tm = *tm_tmp;

View File

@ -1425,11 +1425,12 @@ cvar_override_check(id, a, b)
{ {
a = RCLASS(a)->super; a = RCLASS(a)->super;
while (a) { while (a) {
if (!RCLASS(a)->iv_tbl) continue; if (RCLASS(a)->iv_tbl) {
if (st_lookup(RCLASS(a)->iv_tbl,id,0)) { if (st_lookup(RCLASS(a)->iv_tbl,id,0)) {
rb_warning("class variable %s of %s is overridden by %s", rb_warning("class variable %s of %s is overridden by %s",
rb_id2name(id), rb_class2name(a), rb_id2name(id), rb_class2name(a),
rb_class2name(b)); rb_class2name(b));
}
} }
a = RCLASS(a)->super; a = RCLASS(a)->super;
} }
@ -1445,15 +1446,16 @@ rb_cvar_set(klass, id, val)
tmp = klass; tmp = klass;
while (tmp) { while (tmp) {
if (!RCLASS(tmp)->iv_tbl) continue; if (RCLASS(tmp)->iv_tbl) {
if (st_lookup(RCLASS(tmp)->iv_tbl,id,0)) { if (st_lookup(RCLASS(tmp)->iv_tbl,id,0)) {
if (!OBJ_TAINTED(tmp) && rb_safe_level() >= 4) if (!OBJ_TAINTED(tmp) && rb_safe_level() >= 4)
rb_raise(rb_eSecurityError, "Insecure: can't modify class variable"); rb_raise(rb_eSecurityError, "Insecure: can't modify class variable");
st_insert(RCLASS(tmp)->iv_tbl,id,val); st_insert(RCLASS(tmp)->iv_tbl,id,val);
if (ruby_verbose) { if (ruby_verbose) {
cvar_override_check(id, tmp, klass); cvar_override_check(id, tmp, klass);
}
return;
} }
return;
} }
tmp = RCLASS(tmp)->super; tmp = RCLASS(tmp)->super;
} }
@ -1500,12 +1502,13 @@ rb_cvar_get(klass, id)
tmp = klass; tmp = klass;
while (tmp) { while (tmp) {
if (!RCLASS(tmp)->iv_tbl) continue; if (RCLASS(tmp)->iv_tbl) {
if (st_lookup(RCLASS(tmp)->iv_tbl,id,&value)) { if (st_lookup(RCLASS(tmp)->iv_tbl,id,&value)) {
if (ruby_verbose) { if (ruby_verbose) {
cvar_override_check(id, tmp, klass); cvar_override_check(id, tmp, klass);
}
return value;
} }
return value;
} }
tmp = RCLASS(tmp)->super; tmp = RCLASS(tmp)->super;
} }

View File

@ -17,9 +17,9 @@
void void
Init_version() Init_version()
{ {
VALUE v = rb_str_new2(RUBY_VERSION); VALUE v = rb_obj_freeze(rb_str_new2(RUBY_VERSION));
VALUE d = rb_str_new2(RUBY_RELEASE_DATE); VALUE d = rb_obj_freeze(rb_str_new2(RUBY_RELEASE_DATE));
VALUE p = rb_str_new2(RUBY_PLATFORM); VALUE p = rb_obj_freeze(rb_str_new2(RUBY_PLATFORM));
rb_define_global_const("RUBY_VERSION", v); rb_define_global_const("RUBY_VERSION", v);
rb_define_global_const("RUBY_RELEASE_DATE", d); rb_define_global_const("RUBY_RELEASE_DATE", d);

View File

@ -1,4 +1,4 @@
#define RUBY_VERSION "1.7.1" #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_VERSION_CODE 171
#define RUBY_RELEASE_CODE 20011022 #define RUBY_RELEASE_CODE 20011029