diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2001-10-29 05:04:45 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2001-10-29 05:04:45 +0000 |
commit | 35b21a12c03765244d32b6400a100124f35df091 (patch) | |
tree | 7cc9ed3bebd8006d18cdac6f833cfd611f705ff1 /file.c | |
parent | b07291635892b07bb4afbb62d4fe08aa8dfeb68b (diff) |
* parse.y (str_extend): shuould allow interpolation of $-x.
* 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.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_6@1799 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'file.c')
-rw-r--r-- | file.c | 25 |
1 files changed, 14 insertions, 11 deletions
@@ -145,14 +145,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 @@ -2335,18 +2338,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); |