Skip to content
This repository
Browse code

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 1 changed file with 3 additions and 1 deletion. Show diff stats Hide diff stats

  1. +3 1 sprintf.c
4 sprintf.c
@@ -548,7 +548,6 @@ rb_str_format(int argc, const VALUE *argv, VALUE fmt)
548 548 if (precision_flag) {
549 549 rb_raise(rb_eArgError, "precision given twice");
550 550 }
551   - zero_flag = false;
552 551 precision_flag = true;
553 552 if (format_str[++i] == '*') {
554 553 if (format_str[++i] == '<' || format_str[i] == '{') {
@@ -633,6 +632,9 @@ rb_str_format(int argc, const VALUE *argv, VALUE fmt)
633 632 base = 16;
634 633 negative_pad = rb_str_new2("f");
635 634 sharp_pad = rb_str_new2("0x");
  635 + if (precision_flag) {
  636 + zero_flag = false;
  637 + }
636 638 complete = true;
637 639 break;
638 640

0 comments on commit 1017c7f

Please sign in to comment.
Something went wrong with that request. Please try again.