diff --git a/libr/core/cmd_anal.c b/libr/core/cmd_anal.c index 19cc1f741b35d..0ecdd784a721c 100644 --- a/libr/core/cmd_anal.c +++ b/libr/core/cmd_anal.c @@ -1392,7 +1392,7 @@ static void core_anal_bytes(RCore *core, const ut8 *buf, int len, int nops, int // 0x33->sym.xx char *p = strdup (strsub); r_parse_filter (core->parser, core->flags, p, - strsub, sizeof (strsub), be); + strsub, sizeof (strsub), be, core->cons->use_utf8); free (p); r_cons_printf ("\"disasm\":\"%s\",", strsub); } @@ -5276,7 +5276,7 @@ static bool cmd_anal_refs(RCore *core, const char *input) { asmop.buf_asm, asmop.buf_asm, sizeof (asmop.buf_asm)); } r_parse_filter (core->parser, core->flags, - asmop.buf_asm, str, sizeof (str), core->print->big_endian); + asmop.buf_asm, str, sizeof (str), core->print->big_endian, core->cons->use_utf8); r_cons_printf ("{\"from\":%" PFMT64u ",\"type\":\"%s\",\"opcode\":\"%s\"", ref->addr, r_anal_xrefs_type_tostring (ref->type), str); if (fcn) { @@ -5340,7 +5340,7 @@ static bool cmd_anal_refs(RCore *core, const char *input) { asmop.buf_asm, asmop.buf_asm, sizeof (asmop.buf_asm)); } r_parse_filter (core->parser, core->flags, - asmop.buf_asm, str, sizeof (str), core->print->big_endian); + asmop.buf_asm, str, sizeof (str), core->print->big_endian, core->cons->use_utf8); if (has_color) { buf_asm = r_print_colorize_opcode (core->print, str, core->cons->pal.reg, core->cons->pal.num, false); @@ -5417,7 +5417,7 @@ static bool cmd_anal_refs(RCore *core, const char *input) { r_asm_set_pc (core->assembler, ref->at); r_asm_disassemble (core->assembler, &asmop, buf, 12); r_parse_filter (core->parser, core->flags, - asmop.buf_asm, str, sizeof (str), core->print->big_endian); + asmop.buf_asm, str, sizeof (str), core->print->big_endian, core->cons->use_utf8); if (has_color) { buf_asm = r_print_colorize_opcode (core->print, str, core->cons->pal.reg, core->cons->pal.num, false); diff --git a/libr/core/cmd_flag.c b/libr/core/cmd_flag.c index 84157ecccdaff..0a85a9d0e1baa 100644 --- a/libr/core/cmd_flag.c +++ b/libr/core/cmd_flag.c @@ -817,7 +817,7 @@ static int cmd_flag(void *data, const char *input) { case '*': // "f*" case 'j': // "fj" case 'q': // "fq" - r_flag_list (core->flags, *input, input[0]? input + 1: ""); + r_flag_list (core->flags, *input, input[0]? input + 1: "", core->cons->use_utf8); break; case 'i': // "fi" if (input[1] == ' ' || input[2] == ' ') { @@ -840,13 +840,13 @@ static int cmd_flag(void *data, const char *input) { arg = r_str_newf (" 0x%"PFMT64x" 0x%"PFMT64x, core->offset, core->offset + core->blocksize); } - r_flag_list (core->flags, 'i', arg); + r_flag_list (core->flags, 'i', arg, core->cons->use_utf8); free (arg); } else { // XXX dupe for prev case char *arg = r_str_newf (" 0x%"PFMT64x" 0x%"PFMT64x, core->offset, core->offset + core->blocksize); - r_flag_list (core->flags, 'i', arg); + r_flag_list (core->flags, 'i', arg, core->cons->use_utf8); free (arg); } break; diff --git a/libr/core/cmd_search.c b/libr/core/cmd_search.c index c6828bb70a3cb..d2a92716dc3a9 100644 --- a/libr/core/cmd_search.c +++ b/libr/core/cmd_search.c @@ -1823,7 +1823,7 @@ static void do_ref_search(RCore *core, ut64 addr,ut64 from, ut64 to, struct sear r_asm_disassemble (core->assembler, &asmop, buf, size); fcn = r_anal_get_fcn_in (core->anal, ref->addr, 0); r_parse_filter (core->parser, core->flags, - asmop.buf_asm, str, sizeof (str), core->print->big_endian); + asmop.buf_asm, str, sizeof (str), core->print->big_endian, core->cons->use_utf8); comment = r_meta_get_string (core->anal, R_META_TYPE_COMMENT, ref->addr); char *buf_fcn = comment ? r_str_newf ("%s; %s", fcn ? fcn->name : "(nofunc)", strtok (comment, "\n")) @@ -2082,7 +2082,8 @@ static void do_asm_search(RCore *core, struct search_parameters *param, const ch char tmp[128] = { 0 }; - r_parse_filter (core->parser, core->flags, hit->code, tmp, sizeof (tmp), core->print->big_endian); + r_parse_filter (core->parser, core->flags, hit->code, tmp, sizeof (tmp), + core->print->big_endian, core->cons->use_utf8); r_cons_printf ("0x%08"PFMT64x " # %i: %s\n", hit->addr, hit->len, tmp); } else { diff --git a/libr/core/cmd_zign.c b/libr/core/cmd_zign.c index 8fcc4f6e40a14..3f4a9a1bc5264 100644 --- a/libr/core/cmd_zign.c +++ b/libr/core/cmd_zign.c @@ -782,7 +782,7 @@ static int cmdInfo(void *data, const char *input) { } RCore *core = (RCore *) data; r_flag_space_push (core->flags, "sign"); - r_flag_list (core->flags, *input, input[0] ? input + 1: ""); + r_flag_list (core->flags, *input, input[0] ? input + 1: "", core->cons->use_utf8); r_flag_space_pop (core->flags); return true; } diff --git a/libr/core/disasm.c b/libr/core/disasm.c index 1d2da1545b006..05897d1a9e271 100644 --- a/libr/core/disasm.c +++ b/libr/core/disasm.c @@ -968,7 +968,7 @@ static void ds_build_op_str(RDisasmState *ds, bool print_color) { } } r_parse_filter (core->parser, core->flags, asm_str, - ds->str, sizeof (ds->str), core->print->big_endian); + ds->str, sizeof (ds->str), core->print->big_endian, core->cons->use_utf8); core->parser->flagspace = ofs; free (ds->opstr); ds->opstr = strdup (ds->str); @@ -5029,7 +5029,7 @@ R_API int r_core_print_disasm_instructions(RCore *core, int nb_bytes, int nb_opc } core->parser->hint = ds->hint; r_parse_filter (core->parser, core->flags, ds->asmop.buf_asm, ds->str, - sizeof (ds->str), core->print->big_endian); + sizeof (ds->str), core->print->big_endian, core->cons->use_utf8); ds->opstr = strdup (ds->str); asm_str = colorize_asm_string (core, ds, true); core->parser->flagspace = ofs; @@ -5223,7 +5223,7 @@ R_API int r_core_print_disasm_json(RCore *core, ut64 addr, ut8 *buf, int nb_byte } } r_parse_filter (core->parser, core->flags, asmop.buf_asm, str, - sizeof (str), core->print->big_endian); + sizeof (str), core->print->big_endian, core->cons->use_utf8); r_cons_printf (j > 0 ? ",{" : "{"); r_cons_printf ("\"offset\":%"PFMT64d, at); @@ -5401,7 +5401,7 @@ R_API int r_core_print_disasm_all(RCore *core, ut64 addr, int l, int len, int mo switch (mode) { case 'i': r_parse_filter (core->parser, core->flags, asmop.buf_asm, - str, sizeof (str), core->print->big_endian); + str, sizeof (str), core->print->big_endian, core->cons->use_utf8); if (scr_color) { char *buf_asm; RAnalOp aop; @@ -5887,7 +5887,7 @@ R_API int r_core_disasm_pdi(RCore *core, int nb_opcodes, int nb_bytes, int fmt) if (filter) { core->parser->hint = r_anal_hint_get (core->anal, at); r_parse_filter (core->parser, core->flags, - asm_str, opstr, sizeof (opstr) - 1, core->print->big_endian); + asm_str, opstr, sizeof (opstr) - 1, core->print->big_endian, core->cons->use_utf8); asm_str = (char *)&opstr; } if (show_color) { diff --git a/libr/core/project.c b/libr/core/project.c index cb50296d66900..8393d3b6e6eab 100644 --- a/libr/core/project.c +++ b/libr/core/project.c @@ -653,7 +653,7 @@ static bool projectSaveScript(RCore *core, const char *file, int opts) { r_str_write (fd, "# flags\n"); tmp = core->flags->space_idx; core->flags->space_idx = -1; - r_flag_list (core->flags, true, NULL); + r_flag_list (core->flags, true, NULL, core->cons->use_utf8); core->flags->space_idx = tmp; r_cons_flush (); } diff --git a/libr/flag/flag.c b/libr/flag/flag.c index cfa61d21786cc..7eeb5be2a0b73 100644 --- a/libr/flag/flag.c +++ b/libr/flag/flag.c @@ -3,7 +3,6 @@ #include #include #include -#include #include R_LIB_VERSION(r_flag); @@ -209,7 +208,7 @@ R_API RFlag *r_flag_free(RFlag *f) { } /* print with r_cons the flag items in the flag f, given as a parameter */ -R_API void r_flag_list(RFlag *f, int rad, const char *pfx) { +R_API void r_flag_list(RFlag *f, int rad, const char *pfx, bool flag_realnames) { bool in_range = false; ut64 range_from = UT64_MAX; ut64 range_to = UT64_MAX; @@ -331,9 +330,8 @@ R_API void r_flag_list(RFlag *f, int rad, const char *pfx) { f->cb_printf ("%s %"PFMT64d" %s\n", flag->alias, flag->size, flag->name); } else { - bool utf8 = r_cons_singleton ()->use_utf8; f->cb_printf ("0x%08"PFMT64x" %"PFMT64d" %s\n", - flag->offset, flag->size, utf8 ? flag->realname : flag->name); + flag->offset, flag->size, flag_realnames ? flag->realname : flag->name); } } break; diff --git a/libr/include/r_flag.h b/libr/include/r_flag.h index 0da53c3f323c7..b8da323120feb 100644 --- a/libr/include/r_flag.h +++ b/libr/include/r_flag.h @@ -91,7 +91,7 @@ R_API int r_flag_bind(RFlag *io, RFlagBind *bnd); #ifdef R_API R_API RFlag * r_flag_new(void); R_API RFlag * r_flag_free(RFlag *f); -R_API void r_flag_list(RFlag *f, int rad, const char *pfx); +R_API void r_flag_list(RFlag *f, int rad, const char *pfx, bool flag_realnames); R_API bool r_flag_exist_at(RFlag *f, const char *flag_prefix, ut16 fp_size, ut64 off); R_API RFlagItem *r_flag_get(RFlag *f, const char *name); R_API RFlagItem *r_flag_get_i(RFlag *f, ut64 off); diff --git a/libr/include/r_parse.h b/libr/include/r_parse.h index 144da6ca97d03..07a490ca3f0ff 100644 --- a/libr/include/r_parse.h +++ b/libr/include/r_parse.h @@ -57,7 +57,7 @@ R_API int r_parse_list(RParse *p); R_API int r_parse_use(RParse *p, const char *name); R_API int r_parse_parse(RParse *p, const char *data, char *str); R_API int r_parse_assemble(RParse *p, char *data, char *str); -R_API int r_parse_filter(RParse *p, RFlag *f, char *data, char *str, int len, bool big_endian); +R_API int r_parse_filter(RParse *p, RFlag *f, char *data, char *str, int len, bool big_endian, bool flag_realnames); R_API bool r_parse_varsub(RParse *p, RAnalFunction *f, ut64 addr, int oplen, char *data, char *str, int len); R_API char *r_parse_c_string(RAnal *anal, const char *code); R_API char *r_parse_c_file(RAnal *anal, const char *path); diff --git a/libr/parse/parse.c b/libr/parse/parse.c index 840c52776efb5..f4e9036abe0df 100644 --- a/libr/parse/parse.c +++ b/libr/parse/parse.c @@ -175,7 +175,7 @@ static char *findNextNumber(char *op) { return NULL; } -static int filter(RParse *p, RFlag *f, char *data, char *str, int len, bool big_endian) { +static int filter(RParse *p, RFlag *f, char *data, char *str, int len, bool big_endian, bool flag_realnames) { char *ptr = data, *ptr2, *ptr_backup; RAnalFunction *fcn; RFlagItem *flag; @@ -276,8 +276,7 @@ static int filter(RParse *p, RFlag *f, char *data, char *str, int len, bool big_ } } *ptr = 0; - bool utf8 = r_cons_singleton ()->use_utf8; - snprintf (str, len, "%s%s%s", data, utf8? flag->realname : flag->name, + snprintf (str, len, "%s%s%s", data, flag_realnames? flag->realname : flag->name, (ptr != ptr2) ? ptr2 : ""); bool banned = false; { @@ -528,8 +527,8 @@ R_API bool r_parse_immtrim (char *opstr) { return changed; } -R_API int r_parse_filter(RParse *p, RFlag *f, char *data, char *str, int len, bool big_endian) { - filter (p, f, data, str, len, big_endian); +R_API int r_parse_filter(RParse *p, RFlag *f, char *data, char *str, int len, bool big_endian, bool flag_realnames) { + filter (p, f, data, str, len, big_endian, flag_realnames); if (p->cur && p->cur->filter) { return p->cur->filter (p, f, data, str, len, big_endian); }