From e07cb859cc882adc05f818466b45e75f1d5a1e39 Mon Sep 17 00:00:00 2001 From: nobu Date: Sat, 18 Jul 2009 08:05:32 +0000 Subject: * suppressed shorten-64-to-32 warnings. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24195 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- object.c | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) (limited to 'object.c') diff --git a/object.c b/object.c index d86c6e49d4..b8a33f4697 100644 --- a/object.c +++ b/object.c @@ -99,7 +99,7 @@ VALUE rb_obj_hash(VALUE obj) { VALUE oid = rb_obj_id(obj); - unsigned h = rb_hash_end(rb_hash_start(NUM2LONG(oid))); + unsigned long h = rb_hash_end(rb_hash_start(NUM2LONG(oid))); return LONG2NUM(h); } @@ -1549,7 +1549,7 @@ rb_mod_attr_reader(int argc, VALUE *argv, VALUE klass) int i; for (i=0; i 20) ? (w = 20, ellipsis = "...") : (ellipsis = "")) + enum {max_width = 20}; +#define OutOfRange() ((end - p > max_width) ? \ + (w = max_width, ellipsis = "...") : \ + (w = (int)(end - p), ellipsis = "")) if (!p) return 0.0; q = p; @@ -2225,6 +2228,9 @@ rb_str_to_dbl(VALUE str, int badcheck) s = RSTRING_PTR(str); len = RSTRING_LEN(str); if (s) { + if (badcheck && memchr(s, '\0', len)) { + rb_raise(rb_eArgError, "string for Float contains null byte"); + } if (s[len]) { /* no sentinel somehow */ char *p = ALLOCA_N(char, len+1); @@ -2232,9 +2238,6 @@ rb_str_to_dbl(VALUE str, int badcheck) p[len] = '\0'; s = p; } - if (badcheck && len != strlen(s)) { - rb_raise(rb_eArgError, "string for Float contains null byte"); - } } return rb_cstr_to_dbl(s, badcheck); } @@ -2253,7 +2256,7 @@ rb_Float(VALUE val) return DBL2NUM(rb_big2dbl(val)); case T_STRING: - return DBL2NUM(rb_str_to_dbl(val, Qtrue)); + return DBL2NUM(rb_str_to_dbl(val, TRUE)); case T_NIL: rb_raise(rb_eTypeError, "can't convert nil into Float"); -- cgit v1.2.3