diff options
author | Přemysl Janouch <p.janouch@gmail.com> | 2015-05-07 07:47:58 +0200 |
---|---|---|
committer | Přemysl Janouch <p.janouch@gmail.com> | 2015-05-07 07:47:58 +0200 |
commit | 715def65554892b0f75861391823ed0295492e71 (patch) | |
tree | 6b62f8673b1ba339e5047a37615f850398260de7 /degesch.c | |
parent | e3f1bcecae5e4ab08e5cd7c58ee163fab6635ea4 (diff) | |
download | xK-715def65554892b0f75861391823ed0295492e71.tar.gz xK-715def65554892b0f75861391823ed0295492e71.tar.xz xK-715def65554892b0f75861391823ed0295492e71.zip |
degesch: fix option completion
Diffstat (limited to 'degesch.c')
-rw-r--r-- | degesch.c | 19 |
1 files changed, 14 insertions, 5 deletions
@@ -5212,12 +5212,21 @@ complete_option (struct app_context *ctx, struct completion *data, struct str_vector options; str_vector_init (&options); - // Wildcard expansion is an interesting side-effect - char *x = xstrdup_printf ("%s*", word); - dump_matching_options (ctx, x, &options); - free (x); + config_dump (ctx->config.root, &options); + str_vector_sort (&options); - str_vector_add_vector (output, options.vector); + // Wildcard expansion is an interesting side-effect + char *mask = xstrdup_printf ("%s*", word); + for (size_t i = 0; i < options.len; i++) + { + const char *line = options.vector[i]; + char *key = xstrndup (line, strcspn (line, " ")); + if (!fnmatch (mask, key, 0)) + str_vector_add_owned (output, key); + else + free (key); + } + free (mask); str_vector_free (&options); } |