diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2001-12-03 10:06:39 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2001-12-03 10:06:39 +0000 |
commit | 553634322c31c4f3bd18b77c83e22426e6976b14 (patch) | |
tree | bc659264a05e4068d749b1e2167f39bd7526d241 /string.c | |
parent | 7ff058e9f2c78956faf73dbeccef8cec63488d22 (diff) |
* time.c (time_new_internal): round usec overflow and underflow
here.
* time.c (time_plus): remove overflow/underflow check.
* time.c (time_minus): ditto.
* time.c (time_cmp): should consider tv_usec too.
* time.c (time_gmtime): time_modify() should be called even if tm
struct is not calculated yet.
* string.c (rb_str_equal): object with to_str must be treated as a
string.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_6@1879 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'string.c')
-rw-r--r-- | string.c | 19 |
1 files changed, 17 insertions, 2 deletions
@@ -563,13 +563,28 @@ rb_str_cmp(str1, str2) return -1; } +to_str(str) + VALUE str; +{ + return rb_funcall(str, rb_intern("to_str"), 0); +} + +static VALUE +str_or_nil(str) + VALUE str; +{ + return rb_rescue(to_str, (VALUE)str, 0, 0); +} + static VALUE rb_str_equal(str1, str2) VALUE str1, str2; { if (str1 == str2) return Qtrue; - if (TYPE(str2) != T_STRING) - return Qfalse; + if (TYPE(str2) != T_STRING) { + str2 = str_or_nil(str2); + if (NIL_P(str2)) return Qfalse; + } if (RSTRING(str1)->len == RSTRING(str2)->len && rb_str_cmp(str1, str2) == 0) { |