diff options
author | John Hawthorn <john.hawthorn@gmail.com> | 2017-01-31 18:06:42 -0800 |
---|---|---|
committer | John Hawthorn <john.hawthorn@gmail.com> | 2017-01-31 18:25:35 -0800 |
commit | 15b29a48af2175f620d0acad00bac59d2d5d8630 (patch) | |
tree | d6fa3a573b8149d7075a500407e53ad64e806b1f /src | |
parent | 0ce32085c7b4f93eb72a5e8524a1d39cd40728d0 (diff) |
Pass options to choices_init
Diffstat (limited to 'src')
-rw-r--r-- | src/choices.c | 3 | ||||
-rw-r--r-- | src/choices.h | 3 | ||||
-rw-r--r-- | src/fzy.c | 2 | ||||
-rw-r--r-- | src/options.c | 5 | ||||
-rw-r--r-- | src/options.h | 1 |
5 files changed, 9 insertions, 5 deletions
diff --git a/src/choices.c b/src/choices.c index 6e34fd6..01480cb 100644 --- a/src/choices.c +++ b/src/choices.c @@ -5,6 +5,7 @@ #include <unistd.h> #include <errno.h> +#include "options.h" #include "choices.h" #include "match.h" @@ -96,7 +97,7 @@ static void choices_reset_search(choices_t *c) { c->results = NULL; } -void choices_init(choices_t *c) { +void choices_init(choices_t *c, options_t *options) { c->strings = NULL; c->results = NULL; diff --git a/src/choices.h b/src/choices.h index f5f9892..e8a598b 100644 --- a/src/choices.h +++ b/src/choices.h @@ -4,6 +4,7 @@ #include <stdio.h> #include "match.h" +#include "options.h" struct scored_result { score_t score; @@ -26,7 +27,7 @@ typedef struct { unsigned int worker_count; } choices_t; -void choices_init(choices_t *c); +void choices_init(choices_t *c, options_t *options); void choices_fread(choices_t *c, FILE *file); void choices_destroy(choices_t *c); void choices_add(choices_t *c, const char *choice); @@ -19,7 +19,7 @@ int main(int argc, char *argv[]) { options_parse(&options, argc, argv); choices_t choices; - choices_init(&choices); + choices_init(&choices, &options); choices_fread(&choices, stdin); if (options.benchmark) { diff --git a/src/options.c b/src/options.c index 9e66122..41dbba1 100644 --- a/src/options.c +++ b/src/options.c @@ -30,10 +30,11 @@ static struct option longopts[] = {{"show-matches", required_argument, NULL, 'e' {"show-scores", no_argument, NULL, 's'}, {"version", no_argument, NULL, 'v'}, {"benchmark", optional_argument, NULL, 'b'}, + {"workers", required_argument, NULL, 'j'}, {"help", no_argument, NULL, 'h'}, {NULL, 0, NULL, 0}}; -void options_set_defaults(options_t *options) { +void options_init(options_t *options) { /* set defaults */ options->benchmark = 0; options->filter = NULL; @@ -46,7 +47,7 @@ void options_set_defaults(options_t *options) { } void options_parse(options_t *options, int argc, char *argv[]) { - options_set_defaults(options); + options_init(options); int c; while ((c = getopt_long(argc, argv, "vhse:q:l:t:p:", longopts, NULL)) != -1) { diff --git a/src/options.h b/src/options.h index 1f461bc..f8a44a0 100644 --- a/src/options.h +++ b/src/options.h @@ -12,6 +12,7 @@ typedef struct { const char *prompt; } options_t; +void options_init(options_t *options); void options_parse(options_t *options, int argc, char *argv[]); #endif |