From: Jason Self Date: Sat, 19 Sep 2015 04:16:44 +0000 (-0700) Subject: zilasm/main: Extend wrong_arg routine. X-Git-Url: https://jxself.org/git/?a=commitdiff_plain;h=05f035a384b15e5fba9e93ff501159fc8397a5e5;p=zilutils.git zilasm/main: Extend wrong_arg routine. --- diff --git a/zilasm/main.c b/zilasm/main.c index a6bfa68..daa943c 100644 --- a/zilasm/main.c +++ b/zilasm/main.c @@ -20,6 +20,7 @@ #include #include +#include #include #include #include @@ -47,8 +48,15 @@ struct char zserial[7]; /* YYMMDD */ } Config; -void wrong_arg() +void wrong_arg(const char *err, ...) { + if (err) + { + va_list ap; + va_start(ap, err); + vfprintf(stderr, err, ap); + va_end(ap); + } fprintf(stderr, "Try `" PACKAGE_NAME " --help' for more information.\n"); exit(1); } @@ -108,9 +116,8 @@ void parse_intarg(int *dest, const char name[], int min, int max, int defval) *dest = n; return; } - fprintf(stderr, "Wrong %s value %s, must be integer between %d and %d\n", - name, optarg, min, max); - wrong_arg(); + wrong_arg("Wrong %s value %s, must be integer between %d and %d\n", + name, optarg, min, max); } void parse_zserial(void) @@ -132,8 +139,7 @@ void parse_zserial(void) return; } } - fprintf(stderr, "Wrong zserial value %s, must be 6 ascii characters\n", optarg); - wrong_arg(); + wrong_arg("Wrong zserial value %s, must be 6 ascii characters\n", optarg); } int main(int argc, char *argv[], char *envp[]) @@ -159,7 +165,7 @@ int main(int argc, char *argv[], char *envp[]) parse_zserial(); break; default : - wrong_arg(); + wrong_arg(0); } }