X-Git-Url: http://git.marmaro.de/?a=blobdiff_plain;f=uip%2Ffmtdump.c;h=c9b28cf70a448a8c77d100d7afca88d3362d6c76;hb=43c31a90ba57b93a5504c39a28b9ef55a9b6e801;hp=d948a063d8f4372d9391a9f8577eb2b10252e1ba;hpb=5d4f603fcfc7cf4a238b27de2b18567a733bb6b4;p=mmh diff --git a/uip/fmtdump.c b/uip/fmtdump.c index d948a06..c9b28cf 100644 --- a/uip/fmtdump.c +++ b/uip/fmtdump.c @@ -10,15 +10,15 @@ #include #include #include +#include +#include static struct swit switches[] = { #define FORMSW 0 { "form formatfile", 0 }, -#define FMTSW 1 - { "format string", 5 }, -#define VERSIONSW 2 - { "version", 0 }, -#define HELPSW 3 +#define VERSIONSW 1 + { "Version", 0 }, +#define HELPSW 2 { "help", 0 }, { NULL, 0 } }; @@ -44,14 +44,11 @@ static void litputc(char); int main(int argc, char **argv) { - int ncomps; - char *cp, *form = NULL, *format = NULL; - char buf[BUFSIZ], *nfs, **argp, **arguments; + char *cp, *form = NULL; + char buf[BUFSIZ], *fmtstr, **argp, **arguments; struct format *fmt; -#ifdef LOCALE setlocale(LC_ALL, ""); -#endif invo_name = mhbasename(argv[0]); /* read user profile/context */ @@ -65,36 +62,29 @@ 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]", 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", - argp[-2]); - format = NULL; - continue; - case FMTSW: - if (!(format = *argp++) || *format == '-') - adios(NULL, "missing argument to %s", + adios(EX_USAGE, NULL, "missing argument to %s", argp[-2]); - form = NULL; continue; } } if (form) - adios(NULL, "only one form at a time!"); + adios(EX_USAGE, NULL, "only one form at a time!"); else form = cp; } @@ -102,12 +92,11 @@ main(int argc, char **argv) /* ** Get new format string. Must be before chdir(). */ - nfs = new_fs(form, format, FORMAT); - ncomps = fmt_compile(nfs, &fmt); + fmtstr = new_fs(form, FORMAT); + fmt_compile(fmtstr, &fmt); fmt_dump(fmt); - done(0); - return 1; + return EX_OK; } static void