From da32ce1a67677bd0f5df8fa31e0ab05c26c7d401 Mon Sep 17 00:00:00 2001 From: matz Date: Wed, 7 Dec 2005 08:41:59 +0000 Subject: * sprintf.c (rb_f_sprintf): [ruby-dev:27967] * range.c (range_include): use discrete membership for non Numeric values, for example, String. * numeric.c (num_scalar_p): new method. [ruby-dev:27936] * lib/complex.rb (Complex#scalar?): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9654 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- sprintf.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'sprintf.c') diff --git a/sprintf.c b/sprintf.c index 07526756f2..e8c0d36164 100644 --- a/sprintf.c +++ b/sprintf.c @@ -116,11 +116,11 @@ sign_bits(int base, const char *p) t = p++; \ n = 0; \ for (; p < end && ISDIGIT(*p); p++) { \ - int times10 = n*10; \ - if (times10 / 10 != n) {\ + int next_n = 10 * n + (*p - '0'); \ + if (next_n / 10 != n) {\ rb_raise(rb_eArgError, #val " too big"); \ } \ - n = 10 * n + (*p - '0'); \ + n = next_n; \ } \ if (p >= end) { \ rb_raise(rb_eArgError, "malformed format string - %%*[0-9]"); \ @@ -320,11 +320,11 @@ rb_str_format(int argc, const VALUE *argv, VALUE fmt) case '5': case '6': case '7': case '8': case '9': n = 0; for (; p < end && ISDIGIT(*p); p++) { - int times10 = n*10; - if (times10 / 10 != n) { + int next_n = 10 * n + (*p - '0'); + if (next_n / 10 != n) { rb_raise(rb_eArgError, "width too big"); } - n = 10 * n + (*p - '0'); + n = next_n; } if (p >= end) { rb_raise(rb_eArgError, "malformed format string - %%[0-9]"); -- cgit v1.2.3