mirror of
https://github.com/radareorg/radare2.git
synced 2025-01-09 15:00:42 +00:00
merge pse to ps
This commit is contained in:
parent
6ca808b1e7
commit
156f83fdd9
@ -3366,7 +3366,7 @@ R_API int r_core_config_init(RCore *core) {
|
||||
SETBPREF ("prj.simple", "false", "Use simple project saving style (functions, comments, options)");
|
||||
|
||||
/* cfg */
|
||||
SETCB ("cfg.charset", "", &cb_cfgcharset, "Specify encoding to use in pse");
|
||||
SETCB ("cfg.charset", "", &cb_cfgcharset, "Specify encoding to use when printing strings");
|
||||
SETBPREF ("cfg.r2wars", "false", "Enable some tweaks for the r2wars game");
|
||||
SETBPREF ("cfg.plugins", "true", "Load plugins at startup");
|
||||
SETCB ("time.fmt", "%Y-%m-%d %H:%M:%S %z", &cb_cfgdatefmt, "Date format (%Y-%m-%d %H:%M:%S %z)");
|
||||
|
@ -5770,9 +5770,30 @@ l = use_blocksize;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case ' ': // "ps"
|
||||
r_print_string (core->print, core->offset, core->block, l, 0);
|
||||
case ' ': // "ps"
|
||||
{
|
||||
const char *current_charset = r_config_get (core->config, "cfg.charset");
|
||||
if (R_STR_ISEMPTY (current_charset)) {
|
||||
r_print_string (core->print, core->offset, core->block, l, 0);
|
||||
} else {
|
||||
if (len > 0) {
|
||||
size_t out_len = len * 10;
|
||||
ut8 *out = calloc (len, 10);
|
||||
if (out) {
|
||||
ut8 *data = malloc (len);
|
||||
if (data) {
|
||||
r_io_read_at (core->io, core->offset, data, len);
|
||||
r_charset_encode_str (core->print->charset, out, out_len, data, len);
|
||||
r_print_string (core->print, core->offset,
|
||||
out, len, 0);
|
||||
free (data);
|
||||
}
|
||||
free (out);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 'u': // "psu"
|
||||
if (l > 0) {
|
||||
bool json = input[2] == 'j'; // "psuj"
|
||||
@ -5840,30 +5861,30 @@ l = use_blocksize;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'e': // "pse"
|
||||
// should be done in `ps` when cfg.charset is set
|
||||
if (len > 0) {
|
||||
size_t out_len = len * 10;
|
||||
ut8 *out = calloc (len, 10);
|
||||
if (out) {
|
||||
ut8 *data = malloc (len);
|
||||
if (data) {
|
||||
r_io_read_at (core->io, core->offset, data, len);
|
||||
r_charset_encode_str (core->print->charset, out, out_len, data, len);
|
||||
r_print_string (core->print, core->offset,
|
||||
out, len, R_PRINT_STRING_ZEROEND);
|
||||
free (data);
|
||||
default: // "ps"
|
||||
{
|
||||
const char *current_charset = r_config_get (core->config, "cfg.charset");
|
||||
if (R_STR_ISEMPTY (current_charset)) {
|
||||
r_print_string (core->print, core->offset, core->block, len, R_PRINT_STRING_ZEROEND);
|
||||
} else {
|
||||
if (len > 0) {
|
||||
size_t out_len = len * 10;
|
||||
ut8 *out = calloc (len, 10);
|
||||
if (out) {
|
||||
ut8 *data = malloc (len);
|
||||
if (data) {
|
||||
r_io_read_at (core->io, core->offset, data, len);
|
||||
r_charset_encode_str (core->print->charset, out, out_len, data, len);
|
||||
r_print_string (core->print, core->offset,
|
||||
out, len, R_PRINT_STRING_ZEROEND);
|
||||
free (data);
|
||||
}
|
||||
free (out);
|
||||
}
|
||||
}
|
||||
free (out);
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if (l > 0) {
|
||||
r_print_string (core->print, core->offset, core->block,
|
||||
len, R_PRINT_STRING_ZEROEND);
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 'm': // "pm"
|
||||
|
@ -1,12 +1,12 @@
|
||||
NAME=pse
|
||||
NAME=e cfg.charset
|
||||
FILE=-
|
||||
CMDS=<<EOF
|
||||
e cfg.charset=?
|
||||
b 32
|
||||
wx a6b1aeb4ada37fb3ae7fafb1aeb3a4a2b349a8b3b2a4aba57fa5b1aeac7fa8b3
|
||||
pse
|
||||
ps
|
||||
e cfg.charset=pokered
|
||||
pse
|
||||
ps
|
||||
EOF
|
||||
EXPECT=<<EOF
|
||||
pokered
|
||||
@ -15,3 +15,39 @@ ground-to-protect?itself-from-it
|
||||
EOF
|
||||
RUN
|
||||
|
||||
NAME=ps and psz
|
||||
FILE=-
|
||||
CMDS=<<EOF
|
||||
e cfg.charset=?
|
||||
b 32
|
||||
wx 7f7f7f7f7f7f7f7f92a4aba5e3b1a4afaba8a2a0b3a8ada67f7f7f7fa0b1a1a8b3b1a0b1b87fa2aea3a47f7f7f7f7f7fa1b87f8cb182a7a4a4b9a47f9c9b7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f
|
||||
e cfg.charset=pokered
|
||||
ps $b
|
||||
ps # should be the same as ps $b but its not
|
||||
psz
|
||||
e cfg.charset=
|
||||
ps $b
|
||||
psz
|
||||
EOF
|
||||
EXPECT=<<EOF
|
||||
pokered
|
||||
--------Self-replicating----arbi
|
||||
--------Self-replicating----arbi
|
||||
|
||||
--------Self-replicating----arbi
|
||||
|
||||
EOF
|
||||
RUN
|
||||
|
||||
NAME=ps and psz with write
|
||||
FILE=-
|
||||
CMDS=<<EOF
|
||||
wx 7f7f7f7f7f7f7f7f92a4aba5e3b1a4afaba8a2a0b3a8ada67f7f7f7fa0b1a1a8b3b1a0b1b87fa2aea3a47f7f7f7f7f7fa1b87f8cb182a7a4a4b9a47f9c9b7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f
|
||||
e cfg.charset=pokered
|
||||
"w hello-world\x00this-is-very-new"
|
||||
ps 28
|
||||
EOF
|
||||
EXPECT=<<EOF
|
||||
????????????????????????????
|
||||
EOF
|
||||
RUN
|
Loading…
Reference in New Issue
Block a user