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); *p = GET_OPERAND(pic,i);
break; break;
} }
case 'f': { case 'f': case 'F': {
double *f; double *f;
bool *e, dummy;
pic_value v; pic_value v;
f = va_arg(ap, double *); f = va_arg(ap, double *);
e = (c == 'F' ? va_arg(ap, bool *) : &dummy);
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 *);
v = GET_OPERAND(pic, i); v = GET_OPERAND(pic, i);
switch (pic_type(v)) { switch (pic_type(v)) {
@ -144,18 +125,18 @@ pic_get_args(pic_state *pic, const char *format, ...)
} }
break; break;
} }
case 'I': { case 'i': case 'I': {
int *k; int *k;
bool *e; bool *e, dummy;
pic_value v; pic_value v;
k = va_arg(ap, int *); k = va_arg(ap, int *);
e = va_arg(ap, bool *); e = (c == 'I' ? va_arg(ap, bool *) : &dummy);
v = GET_OPERAND(pic, i); v = GET_OPERAND(pic, i);
switch (pic_type(v)) { switch (pic_type(v)) {
case PIC_TT_FLOAT: case PIC_TT_FLOAT:
*k = (int)pic_float(v); *k = pic_float(v);
*e = false; *e = false;
break; break;
case PIC_TT_INT: case PIC_TT_INT:
@ -167,25 +148,6 @@ pic_get_args(pic_state *pic, const char *format, ...)
} }
break; 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': { case 'c': {
char *k; char *k;
pic_value v; pic_value v;