X-Git-Url: https://diplodocus.org/git/nmh/blobdiff_plain/177f020f122827214159c46dcfe7ded1e3c8d1c3..394a751fd883d2bbfc769fed7e254e008a2ef45e:/sbr/read_switch_multiword_via_readline.c diff --git a/sbr/read_switch_multiword_via_readline.c b/sbr/read_switch_multiword_via_readline.c index fe84b4e0..df91701c 100644 --- a/sbr/read_switch_multiword_via_readline.c +++ b/sbr/read_switch_multiword_via_readline.c @@ -5,7 +5,12 @@ * complete copyright information. */ -#include +#include "h/mh.h" +#include "read_switch_multiword_via_readline.h" +#include "smatch.h" +#include "brkstring.h" +#include "ambigsw.h" +#include "print_sw.h" #ifdef READLINE_SUPPORT #include @@ -49,6 +54,8 @@ read_switch_multiword_via_readline(char *prompt, struct swit *ansp) add_history(ans); strncpy(ansbuf, ans, sizeof(ansbuf)); ansbuf[sizeof(ansbuf) - 1] = '\0'; + free(ans); + cpp = brkstring(ansbuf, " ", NULL); switch (smatch(*cpp, ansp)) { case AMBIGSW: @@ -58,10 +65,8 @@ read_switch_multiword_via_readline(char *prompt, struct swit *ansp) printf(" -%s unknown. Hit for help.\n", *cpp); continue; default: - free(ans); return cpp; } - free(ans); } } @@ -75,16 +80,12 @@ initialize_readline(void) static char ** nmh_completion(const char *text, int start, int end) { - char **matches; - NMH_UNUSED (end); - matches = (char **) NULL; - if (start == 0) - matches = rl_completion_matches(text, nmh_command_generator); + return rl_completion_matches(text, nmh_command_generator); - return matches; + return NULL; } static char *