diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-01-27 14:33:37 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-01-27 14:33:37 +0000 |
commit | b980803a6e89c8e8b951fe6090fca8f083ef4687 (patch) | |
tree | 9e49b29ba9bb241a9b2ef3eb2bfccd80f866bdfe | |
parent | fc208c1bd56a4e3fc03cb2f54616b4479f4b0e41 (diff) | |
download | ruby-b980803a6e89c8e8b951fe6090fca8f083ef4687.tar.gz |
* sprintf.c (rb_str_format): fix for left justify flag.
* sprintf.c (rb_str_format): zero-precision zero bug revised.
[ruby-dev:33419]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15281 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | sprintf.c | 9 |
2 files changed, 13 insertions, 3 deletions
@@ -1,3 +1,10 @@ +Sun Jan 27 23:33:35 2008 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * sprintf.c (rb_str_format): fix for left justify flag. + + * sprintf.c (rb_str_format): zero-precision zero bug revised. + [ruby-dev:33419] + Sun Jan 27 23:20:54 2008 Tanaka Akira <akr@fsij.org> * include/ruby/oniguruma.h: precise mbclen API redesigned to avoid @@ -699,12 +699,15 @@ rb_str_format(int argc, const VALUE *argv, VALUE fmt) if (prefix) { width -= strlen(prefix); } - if ((flags&(FZERO|FPREC)) == FZERO) { + if ((flags & (FZERO|FMINUS|FPREC)) == FZERO) { prec = width; width = 0; } else { - if (prec < len) prec = len; + if (prec < len) { + if ((flags & FPREC) && len == 1 && *s == '0') len = 0; + else prec = len; + } width -= prec; } if (!(flags&FMINUS)) { @@ -726,7 +729,7 @@ rb_str_format(int argc, const VALUE *argv, VALUE fmt) buf[blen++] = c; } } - else { + else if ((flags & (FMINUS|FPREC)) != FMINUS) { char c; if (!sign && bignum && !RBIGNUM_SIGN(val)) |