From 8a0cd16de1b523fa80ec0e02ae7f114d28fa41b7 Mon Sep 17 00:00:00 2001 From: naruse Date: Fri, 15 Oct 2010 08:31:58 +0000 Subject: Revert "* sprintf.c (rb_str_format): fix: sprintf with hex format and" This reverts commit a160986d90cf90a86e01d60eddb04ffe0e584c36. Revert wrong commit. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29504 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- sprintf.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'sprintf.c') diff --git a/sprintf.c b/sprintf.c index 0e97955161..21509eafdd 100644 --- a/sprintf.c +++ b/sprintf.c @@ -844,7 +844,7 @@ rb_str_format(int argc, const VALUE *argv, VALUE fmt) } else { s = nbuf; - if (v < 0 && !(flags & FPREC0)) { + if (v < 0) { dots = 1; } snprintf(fbuf, sizeof(fbuf), "%%l%c", *p == 'X' ? 'x' : *p); @@ -892,8 +892,7 @@ rb_str_format(int argc, const VALUE *argv, VALUE fmt) tmp1 = tmp = rb_big2str0(val, base, RBIGNUM_SIGN(val)); s = RSTRING_PTR(tmp); if (*s == '-') { - if (!(flags & FPREC0)) - dots = 1; + dots = 1; if (base == 10) { rb_warning("negative number for %%u specifier"); } @@ -926,11 +925,14 @@ rb_str_format(int argc, const VALUE *argv, VALUE fmt) } } if (prefix && !prefix[1]) { /* octal */ - if (len == 1 && *s == '0') { + if (dots) { + prefix = 0; + } + else if (len == 1 && *s == '0') { len = 0; if (flags & FPREC) prec--; } - else if ((flags & FPREC) && (prec > len) && v >= 0) { + else if ((flags & FPREC) && (prec > len)) { prefix = 0; } } -- cgit v1.2.3