From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: Dongli Zhang <dongli.zhang@oracle.com>, qemu-devel@nongnu.org
Cc: dgilbert@redhat.com, joe.jin@oracle.com,
Markus Armbruster <armbru@redhat.com>
Subject: Re: [PATCH 1/1] readline: fix hmp completion issue
Date: Wed, 8 Feb 2023 12:05:34 +0100 [thread overview]
Message-ID: <ff9756f8-1b95-f68a-1536-08eec30f7670@linaro.org> (raw)
In-Reply-To: <20230207045241.8843-1-dongli.zhang@oracle.com>
On 7/2/23 05:52, Dongli Zhang wrote:
> The auto completion does not work in some cases.
>
> Case 1.
>
> 1. (qemu) info reg
> 2. Press 'Tab'.
> 3. It does not auto complete.
>
> Case 2.
>
> 1. (qemu) block_resize flo
> 2. Press 'Tab'.
> 3. It does not auto complete 'floppy0'.
>
> Since the readline_add_completion_of() may add any completion when
> strlen(pfx) is zero, we remove the check with (name[0] == '\0') because
> strlen() always returns zero in that case.
>
> Fixes: 52f50b1e9f8f ("readline: Extract readline_add_completion_of() from monitor")
> Cc: Joe Jin <joe.jin@oracle.com>
> Signed-off-by: Dongli Zhang <dongli.zhang@oracle.com>
> ---
> monitor/hmp.c | 8 ++------
> 1 file changed, 2 insertions(+), 6 deletions(-)
>
> diff --git a/monitor/hmp.c b/monitor/hmp.c
> index 2aa85d3982..fee410362f 100644
> --- a/monitor/hmp.c
> +++ b/monitor/hmp.c
> @@ -1189,9 +1189,7 @@ static void cmd_completion(MonitorHMP *mon, const char *name, const char *list)
> }
> memcpy(cmd, pstart, len);
> cmd[len] = '\0';
> - if (name[0] == '\0') {
> - readline_add_completion_of(mon->rs, name, cmd);
> - }
> + readline_add_completion_of(mon->rs, name, cmd);
> if (*p == '\0') {
> break;
> }
> @@ -1335,9 +1333,7 @@ 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) {
> - if (str[0] == '\0') {
> - readline_add_completion_of(mon->rs, str, blk_name(blk));
> - }
> + readline_add_completion_of(mon->rs, str, blk_name(blk));
> }
> break;
> case 's':
Tested-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Thanks!
next prev parent reply other threads:[~2023-02-08 11:06 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-07 4:52 [PATCH 1/1] readline: fix hmp completion issue Dongli Zhang
2023-02-08 11:05 ` Philippe Mathieu-Daudé [this message]
2023-02-08 12:33 ` Markus Armbruster
2023-02-14 13:39 ` Thomas Huth
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ff9756f8-1b95-f68a-1536-08eec30f7670@linaro.org \
--to=philmd@linaro.org \
--cc=armbru@redhat.com \
--cc=dgilbert@redhat.com \
--cc=dongli.zhang@oracle.com \
--cc=joe.jin@oracle.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).