diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2017-09-13 22:48:30 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2017-09-13 22:48:30 +0200 |
commit | 8187e0143874e1bf0412263e716cf8c782a5aa16 (patch) | |
tree | 289b592b43a7226bbd355728798930c9ead45893 /procps | |
parent | 136946c3ea6a14d391b5045b5eb71fa8ec207077 (diff) | |
download | busybox-8187e0143874e1bf0412263e716cf8c782a5aa16.tar.gz |
*: use ESC define instead of "\033"; use ESC[m instead of ESC[0m
text data bss dec hex filename
922535 481 6832 929848 e3038 busybox_old
922534 481 6832 929847 e3037 busybox_unstripped
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'procps')
-rw-r--r-- | procps/powertop.c | 6 | ||||
-rw-r--r-- | procps/top.c | 9 | ||||
-rw-r--r-- | procps/watch.c | 4 |
3 files changed, 12 insertions, 7 deletions
diff --git a/procps/powertop.c b/procps/powertop.c index 5d522bf91..2872035cf 100644 --- a/procps/powertop.c +++ b/procps/powertop.c @@ -51,6 +51,8 @@ /* Max filename length of entry in /sys/devices subsystem */ #define BIG_SYSNAME_LEN 16 +#define ESC "\033" + typedef unsigned long long ullong; struct line { @@ -776,8 +778,8 @@ int powertop_main(int UNUSED_PARAM argc, char UNUSED_PARAM **argv) } } - /* Clear the screen */ - printf("\033[H\033[J"); + /* Home; clear screen */ + printf(ESC"[H" ESC"[J"); /* Clear C-state lines */ memset(&cstate_lines, 0, sizeof(cstate_lines)); diff --git a/procps/top.c b/procps/top.c index f97ded5d6..b777c494e 100644 --- a/procps/top.c +++ b/procps/top.c @@ -117,6 +117,7 @@ #include "libbb.h" +#define ESC "\033" typedef struct top_status_t { unsigned long vsz; @@ -580,7 +581,7 @@ static unsigned long display_header(int scr_width, int *lines_rem_p) meminfo[MI_BUFFERS], meminfo[MI_CACHED]); /* Go to top & clear to the end of screen */ - printf(OPT_BATCH_MODE ? "%s\n" : "\033[H\033[J%s\n", scrbuf); + printf(OPT_BATCH_MODE ? "%s\n" : ESC"[H" ESC"[J" "%s\n", scrbuf); (*lines_rem_p)--; /* Display CPU time split as percentage of total time. @@ -618,7 +619,7 @@ static NOINLINE void display_process_list(int lines_rem, int scr_width) #endif /* what info of the processes is shown */ - printf(OPT_BATCH_MODE ? "%.*s" : "\033[7m%.*s\033[0m", scr_width, + printf(OPT_BATCH_MODE ? "%.*s" : ESC"[7m" "%.*s" ESC"[m", scr_width, " PID PPID USER STAT VSZ %VSZ" IF_FEATURE_TOP_SMP_PROCESS(" CPU") IF_FEATURE_TOP_CPU_USAGE_PERCENTAGE(" %CPU") @@ -802,7 +803,7 @@ static void display_topmem_header(int scr_width, int *lines_rem_p) meminfo[MI_ANONPAGES], meminfo[MI_MAPPED], meminfo[MI_MEMFREE]); - printf(OPT_BATCH_MODE ? "%.*s\n" : "\033[H\033[J%.*s\n", scr_width, line_buf); + printf(OPT_BATCH_MODE ? "%.*s\n" : ESC"[H" ESC"[J" "%.*s\n", scr_width, line_buf); snprintf(line_buf, LINE_BUF_SIZE, " slab:%lu buf:%lu cache:%lu dirty:%lu write:%lu", @@ -844,7 +845,7 @@ static NOINLINE void display_topmem_process_list(int lines_rem, int scr_width) cp[6] = ch; do *cp++ = ch; while (*cp == ' '); - printf(OPT_BATCH_MODE ? "%.*s" : "\e[7m%.*s\e[0m", scr_width, line_buf); + printf(OPT_BATCH_MODE ? "%.*s" : ESC"[7m" "%.*s" ESC"[m", scr_width, line_buf); lines_rem--; if (lines_rem > ntop - G_scroll_ofs) diff --git a/procps/watch.c b/procps/watch.c index 6fc9f7db7..e58fd1f11 100644 --- a/procps/watch.c +++ b/procps/watch.c @@ -37,6 +37,8 @@ #include "libbb.h" +#define ESC "\033" + // procps 2.0.18: // watch [-d] [-n seconds] // [--differences[=cumulative]] [--interval=seconds] command @@ -77,7 +79,7 @@ int watch_main(int argc UNUSED_PARAM, char **argv) header = NULL; while (1) { /* home; clear to the end of screen */ - printf("\033[H""\033[J"); + printf(ESC"[H" ESC"[J"); if (!(opt & 0x2)) { // no -t const unsigned time_len = sizeof("1234-67-90 23:56:89"); |