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-w32-8187e0143874e1bf0412263e716cf8c782a5aa16.tar.gz busybox-w32-8187e0143874e1bf0412263e716cf8c782a5aa16.tar.bz2 busybox-w32-8187e0143874e1bf0412263e716cf8c782a5aa16.zip |
*: 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 @@ | |||
51 | /* Max filename length of entry in /sys/devices subsystem */ | 51 | /* Max filename length of entry in /sys/devices subsystem */ |
52 | #define BIG_SYSNAME_LEN 16 | 52 | #define BIG_SYSNAME_LEN 16 |
53 | 53 | ||
54 | #define ESC "\033" | ||
55 | |||
54 | typedef unsigned long long ullong; | 56 | typedef unsigned long long ullong; |
55 | 57 | ||
56 | struct line { | 58 | struct line { |
@@ -776,8 +778,8 @@ int powertop_main(int UNUSED_PARAM argc, char UNUSED_PARAM **argv) | |||
776 | } | 778 | } |
777 | } | 779 | } |
778 | 780 | ||
779 | /* Clear the screen */ | 781 | /* Home; clear screen */ |
780 | printf("\033[H\033[J"); | 782 | printf(ESC"[H" ESC"[J"); |
781 | 783 | ||
782 | /* Clear C-state lines */ | 784 | /* Clear C-state lines */ |
783 | memset(&cstate_lines, 0, sizeof(cstate_lines)); | 785 | 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 @@ | |||
117 | 117 | ||
118 | #include "libbb.h" | 118 | #include "libbb.h" |
119 | 119 | ||
120 | #define ESC "\033" | ||
120 | 121 | ||
121 | typedef struct top_status_t { | 122 | typedef struct top_status_t { |
122 | unsigned long vsz; | 123 | unsigned long vsz; |
@@ -580,7 +581,7 @@ static unsigned long display_header(int scr_width, int *lines_rem_p) | |||
580 | meminfo[MI_BUFFERS], | 581 | meminfo[MI_BUFFERS], |
581 | meminfo[MI_CACHED]); | 582 | meminfo[MI_CACHED]); |
582 | /* Go to top & clear to the end of screen */ | 583 | /* Go to top & clear to the end of screen */ |
583 | printf(OPT_BATCH_MODE ? "%s\n" : "\033[H\033[J%s\n", scrbuf); | 584 | printf(OPT_BATCH_MODE ? "%s\n" : ESC"[H" ESC"[J" "%s\n", scrbuf); |
584 | (*lines_rem_p)--; | 585 | (*lines_rem_p)--; |
585 | 586 | ||
586 | /* Display CPU time split as percentage of total time. | 587 | /* 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) | |||
618 | #endif | 619 | #endif |
619 | 620 | ||
620 | /* what info of the processes is shown */ | 621 | /* what info of the processes is shown */ |
621 | printf(OPT_BATCH_MODE ? "%.*s" : "\033[7m%.*s\033[0m", scr_width, | 622 | printf(OPT_BATCH_MODE ? "%.*s" : ESC"[7m" "%.*s" ESC"[m", scr_width, |
622 | " PID PPID USER STAT VSZ %VSZ" | 623 | " PID PPID USER STAT VSZ %VSZ" |
623 | IF_FEATURE_TOP_SMP_PROCESS(" CPU") | 624 | IF_FEATURE_TOP_SMP_PROCESS(" CPU") |
624 | IF_FEATURE_TOP_CPU_USAGE_PERCENTAGE(" %CPU") | 625 | IF_FEATURE_TOP_CPU_USAGE_PERCENTAGE(" %CPU") |
@@ -802,7 +803,7 @@ static void display_topmem_header(int scr_width, int *lines_rem_p) | |||
802 | meminfo[MI_ANONPAGES], | 803 | meminfo[MI_ANONPAGES], |
803 | meminfo[MI_MAPPED], | 804 | meminfo[MI_MAPPED], |
804 | meminfo[MI_MEMFREE]); | 805 | meminfo[MI_MEMFREE]); |
805 | printf(OPT_BATCH_MODE ? "%.*s\n" : "\033[H\033[J%.*s\n", scr_width, line_buf); | 806 | printf(OPT_BATCH_MODE ? "%.*s\n" : ESC"[H" ESC"[J" "%.*s\n", scr_width, line_buf); |
806 | 807 | ||
807 | snprintf(line_buf, LINE_BUF_SIZE, | 808 | snprintf(line_buf, LINE_BUF_SIZE, |
808 | " slab:%lu buf:%lu cache:%lu dirty:%lu write:%lu", | 809 | " 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) | |||
844 | cp[6] = ch; | 845 | cp[6] = ch; |
845 | do *cp++ = ch; while (*cp == ' '); | 846 | do *cp++ = ch; while (*cp == ' '); |
846 | 847 | ||
847 | printf(OPT_BATCH_MODE ? "%.*s" : "\e[7m%.*s\e[0m", scr_width, line_buf); | 848 | printf(OPT_BATCH_MODE ? "%.*s" : ESC"[7m" "%.*s" ESC"[m", scr_width, line_buf); |
848 | lines_rem--; | 849 | lines_rem--; |
849 | 850 | ||
850 | if (lines_rem > ntop - G_scroll_ofs) | 851 | 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 @@ | |||
37 | 37 | ||
38 | #include "libbb.h" | 38 | #include "libbb.h" |
39 | 39 | ||
40 | #define ESC "\033" | ||
41 | |||
40 | // procps 2.0.18: | 42 | // procps 2.0.18: |
41 | // watch [-d] [-n seconds] | 43 | // watch [-d] [-n seconds] |
42 | // [--differences[=cumulative]] [--interval=seconds] command | 44 | // [--differences[=cumulative]] [--interval=seconds] command |
@@ -77,7 +79,7 @@ int watch_main(int argc UNUSED_PARAM, char **argv) | |||
77 | header = NULL; | 79 | header = NULL; |
78 | while (1) { | 80 | while (1) { |
79 | /* home; clear to the end of screen */ | 81 | /* home; clear to the end of screen */ |
80 | printf("\033[H""\033[J"); | 82 | printf(ESC"[H" ESC"[J"); |
81 | if (!(opt & 0x2)) { // no -t | 83 | if (!(opt & 0x2)) { // no -t |
82 | const unsigned time_len = sizeof("1234-67-90 23:56:89"); | 84 | const unsigned time_len = sizeof("1234-67-90 23:56:89"); |
83 | 85 | ||