aboutsummaryrefslogtreecommitdiffstats
path: root/src/c_opts.c
diff options
context:
space:
mode:
authorjozan <jozan@noemail.net>2020-11-15 16:24:21 +0000
committerjozan <jozan@noemail.net>2020-11-15 16:24:21 +0000
commitd08c2c074117f8171370a8d3e12f13a3e17d24f0 (patch)
treeaa21a515374c6664d18cac50ebf3c95c82f91af2 /src/c_opts.c
parentMan in progress (diff)
downloadunixize-d08c2c074117f8171370a8d3e12f13a3e17d24f0.tar.gz
unixize-d08c2c074117f8171370a8d3e12f13a3e17d24f0.tar.bz2
unixize-d08c2c074117f8171370a8d3e12f13a3e17d24f0.tar.xz
unixize-d08c2c074117f8171370a8d3e12f13a3e17d24f0.tar.zst
unixize-d08c2c074117f8171370a8d3e12f13a3e17d24f0.zip
A directory is now a required argument, for safety
FossilOrigin-Name: ff2d65680f254c7930990b40e3988f9b0443cd5dd58e852e5b13e0989de4d206
Diffstat (limited to 'src/c_opts.c')
-rw-r--r--src/c_opts.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/c_opts.c b/src/c_opts.c
index 6df0722..996643e 100644
--- a/src/c_opts.c
+++ b/src/c_opts.c
@@ -190,7 +190,7 @@ c_get_opts
C_C_OPT_FMT,
optarg
);
- exit(2);
+ exit(1);
}
else {
opts->cxx = optarg[0] - 48;
@@ -203,18 +203,23 @@ c_get_opts
}
if (
argv[0][0] != C_RECURSIVE_CHAR &&
+ argv[optind] == NULL
+ ) {
+ c_dump_usage();
+ exit(1);
+ }
+ if (
+ argv[0][0] != C_RECURSIVE_CHAR &&
optind < argc &&
argv[optind] != NULL
- ) {
+ ) {
strncpy(opts->dir, argv[optind], PATH_MAX);
if (opts->dir[strlen(opts->dir) - 1] == '/') {
opts->dir[strlen(opts->dir) - 1] = 0x00;
}
}
- else if (argv[0][0] == C_RECURSIVE_CHAR || argv[optind] == NULL) {
+ else if (argv[0][0] == C_RECURSIVE_CHAR) {
strlcpy(opts->dir, ".", 2 * sizeof(char));
- }
- if (argv[0][0] == C_RECURSIVE_CHAR) {
c_recursive_parse(opts, argv);
}
ret = TRUE;