diff options
author | Markus Armbruster <armbru@redhat.com> | 2023-01-24 13:19:20 +0100 |
---|---|---|
committer | Markus Armbruster <armbru@redhat.com> | 2023-02-04 07:56:54 +0100 |
commit | 52f50b1e9f8fd410d4293a211d549ec61b902728 (patch) | |
tree | ec247a22b645c5181143d02cf33cece6f055cc40 /util | |
parent | 444ee02c5ff3b1ce794e9dc2fe2005a13ae8e4a7 (diff) |
readline: Extract readline_add_completion_of() from monitor
monitor/misc.h has static add_completion_option(). It's useful
elsewhere in the monitor. Since it's not monitor-specific, move it to
util/readline.c renamed to readline_add_completion_of(), and put it to
use.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20230124121946.1139465-7-armbru@redhat.com>
Diffstat (limited to 'util')
-rw-r--r-- | util/readline.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/util/readline.c b/util/readline.c index f1ac6e4769..494a3d924e 100644 --- a/util/readline.c +++ b/util/readline.c @@ -286,6 +286,14 @@ void readline_add_completion(ReadLineState *rs, const char *str) } } +void readline_add_completion_of(ReadLineState *rs, + const char *pfx, const char *str) +{ + if (!strncmp(str, pfx, strlen(pfx))) { + readline_add_completion(rs, str); + } +} + void readline_set_completion_index(ReadLineState *rs, int index) { rs->completion_index = index; |