aboutsummaryrefslogtreecommitdiff
path: root/procps
diff options
context:
space:
mode:
Diffstat (limited to 'procps')
-rw-r--r--procps/powertop.c6
-rw-r--r--procps/top.c9
-rw-r--r--procps/watch.c4
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");