aboutsummaryrefslogtreecommitdiffstats
path: root/sprintf.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-12-07 08:41:59 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-12-07 08:41:59 +0000
commitda32ce1a67677bd0f5df8fa31e0ab05c26c7d401 (patch)
tree88fbca16ba3c3b802990d969a13a57ec67bb3ab0 /sprintf.c
parente122cca1791b38e089776bfeb39f0bd1d07afdae (diff)
downloadruby-da32ce1a67677bd0f5df8fa31e0ab05c26c7d401.tar.gz
* 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
Diffstat (limited to 'sprintf.c')
-rw-r--r--sprintf.c12
1 files changed, 6 insertions, 6 deletions
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]");