2017-09-05 04:50:42

by ERAMOTO Masaya

[permalink] [raw]
Subject: [PATCH BlueZ 1/2] client: Fix completion for list/pair command

The unexpected generator is used if the input string forward matches
with the unexpected command string which a generator for completion
is registered on. Thus,
- since 496b6abf743440e937222c62768e0a3b31f47f02, list command
generates the unneeded argument, which is device id like that
list-attributes command generates.
- since b0fe6045b7d9cfdd02a5e419fc9658a0ffa84619, pair command
generates the invalid argument, which is on/off like that
pairable command generates.
This patch use the exact matching command.
---
client/main.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/client/main.c b/client/main.c
index 87eb131..d487eaf 100644
--- a/client/main.c
+++ b/client/main.c
@@ -2578,10 +2578,11 @@ static char **cmd_completion(const char *text, int start, int end)

if (start > 0) {
int i;
+ char *input_cmd;

+ input_cmd = g_strndup(rl_line_buffer, start -1);
for (i = 0; cmd_table[i].cmd; i++) {
- if (strncmp(cmd_table[i].cmd,
- rl_line_buffer, start - 1))
+ if (strcmp(cmd_table[i].cmd, input_cmd))
continue;

if (!cmd_table[i].gen)
@@ -2591,6 +2592,7 @@ static char **cmd_completion(const char *text, int start, int end)
matches = rl_completion_matches(text, cmd_table[i].gen);
break;
}
+ g_free(input_cmd);
} else {
rl_completion_display_matches_hook = NULL;
matches = rl_completion_matches(text, cmd_generator);
--
2.7.4



2017-09-20 11:55:24

by Luiz Augusto von Dentz

[permalink] [raw]
Subject: Re: [PATCH BlueZ 1/2] client: Fix completion for list/pair command

Hi Eramoto,

On Wed, Sep 20, 2017 at 9:54 AM, ERAMOTO Masaya
<[email protected]> wrote:
> Hi Luiz,
>
> On 09/05/2017 01:50 PM, ERAMOTO Masaya wrote:
>> The unexpected generator is used if the input string forward matches
>> with the unexpected command string which a generator for completion
>> is registered on. Thus,
>> - since 496b6abf743440e937222c62768e0a3b31f47f02, list command
>> generates the unneeded argument, which is device id like that
>> list-attributes command generates.
>> - since b0fe6045b7d9cfdd02a5e419fc9658a0ffa84619, pair command
>> generates the invalid argument, which is on/off like that
>> pairable command generates.
>> This patch use the exact matching command.
>> ---
>> client/main.c | 6 ++++--
>> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> Could you help to have a review?
>
> By any chance, are you working on this function? And does this patch
> do conflict?
>
>
> Regards,
> Eramoto

Applied, thanks.



--
Luiz Augusto von Dentz

2017-09-20 06:54:53

by ERAMOTO Masaya

[permalink] [raw]
Subject: Re: [PATCH BlueZ 1/2] client: Fix completion for list/pair command

Hi Luiz,

On 09/05/2017 01:50 PM, ERAMOTO Masaya wrote:
> The unexpected generator is used if the input string forward matches
> with the unexpected command string which a generator for completion
> is registered on. Thus,
> - since 496b6abf743440e937222c62768e0a3b31f47f02, list command
> generates the unneeded argument, which is device id like that
> list-attributes command generates.
> - since b0fe6045b7d9cfdd02a5e419fc9658a0ffa84619, pair command
> generates the invalid argument, which is on/off like that
> pairable command generates.
> This patch use the exact matching command.
> ---
> client/main.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)

Could you help to have a review?

By any chance, are you working on this function? And does this patch
do conflict?


Regards,
Eramoto


2017-09-05 04:54:00

by ERAMOTO Masaya

[permalink] [raw]
Subject: [PATCH BlueZ 2/2] client: Fix indent

---
client/main.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/client/main.c b/client/main.c
index d487eaf..68e7635 100644
--- a/client/main.c
+++ b/client/main.c
@@ -2192,7 +2192,7 @@ static char *generic_generator(const char *text, int state,

if (!strncasecmp(str, text, len))
return strdup(str);
- }
+ }

return NULL;
}
--
2.7.4