aboutsummaryrefslogtreecommitdiff
path: root/monitor/hmp.c
diff options
context:
space:
mode:
authorMarkus Armbruster <armbru@redhat.com>2023-01-24 13:19:20 +0100
committerMarkus Armbruster <armbru@redhat.com>2023-02-04 07:56:54 +0100
commit52f50b1e9f8fd410d4293a211d549ec61b902728 (patch)
treeec247a22b645c5181143d02cf33cece6f055cc40 /monitor/hmp.c
parent444ee02c5ff3b1ce794e9dc2fe2005a13ae8e4a7 (diff)
downloadqemu-52f50b1e9f8fd410d4293a211d549ec61b902728.zip
qemu-52f50b1e9f8fd410d4293a211d549ec61b902728.tar.gz
qemu-52f50b1e9f8fd410d4293a211d549ec61b902728.tar.bz2
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 'monitor/hmp.c')
-rw-r--r--monitor/hmp.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/monitor/hmp.c b/monitor/hmp.c
index e5d914b..1b04f01 100644
--- a/monitor/hmp.c
+++ b/monitor/hmp.c
@@ -1189,8 +1189,8 @@ static void cmd_completion(MonitorHMP *mon, const char *name, const char *list)
}
memcpy(cmd, pstart, len);
cmd[len] = '\0';
- if (name[0] == '\0' || !strncmp(name, cmd, strlen(name))) {
- readline_add_completion(mon->rs, cmd);
+ if (name[0] == '\0') {
+ readline_add_completion_of(mon->rs, name, cmd);
}
if (*p == '\0') {
break;
@@ -1270,7 +1270,7 @@ static void monitor_find_completion_by_table(MonitorHMP *mon,
{
const char *cmdname;
int i;
- const char *ptype, *old_ptype, *str, *name;
+ const char *ptype, *old_ptype, *str;
const HMPCommand *cmd;
BlockBackend *blk = NULL;
@@ -1335,10 +1335,8 @@ static void monitor_find_completion_by_table(MonitorHMP *mon,
/* block device name completion */
readline_set_completion_index(mon->rs, strlen(str));
while ((blk = blk_next(blk)) != NULL) {
- name = blk_name(blk);
- if (str[0] == '\0' ||
- !strncmp(name, str, strlen(str))) {
- readline_add_completion(mon->rs, name);
+ if (str[0] == '\0') {
+ readline_add_completion_of(mon->rs, str, blk_name(blk));
}
}
break;