Changed msg_style and msg_delim to be file static to m_getfld.c
[mmh] / uip / dp.c
index c20e1ac..b915845 100644 (file)
--- a/uip/dp.c
+++ b/uip/dp.c
@@ -2,8 +2,6 @@
 /*
  * dp.c -- parse dates 822-style
  *
- * $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.
@@ -39,11 +37,6 @@ static struct format *fmt;
 static int dat[5];
 
 /*
- * prototypes
- */
-int sc_width (void);  /* from termsbr.c */
-
-/*
  * static prototypes
  */
 static int process (char *, int);
@@ -81,10 +74,10 @@ main (int argc, char **argv)
                    snprintf (buf, sizeof(buf), "%s [switches] dates ...",
                        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 == '-')
@@ -124,7 +117,7 @@ main (int argc, char **argv)
     }
     if (width > WBUFSIZ)
        width = WBUFSIZ;
-    fmt_compile (nfs, &fmt);
+    fmt_compile (nfs, &fmt, 1);
 
     dat[0] = 0;
     dat[1] = 0;
@@ -136,7 +129,9 @@ main (int argc, char **argv)
        status += process (dates[datep], width);
 
     context_save ();   /* save the context file */
-    return done (status);
+    fmt_free (fmt, 1);
+    done (status);
+    return 1;
 }
 
 
@@ -147,10 +142,13 @@ process (char *date, int length)
     char buffer[WBUFSIZ + 1];
     register struct comp *cptr;
 
-    FINDCOMP (cptr, "text");
-    if (cptr)
-       cptr->c_text = date;
-    fmt_scan (fmt, buffer, length, dat);
+    cptr = fmt_findcomp ("text");
+    if (cptr) {
+       if (cptr->c_text)
+           free(cptr->c_text);
+       cptr->c_text = getcpy(date);
+    }
+    fmt_scan (fmt, buffer, sizeof buffer - 1, length, dat);
     fputs (buffer, stdout);
 
     return status;