From 9963fe36c2af2bf99fcbd2eae6e9e050c8cf779b Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Mon, 17 May 2010 04:05:53 +0200 Subject: lineedit: trivial simplifications. -7 bytes Signed-off-by: Denys Vlasenko --- libbb/lineedit.c | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) (limited to 'libbb') diff --git a/libbb/lineedit.c b/libbb/lineedit.c index 836fc0089..36d057bbb 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! */ } } -- cgit v1.2.3