mirror of
https://github.com/radareorg/radare2.git
synced 2025-01-24 06:48:46 +00:00
Improve wz
help and error handling ##shell
* Rename to wz_handler and use core, fix core return code handling
This commit is contained in:
parent
8bc9678023
commit
9160bea40a
@ -1424,20 +1424,22 @@ static int w_handler(RCore *core, const char *input) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int wz_handler_old(void *data, const char *input) {
|
||||
RCore *core = (RCore *)data;
|
||||
static int wz_handler(RCore *core, const char *input) {
|
||||
int wseek = r_config_get_i (core->config, "cfg.wseek");
|
||||
char *str = strdup (input);
|
||||
char *str = strdup (input + 1);
|
||||
int len = r_str_unescape (str) + 1;
|
||||
|
||||
/* write zero-terminated string */
|
||||
int len = r_str_unescape (str);
|
||||
if (!r_core_write_at (core, core->offset, (const ut8 *)str + 1, len)) {
|
||||
if (*input == '?' || *input != ' ' || len < 1) {
|
||||
free (str);
|
||||
r_core_cmd_help_match (core, help_msg_w, "wz", true);
|
||||
r_core_return_code (core, 0);
|
||||
return 0;
|
||||
}
|
||||
if (!r_core_write_at (core, core->offset, (const ut8 *)str, len)) {
|
||||
cmd_write_fail (core);
|
||||
}
|
||||
if (len > 0) {
|
||||
r_core_return_code (core, len);
|
||||
} else {
|
||||
r_core_return_code (core, 0);
|
||||
}
|
||||
r_core_return_code (core, len);
|
||||
WSEEK (core, len + 1);
|
||||
r_core_block_read (core);
|
||||
free (str);
|
||||
@ -2169,7 +2171,7 @@ static int cmd_write(void *data, const char *input) {
|
||||
break;
|
||||
}
|
||||
case 'z': // "wz"
|
||||
wz_handler_old (core, input + 1);
|
||||
wz_handler (core, input + 1);
|
||||
break;
|
||||
case 't': // "wt"
|
||||
wt_handler_old (core, input + 1);
|
||||
|
Loading…
x
Reference in New Issue
Block a user