Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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
}}}

git-svn-id: http://svn.macosforge.org/repository/ruby/MacRuby/trunk@5171 23306eb0-4c56-4727-a40e-e92c0eb68959
  • Loading branch information...
commit 1017c7f755a255dea49b0a5cfd13a3f5622c066d 1 parent 3e1645b
Watson Watson1978 authored
Showing with 3 additions and 1 deletion.
  1. +3 −1 sprintf.c
4 sprintf.c
View
@@ -548,7 +548,6 @@ rb_str_format(int argc, const VALUE *argv, VALUE fmt)
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 @@ rb_str_format(int argc, const VALUE *argv, VALUE fmt)
base = 16;
negative_pad = rb_str_new2("f");
sharp_pad = rb_str_new2("0x");
+ if (precision_flag) {
+ zero_flag = false;
+ }
complete = true;
break;
Please sign in to comment.
Something went wrong with that request. Please try again.