add 'k' specifier to pic_get_args format
This commit is contained in:
parent
4ac6c2b7ab
commit
bfc45a228b
28
vm.c
28
vm.c
|
@ -40,6 +40,7 @@ pic_get_proc(pic_state *pic)
|
||||||
* o pic_value * object
|
* o pic_value * object
|
||||||
* i int * int
|
* i int * int
|
||||||
* I int *, bool * int with exactness
|
* I int *, bool * int with exactness
|
||||||
|
* k size_t * size_t implicitly converted from int
|
||||||
* f double * float
|
* f double * float
|
||||||
* F double *, bool * float with exactness
|
* F double *, bool * float with exactness
|
||||||
* s pic_str ** string object
|
* s pic_str ** string object
|
||||||
|
@ -196,6 +197,33 @@ pic_get_args(pic_state *pic, const char *format, ...)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case 'k': {
|
||||||
|
size_t *k;
|
||||||
|
|
||||||
|
k = va_arg(ap, size_t *);
|
||||||
|
if (i < argc) {
|
||||||
|
pic_value v;
|
||||||
|
int x;
|
||||||
|
|
||||||
|
v = GET_OPERAND(pic, i);
|
||||||
|
switch (pic_type(v)) {
|
||||||
|
case PIC_TT_INT:
|
||||||
|
x = pic_int(v);
|
||||||
|
if (x < 0) {
|
||||||
|
pic_errorf(pic, "pic_get_args: expected non-negative int, but got ~s", v);
|
||||||
|
}
|
||||||
|
if (sizeof(unsigned) > sizeof(size_t) && (unsigned)x > (unsigned)SIZE_MAX) {
|
||||||
|
pic_errorf(pic, "pic_get_args: int unrepresentable with size_t ~s", v);
|
||||||
|
}
|
||||||
|
*k = (size_t)x;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
pic_errorf(pic, "pic_get_args: expected int, but got ~s", v);
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
case 's': {
|
case 's': {
|
||||||
pic_str **str;
|
pic_str **str;
|
||||||
pic_value v;
|
pic_value v;
|
||||||
|
|
Loading…
Reference in New Issue