X-Git-Url: http://git.marmaro.de/?a=blobdiff_plain;f=uip%2Ffmtdump.c;h=d69fb8c1375cdf2574dd7fbed184e0b9479997e6;hb=ac99d23ec89df5e72b39c7ae950c084ca0377eca;hp=9ae23b4121075246c0277b2c170a1e142e8c25e1;hpb=197f95940cc0860683e6988352f721e6603f9339;p=mmh diff --git a/uip/fmtdump.c b/uip/fmtdump.c index 9ae23b4..d69fb8c 100644 --- a/uip/fmtdump.c +++ b/uip/fmtdump.c @@ -2,7 +2,9 @@ /* * fmtdump.c -- compile format file and dump out instructions * - * $Id$ + * This code is Copyright (c) 2002, by the authors of nmh. See the + * COPYRIGHT file in the root directory of the nmh distribution for + * complete copyright information. */ #include @@ -18,13 +20,13 @@ static struct swit switches[] = { #define VERSIONSW 2 { "version", 0 }, #define HELPSW 3 - { "help", 4 }, + { "help", 0 }, { NULL, 0 } }; /* for assignlabel */ static struct format *lvec[128]; -static lused = 0; +static int lused = 0; /* * static prototypes @@ -35,6 +37,7 @@ static int findlabel(struct format *); static void assignlabel(struct format *); static char *f_typestr(int); static char *c_typestr(int); +static char *c_flagsstr(int); static void litputs(char *); static void litputc(char); @@ -42,7 +45,6 @@ static void litputc(char); int main (int argc, char **argv) { - int ncomps; char *cp, *form = NULL, *format = NULL; char buf[BUFSIZ], *nfs, **argp, **arguments; struct format *fmt; @@ -70,10 +72,10 @@ main (int argc, char **argv) case HELPSW: snprintf (buf, sizeof(buf), "%s [switches]", invo_name); print_help (buf, switches, 1); - done (1); + done (0); case VERSIONSW: print_version(invo_name); - done (1); + done (0); case FORMSW: if (!(form = *argp++) || *form == '-') @@ -98,10 +100,11 @@ main (int argc, char **argv) * Get new format string. Must be before chdir(). */ nfs = new_fs (form, format, FORMAT); - ncomps = fmt_compile(nfs, &fmt); + (void) fmt_compile(nfs, &fmt); fmt_dump(fmt); - return done(0); + done(0); + return 1; } static void @@ -159,7 +162,7 @@ dumpone(struct format *fmt) if (fmt->f_comp->c_type) printf(", c_type %s", c_typestr(fmt->f_comp->c_type)); if (fmt->f_comp->c_flags) - printf(", c_flags %d", fmt->f_comp->c_flags); + printf(", c_flags %s", c_flagsstr(fmt->f_comp->c_flags)); break; case FT_LV_SEC: @@ -191,7 +194,7 @@ dumpone(struct format *fmt) if (fmt->f_comp->c_type) printf(", c_type %s", c_typestr(fmt->f_comp->c_type)); if (fmt->f_comp->c_flags) - printf(", c_flags %d", fmt->f_comp->c_flags); + printf(", c_flags %s", c_flagsstr(fmt->f_comp->c_flags)); break; case FT_LS_ADDR: @@ -213,7 +216,7 @@ dumpone(struct format *fmt) if (fmt->f_comp->c_type) printf(", c_type %s", c_typestr(fmt->f_comp->c_type)); if (fmt->f_comp->c_flags) - printf(", c_flags %d", fmt->f_comp->c_flags); + printf(", c_flags %s", c_flagsstr(fmt->f_comp->c_flags)); break; case FT_COMPF: @@ -224,7 +227,7 @@ dumpone(struct format *fmt) if (fmt->f_comp->c_type) printf(", c_type %s", c_typestr(fmt->f_comp->c_type)); if (fmt->f_comp->c_flags) - printf(", c_flags %d", fmt->f_comp->c_flags); + printf(", c_flags %s", c_flagsstr(fmt->f_comp->c_flags)); break; case FT_STRF: @@ -351,6 +354,8 @@ f_typestr(int t) case FT_STRF: return("STRF"); case FT_STRFW: return("STRFW"); case FT_PUTADDR: return("PUTADDR"); + case FT_STRLIT: return("STRLIT"); + case FT_STRLITZ: return("STRLITZ"); case FT_LS_COMP: return("LS_COMP"); case FT_LS_LIT: return("LS_LIT"); case FT_LS_GETENV: return("LS_GETENV"); @@ -405,6 +410,7 @@ f_typestr(int t) case FT_PARSEDATE: return("PARSEDATE"); case FT_PARSEADDR: return("PARSEADDR"); case FT_FORMATADDR: return("FORMATADDR"); + case FT_CONCATADDR: return("CONCATADDR"); case FT_MYMBOX: return("MYMBOX"); #ifdef FT_ADDTOSEQ case FT_ADDTOSEQ: return("ADDTOSEQ"); @@ -448,19 +454,36 @@ c_typestr(int t) static char buf[64]; buf[0] = '\0'; - if (t & ~(CT_ADDR|CT_DATE|CT_MYMBOX|CT_ADDRPARSE)) + if (t & ~(CT_ADDR|CT_DATE)) printf(buf, "0x%x ", t); strcat(buf, "<"); i = 0; FNORD(CT_ADDR, "ADDR"); FNORD(CT_DATE, "DATE"); - FNORD(CT_MYMBOX, "MYMBOX"); - FNORD(CT_ADDRPARSE, "ADDRPARSE"); strcat(buf, ">"); return(buf); -#undef FNORD } +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, ">"); + return(buf); +} +#undef FNORD + static void litputs(char *s) {