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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux