From c88ead9fbb54b15c785e930e1aa245c6c3a03561 Mon Sep 17 00:00:00 2001 From: "B. Watson" Date: Sat, 25 May 2024 12:59:45 -0400 Subject: unprotbas: add --help and --version. --- unprotbas.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'unprotbas.c') diff --git a/unprotbas.c b/unprotbas.c index 7ee5d03..1697aa8 100644 --- a/unprotbas.c +++ b/unprotbas.c @@ -604,7 +604,7 @@ void scramble_vars(void) { } void print_help(void) { - fprintf(stderr, "Usage: %s [-v] [[-f] [-n] [-g] [-c] [-r|-w] | [-p|-pc|-pv] ] \n", self); + fprintf(stderr, "Usage: %s [-v] [[-f] [-n] [-g] [-c] [-r|-w] | [-p|-pc|-pv]] \n", self); fprintf(stderr, "-v: verbose\n"); fprintf(stderr, "-f: force variable name table rebuild\n"); fprintf(stderr, "-n: do not rebuild variable name table, even if it's invalid\n"); @@ -663,11 +663,27 @@ void open_output(const char *name) { } void parse_args(int argc, char **argv) { + char *p; + self = *argv; + p = strrchr(self, '/'); + if(p) self = p + 1; + if(argc < 2) { + print_help(); + exit(1); + } + + if(strcmp(argv[1], "--help") == 0) { print_help(); exit(0); } + + if(strcmp(argv[1], "--version") == 0) { + printf("%s %s\n", self, VERSION); + exit(0); + } + while(++argv, --argc) { if((*argv)[0] == '-') { switch((*argv)[1]) { -- cgit v1.2.3