summaryrefslogtreecommitdiff
path: root/sprintf.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-07-02 08:03:51 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-07-02 08:03:51 +0000
commit420523389ec582f13924608ceb7640c95d7dd7a4 (patch)
tree424ede182cb2aa50c45283707789950f991b9e49 /sprintf.c
parent3659c10b9d156cf8e12602996aa4719efc437ecd (diff)
sprintf.c: check_next_arg
* sprintf.c (check_next_arg): utility function for GETNEXTARG(). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46657 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'sprintf.c')
-rw-r--r--sprintf.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/sprintf.c b/sprintf.c
index 27551b0..8f71529 100644
--- a/sprintf.c
+++ b/sprintf.c
@@ -82,10 +82,7 @@ sign_bits(int base, const char *p)
GETNEXTARG())
#define GETNEXTARG() ( \
- posarg == -1 ? \
- (rb_raise(rb_eArgError, "unnumbered(%d) mixed with numbered", nextarg), 0) : \
- posarg == -2 ? \
- (rb_raise(rb_eArgError, "unnumbered(%d) mixed with named", nextarg), 0) : \
+ check_next_arg(posarg, nextarg), \
(posarg = nextarg++, GETNTHARG(posarg)))
#define GETPOSARG(n) (posarg > 0 ? \
@@ -142,6 +139,17 @@ get_num(const char *p, const char *end, rb_encoding *enc, int *valp)
return p;
}
+static void
+check_next_arg(int posarg, int nextarg)
+{
+ switch (posarg) {
+ case -1:
+ rb_raise(rb_eArgError, "unnumbered(%d) mixed with numbered", nextarg);
+ case -2:
+ rb_raise(rb_eArgError, "unnumbered(%d) mixed with named", nextarg);
+ }
+}
+
static VALUE
get_hash(volatile VALUE *hash, int argc, const VALUE *argv)
{