diff options
-rw-r--r-- | unprotbas.c | 18 |
1 files changed, 17 insertions, 1 deletions
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] ] <inputfile> <outputfile>\n", self); + fprintf(stderr, "Usage: %s [-v] [[-f] [-n] [-g] [-c] [-r|-w] | [-p|-pc|-pv]] <inputfile> <outputfile>\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]) { |