aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRon Yorston <rmy@frippery.org>2015-05-29 11:31:40 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2015-10-30 19:49:33 +0100
commitf23264b35f5bb138c6c3676079251e71bee42c8a (patch)
treee6cba0f51f2db6460f81003e98c4a7107145ace8
parentae57af6e78ed7179b2b12675ad86adc4e8d5bebd (diff)
downloadbusybox-w32-f23264b35f5bb138c6c3676079251e71bee42c8a.tar.gz
busybox-w32-f23264b35f5bb138c6c3676079251e71bee42c8a.tar.bz2
busybox-w32-f23264b35f5bb138c6c3676079251e71bee42c8a.zip
lineedit: search applets as well as PATH for tab completion
In standalone shell mode search the applet table as well as PATH when tab completing a command. Use a stupid linear search: we're also about to read all the directories on PATH so efficiency isn't a big concern. function old new delta add_match - 53 +53 complete_cmd_dir_file 687 724 +37 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 1/0 up/down: 90/0) Total: 90 bytes Signed-off-by: Ron Yorston <rmy@frippery.org> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--libbb/lineedit.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/libbb/lineedit.c b/libbb/lineedit.c
index a83e07c0c..2ddb2b6e9 100644
--- a/libbb/lineedit.c
+++ b/libbb/lineedit.c
@@ -47,7 +47,8 @@
47 * It stems from simplistic "cmdedit_y = cmdedit_prmt_len / cmdedit_termw" 47 * It stems from simplistic "cmdedit_y = cmdedit_prmt_len / cmdedit_termw"
48 * calculation of how many lines the prompt takes. 48 * calculation of how many lines the prompt takes.
49 */ 49 */
50#include "libbb.h" 50#include "busybox.h"
51#include "NUM_APPLETS.h"
51#include "unicode.h" 52#include "unicode.h"
52#ifndef _POSIX_VDISABLE 53#ifndef _POSIX_VDISABLE
53# define _POSIX_VDISABLE '\0' 54# define _POSIX_VDISABLE '\0'
@@ -774,6 +775,20 @@ static NOINLINE unsigned complete_cmd_dir_file(const char *command, int type)
774 } 775 }
775 pf_len = strlen(pfind); 776 pf_len = strlen(pfind);
776 777
778#if ENABLE_FEATURE_SH_STANDALONE && NUM_APPLETS != 1
779 if (type == FIND_EXE_ONLY) {
780 const char *p = applet_names;
781
782 i = 0;
783 while (i < NUM_APPLETS) {
784 if (strncmp(pfind, p, pf_len) == 0)
785 add_match(xstrdup(p));
786 p += strlen(p) + 1;
787 i++;
788 }
789 }
790#endif
791
777 for (i = 0; i < npaths; i++) { 792 for (i = 0; i < npaths; i++) {
778 DIR *dir; 793 DIR *dir;
779 struct dirent *next; 794 struct dirent *next;