]> diplodocus.org Git - nmh/blobdiff - uip/fmtdump.c
Reworked attach to add charset to Content-Type string for
[nmh] / uip / fmtdump.c
index a590a0063529bdff1b52c222a3d06a7d076a48a2..653581684c1c87f82aeafa0a7fbe8f2114e87cad 100644 (file)
@@ -2,8 +2,6 @@
 /*
  * fmtdump.c -- compile format file and dump out instructions
  *
 /*
  * 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.
  * 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 <h/fmt_compile.h>
 #include <h/scansbr.h>
 
 #include <h/fmt_compile.h>
 #include <h/scansbr.h>
 
-static struct swit switches[] = {
-#define        FORMSW              0
-    { "form formatfile", 0 },
-#define        FMTSW               1
-    { "format string", 5 },
-#define VERSIONSW           2
-    { "version", 0 },
-#define        HELPSW              3
-    { "help", 0 },
-    { NULL, 0 }
-};
+#define FMTDUMP_SWITCHES \
+    X("form formatfile", 0, FORMSW) \
+    X("format string", 5, FMTSW) \
+    X("version", 0, VERSIONSW) \
+    X("help", 0, HELPSW) \
+
+#define X(sw, minchars, id) id,
+DEFINE_SWITCH_ENUM(FMTDUMP);
+#undef X
+
+#define X(sw, minchars, id) { sw, minchars, id },
+DEFINE_SWITCH_ARRAY(FMTDUMP, switches);
+#undef X
 
 /* for assignlabel */
 static struct format *lvec[128];
 
 /* for assignlabel */
 static struct format *lvec[128];
@@ -47,7 +47,6 @@ static void litputc(char);
 int
 main (int argc, char **argv)
 {
 int
 main (int argc, char **argv)
 {
-    int ncomps;
     char *cp, *form = NULL, *format = NULL;
     char buf[BUFSIZ], *nfs, **argp, **arguments;
     struct format *fmt;
     char *cp, *form = NULL, *format = NULL;
     char buf[BUFSIZ], *nfs, **argp, **arguments;
     struct format *fmt;
@@ -75,10 +74,10 @@ main (int argc, char **argv)
                case HELPSW: 
                    snprintf (buf, sizeof(buf), "%s [switches]", invo_name);
                    print_help (buf, switches, 1);
                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);
                case VERSIONSW:
                    print_version(invo_name);
-                   done (1);
+                   done (0);
 
                case FORMSW: 
                    if (!(form = *argp++) || *form == '-')
 
                case FORMSW: 
                    if (!(form = *argp++) || *form == '-')
@@ -103,9 +102,12 @@ main (int argc, char **argv)
      * Get new format string.  Must be before chdir().
      */
     nfs = new_fs (form, format, FORMAT);
      * Get new format string.  Must be before chdir().
      */
     nfs = new_fs (form, format, FORMAT);
-    ncomps = fmt_compile(nfs, &fmt);
+    (void) fmt_compile(nfs, &fmt, 1);
 
     fmt_dump(fmt);
 
     fmt_dump(fmt);
+
+    fmt_free(fmt, 1);
+
     done(0);
     return 1;
 }
     done(0);
     return 1;
 }
@@ -357,6 +359,8 @@ f_typestr(int t)
        case FT_STRF: return("STRF");
        case FT_STRFW: return("STRFW");
        case FT_PUTADDR: return("PUTADDR");
        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");
        case FT_LS_COMP: return("LS_COMP");
        case FT_LS_LIT: return("LS_LIT");
        case FT_LS_GETENV: return("LS_GETENV");
@@ -411,10 +415,8 @@ f_typestr(int t)
        case FT_PARSEDATE: return("PARSEDATE");
        case FT_PARSEADDR: return("PARSEADDR");
        case FT_FORMATADDR: return("FORMATADDR");
        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");
        case FT_MYMBOX: return("MYMBOX");
-#ifdef FT_ADDTOSEQ
-       case FT_ADDTOSEQ: return("ADDTOSEQ");
-#endif
        case FT_SAVESTR: return("SAVESTR");
 #ifdef FT_PAUSE
        case FT_PAUSE: return ("PAUSE");
        case FT_SAVESTR: return("SAVESTR");
 #ifdef FT_PAUSE
        case FT_PAUSE: return ("PAUSE");
@@ -471,13 +473,14 @@ c_flagsstr(int t)
        static char buf[64];
 
        buf[0] = '\0';
        static char buf[64];
 
        buf[0] = '\0';
-       if (t & ~(CF_TRUE|CF_PARSED|CF_DATEFAB))
+       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");
                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);
 }
        strcat(buf, ">");
        return(buf);
 }