*: use ESC define instead of "\033"; use ESC[m instead of ESC[0m
No binary (build failed)
—
(log yok)
| @@ -23,9 +23,11 @@ | |
| #include "libbb.h" | |
| + | #define ESC "\033" |
| + | |
| int clear_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; | |
| int clear_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM) | |
| { | |
| /* home; clear to the end of screen */ | |
| - | return full_write1_str("\033[H""\033[J") != 6; |
| + | return full_write1_str(ESC"[H" ESC"[J") != 6; |
| } | |
| @@ -46,11 +46,11 @@ int reset_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM) | |
| /* See 'man 4 console_codes' for details: | |
| * "ESC c" -- Reset | |
| * "ESC ( B" -- Select G0 Character Set (B = US) | |
| - | * "ESC [ 0 m" -- Reset all display attributes |
| + | * "ESC [ m" -- Reset all display attributes |
| * "ESC [ J" -- Erase to the end of screen | |
| * "ESC [ ? 25 h" -- Make cursor visible | |
| */ | |
| - | printf(ESC"c" ESC"(B" ESC"[0m" ESC"[J" ESC"[?25h"); |
| + | printf(ESC"c" ESC"(B" ESC"[m" ESC"[J" ESC"[?25h"); |
| /* http://bugs.busybox.net/view.php?id=1414: | |
| * people want it to reset echo etc: */ | |
| #if ENABLE_STTY | |
| @@ -347,6 +347,8 @@ struct globals { | |
| IF_FEATURE_LS_TIMESTAMPS(time(&G.current_time_t);) \ | |
| } while (0) | |
| + | #define ESC "\033" |
| + | |
| /*** Output code ***/ | |
| @@ -586,12 +588,12 @@ static NOINLINE unsigned display_single(const struct dnode *dn) | |
| if (!mode) | |
| if (lstat(dn->fullname, &statbuf) == 0) | |
| mode = statbuf.st_mode; | |
| - | printf("\033[%u;%um", bold(mode), fgcolor(mode)); |
| + | printf(ESC"[%u;%um", bold(mode), fgcolor(mode)); |
| } | |
| #endif | |
| column += print_name(dn->name); | |
| if (G_show_color) { | |
| - | printf("\033[0m"); |
| + | printf(ESC"[m"); |
| } | |
| if (lpath) { | |
| @@ -609,7 +611,7 @@ static NOINLINE unsigned display_single(const struct dnode *dn) | |
| # endif | |
| # if ENABLE_FEATURE_LS_COLOR | |
| if (G_show_color) { | |
| - | printf("\033[%u;%um", bold(mode), fgcolor(mode)); |
| + | printf(ESC"[%u;%um", bold(mode), fgcolor(mode)); |
| } | |
| # endif | |
| } | |
| @@ -617,7 +619,7 @@ static NOINLINE unsigned display_single(const struct dnode *dn) | |
| column += print_name(lpath) + 4; | |
| free(lpath); | |
| if (G_show_color) { | |
| - | printf("\033[0m"); |
| + | printf(ESC"[m"); |
| } | |
| } | |
| #if ENABLE_FEATURE_LS_FILETYPES | |
| @@ -224,24 +224,25 @@ enum { | |
| * See "Xterm Control Sequences" | |
| * http://invisible-island.net/xterm/ctlseqs/ctlseqs.html | |
| */ | |
| + | #define ESC "\033" |
| /* Inverse/Normal text */ | |
| - | #define ESC_BOLD_TEXT "\033[7m" |
| - | #define ESC_NORM_TEXT "\033[0m" |
| + | #define ESC_BOLD_TEXT ESC"[7m" |
| + | #define ESC_NORM_TEXT ESC"[m" |
| /* Bell */ | |
| #define ESC_BELL "\007" | |
| /* Clear-to-end-of-line */ | |
| - | #define ESC_CLEAR2EOL "\033[K" |
| + | #define ESC_CLEAR2EOL ESC"[K" |
| /* Clear-to-end-of-screen. | |
| * (We use default param here. | |
| * Full sequence is "ESC [ <num> J", | |
| * <num> is 0/1/2 = "erase below/above/all".) | |
| */ | |
| - | #define ESC_CLEAR2EOS "\033[J" |
| + | #define ESC_CLEAR2EOS ESC"[J" |
| /* Cursor to given coordinate (1,1: top left) */ | |
| - | #define ESC_SET_CURSOR_POS "\033[%u;%uH" |
| + | #define ESC_SET_CURSOR_POS ESC"[%u;%uH" |
| //UNUSED | |
| ///* Cursor up and down */ | |
| - | //#define ESC_CURSOR_UP "\033[A" |
| + | //#define ESC_CURSOR_UP ESC"[A" |
| //#define ESC_CURSOR_DOWN "\n" | |
| #if ENABLE_FEATURE_VI_DOT_CMD || ENABLE_FEATURE_VI_YANKMARK | |
| @@ -696,14 +697,14 @@ int vi_main(int argc, char **argv) | |
| save_argc = argc; | |
| optind = 0; | |
| // "Save cursor, use alternate screen buffer, clear screen" | |
| - | write1("\033[?1049h"); |
| + | write1(ESC"[?1049h"); |
| while (1) { | |
| edit_file(argv[optind]); /* param might be NULL */ | |
| if (++optind >= argc) | |
| break; | |
| } | |
| // "Use normal screen buffer, restore cursor" | |
| - | write1("\033[?1049l"); |
| + | write1(ESC"[?1049l"); |
| //----------------------------------------------------------- | |
| return 0; | |
| @@ -772,7 +773,7 @@ static void edit_file(char *fn) | |
| #if ENABLE_FEATURE_VI_ASK_TERMINAL | |
| if (G.get_rowcol_error /* TODO? && no input on stdin */) { | |
| uint64_t k; | |
| - | write1("\033[999;999H" "\033[6n"); |
| + | write1(ESC"[999;999H" ESC"[6n"); |
| fflush_all(); | |
| k = read_key(STDIN_FILENO, readbuffer, /*timeout_ms:*/ 100); | |
| if ((int32_t)k == KEYCODE_CURSOR_POS) { | |
| @@ -4454,7 +4455,7 @@ static void crash_dummy() | |
| sleeptime = 0; // how fast to type | |
| } | |
| } | |
| - | strcat(readbuffer, "\033"); |
| + | strcat(readbuffer, ESC); |
| } | |
| readbuffer[0] = strlen(readbuffer + 1); | |
| cd1: | |
| @@ -2868,7 +2868,7 @@ int main(int argc, char **argv) | |
| #if ENABLE_FEATURE_EDITING_FANCY_PROMPT | |
| "\\[\\033[32;1m\\]\\u@\\[\\x1b[33;1m\\]\\h:" | |
| "\\[\\033[34;1m\\]\\w\\[\\033[35;1m\\] " | |
| - | "\\!\\[\\e[36;1m\\]\\$ \\[\\E[0m\\]"; |
| + | "\\!\\[\\e[36;1m\\]\\$ \\[\\E[m\\]"; |
| #else | |
| "% "; | |
| #endif | |
| @@ -65,6 +65,8 @@ | |
| /* If you want logging messages on /tmp/fbsplash.log... */ | |
| #define DEBUG 0 | |
| + | #define ESC "\033" |
| + | |
| struct globals { | |
| #if DEBUG | |
| bool bdebug_messages; // enable/disable logging | |
| @@ -514,7 +516,7 @@ int fbsplash_main(int argc UNUSED_PARAM, char **argv) | |
| if (fifo_filename && bCursorOff) { | |
| // hide cursor (BEFORE any fb ops) | |
| - | full_write(STDOUT_FILENO, "\033[?25l", 6); |
| + | full_write(STDOUT_FILENO, ESC"[?25l", 6); |
| } | |
| fb_drawimage(); | |
| @@ -559,7 +561,7 @@ int fbsplash_main(int argc UNUSED_PARAM, char **argv) | |
| } | |
| if (bCursorOff) // restore cursor | |
| - | full_write(STDOUT_FILENO, "\033[?25h", 6); |
| + | full_write(STDOUT_FILENO, ESC"[?25h", 6); |
| return EXIT_SUCCESS; | |
| } | |
| @@ -137,7 +137,7 @@ | |
| #define ESC "\033" | |
| /* The escape codes for highlighted and normal text */ | |
| #define HIGHLIGHT ESC"[7m" | |
| - | #define NORMAL ESC"[0m" |
| + | #define NORMAL ESC"[m" |
| /* The escape code to home and clear to the end of screen */ | |
| #define CLEAR ESC"[H"ESC"[J" | |
| /* The escape code to clear to the end of line */ | |
| @@ -1042,7 +1042,7 @@ static void reinitialize(void) | |
| open_file_and_read_lines(); | |
| #if ENABLE_FEATURE_LESS_ASK_TERMINAL | |
| if (G.winsize_err) | |
| - | printf("\033[999;999H" "\033[6n"); |
| + | printf(ESC"[999;999H" ESC"[6n"); |
| #endif | |
| buffer_fill_and_print(); | |
| } | |
| @@ -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"); | |