Autocomplete fix
PATCH 1/1 Autocomplete fix
Autocomplete fixed: now working also to autocomplete file names as first argument.
i.e.:
# ./en<TAB> completes to # ./env/
--- common/complete.c | 13 +++++++++---- 1 files changed, 9 insertions(+), 4 deletions(-)
common/complete.c +9 -4
@@ -71,6 +71,7 @@ static int command_complete(struct string_list *sl, char *instr) {struct command *cmdtp;char cmd[128 ]; +int found =0 ;for_each_command (cmdtp) {if (!strncmp (instr, cmdtp->name,strlen (instr))) {
@@ -78,10 +79,11 @@ static int command_complete(struct string_list *sl, char *instr) cmd[strlen (cmdtp->name)] =' ' ; cmd[strlen (cmdtp->name) +1 ] =0 ;string_list_add (sl, cmd); + found =1 ; } } -return 0 ; +return (found); }static int tab_pressed =0 ;
@@ -116,13 +118,16 @@ int complete(char *instr, char **outstr) instr = t; -/* get the completion possibilities */ if ((t =strrchr (t,' ' ))) { t++;file_complete (&sl, t); instr = t; - }else -command_complete (&sl, instr); + }else { +if (!command_complete (&sl, instr)){ +file_complete (&sl, instr); + } + } + pos =strlen (instr);
Signature · 6 lines
1.7.6.1 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Hello Carlo,
You have trailing whitespaces in your patch, also your mailer wraps lines. Please fix this before resending.
Quoted 26 lines · Carlo Caione
Autocomplete fixed: now working also to autocomplete file names as first argument.
i.e.:
# ./en<TAB> completes to # ./env/
Signed-off-by Carlo Caione <[email protected]>--- common/complete.c | 13 +++++++++---- 1 files changed, 9 insertions(+), 4 deletions(-)common/complete.c +1
-0@@ -71,6 +71,7 @@ static int command_complete(struct string_list *sl, char *instr) {struct command *cmdtp;char cmd[128 ]; +int found =0 ;for_each_command (cmdtp) {common/complete.c +0
-0if (!strncmp (instr, cmdtp->name,strlen (instr))) {
common/complete.c static int command_complete(struct string_list · line 87
Quoted 10 lines
common/complete.c +2
-1@@ -78,10 +79,11 @@ static int command_complete(struct string_list *sl, char *instr) cmd[strlen (cmdtp->name)] =' ' ; cmd[strlen (cmdtp->name) +1 ] =0 ;string_list_add (sl, cmd); + found =1 ; } } -return 0 ; +return (found);
No () with return please.
Quoted 8 lines
common/complete.c +0
-0}static int
tab_pressed= 0;common/complete.c +0
-1@@ -116,13 +118,16 @@ int complete(char *instr, char **outstr) instr = t; -/* get the completion possibilities */
common/complete.c int complete(char *instr, char **outstr) · line 128
Quoted 10 lines
common/complete.c +4
-2if ((t =strrchr (t,' ' ))) { t++;file_complete (&sl, t); instr = t; - }else -command_complete (&sl, instr); + }else { +if (!command_complete (&sl, instr)){ +file_complete (&sl, instr); + }
This will only show the file completion when no suitable command is found which is a bit strange behaviour. Normally I would expect to see all possibilities. This can easily be archieved by calling both command_complete() and file_complete() unconditionally.
Sascha
Signature · 9 lines
Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox