Factor out usage_exit into into tools/common.h

This commit is contained in:
Rangi
2021-09-21 17:37:43 -04:00
parent 2691c9f5c8
commit be7a5e09b5
7 changed files with 48 additions and 58 deletions

View File

@@ -1,8 +1,7 @@
#include "common.h"
#define PROGRAM_NAME "scan_includes"
#define USAGE_OPTS "[-h|--help] [-s|--strict] filename.asm"
void usage() {
fputs("Usage: scan_includes [-h|--help] [-s|--strict] filename.asm\n", stderr);
}
#include "common.h"
void parse_args(int argc, char *argv[], bool *strict) {
struct option long_options[] = {
@@ -16,12 +15,10 @@ void parse_args(int argc, char *argv[], bool *strict) {
*strict = true;
break;
case 'h':
usage();
exit(0);
usage_exit(0);
break;
default:
usage();
exit(1);
usage_exit(1);
}
}
}
@@ -95,8 +92,7 @@ int main(int argc, char *argv[]) {
argc -= optind;
argv += optind;
if (argc < 1) {
usage();
exit(1);
usage_exit(1);
}
scan_file(argv[0], strict);