diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2013-03-15 02:17:29 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2013-03-15 02:17:29 +0100 |
commit | 9e7c002182d2ce57ac23dc65dde23e5f1f6557f0 (patch) | |
tree | a6b1abe5df8a5939956ea348fc3d6fb769ddb869 | |
parent | cb5aa725df472a7ab84c7c513a8dda98b9b3a6bc (diff) | |
download | busybox-w32-9e7c002182d2ce57ac23dc65dde23e5f1f6557f0.tar.gz busybox-w32-9e7c002182d2ce57ac23dc65dde23e5f1f6557f0.tar.bz2 busybox-w32-9e7c002182d2ce57ac23dc65dde23e5f1f6557f0.zip |
vi: code shrink
function old new delta
status_line_bold_errno - 32 +32
colon 2891 2873 -18
file_insert 354 313 -41
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 0/2 up/down: 32/-59) Total: -27 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | editors/vi.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/editors/vi.c b/editors/vi.c index 3d6182bbf..3615ee469 100644 --- a/editors/vi.c +++ b/editors/vi.c | |||
@@ -478,6 +478,7 @@ static void flash(int); // flash the terminal screen | |||
478 | static void show_status_line(void); // put a message on the bottom line | 478 | static void show_status_line(void); // put a message on the bottom line |
479 | static void status_line(const char *, ...); // print to status buf | 479 | static void status_line(const char *, ...); // print to status buf |
480 | static void status_line_bold(const char *, ...); | 480 | static void status_line_bold(const char *, ...); |
481 | static void status_line_bold_errno(const char *fn); | ||
481 | static void not_implemented(const char *); // display "Not implemented" message | 482 | static void not_implemented(const char *); // display "Not implemented" message |
482 | static int format_edit_status(void); // format file status on status line | 483 | static int format_edit_status(void); // format file status on status line |
483 | static void redraw(int); // force a full screen refresh | 484 | static void redraw(int); // force a full screen refresh |
@@ -1321,7 +1322,7 @@ static void colon(char *buf) | |||
1321 | } | 1322 | } |
1322 | if (l < 0) { | 1323 | if (l < 0) { |
1323 | if (l == -1) | 1324 | if (l == -1) |
1324 | status_line_bold("'%s' %s", fn, strerror(errno)); | 1325 | status_line_bold_errno(fn); |
1325 | } else { | 1326 | } else { |
1326 | status_line("'%s' %dL, %dC", fn, li, l); | 1327 | status_line("'%s' %dL, %dC", fn, li, l); |
1327 | if (q == text && r == end - 1 && l == ch) { | 1328 | if (q == text && r == end - 1 && l == ch) { |
@@ -2503,7 +2504,7 @@ static int file_insert(const char *fn, char *p, int update_ro_status) | |||
2503 | 2504 | ||
2504 | /* Validate file */ | 2505 | /* Validate file */ |
2505 | if (stat(fn, &statbuf) < 0) { | 2506 | if (stat(fn, &statbuf) < 0) { |
2506 | status_line_bold("'%s' %s", fn, strerror(errno)); | 2507 | status_line_bold_errno(fn); |
2507 | goto fi0; | 2508 | goto fi0; |
2508 | } | 2509 | } |
2509 | if (!S_ISREG(statbuf.st_mode)) { | 2510 | if (!S_ISREG(statbuf.st_mode)) { |
@@ -2519,14 +2520,14 @@ static int file_insert(const char *fn, char *p, int update_ro_status) | |||
2519 | // read file to buffer | 2520 | // read file to buffer |
2520 | fd = open(fn, O_RDONLY); | 2521 | fd = open(fn, O_RDONLY); |
2521 | if (fd < 0) { | 2522 | if (fd < 0) { |
2522 | status_line_bold("'%s' %s", fn, strerror(errno)); | 2523 | status_line_bold_errno(fn); |
2523 | goto fi0; | 2524 | goto fi0; |
2524 | } | 2525 | } |
2525 | size = (statbuf.st_size < INT_MAX ? (int)statbuf.st_size : INT_MAX); | 2526 | size = (statbuf.st_size < INT_MAX ? (int)statbuf.st_size : INT_MAX); |
2526 | p += text_hole_make(p, size); | 2527 | p += text_hole_make(p, size); |
2527 | cnt = safe_read(fd, p, size); | 2528 | cnt = safe_read(fd, p, size); |
2528 | if (cnt < 0) { | 2529 | if (cnt < 0) { |
2529 | status_line_bold("'%s' %s", fn, strerror(errno)); | 2530 | status_line_bold_errno(fn); |
2530 | p = text_hole_delete(p, p + size - 1); // un-do buffer insert | 2531 | p = text_hole_delete(p, p + size - 1); // un-do buffer insert |
2531 | } else if (cnt < size) { | 2532 | } else if (cnt < size) { |
2532 | // There was a partial read, shrink unused space text[] | 2533 | // There was a partial read, shrink unused space text[] |
@@ -2717,6 +2718,11 @@ static void status_line_bold(const char *format, ...) | |||
2717 | have_status_msg = 1 + sizeof(ESC_BOLD_TEXT) + sizeof(ESC_NORM_TEXT) - 2; | 2718 | have_status_msg = 1 + sizeof(ESC_BOLD_TEXT) + sizeof(ESC_NORM_TEXT) - 2; |
2718 | } | 2719 | } |
2719 | 2720 | ||
2721 | static void status_line_bold_errno(const char *fn) | ||
2722 | { | ||
2723 | status_line_bold("'%s' %s", fn, strerror(errno)); | ||
2724 | } | ||
2725 | |||
2720 | // format status buffer | 2726 | // format status buffer |
2721 | static void status_line(const char *format, ...) | 2727 | static void status_line(const char *format, ...) |
2722 | { | 2728 | { |