]> diplodocus.org Git - nmh/blobdiff - uip/dp.c
Document changes to mhbuild.
[nmh] / uip / dp.c
index b9158459be7ab6236bca8bd63fb457b63c569d58..dabdd74c84adde9eb358988a2b5aa1e64def9e13 100644 (file)
--- a/uip/dp.c
+++ b/uip/dp.c
 
 #define        FORMAT "%<(nodate{text})error: %{text}%|%(putstr(pretty{text}))%>"
 
-static struct swit switches[] = {
-#define        FORMSW                0
-    { "form formatfile", 0 },
-#define        FMTSW                 1
-    { "format string", 5 },
-#define        WIDTHSW               2
-    { "width columns", 0 },
-#define VERSIONSW             3
-    { "version", 0 },
-#define        HELPSW                4
-    { "help", 0 },
-    { NULL, 0 }
-};
+#define DP_SWITCHES \
+    X("form formatfile", 0, FORMSW) \
+    X("format string", 5, FMTSW) \
+    X("width columns", 0, WIDTHSW) \
+    X("version", 0, VERSIONSW) \
+    X("help", 0, HELPSW) \
+
+#define X(sw, minchars, id) id,
+DEFINE_SWITCH_ENUM(DP);
+#undef X
+
+#define X(sw, minchars, id) { sw, minchars, id },
+DEFINE_SWITCH_ARRAY(DP, switches);
+#undef X
 
 static struct format *fmt;
 
@@ -50,13 +51,7 @@ main (int argc, char **argv)
     char buf[BUFSIZ], **argp, **arguments;
     char *dates[NDATES];
 
-#ifdef LOCALE
-    setlocale(LC_ALL, "");
-#endif
-    invo_name = r1bindex (argv[0], '/');
-
-    /* read user profile/context */
-    context_read();
+    if (nmh_init(argv[0], 1)) { return 1; }
 
     arguments = getarguments (invo_name, argc, argv, 1);
     argp = arguments;
@@ -148,7 +143,7 @@ process (char *date, int length)
            free(cptr->c_text);
        cptr->c_text = getcpy(date);
     }
-    fmt_scan (fmt, buffer, sizeof buffer - 1, length, dat);
+    fmt_scan (fmt, buffer, sizeof buffer - 1, length, dat, NULL);
     fputs (buffer, stdout);
 
     return status;