From 7b18107384d950358e146d42bf02b391fab5ffd6 Mon Sep 17 00:00:00 2001 From: Marek Polacek Date: Thu, 28 Oct 2010 21:34:56 +0200 Subject: *: use _exit() in sighandlers; showkey: do not use exit-thru-sighandler While at it, make ESC sequences more readable; and removed check for isatty(stdin) in reset. Code shrink: text data bss dec hex filename 884771 936 17216 902923 dc70b busybox_old 884723 936 17216 902875 dc6db busybox_unstripped Signed-off-by: Marek Polacek Signed-off-by: Denys Vlasenko --- miscutils/less.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'miscutils/less.c') diff --git a/miscutils/less.c b/miscutils/less.c index 500059d2a..9e12c11a7 100644 --- a/miscutils/less.c +++ b/miscutils/less.c @@ -28,13 +28,15 @@ #include "xregex.h" #endif + +#define ESC "\033" /* The escape codes for highlighted and normal text */ -#define HIGHLIGHT "\033[7m" -#define NORMAL "\033[0m" +#define HIGHLIGHT ESC"[7m" +#define NORMAL ESC"[0m" /* The escape code to home and clear to the end of screen */ -#define CLEAR "\033[H\033[J" +#define CLEAR ESC"[H\033[J" /* The escape code to clear to the end of line */ -#define CLEAR_2_EOL "\033[K" +#define CLEAR_2_EOL ESC"[K" enum { /* Absolute max of lines eaten */ @@ -165,12 +167,12 @@ static void set_tty_cooked(void) top-left corner of the console */ static void move_cursor(int line, int row) { - printf("\033[%u;%uH", line, row); + printf(ESC"[%u;%uH", line, row); } static void clear_line(void) { - printf("\033[%u;0H" CLEAR_2_EOL, max_displayed_line + 2); + printf(ESC"[%u;0H" CLEAR_2_EOL, max_displayed_line + 2); } static void print_hilite(const char *str) -- cgit v1.2.3