X-Git-Url: http://git.marmaro.de/?p=mmh;a=blobdiff_plain;f=uip%2Fdp.c;h=70162b2a0b1055b5134a5032fc08f101d9397765;hp=fa3a201870749df16198a3e93fc7b2b5310593ad;hb=6e9577f324bef90765a5edc02044eb111ec48072;hpb=0073224c28bf81dad1812d406bb9915b24b23eb6 diff --git a/uip/dp.c b/uip/dp.c index fa3a201..70162b2 100644 --- a/uip/dp.c +++ b/uip/dp.c @@ -9,6 +9,8 @@ #include #include #include +#include +#include #define NDATES 100 @@ -18,12 +20,14 @@ static struct swit switches[] = { #define FORMSW 0 { "form formatfile", 0 }, #define VERSIONSW 1 - { "version", 0 }, + { "Version", 0 }, #define HELPSW 2 { "help", 0 }, { NULL, 0 } }; +char *version=VERSION; + static struct format *fmt; static int dat[5]; @@ -38,13 +42,11 @@ int main(int argc, char **argv) { int datep = 0, status = 0; - char *cp, *form = NULL, *nfs; + char *cp, *form = NULL, *fmtstr; char buf[BUFSIZ], **argp, **arguments; char *dates[NDATES]; -#ifdef LOCALE setlocale(LC_ALL, ""); -#endif invo_name = mhbasename(argv[0]); /* read user profile/context */ @@ -58,40 +60,40 @@ main(int argc, char **argv) switch (smatch(++cp, switches)) { case AMBIGSW: ambigsw(cp, switches); - done(1); + exit(EX_USAGE); case UNKWNSW: - adios(NULL, "-%s unknown", cp); + adios(EX_USAGE, NULL, "-%s unknown", cp); case HELPSW: snprintf(buf, sizeof(buf), "%s [switches] dates ...", invo_name); print_help(buf, switches, 1); - done(1); + exit(argc == 2 ? EX_OK : EX_USAGE); case VERSIONSW: print_version(invo_name); - done(1); + exit(argc == 2 ? EX_OK : EX_USAGE); case FORMSW: if (!(form = *argp++) || *form == '-') - adios(NULL, "missing argument to %s", + adios(EX_USAGE, NULL, "missing argument to %s", argp[-2]); continue; } } if (datep > NDATES) - adios(NULL, "more than %d dates", NDATES); + adios(EX_USAGE, NULL, "more than %d dates", NDATES); else dates[datep++] = cp; } dates[datep] = NULL; if (datep == 0) - adios(NULL, "usage: %s [switches] dates ...", invo_name); + adios(EX_USAGE, NULL, "usage: %s [switches] dates ...", invo_name); /* get new format string */ - nfs = new_fs(form, FORMAT); + fmtstr = new_fs(form, FORMAT); - fmt_compile(nfs, &fmt); + fmt_compile(fmtstr, &fmt); dat[0] = 0; dat[1] = 0; @@ -103,8 +105,7 @@ main(int argc, char **argv) status += process(dates[datep]); context_save(); /* save the context file */ - done(status); - return 1; + return status; } @@ -113,7 +114,7 @@ process(char *date) { int status = 0; char buffer[BUFSIZ + 1]; - register struct comp *cptr; + struct comp *cptr; FINDCOMP(cptr, "text"); if (cptr)