From 03504d5b49bea78cdf93e471f39f7fce9e40232e Mon Sep 17 00:00:00 2001 From: Anton Kochkov Date: Fri, 9 Feb 2024 23:13:47 +0800 Subject: [PATCH] Remove scr.rainbow option --- librz/core/cconfig.c | 15 --------------- librz/core/cmd/cmd_print.c | 3 --- librz/include/rz_util/rz_print.h | 1 - librz/util/float/float.c | 4 ++++ librz/util/print.c | 14 -------------- test/db/cmd/cmd_eval | 12 ++++++------ 6 files changed, 10 insertions(+), 39 deletions(-) diff --git a/librz/core/cconfig.c b/librz/core/cconfig.c index 8ed82de06d1..54cc7d7ec25 100644 --- a/librz/core/cconfig.c +++ b/librz/core/cconfig.c @@ -351,20 +351,6 @@ static bool cb_scr_wideoff(void *user, void *data) { return true; } -static bool cb_scrrainbow(void *user, void *data) { - RzCore *core = (RzCore *)user; - RzConfigNode *node = (RzConfigNode *)data; - if (node->i_value) { - core->print->flags |= RZ_PRINT_FLAGS_RAINBOW; - rz_cons_pal_random(); - } else { - core->print->flags &= (~RZ_PRINT_FLAGS_RAINBOW); - rz_core_theme_load(core, rz_core_theme_get(core)); - } - rz_print_set_flags(core->print, core->print->flags); - return true; -} - static bool cb_asmpseudo(void *user, void *data) { RzCore *core = (RzCore *)user; RzConfigNode *node = (RzConfigNode *)data; @@ -3147,7 +3133,6 @@ RZ_API int rz_core_config_init(RzCore *core) { SETCB("scr.prompt.vi", "false", &cb_scr_vi, "Use vi mode for input prompt"); SETCB("scr.prompt.mode", "false", &cb_scr_prompt_mode, "Set prompt color based on vi mode"); SETCB("scr.wideoff", "false", &cb_scr_wideoff, "Adjust offsets to match asm.bits"); - SETCB("scr.rainbow", "false", &cb_scrrainbow, "Shows rainbow colors depending of address"); SETCB("scr.last", "true", &cb_scrlast, "Cache last output after flush to make _ command work (disable for performance)"); SETBPREF("asm.reloff", "false", "Show relative offsets instead of absolute address in disasm"); SETBPREF("asm.reloff.flags", "false", "Show relative offsets to flags (not only functions)"); diff --git a/librz/core/cmd/cmd_print.c b/librz/core/cmd/cmd_print.c index 76db01484e0..0b792305355 100644 --- a/librz/core/cmd/cmd_print.c +++ b/librz/core/cmd/cmd_print.c @@ -3122,9 +3122,6 @@ RZ_API void rz_print_offset_sg(RzPrint *p, ut64 off, int invert, int offseg, int char rgbstr[32]; const char *k = rz_cons_singleton()->context->pal.offset; // TODO etooslow. must cache const char *inv = invert ? RZ_CONS_INVERT(true, true) : ""; - if (p->flags & RZ_PRINT_FLAGS_RAINBOW) { - k = rz_cons_rgb_str_off(rgbstr, sizeof(rgbstr), off); - } if (offseg) { ut32 s, a; a = off & 0xffff; diff --git a/librz/include/rz_util/rz_print.h b/librz/include/rz_util/rz_print.h index 32e607aa787..bddf02bb5c0 100644 --- a/librz/include/rz_util/rz_print.h +++ b/librz/include/rz_util/rz_print.h @@ -26,7 +26,6 @@ extern "C" { #define RZ_PRINT_FLAGS_COMPACT 0x00000800 #define RZ_PRINT_FLAGS_NONHEX 0x00001000 #define RZ_PRINT_FLAGS_SECSUB 0x00002000 -#define RZ_PRINT_FLAGS_RAINBOW 0x00004000 #define RZ_PRINT_FLAGS_HDROFF 0x00008000 #define RZ_PRINT_FLAGS_STYLE 0x00010000 #define RZ_PRINT_FLAGS_NONASCII 0x00020000 diff --git a/librz/util/float/float.c b/librz/util/float/float.c index 5463e908f67..15e340e968a 100644 --- a/librz/util/float/float.c +++ b/librz/util/float/float.c @@ -27,6 +27,8 @@ */ #define define_types_gen_nan(fname, ftype) \ RZ_API ftype rz_types_gen_##fname##_nan() { \ + /* The static modifier is on purpose and necessary for all compilers + * to avoid optimizing them and generate NaN values portably */ \ static ftype zero = 0; \ ftype ret = zero / zero; \ feclearexcept(FE_ALL_EXCEPT); \ @@ -35,6 +37,8 @@ #define define_types_gen_inf(fname, ftype) \ RZ_API ftype rz_types_gen_##fname##_inf() { \ + /* The static modifier is on purpose and necessary for all compilers + * to avoid optimizing them and generate NaN values portably */ \ static ftype zero = 0; \ static ftype one = 1.0; \ ftype ret = one / zero; \ diff --git a/librz/util/print.c b/librz/util/print.c index 69d426f69d4..2db84b77124 100644 --- a/librz/util/print.c +++ b/librz/util/print.c @@ -264,15 +264,8 @@ RZ_API char *rz_print_hexpair(RzPrint *p, const char *str, int n) { return dst; } -static char colorbuffer[64]; #define P(x) (p->cons && p->cons->context->pal.x) ? p->cons->context->pal.x RZ_API const char *rz_print_byte_color(RzPrint *p, int ch) { - if (p->flags & RZ_PRINT_FLAGS_RAINBOW) { - // EXPERIMENTAL - int bg = (p->flags & RZ_PRINT_FLAGS_NONHEX) ? 48 : 38; - snprintf(colorbuffer, sizeof(colorbuffer), "\033[%d;5;%dm", bg, ch); - return colorbuffer; - } const bool use_color = p->flags & RZ_PRINT_FLAGS_COLOR; if (!use_color) { return NULL; @@ -452,16 +445,9 @@ static inline void print_addr(RzStrBuf *sb, RzPrint *p, ut64 addr) { white = allocated = rz_str_pad(' ', w); } if (use_color) { - char rgbstr[32] = { 0 }; const char *pre = PREOFF(offset) : Color_GREEN; const char *fin = Color_RESET; - if (p && p->flags & RZ_PRINT_FLAGS_RAINBOW) { - // pre = rz_cons_rgb_str_off (rgbstr, addr); - if (p->cons && p->cons->rgbstr) { - pre = p->cons->rgbstr(rgbstr, sizeof(rgbstr), addr); - } - } if (dec) { rz_strbuf_appendf(sb, "%s%s%" PFMT64d "%s%c", pre, white, addr, fin, ch); } else { diff --git a/test/db/cmd/cmd_eval b/test/db/cmd/cmd_eval index 7c24b7cc8dd..d2244f68a3d 100644 --- a/test/db/cmd/cmd_eval +++ b/test/db/cmd/cmd_eval @@ -82,13 +82,13 @@ RUN NAME=multiple assignments FILE== CMDS=<