diff options
author | Eric Andersen <andersen@codepoet.org> | 2001-03-15 20:51:09 +0000 |
---|---|---|
committer | Eric Andersen <andersen@codepoet.org> | 2001-03-15 20:51:09 +0000 |
commit | f9ff8a7d90855a2131b2da0ec379e8e58ab07b37 (patch) | |
tree | 325f446630548e546e362a0829ab51e6516eb863 | |
parent | af9e533a5419084ec9260c3c55cd2799122cc7e1 (diff) | |
download | busybox-w32-f9ff8a7d90855a2131b2da0ec379e8e58ab07b37.tar.gz busybox-w32-f9ff8a7d90855a2131b2da0ec379e8e58ab07b37.tar.bz2 busybox-w32-f9ff8a7d90855a2131b2da0ec379e8e58ab07b37.zip |
cmdedit.c bugfix patch from Vladimir.
-Erik
-rw-r--r-- | cmdedit.c | 26 | ||||
-rw-r--r-- | shell/cmdedit.c | 26 |
2 files changed, 28 insertions, 24 deletions
@@ -55,7 +55,6 @@ | |||
55 | #define BB_FEATURE_COMMAND_TAB_COMPLETION | 55 | #define BB_FEATURE_COMMAND_TAB_COMPLETION |
56 | #define BB_FEATURE_COMMAND_USERNAME_COMPLETION | 56 | #define BB_FEATURE_COMMAND_USERNAME_COMPLETION |
57 | #define BB_FEATURE_NONPRINTABLE_INVERSE_PUT | 57 | #define BB_FEATURE_NONPRINTABLE_INVERSE_PUT |
58 | #undef BB_FEATURE_SH_SIMPLE_PROMPT | ||
59 | #define BB_FEATURE_CLEAN_UP | 58 | #define BB_FEATURE_CLEAN_UP |
60 | 59 | ||
61 | #define D(x) x | 60 | #define D(x) x |
@@ -268,15 +267,15 @@ static void cmdedit_reset_term(void) | |||
268 | static void cmdedit_set_out_char(int next_char) | 267 | static void cmdedit_set_out_char(int next_char) |
269 | { | 268 | { |
270 | 269 | ||
271 | int c = command_ps[cursor]; | 270 | int c = (int)((unsigned char) command_ps[cursor]); |
272 | 271 | ||
273 | if (c == 0) | 272 | if (c == 0) |
274 | c = ' '; /* destroy end char? */ | 273 | c = ' '; /* destroy end char? */ |
275 | #ifdef BB_FEATURE_NONPRINTABLE_INVERSE_PUT | 274 | #ifdef BB_FEATURE_NONPRINTABLE_INVERSE_PUT |
276 | if (!isprint(c)) { /* Inverse put non-printable characters */ | 275 | if (!isprint(c)) { /* Inverse put non-printable characters */ |
277 | if (((unsigned char) c) >= 128) | 276 | if (c >= 128) |
278 | c -= 128; | 277 | c -= 128; |
279 | if (((unsigned char) c) < ' ') | 278 | if (c < ' ') |
280 | c += '@'; | 279 | c += '@'; |
281 | if (c == 127) | 280 | if (c == 127) |
282 | c = '?'; | 281 | c = '?'; |
@@ -498,12 +497,8 @@ static void parse_prompt(const char *prmt_ptr) | |||
498 | if (flg_not_length == ']') | 497 | if (flg_not_length == ']') |
499 | sub_len++; | 498 | sub_len++; |
500 | } | 499 | } |
501 | #if 0 | ||
502 | cmdedit_prmt_len = prmt_len - sub_len; | ||
503 | cmdedit_prompt = prmt_ptr; | ||
504 | #endif | ||
505 | cmdedit_prompt = prmt_mem_ptr; | 500 | cmdedit_prompt = prmt_mem_ptr; |
506 | cmdedit_prmt_len = strlen(cmdedit_prompt); | 501 | cmdedit_prmt_len = prmt_len - sub_len; |
507 | put_prompt(); | 502 | put_prompt(); |
508 | } | 503 | } |
509 | #endif | 504 | #endif |
@@ -1223,7 +1218,7 @@ extern void cmdedit_read_input(char *prompt, char command[BUFSIZ]) | |||
1223 | 1218 | ||
1224 | int break_out = 0; | 1219 | int break_out = 0; |
1225 | int lastWasTab = FALSE; | 1220 | int lastWasTab = FALSE; |
1226 | char c = 0; | 1221 | unsigned char c = 0; |
1227 | struct history *hp = his_end; | 1222 | struct history *hp = his_end; |
1228 | 1223 | ||
1229 | /* prepare before init handlers */ | 1224 | /* prepare before init handlers */ |
@@ -1250,10 +1245,10 @@ extern void cmdedit_read_input(char *prompt, char command[BUFSIZ]) | |||
1250 | setTermSettings(inputFd, (void *) &new_settings); | 1245 | setTermSettings(inputFd, (void *) &new_settings); |
1251 | handlers_sets |= SET_RESET_TERM; | 1246 | handlers_sets |= SET_RESET_TERM; |
1252 | 1247 | ||
1253 | /* Print out the command prompt */ | ||
1254 | parse_prompt(prompt); | ||
1255 | /* Now initialize things */ | 1248 | /* Now initialize things */ |
1256 | cmdedit_init(); | 1249 | cmdedit_init(); |
1250 | /* Print out the command prompt */ | ||
1251 | parse_prompt(prompt); | ||
1257 | 1252 | ||
1258 | while (1) { | 1253 | while (1) { |
1259 | 1254 | ||
@@ -1545,6 +1540,10 @@ extern void cmdedit_terminate(void) | |||
1545 | 1540 | ||
1546 | #ifdef TEST | 1541 | #ifdef TEST |
1547 | 1542 | ||
1543 | #ifdef BB_FEATURE_NONPRINTABLE_INVERSE_PUT | ||
1544 | #include <locale.h> | ||
1545 | #endif | ||
1546 | |||
1548 | unsigned int shell_context; | 1547 | unsigned int shell_context; |
1549 | 1548 | ||
1550 | int main(int argc, char **argv) | 1549 | int main(int argc, char **argv) |
@@ -1559,6 +1558,9 @@ int main(int argc, char **argv) | |||
1559 | "% "; | 1558 | "% "; |
1560 | #endif | 1559 | #endif |
1561 | 1560 | ||
1561 | #ifdef BB_FEATURE_NONPRINTABLE_INVERSE_PUT | ||
1562 | setlocale(LC_ALL, ""); | ||
1563 | #endif | ||
1562 | shell_context = 1; | 1564 | shell_context = 1; |
1563 | do { | 1565 | do { |
1564 | int l; | 1566 | int l; |
diff --git a/shell/cmdedit.c b/shell/cmdedit.c index 7f403b44f..6dcc33844 100644 --- a/shell/cmdedit.c +++ b/shell/cmdedit.c | |||
@@ -55,7 +55,6 @@ | |||
55 | #define BB_FEATURE_COMMAND_TAB_COMPLETION | 55 | #define BB_FEATURE_COMMAND_TAB_COMPLETION |
56 | #define BB_FEATURE_COMMAND_USERNAME_COMPLETION | 56 | #define BB_FEATURE_COMMAND_USERNAME_COMPLETION |
57 | #define BB_FEATURE_NONPRINTABLE_INVERSE_PUT | 57 | #define BB_FEATURE_NONPRINTABLE_INVERSE_PUT |
58 | #undef BB_FEATURE_SH_SIMPLE_PROMPT | ||
59 | #define BB_FEATURE_CLEAN_UP | 58 | #define BB_FEATURE_CLEAN_UP |
60 | 59 | ||
61 | #define D(x) x | 60 | #define D(x) x |
@@ -268,15 +267,15 @@ static void cmdedit_reset_term(void) | |||
268 | static void cmdedit_set_out_char(int next_char) | 267 | static void cmdedit_set_out_char(int next_char) |
269 | { | 268 | { |
270 | 269 | ||
271 | int c = command_ps[cursor]; | 270 | int c = (int)((unsigned char) command_ps[cursor]); |
272 | 271 | ||
273 | if (c == 0) | 272 | if (c == 0) |
274 | c = ' '; /* destroy end char? */ | 273 | c = ' '; /* destroy end char? */ |
275 | #ifdef BB_FEATURE_NONPRINTABLE_INVERSE_PUT | 274 | #ifdef BB_FEATURE_NONPRINTABLE_INVERSE_PUT |
276 | if (!isprint(c)) { /* Inverse put non-printable characters */ | 275 | if (!isprint(c)) { /* Inverse put non-printable characters */ |
277 | if (((unsigned char) c) >= 128) | 276 | if (c >= 128) |
278 | c -= 128; | 277 | c -= 128; |
279 | if (((unsigned char) c) < ' ') | 278 | if (c < ' ') |
280 | c += '@'; | 279 | c += '@'; |
281 | if (c == 127) | 280 | if (c == 127) |
282 | c = '?'; | 281 | c = '?'; |
@@ -498,12 +497,8 @@ static void parse_prompt(const char *prmt_ptr) | |||
498 | if (flg_not_length == ']') | 497 | if (flg_not_length == ']') |
499 | sub_len++; | 498 | sub_len++; |
500 | } | 499 | } |
501 | #if 0 | ||
502 | cmdedit_prmt_len = prmt_len - sub_len; | ||
503 | cmdedit_prompt = prmt_ptr; | ||
504 | #endif | ||
505 | cmdedit_prompt = prmt_mem_ptr; | 500 | cmdedit_prompt = prmt_mem_ptr; |
506 | cmdedit_prmt_len = strlen(cmdedit_prompt); | 501 | cmdedit_prmt_len = prmt_len - sub_len; |
507 | put_prompt(); | 502 | put_prompt(); |
508 | } | 503 | } |
509 | #endif | 504 | #endif |
@@ -1223,7 +1218,7 @@ extern void cmdedit_read_input(char *prompt, char command[BUFSIZ]) | |||
1223 | 1218 | ||
1224 | int break_out = 0; | 1219 | int break_out = 0; |
1225 | int lastWasTab = FALSE; | 1220 | int lastWasTab = FALSE; |
1226 | char c = 0; | 1221 | unsigned char c = 0; |
1227 | struct history *hp = his_end; | 1222 | struct history *hp = his_end; |
1228 | 1223 | ||
1229 | /* prepare before init handlers */ | 1224 | /* prepare before init handlers */ |
@@ -1250,10 +1245,10 @@ extern void cmdedit_read_input(char *prompt, char command[BUFSIZ]) | |||
1250 | setTermSettings(inputFd, (void *) &new_settings); | 1245 | setTermSettings(inputFd, (void *) &new_settings); |
1251 | handlers_sets |= SET_RESET_TERM; | 1246 | handlers_sets |= SET_RESET_TERM; |
1252 | 1247 | ||
1253 | /* Print out the command prompt */ | ||
1254 | parse_prompt(prompt); | ||
1255 | /* Now initialize things */ | 1248 | /* Now initialize things */ |
1256 | cmdedit_init(); | 1249 | cmdedit_init(); |
1250 | /* Print out the command prompt */ | ||
1251 | parse_prompt(prompt); | ||
1257 | 1252 | ||
1258 | while (1) { | 1253 | while (1) { |
1259 | 1254 | ||
@@ -1545,6 +1540,10 @@ extern void cmdedit_terminate(void) | |||
1545 | 1540 | ||
1546 | #ifdef TEST | 1541 | #ifdef TEST |
1547 | 1542 | ||
1543 | #ifdef BB_FEATURE_NONPRINTABLE_INVERSE_PUT | ||
1544 | #include <locale.h> | ||
1545 | #endif | ||
1546 | |||
1548 | unsigned int shell_context; | 1547 | unsigned int shell_context; |
1549 | 1548 | ||
1550 | int main(int argc, char **argv) | 1549 | int main(int argc, char **argv) |
@@ -1559,6 +1558,9 @@ int main(int argc, char **argv) | |||
1559 | "% "; | 1558 | "% "; |
1560 | #endif | 1559 | #endif |
1561 | 1560 | ||
1561 | #ifdef BB_FEATURE_NONPRINTABLE_INVERSE_PUT | ||
1562 | setlocale(LC_ALL, ""); | ||
1563 | #endif | ||
1562 | shell_context = 1; | 1564 | shell_context = 1; |
1563 | do { | 1565 | do { |
1564 | int l; | 1566 | int l; |