X-Git-Url: http://git.marmaro.de/?a=blobdiff_plain;f=uip%2Fdp.c;h=1cbb7ed5d0b7dd9e1a14651968dbddad6746a3c2;hb=43c31a90ba57b93a5504c39a28b9ef55a9b6e801;hp=22e725c30cfb0c2a4515c0edc837d5fd16883311;hpb=fede6e42d81ce34fd5c1bbe7fb2757b281c2573a;p=mmh diff --git a/uip/dp.c b/uip/dp.c index 22e725c..1cbb7ed 100644 --- a/uip/dp.c +++ b/uip/dp.c @@ -9,6 +9,8 @@ #include #include #include +#include +#include #define NDATES 100 @@ -56,36 +58,35 @@ main(int argc, char **argv) switch (smatch(++cp, switches)) { case AMBIGSW: ambigsw(cp, switches); - /* sysexits.h EX_USAGE */ - exit(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); - exit(0); + exit(argc == 2 ? EX_OK : EX_USAGE); case VERSIONSW: print_version(invo_name); - exit(0); + 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 */ fmtstr = new_fs(form, FORMAT);