Re: [PATCH 4/4] client: Use bt_shell_completion

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

 



Hi Luiz,

On 22 September 2017 at 03:47, Luiz Augusto von Dentz
<luiz.dentz@xxxxxxxxx> wrote:
> Hi Marcin,
>
> On Fri, Sep 22, 2017 at 8:00 AM, Marcin Kraglak
> <marcin.kraglak@xxxxxxxxx> wrote:
>> ---
>>  client/main.c | 49 +------------------------------------------------
>>  1 file changed, 1 insertion(+), 48 deletions(-)
>>
>> diff --git a/client/main.c b/client/main.c
>> index 87019b463..86514f67e 100644
>> --- a/client/main.c
>> +++ b/client/main.c
>> @@ -2564,61 +2564,14 @@ static const struct bt_shell_menu_entry cmd_table[] = {
>>         { }
>>  };
>>
>> -static char *cmd_generator(const char *text, int state)
>> -{
>> -       static int index, len;
>> -       const char *cmd;
>> -
>> -       if (!state) {
>> -               index = 0;
>> -               len = strlen(text);
>> -       }
>> -
>> -       while ((cmd = cmd_table[index].cmd)) {
>> -               index++;
>> -
>> -               if (!strncmp(cmd, text, len))
>> -                       return strdup(cmd);
>> -       }
>> -
>> -       return NULL;
>> -}
>> -
>>  static char **cmd_completion(const char *text, int start, int end)
>>  {
>> -       char **matches = NULL;
>> -
>>         if (agent_completion() == TRUE) {
>>                 rl_attempted_completion_over = 1;
>>                 return NULL;
>>         }
>>
>> -       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 (strcmp(cmd_table[i].cmd, input_cmd))
>> -                               continue;
>> -
>> -                       if (!cmd_table[i].gen)
>> -                               continue;
>> -
>> -                       rl_completion_display_matches_hook = cmd_table[i].disp;
>> -                       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);
>> -       }
>> -
>> -       if (!matches)
>> -               rl_attempted_completion_over = 1;
>> -
>> -       return matches;
>> +       return bt_shell_completion(text, start, end);
>>  }
>
> While this is great as we reuse more code I think we better move the
> whole input handling into the bt_shell so the application don't even
> need to call bt_shell_completion, etc.
>
> --
> Luiz Augusto von Dentz

You mean bt_shell should set rl_attempted_completion_function in
bt_shell_init() (then bt_shell_completion is not exposed)?



-- 
BR
Marcin Kraglak
--
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