mirror of
https://github.com/radareorg/radare2.git
synced 2025-03-01 18:57:20 +00:00
Enhance @@ foreach operator
This commit is contained in:
parent
02fa7b92e1
commit
842623c028
@ -2346,37 +2346,58 @@ R_API int r_core_cmd_foreach3(RCore *core, const char *cmd, char *each) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void foreachOffset (RCore *core, const char *cmd, const char *each) {
|
||||
char *str = strdup (cmd);
|
||||
static void foreachOffset (RCore *core, const char *_cmd, const char *each) {
|
||||
char *cmd = strdup (_cmd);
|
||||
char *str = cmd;
|
||||
char *nextLine = NULL;
|
||||
ut64 addr;
|
||||
/* foreach list of items */
|
||||
do {
|
||||
while (each) {
|
||||
// skip spaces
|
||||
while (*each == ' ') {
|
||||
each++;
|
||||
}
|
||||
// stahp if empty string
|
||||
if (!*each) {
|
||||
break;
|
||||
}
|
||||
// find newline
|
||||
char *nl = strchr (each, '\n');
|
||||
if (nl) {
|
||||
*nl = 0;
|
||||
each = nl + 1;
|
||||
}
|
||||
str = strchr (each, ' ');
|
||||
if (str) {
|
||||
*str = '\0';
|
||||
addr = r_num_math (core->num, each);
|
||||
*str = ' ';
|
||||
each = str + 1;
|
||||
nextLine = nl + 1;
|
||||
} else {
|
||||
addr = r_num_math (core->num, each);
|
||||
nextLine = NULL;
|
||||
}
|
||||
//eprintf ("; 0x%08"PFMT64x":\n", addr);
|
||||
r_core_seek (core, addr, 1);
|
||||
r_core_cmd (core, cmd, 0);
|
||||
r_cons_flush ();
|
||||
} while (str != NULL);
|
||||
free (str);
|
||||
// chop comment in line
|
||||
nl = strchr (each, '#');
|
||||
if (nl) {
|
||||
*nl = 0;
|
||||
}
|
||||
// space separated numbers
|
||||
while (each && *each) {
|
||||
// find spaces
|
||||
while (*each== ' ') each++;
|
||||
str = strchr (each, ' ');
|
||||
if (str) {
|
||||
*str = '\0';
|
||||
addr = r_num_math (core->num, each);
|
||||
*str = ' ';
|
||||
each = str + 1;
|
||||
} else {
|
||||
if (!*each) {
|
||||
break;
|
||||
}
|
||||
addr = r_num_math (core->num, each);
|
||||
each = NULL;
|
||||
}
|
||||
r_core_seek (core, addr, 1);
|
||||
r_core_cmd (core, cmd, 0);
|
||||
r_cons_flush ();
|
||||
}
|
||||
each = nextLine;
|
||||
}
|
||||
free (cmd);
|
||||
}
|
||||
|
||||
R_API int r_core_cmd_foreach(RCore *core, const char *cmd, char *each) {
|
||||
|
@ -1050,15 +1050,16 @@ static void ds_print_show_cursor(RDisasmState *ds) {
|
||||
RCore *core = ds->core;
|
||||
char res[] = " ";
|
||||
void *p;
|
||||
int q, t;
|
||||
if (!ds->show_marks) {
|
||||
return;
|
||||
}
|
||||
q = core->print->cur_enabled &&
|
||||
int q = core->print->cur_enabled &&
|
||||
ds->cursor >= ds->index &&
|
||||
ds->cursor < (ds->index + ds->asmop.size);
|
||||
p = r_bp_get_at (core->dbg->bp, ds->at);
|
||||
t = ds->midflags && handleMidFlags (core, ds, false) > 0;
|
||||
if (ds->midflags) {
|
||||
(void)handleMidFlags (core, ds, false);
|
||||
}
|
||||
if (p) {
|
||||
res[0] = 'b';
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user