diff options
author | Marek Polacek <mmpolacek@gmail.com> | 2010-10-28 21:34:56 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2010-10-28 21:34:56 +0200 |
commit | 7b18107384d950358e146d42bf02b391fab5ffd6 (patch) | |
tree | 9994e2bcaa038c3128ed8b3bca99486e22f660fb /miscutils/less.c | |
parent | 02788ac7e2a44eee889aa1005e89076f928e964a (diff) | |
download | busybox-w32-7b18107384d950358e146d42bf02b391fab5ffd6.tar.gz busybox-w32-7b18107384d950358e146d42bf02b391fab5ffd6.tar.bz2 busybox-w32-7b18107384d950358e146d42bf02b391fab5ffd6.zip |
*: 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.c | 14 |
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 @@ | |||
28 | #include "xregex.h" | 28 | #include "xregex.h" |
29 | #endif | 29 | #endif |
30 | 30 | ||
31 | |||
32 | #define ESC "\033" | ||
31 | /* The escape codes for highlighted and normal text */ | 33 | /* The escape codes for highlighted and normal text */ |
32 | #define HIGHLIGHT "\033[7m" | 34 | #define HIGHLIGHT ESC"[7m" |
33 | #define NORMAL "\033[0m" | 35 | #define NORMAL ESC"[0m" |
34 | /* The escape code to home and clear to the end of screen */ | 36 | /* The escape code to home and clear to the end of screen */ |
35 | #define CLEAR "\033[H\033[J" | 37 | #define CLEAR ESC"[H\033[J" |
36 | /* The escape code to clear to the end of line */ | 38 | /* The escape code to clear to the end of line */ |
37 | #define CLEAR_2_EOL "\033[K" | 39 | #define CLEAR_2_EOL ESC"[K" |
38 | 40 | ||
39 | enum { | 41 | enum { |
40 | /* Absolute max of lines eaten */ | 42 | /* Absolute max of lines eaten */ |
@@ -165,12 +167,12 @@ static void set_tty_cooked(void) | |||
165 | top-left corner of the console */ | 167 | top-left corner of the console */ |
166 | static void move_cursor(int line, int row) | 168 | static void move_cursor(int line, int row) |
167 | { | 169 | { |
168 | printf("\033[%u;%uH", line, row); | 170 | printf(ESC"[%u;%uH", line, row); |
169 | } | 171 | } |
170 | 172 | ||
171 | static void clear_line(void) | 173 | static void clear_line(void) |
172 | { | 174 | { |
173 | printf("\033[%u;0H" CLEAR_2_EOL, max_displayed_line + 2); | 175 | printf(ESC"[%u;0H" CLEAR_2_EOL, max_displayed_line + 2); |
174 | } | 176 | } |
175 | 177 | ||
176 | static void print_hilite(const char *str) | 178 | static void print_hilite(const char *str) |