unify 'i' and 'I', and 'f' and 'F'

This commit is contained in:
Yuichi Nishiwaki 2015-08-26 22:25:56 +09:00
parent e841764b68
commit 210fecab3f
1 changed files with 7 additions and 45 deletions

View File

@ -102,32 +102,13 @@ pic_get_args(pic_state *pic, const char *format, ...)
*p = GET_OPERAND(pic,i);
break;
}
case 'f': {
case 'f': case 'F': {
double *f;
bool *e, dummy;
pic_value v;
f = va_arg(ap, double *);
v = GET_OPERAND(pic, i);
switch (pic_type(v)) {
case PIC_TT_FLOAT:
*f = pic_float(v);
break;
case PIC_TT_INT:
*f = pic_int(v);
break;
default:
pic_errorf(pic, "pic_get_args: expected float or int, but got ~s", v);
}
break;
}
case 'F': {
double *f;
bool *e;
pic_value v;
f = va_arg(ap, double *);
e = va_arg(ap, bool *);
e = (c == 'F' ? va_arg(ap, bool *) : &dummy);
v = GET_OPERAND(pic, i);
switch (pic_type(v)) {
@ -144,18 +125,18 @@ pic_get_args(pic_state *pic, const char *format, ...)
}
break;
}
case 'I': {
case 'i': case 'I': {
int *k;
bool *e;
bool *e, dummy;
pic_value v;
k = va_arg(ap, int *);
e = va_arg(ap, bool *);
e = (c == 'I' ? va_arg(ap, bool *) : &dummy);
v = GET_OPERAND(pic, i);
switch (pic_type(v)) {
case PIC_TT_FLOAT:
*k = (int)pic_float(v);
*k = pic_float(v);
*e = false;
break;
case PIC_TT_INT:
@ -167,25 +148,6 @@ pic_get_args(pic_state *pic, const char *format, ...)
}
break;
}
case 'i': {
int *k;
pic_value v;
k = va_arg(ap, int *);
v = GET_OPERAND(pic, i);
switch (pic_type(v)) {
case PIC_TT_FLOAT:
*k = (int)pic_float(v);
break;
case PIC_TT_INT:
*k = pic_int(v);
break;
default:
pic_errorf(pic, "pic_get_args: expected int, but got ~s", v);
}
break;
}
case 'c': {
char *k;
pic_value v;