sprintf.c: unnumbered asterisk with numbered argument
* sprintf.c (GETASTER): should not use the numbered argument to be formatted, raise ArgumentError instead. [ruby-dev:48330] [Bug #9982] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46569 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
545165770b
commit
cfa7b2283b
@ -1,3 +1,9 @@
|
|||||||
|
Fri Jun 27 03:41:53 2014 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* sprintf.c (GETASTER): should not use the numbered argument to be
|
||||||
|
formatted, raise ArgumentError instead.
|
||||||
|
[ruby-dev:48330] [Bug #9982]
|
||||||
|
|
||||||
Thu Jun 26 18:18:28 2014 SHIBATA Hiroshi <shibata.hiroshi@gmail.com>
|
Thu Jun 26 18:18:28 2014 SHIBATA Hiroshi <shibata.hiroshi@gmail.com>
|
||||||
|
|
||||||
* test/with_different_ofs.rb: move into test library directory.
|
* test/with_different_ofs.rb: move into test library directory.
|
||||||
|
@ -79,6 +79,9 @@ sign_bits(int base, const char *p)
|
|||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#define GETARG() (nextvalue != Qundef ? nextvalue : \
|
#define GETARG() (nextvalue != Qundef ? nextvalue : \
|
||||||
|
GETNEXTARG())
|
||||||
|
|
||||||
|
#define GETNEXTARG() ( \
|
||||||
posarg == -1 ? \
|
posarg == -1 ? \
|
||||||
(rb_raise(rb_eArgError, "unnumbered(%d) mixed with numbered", nextarg), 0) : \
|
(rb_raise(rb_eArgError, "unnumbered(%d) mixed with numbered", nextarg), 0) : \
|
||||||
posarg == -2 ? \
|
posarg == -2 ? \
|
||||||
@ -125,7 +128,7 @@ sign_bits(int base, const char *p)
|
|||||||
tmp = GETPOSARG(n); \
|
tmp = GETPOSARG(n); \
|
||||||
} \
|
} \
|
||||||
else { \
|
else { \
|
||||||
tmp = GETARG(); \
|
tmp = GETNEXTARG(); \
|
||||||
p = t; \
|
p = t; \
|
||||||
} \
|
} \
|
||||||
(val) = NUM2INT(tmp); \
|
(val) = NUM2INT(tmp); \
|
||||||
|
@ -184,6 +184,10 @@ class TestSprintf < Test::Unit::TestCase
|
|||||||
assert_raise(ArgumentError) { sprintf("%!", 1) }
|
assert_raise(ArgumentError) { sprintf("%!", 1) }
|
||||||
assert_raise(ArgumentError) { sprintf("%1$1$d", 1) }
|
assert_raise(ArgumentError) { sprintf("%1$1$d", 1) }
|
||||||
assert_raise(ArgumentError) { sprintf("%0%") }
|
assert_raise(ArgumentError) { sprintf("%0%") }
|
||||||
|
|
||||||
|
assert_raise_with_message(ArgumentError, /unnumbered\(1\) mixed with numbered/) { sprintf("%1$*d", 3) }
|
||||||
|
assert_raise_with_message(ArgumentError, /unnumbered\(1\) mixed with numbered/) { sprintf("%1$.*d", 3) }
|
||||||
|
|
||||||
verbose, $VERBOSE = $VERBOSE, nil
|
verbose, $VERBOSE = $VERBOSE, nil
|
||||||
assert_nothing_raised { sprintf("", 1) }
|
assert_nothing_raised { sprintf("", 1) }
|
||||||
ensure
|
ensure
|
||||||
|
Loading…
x
Reference in New Issue
Block a user