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-9e7c002182d2ce57ac23dc65dde23e5f1f6557f0.tar.gz |
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 static void show_status_line(void); // put a message on the bottom line static void status_line(const char *, ...); // print to status buf static void status_line_bold(const char *, ...); +static void status_line_bold_errno(const char *fn); static void not_implemented(const char *); // display "Not implemented" message static int format_edit_status(void); // format file status on status line static void redraw(int); // force a full screen refresh @@ -1321,7 +1322,7 @@ static void colon(char *buf) } if (l < 0) { if (l == -1) - status_line_bold("'%s' %s", fn, strerror(errno)); + status_line_bold_errno(fn); } else { status_line("'%s' %dL, %dC", fn, li, l); 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) /* Validate file */ if (stat(fn, &statbuf) < 0) { - status_line_bold("'%s' %s", fn, strerror(errno)); + status_line_bold_errno(fn); goto fi0; } if (!S_ISREG(statbuf.st_mode)) { @@ -2519,14 +2520,14 @@ static int file_insert(const char *fn, char *p, int update_ro_status) // read file to buffer fd = open(fn, O_RDONLY); if (fd < 0) { - status_line_bold("'%s' %s", fn, strerror(errno)); + status_line_bold_errno(fn); goto fi0; } size = (statbuf.st_size < INT_MAX ? (int)statbuf.st_size : INT_MAX); p += text_hole_make(p, size); cnt = safe_read(fd, p, size); if (cnt < 0) { - status_line_bold("'%s' %s", fn, strerror(errno)); + status_line_bold_errno(fn); p = text_hole_delete(p, p + size - 1); // un-do buffer insert } else if (cnt < size) { // There was a partial read, shrink unused space text[] @@ -2717,6 +2718,11 @@ static void status_line_bold(const char *format, ...) have_status_msg = 1 + sizeof(ESC_BOLD_TEXT) + sizeof(ESC_NORM_TEXT) - 2; } +static void status_line_bold_errno(const char *fn) +{ + status_line_bold("'%s' %s", fn, strerror(errno)); +} + // format status buffer static void status_line(const char *format, ...) { |