mirror of
https://github.com/radareorg/radare2.git
synced 2024-11-23 13:19:54 +00:00
Fix scr.html in pdc ##cons
This commit is contained in:
parent
f779a9be0d
commit
eb885640c4
@ -1,4 +1,4 @@
|
||||
/* radare - LGPL - Copyright 2009-2023 - pancake, nibble */
|
||||
/* radare - LGPL - Copyright 2009-2024 - pancake, nibble */
|
||||
|
||||
#include <r_cons.h>
|
||||
|
||||
@ -48,7 +48,7 @@ R_API char *r_cons_html_filter(const char *ptr, int *newlen) {
|
||||
if (!res) {
|
||||
return NULL;
|
||||
}
|
||||
for (; ptr[0]; ptr = ptr + 1) {
|
||||
for (; ptr[0]; ptr++) {
|
||||
if (esc == 0 && ptr[0] != 0x1b && need_to_set) {
|
||||
if (has_set) {
|
||||
r_strbuf_append (res, "</font>");
|
||||
@ -82,15 +82,19 @@ R_API char *r_cons_html_filter(const char *ptr, int *newlen) {
|
||||
need_to_set = false;
|
||||
}
|
||||
if (ptr[0] == '\n') {
|
||||
tmp = (int) (size_t) (ptr - str);
|
||||
r_strbuf_append_n (res, str, tmp);
|
||||
if (!ptr[1]) {
|
||||
// write new line if it's the end of the output
|
||||
r_strbuf_append (res, "\n");
|
||||
if (ptr > str) {
|
||||
tmp = (int) (size_t) (ptr - str);
|
||||
r_strbuf_append_n (res, str, tmp);
|
||||
if (!ptr[1]) {
|
||||
// write new line if it's the end of the output
|
||||
r_strbuf_append (res, "\n");
|
||||
} else {
|
||||
r_strbuf_append (res, "<br />");
|
||||
}
|
||||
str = ptr + 1;
|
||||
} else {
|
||||
r_strbuf_append (res, "<br />");
|
||||
r_strbuf_append (res, "<br />\n");
|
||||
}
|
||||
str = ptr + 1;
|
||||
continue;
|
||||
} else if (ptr[0] == '<') {
|
||||
tmp = (int)(size_t) (ptr - str);
|
||||
@ -106,9 +110,13 @@ R_API char *r_cons_html_filter(const char *ptr, int *newlen) {
|
||||
continue;
|
||||
} else if (ptr[0] == ' ') {
|
||||
tmp = (int) (size_t) (ptr - str);
|
||||
r_strbuf_append_n (res, str, tmp);
|
||||
if (tmp > 0) {
|
||||
r_strbuf_append_n (res, str, tmp);
|
||||
str = ptr + 1;
|
||||
} else {
|
||||
str++;
|
||||
}
|
||||
r_strbuf_append (res, " ");
|
||||
str = ptr + 1;
|
||||
continue;
|
||||
}
|
||||
if (ptr[0] == 0x1b) {
|
||||
@ -190,13 +198,6 @@ R_API char *r_cons_html_filter(const char *ptr, int *newlen) {
|
||||
esc = 0;
|
||||
str = ptr;
|
||||
continue;
|
||||
} else if ((ptr[0] == '0' || ptr[0] == '1') && ptr[1] == ';' && ptr[2] == '0') {
|
||||
// bg color is kind of ignored, but no glitch so far
|
||||
r_cons_gotoxy (0, 0);
|
||||
ptr += 4;
|
||||
esc = 0;
|
||||
str = ptr;
|
||||
continue;
|
||||
} else if (ptr[0] == '0' && ptr[1] == 'm') {
|
||||
ptr++;
|
||||
str = ptr + 1;
|
||||
@ -246,7 +247,9 @@ R_API char *r_cons_html_filter(const char *ptr, int *newlen) {
|
||||
}
|
||||
}
|
||||
}
|
||||
r_strbuf_append_n (res, str, ptr - str);
|
||||
if (ptr > str) {
|
||||
r_strbuf_append_n (res, str, ptr - str);
|
||||
}
|
||||
if (has_set) {
|
||||
r_strbuf_append (res, "</font>");
|
||||
}
|
||||
|
@ -541,16 +541,23 @@ R_API int r_core_pseudo_code(RCore *core, const char *input) {
|
||||
}
|
||||
}
|
||||
RListIter *iter;
|
||||
bool use_html = r_config_get_b (core->config, "scr.html");
|
||||
r_list_foreach (fcn->bbs, iter, bb) {
|
||||
if (r_list_contains (visited, bb)) {
|
||||
continue;
|
||||
}
|
||||
char *s = NULL;
|
||||
if (use_html) {
|
||||
r_config_set_b (core->config, "scr.html", false);
|
||||
}
|
||||
if (show_addr) {
|
||||
s = r_core_cmd_strf (core, "pdb@0x%08"PFMT64x"@e:asm.offset=1", bb->addr);
|
||||
} else {
|
||||
s = r_core_cmd_strf (core, "pdb@0x%08"PFMT64x"@e:asm.offset=0", bb->addr);
|
||||
}
|
||||
if (use_html) {
|
||||
r_config_set_b (core->config, "scr.html", true);
|
||||
}
|
||||
s = r_str_replace (s, ";", "//", true);
|
||||
s = r_str_replace (s, "goto ", "goto loc_", true);
|
||||
if (show_addr) {
|
||||
|
Loading…
Reference in New Issue
Block a user