[macruby-changes] [5171] MacRuby/trunk/sprintf.c
source_changes at macosforge.org
source_changes at macosforge.org
Sat Jan 15 08:52:23 PST 2011
Revision: 5171
http://trac.macosforge.org/projects/ruby/changeset/5171
Author: watson1978 at gmail.com
Date: 2011-01-15 08:52:17 -0800 (Sat, 15 Jan 2011)
Log Message:
-----------
Fixed the bug of sprintf with format like a "%010.4f".
Test Script:
{{{
require 'test/unit/assertions.rb'
include Test::Unit::Assertions
assert_equal("00123.1000", sprintf("%010.4f", 123.1))
assert_equal(" 0000007b", sprintf("%010.8x", 123))
puts :ok
}}}
Modified Paths:
--------------
MacRuby/trunk/sprintf.c
Modified: MacRuby/trunk/sprintf.c
===================================================================
--- MacRuby/trunk/sprintf.c 2011-01-15 14:21:18 UTC (rev 5170)
+++ MacRuby/trunk/sprintf.c 2011-01-15 16:52:17 UTC (rev 5171)
@@ -548,7 +548,6 @@
if (precision_flag) {
rb_raise(rb_eArgError, "precision given twice");
}
- zero_flag = false;
precision_flag = true;
if (format_str[++i] == '*') {
if (format_str[++i] == '<' || format_str[i] == '{') {
@@ -633,6 +632,9 @@
base = 16;
negative_pad = rb_str_new2("f");
sharp_pad = rb_str_new2("0x");
+ if (precision_flag) {
+ zero_flag = false;
+ }
complete = true;
break;
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20110115/ff748c56/attachment.html>
More information about the macruby-changes
mailing list