mirror of
https://github.com/sheumann/hush.git
synced 2024-12-27 16:31:24 +00:00
Warning cleanup from Gennady Feldman
-Erik
This commit is contained in:
parent
ef936da7c5
commit
a75466e981
19
cmdedit.c
19
cmdedit.c
@ -283,12 +283,12 @@ char** exe_n_cwd_tab_completion(char* command, int *num_matches)
|
|||||||
return (matches);
|
return (matches);
|
||||||
}
|
}
|
||||||
|
|
||||||
void input_tab(char* command, char* prompt, int outputFd, int *cursor, int *len)
|
void input_tab(char* command, char* prompt, int outputFd, int *cursor, int *len, int lastWasTab)
|
||||||
{
|
{
|
||||||
/* Do TAB completion */
|
/* Do TAB completion */
|
||||||
static int num_matches=0;
|
static int num_matches=0;
|
||||||
static char **matches = (char **) NULL;
|
static char **matches = (char **) NULL;
|
||||||
int pos = cursor;
|
int pos = *cursor;
|
||||||
|
|
||||||
|
|
||||||
if (lastWasTab == FALSE) {
|
if (lastWasTab == FALSE) {
|
||||||
@ -303,7 +303,7 @@ void input_tab(char* command, char* prompt, int outputFd, int *cursor, int *len)
|
|||||||
/* Make a local copy of the string -- up
|
/* Make a local copy of the string -- up
|
||||||
* to the position of the cursor */
|
* to the position of the cursor */
|
||||||
matchBuf = (char *) xcalloc(BUFSIZ, sizeof(char));
|
matchBuf = (char *) xcalloc(BUFSIZ, sizeof(char));
|
||||||
strncpy(matchBuf, command, cursor);
|
strncpy(matchBuf, command, *cursor);
|
||||||
tmp=matchBuf;
|
tmp=matchBuf;
|
||||||
|
|
||||||
/* skip past any command seperator tokens */
|
/* skip past any command seperator tokens */
|
||||||
@ -343,10 +343,10 @@ void input_tab(char* command, char* prompt, int outputFd, int *cursor, int *len)
|
|||||||
if (matches && num_matches==1) {
|
if (matches && num_matches==1) {
|
||||||
/* write out the matched command */
|
/* write out the matched command */
|
||||||
strncpy(command+pos, matches[0]+pos, strlen(matches[0])-pos);
|
strncpy(command+pos, matches[0]+pos, strlen(matches[0])-pos);
|
||||||
len=strlen(command);
|
*len=strlen(command);
|
||||||
cursor=len;
|
*cursor=*len;
|
||||||
xwrite(outputFd, matches[0]+pos, strlen(matches[0])-pos);
|
xwrite(outputFd, matches[0]+pos, strlen(matches[0])-pos);
|
||||||
break;
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/* Ok -- the last char was a TAB. Since they
|
/* Ok -- the last char was a TAB. Since they
|
||||||
@ -372,9 +372,9 @@ void input_tab(char* command, char* prompt, int outputFd, int *cursor, int *len)
|
|||||||
/* Rewrite the prompt */
|
/* Rewrite the prompt */
|
||||||
xwrite(outputFd, prompt, strlen(prompt));
|
xwrite(outputFd, prompt, strlen(prompt));
|
||||||
/* Rewrite the command */
|
/* Rewrite the command */
|
||||||
xwrite(outputFd, command, len);
|
xwrite(outputFd, command, *len);
|
||||||
/* Put the cursor back to where it used to be */
|
/* Put the cursor back to where it used to be */
|
||||||
for (cursor=len; cursor > pos; cursor--)
|
for (cursor=len; *cursor > pos; cursor--)
|
||||||
xwrite(outputFd, "\b", 1);
|
xwrite(outputFd, "\b", 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -505,7 +505,8 @@ extern void cmdedit_read_input(char* prompt, char command[BUFSIZ])
|
|||||||
break;
|
break;
|
||||||
case '\t':
|
case '\t':
|
||||||
#ifdef BB_FEATURE_SH_TAB_COMPLETION
|
#ifdef BB_FEATURE_SH_TAB_COMPLETION
|
||||||
input_tab(command, prompt, outputFd, &cursor, &len);
|
input_tab(command, prompt, outputFd, &cursor,
|
||||||
|
&len, lastWasTab);
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
case 14:
|
case 14:
|
||||||
|
@ -283,12 +283,12 @@ char** exe_n_cwd_tab_completion(char* command, int *num_matches)
|
|||||||
return (matches);
|
return (matches);
|
||||||
}
|
}
|
||||||
|
|
||||||
void input_tab(char* command, char* prompt, int outputFd, int *cursor, int *len)
|
void input_tab(char* command, char* prompt, int outputFd, int *cursor, int *len, int lastWasTab)
|
||||||
{
|
{
|
||||||
/* Do TAB completion */
|
/* Do TAB completion */
|
||||||
static int num_matches=0;
|
static int num_matches=0;
|
||||||
static char **matches = (char **) NULL;
|
static char **matches = (char **) NULL;
|
||||||
int pos = cursor;
|
int pos = *cursor;
|
||||||
|
|
||||||
|
|
||||||
if (lastWasTab == FALSE) {
|
if (lastWasTab == FALSE) {
|
||||||
@ -303,7 +303,7 @@ void input_tab(char* command, char* prompt, int outputFd, int *cursor, int *len)
|
|||||||
/* Make a local copy of the string -- up
|
/* Make a local copy of the string -- up
|
||||||
* to the position of the cursor */
|
* to the position of the cursor */
|
||||||
matchBuf = (char *) xcalloc(BUFSIZ, sizeof(char));
|
matchBuf = (char *) xcalloc(BUFSIZ, sizeof(char));
|
||||||
strncpy(matchBuf, command, cursor);
|
strncpy(matchBuf, command, *cursor);
|
||||||
tmp=matchBuf;
|
tmp=matchBuf;
|
||||||
|
|
||||||
/* skip past any command seperator tokens */
|
/* skip past any command seperator tokens */
|
||||||
@ -343,10 +343,10 @@ void input_tab(char* command, char* prompt, int outputFd, int *cursor, int *len)
|
|||||||
if (matches && num_matches==1) {
|
if (matches && num_matches==1) {
|
||||||
/* write out the matched command */
|
/* write out the matched command */
|
||||||
strncpy(command+pos, matches[0]+pos, strlen(matches[0])-pos);
|
strncpy(command+pos, matches[0]+pos, strlen(matches[0])-pos);
|
||||||
len=strlen(command);
|
*len=strlen(command);
|
||||||
cursor=len;
|
*cursor=*len;
|
||||||
xwrite(outputFd, matches[0]+pos, strlen(matches[0])-pos);
|
xwrite(outputFd, matches[0]+pos, strlen(matches[0])-pos);
|
||||||
break;
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/* Ok -- the last char was a TAB. Since they
|
/* Ok -- the last char was a TAB. Since they
|
||||||
@ -372,9 +372,9 @@ void input_tab(char* command, char* prompt, int outputFd, int *cursor, int *len)
|
|||||||
/* Rewrite the prompt */
|
/* Rewrite the prompt */
|
||||||
xwrite(outputFd, prompt, strlen(prompt));
|
xwrite(outputFd, prompt, strlen(prompt));
|
||||||
/* Rewrite the command */
|
/* Rewrite the command */
|
||||||
xwrite(outputFd, command, len);
|
xwrite(outputFd, command, *len);
|
||||||
/* Put the cursor back to where it used to be */
|
/* Put the cursor back to where it used to be */
|
||||||
for (cursor=len; cursor > pos; cursor--)
|
for (cursor=len; *cursor > pos; cursor--)
|
||||||
xwrite(outputFd, "\b", 1);
|
xwrite(outputFd, "\b", 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -505,7 +505,8 @@ extern void cmdedit_read_input(char* prompt, char command[BUFSIZ])
|
|||||||
break;
|
break;
|
||||||
case '\t':
|
case '\t':
|
||||||
#ifdef BB_FEATURE_SH_TAB_COMPLETION
|
#ifdef BB_FEATURE_SH_TAB_COMPLETION
|
||||||
input_tab(command, prompt, outputFd, &cursor, &len);
|
input_tab(command, prompt, outputFd, &cursor,
|
||||||
|
&len, lastWasTab);
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
case 14:
|
case 14:
|
||||||
|
Loading…
Reference in New Issue
Block a user