aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2000-11-02 17:02:26 +0000
committerEric Andersen <andersen@codepoet.org>2000-11-02 17:02:26 +0000
commita75466e9819a7172ba48b06958a868022f4510a9 (patch)
tree23cd76a71ae5d5a07900eec39e1869e060a034f6
parentef936da7c5608c8cae553216f8661764247c2819 (diff)
downloadbusybox-w32-a75466e9819a7172ba48b06958a868022f4510a9.tar.gz
busybox-w32-a75466e9819a7172ba48b06958a868022f4510a9.tar.bz2
busybox-w32-a75466e9819a7172ba48b06958a868022f4510a9.zip
Warning cleanup from Gennady Feldman
-Erik
-rw-r--r--cmdedit.c19
-rw-r--r--shell/cmdedit.c19
2 files changed, 20 insertions, 18 deletions
diff --git a/cmdedit.c b/cmdedit.c
index af29b059a..a59aeebb7 100644
--- a/cmdedit.c
+++ b/cmdedit.c
@@ -283,12 +283,12 @@ char** exe_n_cwd_tab_completion(char* command, int *num_matches)
283 return (matches); 283 return (matches);
284} 284}
285 285
286void input_tab(char* command, char* prompt, int outputFd, int *cursor, int *len) 286void input_tab(char* command, char* prompt, int outputFd, int *cursor, int *len, int lastWasTab)
287{ 287{
288 /* Do TAB completion */ 288 /* Do TAB completion */
289 static int num_matches=0; 289 static int num_matches=0;
290 static char **matches = (char **) NULL; 290 static char **matches = (char **) NULL;
291 int pos = cursor; 291 int pos = *cursor;
292 292
293 293
294 if (lastWasTab == FALSE) { 294 if (lastWasTab == FALSE) {
@@ -303,7 +303,7 @@ void input_tab(char* command, char* prompt, int outputFd, int *cursor, int *len)
303 /* Make a local copy of the string -- up 303 /* Make a local copy of the string -- up
304 * to the position of the cursor */ 304 * to the position of the cursor */
305 matchBuf = (char *) xcalloc(BUFSIZ, sizeof(char)); 305 matchBuf = (char *) xcalloc(BUFSIZ, sizeof(char));
306 strncpy(matchBuf, command, cursor); 306 strncpy(matchBuf, command, *cursor);
307 tmp=matchBuf; 307 tmp=matchBuf;
308 308
309 /* skip past any command seperator tokens */ 309 /* skip past any command seperator tokens */
@@ -343,10 +343,10 @@ void input_tab(char* command, char* prompt, int outputFd, int *cursor, int *len)
343 if (matches && num_matches==1) { 343 if (matches && num_matches==1) {
344 /* write out the matched command */ 344 /* write out the matched command */
345 strncpy(command+pos, matches[0]+pos, strlen(matches[0])-pos); 345 strncpy(command+pos, matches[0]+pos, strlen(matches[0])-pos);
346 len=strlen(command); 346 *len=strlen(command);
347 cursor=len; 347 *cursor=*len;
348 xwrite(outputFd, matches[0]+pos, strlen(matches[0])-pos); 348 xwrite(outputFd, matches[0]+pos, strlen(matches[0])-pos);
349 break; 349 return;
350 } 350 }
351 } else { 351 } else {
352 /* Ok -- the last char was a TAB. Since they 352 /* 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)
372 /* Rewrite the prompt */ 372 /* Rewrite the prompt */
373 xwrite(outputFd, prompt, strlen(prompt)); 373 xwrite(outputFd, prompt, strlen(prompt));
374 /* Rewrite the command */ 374 /* Rewrite the command */
375 xwrite(outputFd, command, len); 375 xwrite(outputFd, command, *len);
376 /* Put the cursor back to where it used to be */ 376 /* Put the cursor back to where it used to be */
377 for (cursor=len; cursor > pos; cursor--) 377 for (cursor=len; *cursor > pos; cursor--)
378 xwrite(outputFd, "\b", 1); 378 xwrite(outputFd, "\b", 1);
379 } 379 }
380 } 380 }
@@ -505,7 +505,8 @@ extern void cmdedit_read_input(char* prompt, char command[BUFSIZ])
505 break; 505 break;
506 case '\t': 506 case '\t':
507#ifdef BB_FEATURE_SH_TAB_COMPLETION 507#ifdef BB_FEATURE_SH_TAB_COMPLETION
508 input_tab(command, prompt, outputFd, &cursor, &len); 508 input_tab(command, prompt, outputFd, &cursor,
509&len, lastWasTab);
509#endif 510#endif
510 break; 511 break;
511 case 14: 512 case 14:
diff --git a/shell/cmdedit.c b/shell/cmdedit.c
index af29b059a..a59aeebb7 100644
--- a/shell/cmdedit.c
+++ b/shell/cmdedit.c
@@ -283,12 +283,12 @@ char** exe_n_cwd_tab_completion(char* command, int *num_matches)
283 return (matches); 283 return (matches);
284} 284}
285 285
286void input_tab(char* command, char* prompt, int outputFd, int *cursor, int *len) 286void input_tab(char* command, char* prompt, int outputFd, int *cursor, int *len, int lastWasTab)
287{ 287{
288 /* Do TAB completion */ 288 /* Do TAB completion */
289 static int num_matches=0; 289 static int num_matches=0;
290 static char **matches = (char **) NULL; 290 static char **matches = (char **) NULL;
291 int pos = cursor; 291 int pos = *cursor;
292 292
293 293
294 if (lastWasTab == FALSE) { 294 if (lastWasTab == FALSE) {
@@ -303,7 +303,7 @@ void input_tab(char* command, char* prompt, int outputFd, int *cursor, int *len)
303 /* Make a local copy of the string -- up 303 /* Make a local copy of the string -- up
304 * to the position of the cursor */ 304 * to the position of the cursor */
305 matchBuf = (char *) xcalloc(BUFSIZ, sizeof(char)); 305 matchBuf = (char *) xcalloc(BUFSIZ, sizeof(char));
306 strncpy(matchBuf, command, cursor); 306 strncpy(matchBuf, command, *cursor);
307 tmp=matchBuf; 307 tmp=matchBuf;
308 308
309 /* skip past any command seperator tokens */ 309 /* skip past any command seperator tokens */
@@ -343,10 +343,10 @@ void input_tab(char* command, char* prompt, int outputFd, int *cursor, int *len)
343 if (matches && num_matches==1) { 343 if (matches && num_matches==1) {
344 /* write out the matched command */ 344 /* write out the matched command */
345 strncpy(command+pos, matches[0]+pos, strlen(matches[0])-pos); 345 strncpy(command+pos, matches[0]+pos, strlen(matches[0])-pos);
346 len=strlen(command); 346 *len=strlen(command);
347 cursor=len; 347 *cursor=*len;
348 xwrite(outputFd, matches[0]+pos, strlen(matches[0])-pos); 348 xwrite(outputFd, matches[0]+pos, strlen(matches[0])-pos);
349 break; 349 return;
350 } 350 }
351 } else { 351 } else {
352 /* Ok -- the last char was a TAB. Since they 352 /* 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)
372 /* Rewrite the prompt */ 372 /* Rewrite the prompt */
373 xwrite(outputFd, prompt, strlen(prompt)); 373 xwrite(outputFd, prompt, strlen(prompt));
374 /* Rewrite the command */ 374 /* Rewrite the command */
375 xwrite(outputFd, command, len); 375 xwrite(outputFd, command, *len);
376 /* Put the cursor back to where it used to be */ 376 /* Put the cursor back to where it used to be */
377 for (cursor=len; cursor > pos; cursor--) 377 for (cursor=len; *cursor > pos; cursor--)
378 xwrite(outputFd, "\b", 1); 378 xwrite(outputFd, "\b", 1);
379 } 379 }
380 } 380 }
@@ -505,7 +505,8 @@ extern void cmdedit_read_input(char* prompt, char command[BUFSIZ])
505 break; 505 break;
506 case '\t': 506 case '\t':
507#ifdef BB_FEATURE_SH_TAB_COMPLETION 507#ifdef BB_FEATURE_SH_TAB_COMPLETION
508 input_tab(command, prompt, outputFd, &cursor, &len); 508 input_tab(command, prompt, outputFd, &cursor,
509&len, lastWasTab);
509#endif 510#endif
510 break; 511 break;
511 case 14: 512 case 14: