From 210fecab3f58ab667ac12d759e2ed7e8bfb94f48 Mon Sep 17 00:00:00 2001 From: Yuichi Nishiwaki Date: Wed, 26 Aug 2015 22:25:56 +0900 Subject: [PATCH] unify 'i' and 'I', and 'f' and 'F' --- extlib/benz/vm.c | 52 +++++++----------------------------------------- 1 file changed, 7 insertions(+), 45 deletions(-) diff --git a/extlib/benz/vm.c b/extlib/benz/vm.c index 5faa602b..f43a4c19 100644 --- a/extlib/benz/vm.c +++ b/extlib/benz/vm.c @@ -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;