aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorB. Watson <urchlay@slackware.uk>2024-05-25 12:59:45 -0400
committerB. Watson <urchlay@slackware.uk>2024-05-25 12:59:45 -0400
commitc88ead9fbb54b15c785e930e1aa245c6c3a03561 (patch)
tree81d73297b9116b1f884aaf07a9d5f6a19538dec8
parentb07b79049a7bc7b722513700118ac5142d6f03d5 (diff)
downloadbw-atari8-tools-c88ead9fbb54b15c785e930e1aa245c6c3a03561.tar.gz
unprotbas: add --help and --version.
-rw-r--r--unprotbas.c18
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]) {