diff options
author | Robert Griebl <griebl@gmx.de> | 2002-07-31 21:22:21 +0000 |
---|---|---|
committer | Robert Griebl <griebl@gmx.de> | 2002-07-31 21:22:21 +0000 |
commit | a71389bfe8b7a047ef6da555f274d124318977c9 (patch) | |
tree | ae85713d0c3bbdeebbd4e1c7cbb0c6e335db35c2 | |
parent | 7373e485d3314e8a7085c4d1d9cea9f270445c45 (diff) | |
download | busybox-w32-a71389bfe8b7a047ef6da555f274d124318977c9.tar.gz busybox-w32-a71389bfe8b7a047ef6da555f274d124318977c9.tar.bz2 busybox-w32-a71389bfe8b7a047ef6da555f274d124318977c9.zip |
Applied a patch from Philip Blundell <pb@nexus.co.uk>:
Added support for ":x" as an alias for ":wq" to vi
-rw-r--r-- | editors/vi.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/editors/vi.c b/editors/vi.c index a8f5203c8..ad6dd5c74 100644 --- a/editors/vi.c +++ b/editors/vi.c | |||
@@ -19,7 +19,7 @@ | |||
19 | */ | 19 | */ |
20 | 20 | ||
21 | static const char vi_Version[] = | 21 | static const char vi_Version[] = |
22 | "$Id: vi.c,v 1.21 2002/04/26 07:41:22 timr Exp $"; | 22 | "$Id: vi.c,v 1.22 2002/07/31 21:22:21 sandman Exp $"; |
23 | 23 | ||
24 | /* | 24 | /* |
25 | * To compile for standalone use: | 25 | * To compile for standalone use: |
@@ -1225,11 +1225,12 @@ key_cmd_mode: | |||
1225 | editing = 0; | 1225 | editing = 0; |
1226 | } | 1226 | } |
1227 | } else if (strncasecmp((char *) p, "write", cnt) == 0 || | 1227 | } else if (strncasecmp((char *) p, "write", cnt) == 0 || |
1228 | strncasecmp((char *) p, "wq", cnt) == 0) { | 1228 | strncasecmp((char *) p, "wq", cnt) == 0 || |
1229 | strncasecmp((char *) p, "x", cnt) == 0) { | ||
1229 | cnt = file_write(cfn, text, end - 1); | 1230 | cnt = file_write(cfn, text, end - 1); |
1230 | file_modified = FALSE; | 1231 | file_modified = FALSE; |
1231 | psb("\"%s\" %dL, %dC", cfn, count_lines(text, end - 1), cnt); | 1232 | psb("\"%s\" %dL, %dC", cfn, count_lines(text, end - 1), cnt); |
1232 | if (p[1] == 'q') { | 1233 | if (p[0] == 'x' || p[1] == 'q') { |
1233 | editing = 0; | 1234 | editing = 0; |
1234 | } | 1235 | } |
1235 | } else if (strncasecmp((char *) p, "file", cnt) == 0 ) { | 1236 | } else if (strncasecmp((char *) p, "file", cnt) == 0 ) { |
@@ -2134,7 +2135,8 @@ static void colon(Byte * buf) | |||
2134 | } else if (strncasecmp((char *) cmd, "version", i) == 0) { // show software version | 2135 | } else if (strncasecmp((char *) cmd, "version", i) == 0) { // show software version |
2135 | psb("%s", vi_Version); | 2136 | psb("%s", vi_Version); |
2136 | } else if ((strncasecmp((char *) cmd, "write", i) == 0) || // write text to file | 2137 | } else if ((strncasecmp((char *) cmd, "write", i) == 0) || // write text to file |
2137 | (strncasecmp((char *) cmd, "wq", i) == 0)) { // write text to file | 2138 | (strncasecmp((char *) cmd, "wq", i) == 0) || |
2139 | (strncasecmp((char *) cmd, "x", i) == 0)) { | ||
2138 | // is there a file name to write to? | 2140 | // is there a file name to write to? |
2139 | if (strlen((char *) args) > 0) { | 2141 | if (strlen((char *) args) > 0) { |
2140 | fn = args; | 2142 | fn = args; |
@@ -2165,7 +2167,7 @@ static void colon(Byte * buf) | |||
2165 | psb("\"%s\" %dL, %dC", fn, li, l); | 2167 | psb("\"%s\" %dL, %dC", fn, li, l); |
2166 | if (q == text && r == end - 1 && l == ch) | 2168 | if (q == text && r == end - 1 && l == ch) |
2167 | file_modified = FALSE; | 2169 | file_modified = FALSE; |
2168 | if (cmd[1] == 'q' && l == ch) { | 2170 | if ((cmd[0] == 'x' || cmd[1] == 'q') && l == ch) { |
2169 | editing = 0; | 2171 | editing = 0; |
2170 | } | 2172 | } |
2171 | #ifdef CONFIG_FEATURE_VI_READONLY | 2173 | #ifdef CONFIG_FEATURE_VI_READONLY |