diff options
| author | Denis Vlasenko <vda.linux@googlemail.com> | 2007-01-22 08:34:44 +0000 |
|---|---|---|
| committer | Denis Vlasenko <vda.linux@googlemail.com> | 2007-01-22 08:34:44 +0000 |
| commit | 253ce0029669919fbb7cf60b5c9eab2f791939d8 (patch) | |
| tree | 6eac5537d290bb529c26eddf7fe594ce4ed54c37 /shell | |
| parent | b01b4e2a1f16d7e5ff8369195421dd80047d55eb (diff) | |
| download | busybox-w32-253ce0029669919fbb7cf60b5c9eab2f791939d8.tar.gz busybox-w32-253ce0029669919fbb7cf60b5c9eab2f791939d8.tar.bz2 busybox-w32-253ce0029669919fbb7cf60b5c9eab2f791939d8.zip | |
cmdedit: fix breakage
Diffstat (limited to 'shell')
| -rw-r--r-- | shell/cmdedit.c | 47 |
1 files changed, 23 insertions, 24 deletions
diff --git a/shell/cmdedit.c b/shell/cmdedit.c index b0a5de7ac..7588922a6 100644 --- a/shell/cmdedit.c +++ b/shell/cmdedit.c | |||
| @@ -255,9 +255,9 @@ static void put(void) | |||
| 255 | return; | 255 | return; |
| 256 | ocursor = cursor; | 256 | ocursor = cursor; |
| 257 | /* open hole and then fill it */ | 257 | /* open hole and then fill it */ |
| 258 | memmove(command_ps + cursor + j, command_ps + cursor, len - cursor + 1); | 258 | memmove(command_ps + cursor + j, command_ps + cursor, command_len - cursor + 1); |
| 259 | strncpy(command_ps + cursor, delbuf, j); | 259 | strncpy(command_ps + cursor, delbuf, j); |
| 260 | len += j; | 260 | command_len += j; |
| 261 | input_end(); /* rewrite new line */ | 261 | input_end(); /* rewrite new line */ |
| 262 | input_backward(cursor - ocursor - j + 1); /* at end of new text */ | 262 | input_backward(cursor - ocursor - j + 1); /* at end of new text */ |
| 263 | } | 263 | } |
| @@ -365,8 +365,8 @@ enum { | |||
| 365 | static int path_parse(char ***p, int flags) | 365 | static int path_parse(char ***p, int flags) |
| 366 | { | 366 | { |
| 367 | int npth; | 367 | int npth; |
| 368 | const char *tmp; | ||
| 369 | const char *pth; | 368 | const char *pth; |
| 369 | char *tmp; | ||
| 370 | char **res; | 370 | char **res; |
| 371 | 371 | ||
| 372 | /* if not setenv PATH variable, to search cur dir "." */ | 372 | /* if not setenv PATH variable, to search cur dir "." */ |
| @@ -381,7 +381,7 @@ static int path_parse(char ***p, int flags) | |||
| 381 | if (!pth || !pth[0] || LONE_CHAR(pth, ':')) | 381 | if (!pth || !pth[0] || LONE_CHAR(pth, ':')) |
| 382 | return 1; | 382 | return 1; |
| 383 | 383 | ||
| 384 | tmp = pth; | 384 | tmp = (char*)pth; |
| 385 | npth = 1; /* path component count */ | 385 | npth = 1; /* path component count */ |
| 386 | while (1) { | 386 | while (1) { |
| 387 | tmp = strchr(tmp, ':'); | 387 | tmp = strchr(tmp, ':'); |
| @@ -393,8 +393,7 @@ static int path_parse(char ***p, int flags) | |||
| 393 | } | 393 | } |
| 394 | 394 | ||
| 395 | res = xmalloc(npth * sizeof(char*)); | 395 | res = xmalloc(npth * sizeof(char*)); |
| 396 | res[0] = xstrdup(pth); | 396 | res[0] = tmp = xstrdup(pth); |
| 397 | tmp = pth; | ||
| 398 | npth = 1; | 397 | npth = 1; |
| 399 | while (1) { | 398 | while (1) { |
| 400 | tmp = strchr(tmp, ':'); | 399 | tmp = strchr(tmp, ':'); |
| @@ -810,7 +809,7 @@ static void input_tab(int *lastWasTab) | |||
| 810 | } | 809 | } |
| 811 | len_found = strlen(tmp); | 810 | len_found = strlen(tmp); |
| 812 | /* have space to placed match? */ | 811 | /* have space to placed match? */ |
| 813 | if ((len_found - strlen(matchBuf) + len) < BUFSIZ) { | 812 | if ((len_found - strlen(matchBuf) + command_len) < BUFSIZ) { |
| 814 | /* before word for match */ | 813 | /* before word for match */ |
| 815 | command_ps[cursor - recalc_pos] = 0; | 814 | command_ps[cursor - recalc_pos] = 0; |
| 816 | /* save tail line */ | 815 | /* save tail line */ |
| @@ -824,9 +823,9 @@ static void input_tab(int *lastWasTab) | |||
| 824 | /* new pos */ | 823 | /* new pos */ |
| 825 | recalc_pos = cursor + len_found; | 824 | recalc_pos = cursor + len_found; |
| 826 | /* new len */ | 825 | /* new len */ |
| 827 | len = strlen(command_ps); | 826 | command_len = strlen(command_ps); |
| 828 | /* write out the matched command */ | 827 | /* write out the matched command */ |
| 829 | redraw(cmdedit_y, len - recalc_pos); | 828 | redraw(cmdedit_y, command_len - recalc_pos); |
| 830 | } | 829 | } |
| 831 | free(tmp); | 830 | free(tmp); |
| 832 | } else { | 831 | } else { |
| @@ -839,7 +838,7 @@ static void input_tab(int *lastWasTab) | |||
| 839 | /* Go to the next line */ | 838 | /* Go to the next line */ |
| 840 | goto_new_line(); | 839 | goto_new_line(); |
| 841 | showfiles(); | 840 | showfiles(); |
| 842 | redraw(0, len - sav_cursor); | 841 | redraw(0, command_len - sav_cursor); |
| 843 | } | 842 | } |
| 844 | } | 843 | } |
| 845 | } | 844 | } |
| @@ -982,9 +981,9 @@ static void remember_in_history(const char *str) | |||
| 982 | static void | 981 | static void |
| 983 | vi_Word_motion(char *command, int eat) | 982 | vi_Word_motion(char *command, int eat) |
| 984 | { | 983 | { |
| 985 | while (cursor < len && !isspace(command[cursor])) | 984 | while (cursor < command_len && !isspace(command[cursor])) |
| 986 | input_forward(); | 985 | input_forward(); |
| 987 | if (eat) while (cursor < len && isspace(command[cursor])) | 986 | if (eat) while (cursor < command_len && isspace(command[cursor])) |
| 988 | input_forward(); | 987 | input_forward(); |
| 989 | } | 988 | } |
| 990 | 989 | ||
| @@ -992,19 +991,19 @@ static void | |||
| 992 | vi_word_motion(char *command, int eat) | 991 | vi_word_motion(char *command, int eat) |
| 993 | { | 992 | { |
| 994 | if (isalnum(command[cursor]) || command[cursor] == '_') { | 993 | if (isalnum(command[cursor]) || command[cursor] == '_') { |
| 995 | while (cursor < len | 994 | while (cursor < command_len |
| 996 | && (isalnum(command[cursor+1]) || command[cursor+1] == '_')) | 995 | && (isalnum(command[cursor+1]) || command[cursor+1] == '_')) |
| 997 | input_forward(); | 996 | input_forward(); |
| 998 | } else if (ispunct(command[cursor])) { | 997 | } else if (ispunct(command[cursor])) { |
| 999 | while (cursor < len && ispunct(command[cursor+1])) | 998 | while (cursor < command_len && ispunct(command[cursor+1])) |
| 1000 | input_forward(); | 999 | input_forward(); |
| 1001 | } | 1000 | } |
| 1002 | 1001 | ||
| 1003 | if (cursor < len) | 1002 | if (cursor < command_len) |
| 1004 | input_forward(); | 1003 | input_forward(); |
| 1005 | 1004 | ||
| 1006 | if (eat && cursor < len && isspace(command[cursor])) | 1005 | if (eat && cursor < command_len && isspace(command[cursor])) |
| 1007 | while (cursor < len && isspace(command[cursor])) | 1006 | while (cursor < command_len && isspace(command[cursor])) |
| 1008 | input_forward(); | 1007 | input_forward(); |
| 1009 | } | 1008 | } |
| 1010 | 1009 | ||
| @@ -1012,30 +1011,30 @@ static void | |||
| 1012 | vi_End_motion(char *command) | 1011 | vi_End_motion(char *command) |
| 1013 | { | 1012 | { |
| 1014 | input_forward(); | 1013 | input_forward(); |
| 1015 | while (cursor < len && isspace(command[cursor])) | 1014 | while (cursor < command_len && isspace(command[cursor])) |
| 1016 | input_forward(); | 1015 | input_forward(); |
| 1017 | while (cursor < len-1 && !isspace(command[cursor+1])) | 1016 | while (cursor < command_len-1 && !isspace(command[cursor+1])) |
| 1018 | input_forward(); | 1017 | input_forward(); |
| 1019 | } | 1018 | } |
| 1020 | 1019 | ||
| 1021 | static void | 1020 | static void |
| 1022 | vi_end_motion(char *command) | 1021 | vi_end_motion(char *command) |
| 1023 | { | 1022 | { |
| 1024 | if (cursor >= len-1) | 1023 | if (cursor >= command_len-1) |
| 1025 | return; | 1024 | return; |
| 1026 | input_forward(); | 1025 | input_forward(); |
| 1027 | while (cursor < len-1 && isspace(command[cursor])) | 1026 | while (cursor < command_len-1 && isspace(command[cursor])) |
| 1028 | input_forward(); | 1027 | input_forward(); |
| 1029 | if (cursor >= len-1) | 1028 | if (cursor >= command_len-1) |
| 1030 | return; | 1029 | return; |
| 1031 | if (isalnum(command[cursor]) || command[cursor] == '_') { | 1030 | if (isalnum(command[cursor]) || command[cursor] == '_') { |
| 1032 | while (cursor < len-1 | 1031 | while (cursor < command_len-1 |
| 1033 | && (isalnum(command[cursor+1]) || command[cursor+1] == '_') | 1032 | && (isalnum(command[cursor+1]) || command[cursor+1] == '_') |
| 1034 | ) { | 1033 | ) { |
| 1035 | input_forward(); | 1034 | input_forward(); |
| 1036 | } | 1035 | } |
| 1037 | } else if (ispunct(command[cursor])) { | 1036 | } else if (ispunct(command[cursor])) { |
| 1038 | while (cursor < len-1 && ispunct(command[cursor+1])) | 1037 | while (cursor < command_len-1 && ispunct(command[cursor+1])) |
| 1039 | input_forward(); | 1038 | input_forward(); |
| 1040 | } | 1039 | } |
| 1041 | } | 1040 | } |
