aboutsummaryrefslogtreecommitdiff
path: root/miscutils/less.c
diff options
context:
space:
mode:
authorMarek Polacek <mmpolacek@gmail.com>2010-10-28 21:34:56 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2010-10-28 21:34:56 +0200
commit7b18107384d950358e146d42bf02b391fab5ffd6 (patch)
tree9994e2bcaa038c3128ed8b3bca99486e22f660fb /miscutils/less.c
parent02788ac7e2a44eee889aa1005e89076f928e964a (diff)
downloadbusybox-7b18107384d950358e146d42bf02b391fab5ffd6.tar.gz
*: 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 <mmpolacek@gmail.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'miscutils/less.c')
-rw-r--r--miscutils/less.c14
1 files changed, 8 insertions, 6 deletions
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)