diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2010-04-16 22:13:55 -0700 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2010-04-16 22:13:55 -0700 |
commit | 04cecd5e614f89b9e65a4d8141ec75053f563ad9 (patch) | |
tree | 8b77d05937faed40cc6145c1ff21c7d7762f7286 | |
parent | 2bb651ae10e36999949812d3ac4f7789ed665037 (diff) | |
download | busybox-w32-04cecd5e614f89b9e65a4d8141ec75053f563ad9.tar.gz busybox-w32-04cecd5e614f89b9e65a4d8141ec75053f563ad9.tar.bz2 busybox-w32-04cecd5e614f89b9e65a4d8141ec75053f563ad9.zip |
vi: code shrink
function old new delta
vi_main 250 242 -8
colon 2980 2970 -10
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-18) Total: -18 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | editors/vi.c | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/editors/vi.c b/editors/vi.c index 94d36ae99..28612508f 100644 --- a/editors/vi.c +++ b/editors/vi.c | |||
@@ -458,12 +458,10 @@ int vi_main(int argc, char **argv) | |||
458 | save_argc = argc; | 458 | save_argc = argc; |
459 | 459 | ||
460 | //----- This is the main file handling loop -------------- | 460 | //----- This is the main file handling loop -------------- |
461 | if (optind >= argc) { | 461 | while (1) { |
462 | edit_file(0); | 462 | edit_file(argv[optind]); /* param might be NULL */ |
463 | } else { | 463 | if (++optind >= argc) |
464 | for (; optind < argc; optind++) { | 464 | break; |
465 | edit_file(argv[optind]); | ||
466 | } | ||
467 | } | 465 | } |
468 | //----------------------------------------------------------- | 466 | //----------------------------------------------------------- |
469 | 467 | ||
@@ -955,6 +953,7 @@ static void colon(char *buf) | |||
955 | } else if (strncmp(cmd, "quit", i) == 0 // Quit | 953 | } else if (strncmp(cmd, "quit", i) == 0 // Quit |
956 | || strncmp(cmd, "next", i) == 0 // edit next file | 954 | || strncmp(cmd, "next", i) == 0 // edit next file |
957 | ) { | 955 | ) { |
956 | int n; | ||
958 | if (useforce) { | 957 | if (useforce) { |
959 | // force end of argv list | 958 | // force end of argv list |
960 | if (*cmd == 'q') { | 959 | if (*cmd == 'q') { |
@@ -970,11 +969,12 @@ static void colon(char *buf) | |||
970 | goto vc1; | 969 | goto vc1; |
971 | } | 970 | } |
972 | // are there other file to edit | 971 | // are there other file to edit |
973 | if (*cmd == 'q' && optind < save_argc - 1) { | 972 | n = save_argc - optind - 1; |
974 | status_line_bold("%d more file to edit", (save_argc - optind - 1)); | 973 | if (*cmd == 'q' && n > 0) { |
974 | status_line_bold("%d more file(s) to edit", n); | ||
975 | goto vc1; | 975 | goto vc1; |
976 | } | 976 | } |
977 | if (*cmd == 'n' && optind >= save_argc - 1) { | 977 | if (*cmd == 'n' && n <= 0) { |
978 | status_line_bold("No more files to edit"); | 978 | status_line_bold("No more files to edit"); |
979 | goto vc1; | 979 | goto vc1; |
980 | } | 980 | } |