Prevent dup flag cmt if scr.color > 0 (#6501)

This commit is contained in:
Khairul Azhar Kasmiran 2026-06-13 14:30:24 +08:00 committed by GitHub
parent f832acdb5d
commit 8abb4ca4d3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 20 additions and 14 deletions

View file

@ -231,6 +231,7 @@ typedef struct {
char *refline, *refline2;
char *comment;
char *opstr;
char *opstr_nocolor;
char *osl, *sl;
int index;
ut64 at, vat, addr, dest;
@ -857,6 +858,7 @@ static void ds_free(RzDisasmState *ds) {
free(ds->refline2);
free(ds->prev_line_col);
free(ds->opstr);
free(ds->opstr_nocolor);
free(ds->osl);
free(ds->sl);
free(ds->_tabsbuf);
@ -965,7 +967,8 @@ static void ds_opstr_try_colorize(RzDisasmState *ds, bool print_color) {
return;
}
char *new_opstr = rz_strbuf_drain(colored_asm);
free(ds->opstr);
free(ds->opstr_nocolor);
ds->opstr_nocolor = ds->opstr;
ds->opstr = new_opstr;
}
@ -3621,7 +3624,7 @@ static void ds_print_fcn_name(RzDisasmState *ds) {
} else if (delta < 0) {
ds_begin_comment(ds);
ds_comment(ds, true, "; %s-0x%" PFMT64x, f->name, (ut64)(-delta));
} else if ((!ds->core->vmode || (!ds->subjmp && !ds->subnames)) && (!ds->opstr || !strstr(ds->opstr, f->name))) {
} else if ((!ds->core->vmode || (!ds->subjmp && !ds->subnames)) && (!ds->opstr || !strstr(ds->opstr_nocolor ? ds->opstr_nocolor : ds->opstr, f->name))) {
RzFlagItem *flag_sym;
if (ds->core->vmode && (flag_sym = rz_flag_get_by_spaces(ds->core->flags, ds->analysis_op.jump, RZ_FLAGS_FS_SYMBOLS, NULL)) && flag_sym->demangled) {
return;

View file

@ -949,21 +949,24 @@ EXPECT=<<EOF
EOF
RUN
NAME=asm.flags.real -- section flag at imported func
NAME=asm.flags.real -- section flag at imported func; no dup cmt flag if color
FILE=bins/elf/_Exit_0x91
CMDS=<<EOF
aF
e asm.flags.real=true
pdf
aa
(pdcall real?; e asm.flags.real=${real?}; pd 1 @ $$+`aos 4`)
e scr.color=0
.(pdcall false)
.(pdcall true)
echo
e scr.color=1
.(pdcall false)
.(pdcall true)
EOF
EXPECT=<<EOF
;-- section..text:
;-- _start:
/ entry0();
| 0x00001030 endbr64 ; [11] -r-x section size 18 named .text
| 0x00001034 push rbp
| 0x00001035 mov rbp, rsp
| 0x00001038 mov edi, 0x91
\ 0x0000103d call _Exit
\ 0x0000103d call sym.imp._Exit ; void _Exit(int status)
\ 0x0000103d call _Exit ; sym.imp._Exit ; void _Exit(int status)
\ 0x0000103d call sym.imp._Exit ; void _Exit(int status)
\ 0x0000103d call _Exit ; sym.imp._Exit ; void _Exit(int status)
EOF
RUN