[macruby-changes] [4950] MacRuby/trunk/sprintf.c

source_changes at macosforge.org source_changes at macosforge.org
Fri Nov 26 06:17:29 PST 2010


Revision: 4950
          http://trac.macosforge.org/projects/ruby/changeset/4950
Author:   watson1978 at gmail.com
Date:     2010-11-26 06:17:25 -0800 (Fri, 26 Nov 2010)
Log Message:
-----------
sprintf() will be given a format which is width's * and precision's *.

Test Script:
{{{
require 'test/unit/assertions.rb'
include Test::Unit::Assertions

assert_equal("   1.00000", sprintf("%*.*f", 10, 5, 1))

puts :ok
}}}

Modified Paths:
--------------
    MacRuby/trunk/sprintf.c

Modified: MacRuby/trunk/sprintf.c
===================================================================
--- MacRuby/trunk/sprintf.c	2010-11-26 10:34:50 UTC (rev 4949)
+++ MacRuby/trunk/sprintf.c	2010-11-26 14:17:25 UTC (rev 4950)
@@ -577,12 +577,7 @@
 
 			    num = rb_uchar_strtol(format_str, format_len,
 				    i, &pos);
-			    if (num == i--) {
-				SET_REF_TYPE(REL_REF);
-				precision = NUM2LONG(rb_Integer(GETNTHARG(j)));
-				j++;
-			    }
-			    else if (format_str[pos] == '$') {
+			    if (format_str[pos] == '$') {
 				if (num == 0) {
 				    rb_raise(rb_eArgError, "invalid absolute argument");
 				}
@@ -591,6 +586,12 @@
 					num - 1)));
 				i = pos;
 			    }
+			    else {
+				SET_REF_TYPE(REL_REF);
+				precision = NUM2LONG(rb_Integer(GETNTHARG(j)));
+				j++;
+				i--;
+			    }
 			}
 		    }
 		    else if (isdigit(format_str[i])) {
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20101126/80432b1f/attachment.html>


More information about the macruby-changes mailing list