summaryrefslogtreecommitdiff
path: root/src/cli.c
diff options
context:
space:
mode:
authorjakob <jakob@memeware.net>2017-04-12 16:54:36 -0400
committerjakob <jakob@memeware.net>2017-04-12 16:54:36 -0400
commit07347dcaa361607a924178eff787177e8cca6d68 (patch)
tree5109650cbaf0a8ff5a9dadad5ab912f1cf59911d /src/cli.c
parent411a40b5c077ca69e34c7016428eb9d856f8fe73 (diff)
Expanded tests for the command-line interface.
Diffstat (limited to 'src/cli.c')
-rw-r--r--src/cli.c10
1 files changed, 8 insertions, 2 deletions
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) {