aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Fox <pgf@brightstareng.com>2006-03-27 21:51:16 +0000
committerPaul Fox <pgf@brightstareng.com>2006-03-27 21:51:16 +0000
commit9360f42d32f63c3d5239b297f4696d9d085bc5ba (patch)
treef75628a9fad9ce209ecfb4f05a087ba5c76402cd
parentdbf935dae6917b1c6f322f1a5c34c315fa8ba347 (diff)
downloadbusybox-w32-9360f42d32f63c3d5239b297f4696d9d085bc5ba.tar.gz
busybox-w32-9360f42d32f63c3d5239b297f4696d9d085bc5ba.tar.bz2
busybox-w32-9360f42d32f63c3d5239b297f4696d9d085bc5ba.zip
add support for :wn (initial patch from Alexander Griesser)
-rw-r--r--editors/vi.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/editors/vi.c b/editors/vi.c
index 6e5f07ee9..1cd1b1ae9 100644
--- a/editors/vi.c
+++ b/editors/vi.c
@@ -1072,9 +1072,10 @@ static void colon(Byte * buf)
1072#endif /* CONFIG_FEATURE_VI_SEARCH */ 1072#endif /* CONFIG_FEATURE_VI_SEARCH */
1073 } else if (strncasecmp((char *) cmd, "version", i) == 0) { // show software version 1073 } else if (strncasecmp((char *) cmd, "version", i) == 0) { // show software version
1074 psb("%s", vi_Version); 1074 psb("%s", vi_Version);
1075 } else if ((strncasecmp((char *) cmd, "write", i) == 0) || // write text to file 1075 } else if (strncasecmp((char *) cmd, "write", i) == 0 // write text to file
1076 (strncasecmp((char *) cmd, "wq", i) == 0) || 1076 || strncasecmp((char *) cmd, "wq", i) == 0
1077 (strncasecmp((char *) cmd, "x", i) == 0)) { 1077 || strncasecmp((char *) cmd, "wn", i) == 0
1078 || strncasecmp((char *) cmd, "x", i) == 0) {
1078 // is there a file name to write to? 1079 // is there a file name to write to?
1079 if (strlen((char *) args) > 0) { 1080 if (strlen((char *) args) > 0) {
1080 fn = args; 1081 fn = args;
@@ -1111,7 +1112,9 @@ static void colon(Byte * buf)
1111 file_modified = 0; 1112 file_modified = 0;
1112 last_file_modified = -1; 1113 last_file_modified = -1;
1113 } 1114 }
1114 if ((cmd[0] == 'x' || cmd[1] == 'q') && l == ch) { 1115 if ((cmd[0] == 'x' || cmd[1] == 'q' || cmd[1] == 'n' ||
1116 cmd[0] == 'X' || cmd[1] == 'Q' || cmd[1] == 'N')
1117 && l == ch) {
1115 editing = 0; 1118 editing = 0;
1116 } 1119 }
1117 } 1120 }
@@ -3420,9 +3423,10 @@ key_cmd_mode:
3420 } else { 3423 } else {
3421 editing = 0; 3424 editing = 0;
3422 } 3425 }
3423 } else if (strncasecmp((char *) p, "write", cnt) == 0 || 3426 } else if (strncasecmp((char *) p, "write", cnt) == 0
3424 strncasecmp((char *) p, "wq", cnt) == 0 || 3427 || strncasecmp((char *) p, "wq", cnt) == 0
3425 strncasecmp((char *) p, "x", cnt) == 0) { 3428 || strncasecmp((char *) p, "wn", cnt) == 0
3429 || strncasecmp((char *) p, "x", cnt) == 0) {
3426 cnt = file_write(cfn, text, end - 1); 3430 cnt = file_write(cfn, text, end - 1);
3427 if (cnt < 0) { 3431 if (cnt < 0) {
3428 if (cnt == -1) 3432 if (cnt == -1)
@@ -3431,7 +3435,8 @@ key_cmd_mode:
3431 file_modified = 0; 3435 file_modified = 0;
3432 last_file_modified = -1; 3436 last_file_modified = -1;
3433 psb("\"%s\" %dL, %dC", cfn, count_lines(text, end - 1), cnt); 3437 psb("\"%s\" %dL, %dC", cfn, count_lines(text, end - 1), cnt);
3434 if (p[0] == 'x' || p[1] == 'q') { 3438 if (p[0] == 'x' || p[1] == 'q' || p[1] == 'n' ||
3439 p[0] == 'X' || p[1] == 'Q' || p[1] == 'N') {
3435 editing = 0; 3440 editing = 0;
3436 } 3441 }
3437 } 3442 }