diff options
author | Denys Vlasenko | 2010-05-17 04:05:53 +0200 |
---|---|---|
committer | Denys Vlasenko | 2010-05-17 04:05:53 +0200 |
commit | 9963fe36c2af2bf99fcbd2eae6e9e050c8cf779b (patch) | |
tree | dce2c33a8ac91b21db10aaa1a3a5c2a04e940c38 | |
parent | 27ff681cfa573ce2a63b35c48047f1d7adcb1f02 (diff) | |
download | busybox-9963fe36c2af2bf99fcbd2eae6e9e050c8cf779b.zip busybox-9963fe36c2af2bf99fcbd2eae6e9e050c8cf779b.tar.gz |
lineedit: trivial simplifications. -7 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | libbb/lineedit.c | 20 |
1 files changed, 6 insertions, 14 deletions
diff --git a/libbb/lineedit.c b/libbb/lineedit.c index 836fc00..36d057b 100644 --- a/libbb/lineedit.c +++ b/libbb/lineedit.c @@ -397,17 +397,10 @@ static void put_till_end_and_adv_cursor(void) static void goto_new_line(void) { put_till_end_and_adv_cursor(); - if (cmdedit_x) + if (cmdedit_x != 0) bb_putchar('\n'); } - -static void out1str(const char *s) -{ - if (s) - fputs(s, stdout); -} - static void beep(void) { bb_putchar('\007'); @@ -417,7 +410,7 @@ static void put_prompt(void) { unsigned w; - out1str(cmdedit_prompt); + fputs(cmdedit_prompt, stdout); fflush_all(); cursor = 0; w = cmdedit_termw; /* read volatile var once */ @@ -485,9 +478,8 @@ static void input_backward(unsigned num) * up to new cursor position (which is already known): */ unsigned sv_cursor; - if (cmdedit_y > 0) /* up to start y */ - printf("\033[%uA", cmdedit_y); - bb_putchar('\r'); + /* go to 1st column; go up to first line */ + printf("\r" "\033[%uA", cmdedit_y); cmdedit_y = 0; sv_cursor = cursor; put_prompt(); /* sets cursor to 0 */ @@ -509,7 +501,7 @@ static void input_backward(unsigned num) /* draw prompt, editor line, and clear tail */ static void redraw(int y, int back_cursor) { - if (y > 0) /* up to start y */ + if (y > 0) /* up y lines */ printf("\033[%uA", y); bb_putchar('\r'); put_prompt(); @@ -1616,7 +1608,7 @@ static void ask_terminal(void) pfd.events = POLLIN; if (safe_poll(&pfd, 1, 0) == 0) { S.sent_ESC_br6n = 1; - out1str("\033" "[6n"); + fputs("\033" "[6n", stdout); fflush_all(); /* make terminal see it ASAP! */ } } |