summaryrefslogtreecommitdiff
path: root/editors/vi.c
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2008-09-28 16:40:02 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2008-09-28 16:40:02 +0000
commit4a81fe4173bf5029058253cf0be194c23a5ad369 (patch)
tree0806d2c3d6df92784c407221d862b9956c9ea115 /editors/vi.c
parent3e7eca97b987b351c6f68308c6e0c421541f10c8 (diff)
downloadbusybox-w32-1_11_3.tar.gz
busybox-w32-1_11_3.tar.bz2
busybox-w32-1_11_3.zip
apply post-1.11.2 fixes, bump version to 1.11.31_11_3
Diffstat (limited to 'editors/vi.c')
-rw-r--r--editors/vi.c34
1 files changed, 18 insertions, 16 deletions
diff --git a/editors/vi.c b/editors/vi.c
index 81baa890f..1985be7db 100644
--- a/editors/vi.c
+++ b/editors/vi.c
@@ -147,10 +147,10 @@ struct globals {
147#endif 147#endif
148 148
149 smallint editing; // >0 while we are editing a file 149 smallint editing; // >0 while we are editing a file
150 // [code audit says "can be 0 or 1 only"] 150 // [code audit says "can be 0, 1 or 2 only"]
151 smallint cmd_mode; // 0=command 1=insert 2=replace 151 smallint cmd_mode; // 0=command 1=insert 2=replace
152 int file_modified; // buffer contents changed (counter, not flag!) 152 int file_modified; // buffer contents changed (counter, not flag!)
153 int last_file_modified; // = -1; 153 int last_file_modified; // = -1;
154 int fn_start; // index of first cmd line file name 154 int fn_start; // index of first cmd line file name
155 int save_argc; // how many file names on cmd line 155 int save_argc; // how many file names on cmd line
156 int cmdcnt; // repetition count 156 int cmdcnt; // repetition count
@@ -623,7 +623,7 @@ static void edit_file(char *fn)
623 // These are commands that change text[]. 623 // These are commands that change text[].
624 // Remember the input for the "." command 624 // Remember the input for the "." command
625 if (!adding2q && ioq_start == NULL 625 if (!adding2q && ioq_start == NULL
626 && strchr(modifying_cmds, c) 626 && c != '\0' && strchr(modifying_cmds, c)
627 ) { 627 ) {
628 start_new_cmd_q(c); 628 start_new_cmd_q(c);
629 } 629 }
@@ -645,8 +645,8 @@ static void edit_file(char *fn)
645 } 645 }
646 //------------------------------------------------------------------- 646 //-------------------------------------------------------------------
647 647
648 place_cursor(rows, 0, FALSE); // go to bottom of screen 648 place_cursor(rows - 1, 0, FALSE); // go to bottom of screen
649 clear_to_eol(); // Erase to end of line 649 clear_to_eol(); // erase to end of line
650 cookmode(); 650 cookmode();
651#undef cur_line 651#undef cur_line
652} 652}
@@ -2009,9 +2009,9 @@ static void start_new_cmd_q(char c)
2009{ 2009{
2010 // get buffer for new cmd 2010 // get buffer for new cmd
2011 // if there is a current cmd count put it in the buffer first 2011 // if there is a current cmd count put it in the buffer first
2012 if (cmdcnt > 0) 2012 if (cmdcnt > 0) {
2013 lmc_len = sprintf(last_modifying_cmd, "%d%c", cmdcnt, c); 2013 lmc_len = sprintf(last_modifying_cmd, "%d%c", cmdcnt, c);
2014 else { // just save char c onto queue 2014 } else { // just save char c onto queue
2015 last_modifying_cmd[0] = c; 2015 last_modifying_cmd[0] = c;
2016 lmc_len = 1; 2016 lmc_len = 1;
2017 } 2017 }
@@ -2247,18 +2247,20 @@ static char readit(void) // read (maybe cursor) key from stdin
2247 2247
2248 fflush(stdout); 2248 fflush(stdout);
2249 n = chars_to_parse; 2249 n = chars_to_parse;
2250 // get input from User- are there already input chars in Q? 2250 // get input from User - are there already input chars in Q?
2251 if (n <= 0) { 2251 if (n <= 0) {
2252 // the Q is empty, wait for a typed char 2252 // the Q is empty, wait for a typed char
2253 again:
2253 n = safe_read(STDIN_FILENO, readbuffer, sizeof(readbuffer)); 2254 n = safe_read(STDIN_FILENO, readbuffer, sizeof(readbuffer));
2254 if (n < 0) { 2255 if (n <= 0) {
2255 if (errno == EBADF || errno == EFAULT || errno == EINVAL 2256 place_cursor(rows - 1, 0, FALSE); // go to bottom of screen
2256 || errno == EIO) 2257 clear_to_eol(); // erase to end of line
2257 editing = 0; // want to exit 2258 cookmode(); // terminal to "cooked"
2258 errno = 0; 2259 bb_error_msg_and_die("can't read user input");
2259 } 2260 }
2260 if (n <= 0) 2261 /* elsewhere we can get very confused by NULs */
2261 return 0; // error 2262 if (readbuffer[0] == '\0')
2263 goto again;
2262 if (readbuffer[0] == 27) { 2264 if (readbuffer[0] == 27) {
2263 // This is an ESC char. Is this Esc sequence? 2265 // This is an ESC char. Is this Esc sequence?
2264 // Could be bare Esc key. See if there are any 2266 // Could be bare Esc key. See if there are any