[BusyBox] cmdedit.c in CVS
Gennady Feldman
gfeldman at tradeline.net
Thu Nov 2 16:47:14 UTC 2000
Hello Erik.
I am going to try to take a stab at it. I already got it to compile and removed
the warning messages.
I also found a couple of issues while playing/testing the command line completion:
1. If you hit TAB twice in a row right at the prompt (empty command string) it
hangs. I am trying to figure this out and the patch will need to update >1
function.
2. In certain cases it does a segmentation fault when doing command line
completion.
On a different note, while looking through the TinyLogin Makefile I found no
references to uC-libc. I am just curious if Tiny-Login works w/ the new Libc
Library?
P.S. I am attaching a small patch to cleanup the warnings.
G.F.
Erik Andersen wrote:
> If you read the comments in Config.h, you will see:
>
> // Enable tab completion in the shell (not yet
> // working very well -- so don't turn this on)
> //#define BB_FEATURE_SH_TAB_COMPLETION
>
> The part about "don't turn this on" is very serious -- Don't turn on
> BB_FEATURE_SH_TAB_COMPLETION unless you have the time, interest, and ability to
> fix it, since it does not work. If you do want to take a stab a fixing it,
> that would be great -- I've been otherwise occupied and have not needed this
> for my embedded work, so I never finished it.
>
> That said, if you turn off BB_FEATURE_SH_TAB_COMPLETION, it should work
> as a very minimal shell.
>
> -Erik
>
-------------- next part --------------
*** cmdedit.c_orig Mon Oct 30 16:30:57 2000
--- cmdedit.c Tue Oct 31 14:09:49 2000
***************
*** 283,294 ****
return (matches);
}
! void input_tab(char* command, char* prompt, int outputFd, int *cursor, int *len)
{
/* Do TAB completion */
static int num_matches=0;
static char **matches = (char **) NULL;
! int pos = cursor;
if (lastWasTab == FALSE) {
--- 283,294 ----
return (matches);
}
! void input_tab(char* command, char* prompt, int outputFd, int *cursor, int *len, int lastWasTab)
{
/* Do TAB completion */
static int num_matches=0;
static char **matches = (char **) NULL;
! int pos = *cursor;
if (lastWasTab == FALSE) {
***************
*** 303,309 ****
/* Make a local copy of the string -- up
* to the position of the cursor */
matchBuf = (char *) xcalloc(BUFSIZ, sizeof(char));
! strncpy(matchBuf, command, cursor);
tmp=matchBuf;
/* skip past any command seperator tokens */
--- 303,309 ----
/* Make a local copy of the string -- up
* to the position of the cursor */
matchBuf = (char *) xcalloc(BUFSIZ, sizeof(char));
! strncpy(matchBuf, command, *cursor);
tmp=matchBuf;
/* skip past any command seperator tokens */
***************
*** 343,352 ****
if (matches && num_matches==1) {
/* write out the matched command */
strncpy(command+pos, matches[0]+pos, strlen(matches[0])-pos);
! len=strlen(command);
! cursor=len;
xwrite(outputFd, matches[0]+pos, strlen(matches[0])-pos);
! break;
}
} else {
/* Ok -- the last char was a TAB. Since they
--- 343,352 ----
if (matches && num_matches==1) {
/* write out the matched command */
strncpy(command+pos, matches[0]+pos, strlen(matches[0])-pos);
! *len=strlen(command);
! *cursor=*len;
xwrite(outputFd, matches[0]+pos, strlen(matches[0])-pos);
! return;
}
} else {
/* Ok -- the last char was a TAB. Since they
***************
*** 372,380 ****
/* Rewrite the prompt */
xwrite(outputFd, prompt, strlen(prompt));
/* Rewrite the command */
! xwrite(outputFd, command, len);
/* Put the cursor back to where it used to be */
! for (cursor=len; cursor > pos; cursor--)
xwrite(outputFd, "\b", 1);
}
}
--- 372,380 ----
/* Rewrite the prompt */
xwrite(outputFd, prompt, strlen(prompt));
/* Rewrite the command */
! xwrite(outputFd, command, *len);
/* Put the cursor back to where it used to be */
! for (cursor=len; *cursor > pos; cursor--)
xwrite(outputFd, "\b", 1);
}
}
***************
*** 505,511 ****
break;
case '\t':
#ifdef BB_FEATURE_SH_TAB_COMPLETION
! input_tab(command, prompt, outputFd, &cursor, &len);
#endif
break;
case 14:
--- 505,512 ----
break;
case '\t':
#ifdef BB_FEATURE_SH_TAB_COMPLETION
! input_tab(command, prompt, outputFd, &cursor,
! &len, lastWasTab);
#endif
break;
case 14:
More information about the busybox
mailing list