From: Ken Hornstein Date: Thu, 14 Nov 2013 01:54:48 +0000 (-0500) Subject: Switch fmttest over to using snprintb() instead of the private custom version X-Git-Url: https://diplodocus.org/git/nmh/commitdiff_plain/4c1236a0c2f9fd289746f1e371d61f086e643cfa?ds=inline;hp=--cc Switch fmttest over to using snprintb() instead of the private custom version we originally cribbed from fmtdump. --- 4c1236a0c2f9fd289746f1e371d61f086e643cfa diff --git a/h/fmt_scan.h b/h/fmt_scan.h index 50b597e1..771d9fba 100644 --- a/h/fmt_scan.h +++ b/h/fmt_scan.h @@ -37,6 +37,8 @@ struct comp { #define CT_ADDR (1<<0) /* referenced as address */ #define CT_DATE (1<<1) /* referenced as date */ +#define CT_BITS "\020\01ADDR\02DATE" + /* * c_flags bits */ @@ -45,6 +47,8 @@ struct comp { #define CF_DATEFAB (1<<2) /* datefield fabricated */ #define CF_TRIMMED (1<<3) /* Component has been trimmed */ +#define CF_BITS "\020\01TRUE\02PARSED\03CF_DATEFAB\04TRIMMED" + extern int fmt_norm; /* diff --git a/uip/fmttest.c b/uip/fmttest.c index c8dc589d..b3deda81 100644 --- a/uip/fmttest.c +++ b/uip/fmttest.c @@ -1081,47 +1081,23 @@ f_typestr(int t) } } -#define FNORD(v, s) if (t & (v)) { \ - if (i++ > 0) \ - strcat(buf, "|"); \ - strcat(buf, s); } - static char * c_typestr(int t) { - register int i; static char buf[64]; - buf[0] = '\0'; - if (t & ~(CT_ADDR|CT_DATE)) - printf(buf, "0x%x ", t); - strcat(buf, "<"); - i = 0; - FNORD(CT_ADDR, "ADDR"); - FNORD(CT_DATE, "DATE"); - strcat(buf, ">"); + snprintb(buf, sizeof(buf), t, CT_BITS); return(buf); } static char * c_flagsstr(int t) { - register int i; static char buf[64]; - buf[0] = '\0'; - if (t & ~(CF_TRUE|CF_PARSED|CF_DATEFAB|CF_TRIMMED)) - printf(buf, "0x%x ", t); - strcat(buf, "<"); - i = 0; - FNORD(CF_TRUE, "TRUE"); - FNORD(CF_PARSED, "PARSED"); - FNORD(CF_DATEFAB, "DATEFAB"); - FNORD(CF_TRIMMED, "TRIMMED"); - strcat(buf, ">"); + snprintb(buf, sizeof(buf), t, CF_BITS); return(buf); } -#undef FNORD static void litputs(char *s)