fix bug with fmt(x, 'a'). Reference: /n/atom/patch/applied/acidfmtsize Date: Thu Feb 20 02:44:09 CET 2014 Signed-off-by: quanstro@quanstro.net --- /sys/src/cmd/acid/expr.c Thu Feb 20 02:43:56 2014 +++ /sys/src/cmd/acid/expr.c Thu Feb 20 02:43:57 2014 @@ -6,7 +6,7 @@ #define Extern extern #include "acid.h" -int fsize[] = +static int fsize[] = { // ['A'] 4, ['B'] 4, @@ -41,19 +41,30 @@ }; int -fmtsize(Value *v) +fmtcharsize(int c) { int ret; - switch(v->fmt) { + switch(c) { default: - assert(v->fmt < nelem(fsize)); - ret = fsize[v->fmt]; + assert(c < nelem(fsize)); + ret = fsize[c]; assert(ret>0 && ret<32); return ret; case 'a': case 'A': return mach->szaddr; + } +} + +int +fmtsize(Value *v) +{ + int ret; + + switch(v->fmt) { + default: + return fmtcharsize(v->fmt); case 'i': case 'I': if(v->type != TINT || machdata == 0) --- /sys/src/cmd/acid/acid.h Thu Feb 20 02:43:59 2014 +++ /sys/src/cmd/acid/acid.h Thu Feb 20 02:43:59 2014 @@ -58,6 +58,7 @@ extern void (*expop[])(Node*, Node*); #define expr(n, r) (r)->comt=0; (*expop[(n)->op])(n, r); extern int fmtsize(Value *v) ; +extern int fmtcharsize(int) ; enum {