asm.asciidot -> scr.strconv=asciidot (#9485)

This commit is contained in:
Khairul Azhar Kasmiran 2018-02-24 19:01:21 +08:00 committed by radare
parent 5e097dbae1
commit acea95544d
4 changed files with 27 additions and 3 deletions

View File

@ -1680,6 +1680,27 @@ static int cb_scrflush(void *user, void *data) {
return true;
}
static int cb_scrstrconv(void *user, void *data) {
RCore *core = (RCore*) user;
RConfigNode *node = (RConfigNode*) data;
if (node->value[0] == '?') {
if (strlen (node->value) > 1 && node->value[1] == '?') {
r_cons_printf ("Valid values for scr.strconv:\n"
" asciiesc convert to ascii with non-ascii chars escaped\n"
" asciidot convert to ascii with non-ascii chars turned into a dot (except some control chars)\n"
"\n"
"Ascii chars are in the range 0x20-0x7e.\n");
} else {
print_node_options (node);
}
return false;
} else {
free ((char *)core->print->strconv_mode);
core->print->strconv_mode = strdup (node->value);
}
return true;
}
static int cb_exectrap(void *user, void *data) {
RConfigNode *node = (RConfigNode *) data;
RCore *core = (RCore*) user;
@ -2408,8 +2429,6 @@ R_API int r_core_config_init(RCore *core) {
SETPREF ("asm.cmt.patch", "false", "Show patch comments in disasm");
SETPREF ("asm.cmt.off", "nodup", "Show offset comment in disasm (true, false, nodup)");
SETPREF ("asm.payloads", "false", "Show payload bytes in disasm");
SETPREF ("asm.asciidot", "false", "Enable a char filter for string comments that passes through chars in the "
"range 0x20-0x7e and turns the rest into dots (except some control chars)");
n = NODECB ("asm.strenc", "guess", &cb_asmstrenc);
SETDESC (n, "Assumed string encoding for disasm");
SETOPTIONS (n, "latin1", "utf8", "utf16le", "utf32le", "guess", NULL);
@ -2786,6 +2805,9 @@ R_API int r_core_config_init(RCore *core) {
&cb_utf8, "Show UTF-8 characters instead of ANSI");
SETCB ("scr.utf8.curvy", "false", &cb_utf8_curvy, "Show curved UTF-8 corners (requires scr.utf8)");
SETPREF ("scr.histsave", "true", "Always save history on exit");
n = NODECB ("scr.strconv", "asciiesc", &cb_scrstrconv);
SETDESC (n, "Convert string before display");
SETOPTIONS (n, "asciiesc", "asciidot", NULL);
/* str */
SETCB ("str.escbslash", "false", &cb_str_escbslash, "Escape the backslash (iz and Cs-based output only)");

View File

@ -636,7 +636,7 @@ static RDisasmState * ds_init(RCore *core) {
ds->show_functions = r_config_get_i (core->config, "asm.functions");
ds->show_fcncalls = r_config_get_i (core->config, "asm.fcncalls");
ds->nbytes = r_config_get_i (core->config, "asm.nbytes");
ds->show_asciidot = r_config_get_i (core->config, "asm.asciidot");
ds->show_asciidot = !strcmp (core->print->strconv_mode, "asciidot");
const char *strenc_str = r_config_get (core->config, "asm.strenc");
if (!strcmp (strenc_str, "latin1")) {
ds->strenc = R_STRING_ENC_LATIN1;

View File

@ -88,6 +88,7 @@ typedef struct r_print_t {
int lines_cache_sz;
int lines_abs;
bool esc_bslash;
const char *strconv_mode;
// when true it uses row_offsets
bool calc_row_offsets;

View File

@ -303,6 +303,7 @@ R_API RPrint* r_print_new() {
p->vflush = true;
p->screen_bounds = 0;
p->esc_bslash = false;
p->strconv_mode = NULL;
memset (&p->consbind, 0, sizeof (p->consbind));
return p;
}