From 07347dcaa361607a924178eff787177e8cca6d68 Mon Sep 17 00:00:00 2001 From: jakob Date: Wed, 12 Apr 2017 16:54:36 -0400 Subject: Expanded tests for the command-line interface. --- src/cli.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src/cli.c') diff --git a/src/cli.c b/src/cli.c index 532388a..2e335af 100644 --- a/src/cli.c +++ b/src/cli.c @@ -33,8 +33,8 @@ static void parse_output_path(const char *optarg, struct params *p) { p->out = malloc(p->out_len + 2); strcpy(p->out, optarg); if (p->out[p->out_len - 1] != '/') { - p->out[p->out_len] = '/'; - p->out_len += 1; + p->out[p->out_len] = '/'; + p->out_len += 1; } } @@ -55,6 +55,12 @@ static void parse_game_id(const char *optarg, struct params *p) { /* Returns a params structure parsed from `argv`. */ struct params parse_args(int argc, char **argv) { + /* getopt maintains external state which needs to be reset each time + `parse_args` is called, otherwise strange things will occur. */ + optind = 1; + opterr = 1; + optopt = 63; + struct params p = {0}; if (argc < 2) { -- cgit v1.3