summaryrefslogtreecommitdiffstats
path: root/tools/plistutil.c
diff options
context:
space:
mode:
authorGravatar Nikias Bassen2020-06-05 17:06:39 +0200
committerGravatar Nikias Bassen2020-06-05 17:06:39 +0200
commite64fbba33a3ca1c3194fb93322feb1b19169878c (patch)
tree57fc59309c0738c363820ccada53a542a2b478ee /tools/plistutil.c
parentd237e7125a6b19226598f4e53ae1455cff13f149 (diff)
downloadlibplist-e64fbba33a3ca1c3194fb93322feb1b19169878c.tar.gz
libplist-e64fbba33a3ca1c3194fb93322feb1b19169878c.tar.bz2
plistutil: Fix option parsing
Diffstat (limited to 'tools/plistutil.c')
-rw-r--r--tools/plistutil.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/tools/plistutil.c b/tools/plistutil.c
index e439d13..9c503b7 100644
--- a/tools/plistutil.c
+++ b/tools/plistutil.c
@@ -84,8 +84,7 @@ static options_t *parse_arguments(int argc, char *argv[])
i++;
continue;
}
-
- if (!strcmp(argv[i], "--outfile") || !strcmp(argv[i], "-o"))
+ else if (!strcmp(argv[i], "--outfile") || !strcmp(argv[i], "-o"))
{
if ((i + 1) == argc)
{
@@ -96,8 +95,7 @@ static options_t *parse_arguments(int argc, char *argv[])
i++;
continue;
}
-
- if (!strcmp(argv[i], "--format") || !strcmp(argv[i], "-f"))
+ else if (!strcmp(argv[i], "--format") || !strcmp(argv[i], "-f"))
{
if ((i + 1) == argc)
{
@@ -116,14 +114,18 @@ static options_t *parse_arguments(int argc, char *argv[])
i++;
continue;
}
-
- if (!strcmp(argv[i], "--debug") || !strcmp(argv[i], "-d"))
+ else if (!strcmp(argv[i], "--debug") || !strcmp(argv[i], "-d"))
{
options->debug = 1;
}
-
- if (!strcmp(argv[i], "--help") || !strcmp(argv[i], "-h"))
+ else if (!strcmp(argv[i], "--help") || !strcmp(argv[i], "-h"))
+ {
+ free(options);
+ return NULL;
+ }
+ else
{
+ printf("ERROR: Invalid option '%s'\n", argv[i]);
free(options);
return NULL;
}