summaryrefslogtreecommitdiff
path: root/sprintf.c
diff options
context:
space:
mode:
authornaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-10-15 08:31:58 +0000
committernaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-10-15 08:31:58 +0000
commit8a0cd16de1b523fa80ec0e02ae7f114d28fa41b7 (patch)
tree656aea4dc99e2783673a5d74e14fc64d78aee266 /sprintf.c
parent6a443e2eb2ce6dcde4d01be4a48fd1158dc96356 (diff)
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
Diffstat (limited to 'sprintf.c')
-rw-r--r--sprintf.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/sprintf.c b/sprintf.c
index 0e97955..21509ea 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;
}
}