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

source_changes at macosforge.org source_changes at macosforge.org
Mon Nov 22 20:10:53 PST 2010


Revision: 4939
          http://trac.macosforge.org/projects/ruby/changeset/4939
Author:   watson1978 at gmail.com
Date:     2010-11-22 20:10:51 -0800 (Mon, 22 Nov 2010)
Log Message:
-----------
sprintf() will throw an exception when was given positional format twice.

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

assert_raise(ArgumentError){ sprintf("%1$1$s", "foo") }

puts :ok
}}}

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

Modified: MacRuby/trunk/sprintf.c
===================================================================
--- MacRuby/trunk/sprintf.c	2010-11-23 03:31:28 UTC (rev 4938)
+++ MacRuby/trunk/sprintf.c	2010-11-23 04:10:51 UTC (rev 4939)
@@ -539,6 +539,9 @@
 			if (num == 0) {
 			    rb_raise(rb_eArgError, "invalid absolute argument");
 			}
+			if (arg != 0) {
+			    rb_raise(rb_eArgError, "value given twice");
+			}
 			SET_REF_TYPE(ABS_REF);
 			arg = GETNTHARG(num - 1);
 		    }
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20101122/eac0425a/attachment-0001.html>


More information about the macruby-changes mailing list