summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLars Henriksen <LarsHenriksen@get2net.dk>2020-08-27 23:09:29 +0200
committerLukas Fleischer <lfleischer@calcurse.org>2020-10-07 17:36:55 -0400
commit1cecfead4324ea36c2da8f3f875deb8a1bdd8d8c (patch)
tree095736771a29a2bca599333d42afb479349998a9 /src
parentf2a7eea311116691a90120c3e0ba0f1ce7fac6c5 (diff)
downloadcalcurse-1cecfead4324ea36c2da8f3f875deb8a1bdd8d8c.tar.gz
calcurse-1cecfead4324ea36c2da8f3f875deb8a1bdd8d8c.zip
Always exit with failure in case of option parsing errors
Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk> Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
Diffstat (limited to 'src')
-rw-r--r--src/args.c23
1 files changed, 9 insertions, 14 deletions
diff --git a/src/args.c b/src/args.c
index 886429d..abcc70a 100644
--- a/src/args.c
+++ b/src/args.c
@@ -398,7 +398,7 @@ cleanup:
/*
* Parse the command-line arguments and call the appropriate
* routines to handle those arguments. Also initialize the data paths.
- * Returns the non-interactive value.
+ * Exit here in case of errors else return the non-interactive value.
*/
int parse_args(int argc, char **argv)
{
@@ -515,6 +515,10 @@ int parse_args(int argc, char **argv)
case 'c':
cfile = optarg;
break;
+ case '?':
+ usage();
+ usage_try();
+ exit(EXIT_FAILURE); \
}
}
io_init(cfile, datadir, confdir);
@@ -557,7 +561,7 @@ int parse_args(int argc, char **argv)
break;
case 'h':
help_arg();
- goto cleanup;
+ exit(EXIT_SUCCESS);
case 'g':
gc = 1;
break;
@@ -615,7 +619,7 @@ int parse_args(int argc, char **argv)
break;
case 'v':
version_arg();
- goto cleanup;
+ exit(EXIT_SUCCESS);
case 'x':
export = 1;
if (optarg) {
@@ -860,10 +864,6 @@ int parse_args(int argc, char **argv)
'\0';
cmd_line = 1;
break;
- default:
- usage();
- usage_try();
- goto cleanup;
}
}
@@ -876,12 +876,8 @@ int parse_args(int argc, char **argv)
(format_opt && !(grep + query + dump_imported)) ||
(query_range && !query) ||
(purge && !filter.invert)
- ) {
- ERROR_MSG(_("invalid argument combination"));
- usage();
- usage_try();
- goto cleanup;
- }
+ )
+ EXIT(_("invalid argument combination"));
EXIT_IF(to >= 0 && range, _("cannot specify a range and an end date"));
if (from == -1)
@@ -984,7 +980,6 @@ int parse_args(int argc, char **argv)
non_interactive = 0;
}
-cleanup:
/* Free filter parameters. */
if (filter.regex)
regfree(filter.regex);