*: 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>
This commit is contained in:
@@ -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));
|
||||
|
@@ -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)
|
||||
|
@@ -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");
|
||||
|
||||
|
Reference in New Issue
Block a user