зеркало из https://github.com/github/ruby.git
sprintf.c: check_pos_arg
* sprintf.c (check_pos_arg): utility function for GETPOSARG(). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46658 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
420523389e
Коммит
3f48c1fdf7
23
sprintf.c
23
sprintf.c
|
@ -85,12 +85,9 @@ sign_bits(int base, const char *p)
|
||||||
check_next_arg(posarg, nextarg), \
|
check_next_arg(posarg, nextarg), \
|
||||||
(posarg = nextarg++, GETNTHARG(posarg)))
|
(posarg = nextarg++, GETNTHARG(posarg)))
|
||||||
|
|
||||||
#define GETPOSARG(n) (posarg > 0 ? \
|
#define GETPOSARG(n) ( \
|
||||||
(rb_raise(rb_eArgError, "numbered(%d) after unnumbered(%d)", (n), posarg), 0) : \
|
check_pos_arg(posarg, (n)), \
|
||||||
posarg == -2 ? \
|
(posarg = -1, GETNTHARG(n)))
|
||||||
(rb_raise(rb_eArgError, "numbered(%d) after named", (n)), 0) : \
|
|
||||||
(((n) < 1) ? (rb_raise(rb_eArgError, "invalid index - %d$", (n)), 0) : \
|
|
||||||
(posarg = -1, GETNTHARG(n))))
|
|
||||||
|
|
||||||
#define GETNTHARG(nth) \
|
#define GETNTHARG(nth) \
|
||||||
(((nth) >= argc) ? (rb_raise(rb_eArgError, "too few arguments"), 0) : argv[(nth)])
|
(((nth) >= argc) ? (rb_raise(rb_eArgError, "too few arguments"), 0) : argv[(nth)])
|
||||||
|
@ -150,6 +147,20 @@ check_next_arg(int posarg, int nextarg)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
check_pos_arg(int posarg, int n)
|
||||||
|
{
|
||||||
|
if (posarg > 0) {
|
||||||
|
rb_raise(rb_eArgError, "numbered(%d) after unnumbered(%d)", n, posarg);
|
||||||
|
}
|
||||||
|
if (posarg == -2) {
|
||||||
|
rb_raise(rb_eArgError, "numbered(%d) after named", n);
|
||||||
|
}
|
||||||
|
if (n < 1) {
|
||||||
|
rb_raise(rb_eArgError, "invalid index - %d$", n);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
get_hash(volatile VALUE *hash, int argc, const VALUE *argv)
|
get_hash(volatile VALUE *hash, int argc, const VALUE *argv)
|
||||||
{
|
{
|
||||||
|
|
Загрузка…
Ссылка в новой задаче