ruby-changes:4221
From: ko1@a...
Date: Thu, 6 Mar 2008 15:12:06 +0900 (JST)
Subject: [ruby-changes:4221] nobu - Ruby:r15711 (trunk): * sprintf.c (rb_str_format): ignore 0 flag for NaN and Inf.
nobu 2008-03-06 15:11:43 +0900 (Thu, 06 Mar 2008)
New Revision: 15711
Modified files:
trunk/ChangeLog
trunk/sprintf.c
trunk/test/ruby/test_sprintf.rb
Log:
* sprintf.c (rb_str_format): ignore 0 flag for NaN and Inf.
[ruby-dev:33994]
http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ChangeLog?r1=15711&r2=15710&diff_format=u
http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/test/ruby/test_sprintf.rb?r1=15711&r2=15710&diff_format=u
http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/sprintf.c?r1=15711&r2=15710&diff_format=u
Index: ChangeLog
===================================================================
--- ChangeLog (revision 15710)
+++ ChangeLog (revision 15711)
@@ -1,3 +1,8 @@
+Thu Mar 6 15:11:40 2008 Nobuyoshi Nakada <nobu@r...>
+
+ * sprintf.c (rb_str_format): ignore 0 flag for NaN and Inf.
+ [ruby-dev:33994]
+
Thu Mar 6 15:05:25 2008 NAKAMURA Usaku <usa@r...>
* {bcc32,win32}/Makefile.sub (RUNRUBY): use $(PROGRAM) instead of
Index: sprintf.c
===================================================================
--- sprintf.c (revision 15710)
+++ sprintf.c (revision 15711)
@@ -766,7 +766,7 @@
if (isnan(fval) || isinf(fval)) {
const char *expr;
- if (isnan(fval)) {
+ if (isnan(fval)) {
expr = "NaN";
}
else {
@@ -789,25 +789,6 @@
blen++;
strncpy(&buf[blen], expr, strlen(expr));
}
- else if (flags & FZERO) {
- if (!isnan(fval) && fval < 0.0) {
- buf[blen++] = '-';
- need--;
- }
- else if (flags & FPLUS) {
- buf[blen++] = '+';
- need--;
- }
- else if (flags & FSPACE) {
- blen++;
- need--;
- }
- if ((need -= strlen(expr)) > 0) {
- memset(buf+blen, '0', need);
- blen += need;
- }
- strncpy(&buf[blen], expr, strlen(expr));
- }
else {
if (!isnan(fval) && fval < 0.0)
buf[blen + need - strlen(expr) - 1] = '-';
Index: test/ruby/test_sprintf.rb
===================================================================
--- test/ruby/test_sprintf.rb (revision 15710)
+++ test/ruby/test_sprintf.rb (revision 15711)
@@ -87,17 +87,17 @@
assert_equal("NaN ", sprintf("%-8f", nan))
assert_equal(" +NaN", sprintf("%+8f", nan))
- assert_equal("00000NaN", sprintf("%08f", nan))
+ assert_equal(" NaN", sprintf("%08f", nan))
assert_equal("NaN ", sprintf("%-08f", nan))
- assert_equal("+0000NaN", sprintf("%+08f", nan))
+ assert_equal(" +NaN", sprintf("%+08f", nan))
assert_equal(" NaN", sprintf("% 8f", nan))
assert_equal(" NaN ", sprintf("%- 8f", nan))
assert_equal(" +NaN", sprintf("%+ 8f", nan))
- assert_equal(" 0000NaN", sprintf("% 08f", nan))
+ assert_equal(" NaN", sprintf("% 08f", nan))
assert_equal(" NaN ", sprintf("%- 08f", nan))
- assert_equal("+0000NaN", sprintf("%+ 08f", nan))
+ assert_equal(" +NaN", sprintf("%+ 08f", nan))
end
def test_inf
@@ -110,17 +110,17 @@
assert_equal("Inf ", sprintf("%-8f", inf))
assert_equal(" +Inf", sprintf("%+8f", inf))
- assert_equal("00000Inf", sprintf("%08f", inf))
+ assert_equal(" Inf", sprintf("%08f", inf))
assert_equal("Inf ", sprintf("%-08f", inf))
- assert_equal("+0000Inf", sprintf("%+08f", inf))
+ assert_equal(" +Inf", sprintf("%+08f", inf))
assert_equal(" Inf", sprintf("% 8f", inf))
assert_equal(" Inf ", sprintf("%- 8f", inf))
assert_equal(" +Inf", sprintf("%+ 8f", inf))
- assert_equal(" 0000Inf", sprintf("% 08f", inf))
+ assert_equal(" Inf", sprintf("% 08f", inf))
assert_equal(" Inf ", sprintf("%- 08f", inf))
- assert_equal("+0000Inf", sprintf("%+ 08f", inf))
+ assert_equal(" +Inf", sprintf("%+ 08f", inf))
assert_equal("-Inf", sprintf("%f", -inf))
assert_equal("-Inf", sprintf("%-f", -inf))
@@ -130,17 +130,17 @@
assert_equal("-Inf ", sprintf("%-8f", -inf))
assert_equal(" -Inf", sprintf("%+8f", -inf))
- assert_equal("-0000Inf", sprintf("%08f", -inf))
+ assert_equal(" -Inf", sprintf("%08f", -inf))
assert_equal("-Inf ", sprintf("%-08f", -inf))
- assert_equal("-0000Inf", sprintf("%+08f", -inf))
+ assert_equal(" -Inf", sprintf("%+08f", -inf))
assert_equal(" -Inf", sprintf("% 8f", -inf))
assert_equal("-Inf ", sprintf("%- 8f", -inf))
assert_equal(" -Inf", sprintf("%+ 8f", -inf))
- assert_equal("-0000Inf", sprintf("% 08f", -inf))
+ assert_equal(" -Inf", sprintf("% 08f", -inf))
assert_equal("-Inf ", sprintf("%- 08f", -inf))
- assert_equal("-0000Inf", sprintf("%+ 08f", -inf))
+ assert_equal(" -Inf", sprintf("%+ 08f", -inf))
assert_equal('..f00000000',
sprintf("%x", -2**32), '[ruby-dev:32351]')
assert_equal("..101111111111111111111111111111111",
--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/