From e36cc1889329edaaa6b6a06bd597b8bfa018e470 Mon Sep 17 00:00:00 2001 From: C-3PO Date: Fri, 14 Sep 2018 01:57:49 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=91=20Fix=20segmentation=20fault=20is?= =?UTF-8?q?=20supplying=20an=20unknown=20long=20argument?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main.c | 2 ++ src/parseArguments.c | 5 +++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main.c b/src/main.c index 07a9a9c..7ab3627 100644 --- a/src/main.c +++ b/src/main.c @@ -116,6 +116,8 @@ int main(int argc, char *argv[]) { //Optionally perform xdelta3 if (state.prevFile) { //TODO + fprintf(stderr, "xdelta3 is not yet implemented.\n"); + errorAndExit(); } } diff --git a/src/parseArguments.c b/src/parseArguments.c index 019d764..8864f5d 100644 --- a/src/parseArguments.c +++ b/src/parseArguments.c @@ -15,6 +15,7 @@ static struct option long_options[] = { {"size", required_argument, 0, 's'}, {"keys", required_argument, 0, 'k'}, {"prev", required_argument, 0, 'p'}, + {NULL, 0, 0, 0}, }; @@ -74,7 +75,7 @@ struct arguments parseArguments(int argc, char *argv[]) { break; } case 'p': //prev file for xdelta3 - //TODO + state.prevFile = optarg; break; case '?': errorAndExit(); @@ -101,7 +102,7 @@ struct arguments parseArguments(int argc, char *argv[]) { } if (optind < argc) { - fprintf(stderr, "Found %i arguments without an option. All arguments must be preceded by an option.\n", argc - optind); + fprintf(stderr, "Found %i argument(s) without an option. All arguments must be preceded by an option.\n", argc - optind); errorAndExit(); }