From 79c5eb1af36690c6d45975b3db93613819230bc3 Mon Sep 17 00:00:00 2001 From: nobu Date: Wed, 26 Jul 2006 08:28:57 +0000 Subject: [PATCH] * sprintf.c (rb_str_format): prepend ".." to %u for negative bignum, but not "-". fixed: [ruby-core:08167] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10604 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ sprintf.c | 34 ++++++++++++++++------------------ 2 files changed, 21 insertions(+), 18 deletions(-) diff --git a/ChangeLog b/ChangeLog index e3b2bcd53d..0278d0be3e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Wed Jul 26 17:28:16 2006 Nobuyoshi Nakada + + * sprintf.c (rb_str_format): prepend ".." to %u for negative bignum, + but not "-". fixed: [ruby-core:08167] + Wed Jul 26 16:39:07 2006 Yukihiro Matsumoto * string.c (rb_str_scan): add string modification check. diff --git a/sprintf.c b/sprintf.c index a85595f3cc..264b17c6b9 100644 --- a/sprintf.c +++ b/sprintf.c @@ -625,25 +625,23 @@ rb_str_format(int argc, const VALUE *argv, VALUE fmt) if (base == 10) { rb_warning("negative number for %%u specifier"); } - else { - remove_sign_bits(++s, base); - tmp = rb_str_new(0, 3+strlen(s)); - t = RSTRING(tmp)->ptr; - if (!(flags&(FPREC|FZERO))) { - strcpy(t, ".."); - t += 2; - } - switch (base) { - case 16: - if (s[0] != 'f') strcpy(t++, "f"); break; - case 8: - if (s[0] != '7') strcpy(t++, "7"); break; - case 2: - if (s[0] != '1') strcpy(t++, "1"); break; - } - strcpy(t, s); - s = RSTRING(tmp)->ptr; + remove_sign_bits(++s, base); + tmp = rb_str_new(0, 3+strlen(s)); + t = RSTRING(tmp)->ptr; + if (!(flags&(FPREC|FZERO))) { + strcpy(t, ".."); + t += 2; } + switch (base) { + case 16: + if (s[0] != 'f') strcpy(t++, "f"); break; + case 8: + if (s[0] != '7') strcpy(t++, "7"); break; + case 2: + if (s[0] != '1') strcpy(t++, "1"); break; + } + strcpy(t, s); + s = RSTRING(tmp)->ptr; } } }