Fix warning and add more tests for the foreach operators

This commit is contained in:
pancake 2021-09-23 13:14:42 +02:00 committed by pancake
parent 5ee6961f0f
commit d0044b9e95
3 changed files with 37 additions and 3 deletions

View File

@ -1977,7 +1977,7 @@ static int bin_imports(RCore *r, PJ *pj, int mode, int va, const char *name) {
return false;
}
RList *imports = r_bin_get_imports (r->bin);
const RList *imports = r_bin_get_imports (r->bin);
int cdsz = info? (info->bits == 64? 8: info->bits == 32? 4: info->bits == 16 ? 4: 0): 0;
if (IS_MODE_JSON (mode)) {
pj_a (pj);

View File

@ -4635,8 +4635,10 @@ R_API int r_core_cmd_foreach3(RCore *core, const char *cmd, char *each) { // "@@
case 'c':
if (glob) {
char *arg = r_core_cmd_str (core, glob);
foreach_pairs (core, cmd, arg);
free (arg);
if (arg) {
foreach_pairs (core, cmd, arg);
free (arg);
}
} else {
eprintf ("Usage: @@@c:command # same as @@@=`command`\n");
}

View File

@ -53,3 +53,35 @@ hello
world
EOF
RUN
NAME=foreach iterator for other stuff
FILE=bins/mach0/mac-ls
CMDS=<<EOF
?e hello
?e=1@@@s~?
?e=1@@@s~?
?e=1@@@S~?
?e=1@@@S~?
?e=1@@@f~?
?e=1@@@f~?
?e=1@@@m~?
?e=1@@@m~?
?e=1@@@s~?
?e=1@@@s~?
?e world
EOF
EXPECT=<<EOF
hello
116
116
16
16
342
342
3
3
116
116
world
EOF
RUN