Skip to content

Commit

Permalink
Flags without a space are priorized in RCoreFlag.getBySpace ##disasm
Browse files Browse the repository at this point in the history
  • Loading branch information
trufae authored Dec 9, 2024
1 parent 62323cc commit 9fd64ee
Show file tree
Hide file tree
Showing 15 changed files with 46 additions and 42 deletions.
4 changes: 2 additions & 2 deletions libr/anal/anal.c
Original file line number Diff line number Diff line change
Expand Up @@ -657,7 +657,7 @@ R_API bool r_anal_noreturn_at(RAnal *anal, ut64 addr) {
return true;
}
}
RFlagItem *fi = anal->flag_get (anal->flb.f, addr);
RFlagItem *fi = anal->flag_get (anal->flb.f, false, addr);
if (fi) {
if (r_anal_noreturn_at_name (anal, fi->realname ? fi->realname : fi->name)) {
return true;
Expand Down Expand Up @@ -709,7 +709,7 @@ R_API bool r_anal_is_prelude(RAnal *anal, ut64 addr, const ut8 *data, int len) {
return false;
}
ut8 *owned = NULL;
RFlagItem *flag = anal->flag_get (anal->flb.f, addr); // XXX should get a list
RFlagItem *flag = anal->flag_get (anal->flb.f, false, addr); // XXX should get a list
if (flag) {
if (r_str_startswith (flag->name, "func.")) {
return true;
Expand Down
8 changes: 4 additions & 4 deletions libr/anal/fcn.c
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,7 @@ static void fcn_takeover_block_recursive(RAnalFunction *fcn, RAnalBlock *start_b
}

static const char *retpoline_reg(RAnal *anal, ut64 addr) {
RFlagItem *flag = anal->flag_get (anal->flb.f, addr);
RFlagItem *flag = anal->flag_get (anal->flb.f, false, addr);
if (flag) {
const char *token = "x86_indirect_thunk_";
const char *thunk = strstr (flag->name, token);
Expand Down Expand Up @@ -845,7 +845,7 @@ static int fcn_recurse(RAnal *anal, RAnalFunction *fcn, ut64 addr, ut64 len, int
}
}
if (flagends && fcn->addr != at) {
RFlagItem *flag = anal->flag_get (anal->flb.f, at);
RFlagItem *flag = anal->flag_get (anal->flb.f, false, at);
if (flag) {
if (r_str_startswith (flag->name, "sym")) {
gotoBeach (R_ANAL_RET_END);
Expand Down Expand Up @@ -2044,7 +2044,7 @@ R_API char *r_anal_function_get_json(RAnalFunction *function) {
PJ *pj = a->coreb.pjWithEncoding (a->coreb.core);
const char *realname = NULL, *import_substring = NULL;

RFlagItem *flag = a->flag_get (a->flb.f, function->addr);
RFlagItem *flag = a->flag_get (a->flb.f, false, function->addr);
// Can't access R_FLAGS_FS_IMPORTS, since it is defined in r_core.h
if (flag && flag->space && !strcmp (flag->space->name, "imports")) {
// Get substring after last dot
Expand Down Expand Up @@ -2136,7 +2136,7 @@ R_API char *r_anal_function_get_signature(RAnalFunction *function) {
RAnal *a = function->anal;
const char *realname = NULL, *import_substring = NULL;

RFlagItem *flag = a->flag_get (a->flb.f, function->addr);
RFlagItem *flag = a->flag_get (a->flb.f, false, function->addr);
// Can't access R_FLAGS_FS_IMPORTS, since it is defined in r_core.h
if (flag && flag->space && !strcmp (flag->space->name, "imports")) {
// Get substring after last dot
Expand Down
2 changes: 1 addition & 1 deletion libr/anal/var.c
Original file line number Diff line number Diff line change
Expand Up @@ -1230,7 +1230,7 @@ R_API void r_anal_extract_rarg(RAnal *anal, RAnalOp *op, RAnalFunction *fcn, int
RAnalFunction *f = r_anal_get_function_at (anal, offset);
if (!f) {
RCore *core = (RCore *)anal->coreb.core;
RFlagItem *flag = r_flag_get_by_spaces (core->flags, offset, R_FLAGS_FS_IMPORTS, NULL);
RFlagItem *flag = r_flag_get_by_spaces (core->flags, false, offset, R_FLAGS_FS_IMPORTS, NULL);
if (flag) {
callee = r_type_func_guess (TDB, flag->name);
if (callee) {
Expand Down
6 changes: 3 additions & 3 deletions libr/asm/filter.c
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ static bool filter(RAsmPluginSession *aps, ut64 addr, RFlag *f, RAnalHint *hint,
const char *name = fcn->name;
// TODO: implement realname with flags, because functions dont hold this yet
if (f->realnames) {
flag = p->flag_get (f, off);
flag = p->flag_get (f, false, off);
if (flag && flag->realname) {
name = flag->realname;
}
Expand All @@ -235,10 +235,10 @@ static bool filter(RAsmPluginSession *aps, ut64 addr, RFlag *f, RAnalHint *hint,
bool lea = x86 && r_str_startswith (data, "lea")
&& (data[3] == ' ' || data[3] == 0x1b);
bool remove_brackets = false;
flag = p->flag_get (f, off);
flag = p->flag_get (f, false, off);
if ((!flag || arm) && p->subrel_addr) {
remove_brackets = lea || (arm && p->subrel_addr);
flag2 = p->flag_get (f, p->subrel_addr);
flag2 = p->flag_get (f, false, p->subrel_addr);
if (!flag || arm) {
flag = flag2;
}
Expand Down
6 changes: 3 additions & 3 deletions libr/core/anal_tp.c
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,7 @@ static void type_match(RCore *core, char *fcn_name, ut64 addr, ut64 baddr, const
free (ms);
cmt_set = true;
if ((op->ptr && op->ptr != UT64_MAX) && !strcmp (name, "format")) {
RFlagItem *f = r_flag_get_by_spaces (core->flags, op->ptr, R_FLAGS_FS_STRINGS, NULL);
RFlagItem *f = r_flag_get_by_spaces (core->flags, false, op->ptr, R_FLAGS_FS_STRINGS, NULL);
if (f) {
char formatstr[0x200];
int read = r_io_nread_at (core->io, f->offset, (ut8 *)formatstr, R_MIN (sizeof (formatstr) - 1, f->size));
Expand Down Expand Up @@ -770,7 +770,7 @@ R_API void r_core_anal_type_match(RCore *core, RAnalFunction *fcn) {
callee_addr = fcn_call->addr;
}
} else if (aop.ptr != UT64_MAX) {
RFlagItem *flag = r_flag_get_by_spaces (core->flags, aop.ptr, R_FLAGS_FS_IMPORTS, NULL);
RFlagItem *flag = r_flag_get_by_spaces (core->flags, false, aop.ptr, R_FLAGS_FS_IMPORTS, NULL);
if (flag && flag->realname) {
full_name = flag->realname;
callee_addr = aop.ptr;
Expand Down Expand Up @@ -947,7 +947,7 @@ R_API void r_core_anal_type_match(RCore *core, RAnalFunction *fcn) {
r_io_read_at (core->io, aop.ptr, sbuf, sizeof (sbuf) - 1);
ut64 ptr = r_read_ble (sbuf, be, aop.refptr * 8);
if (ptr && ptr != UT64_MAX) {
RFlagItem *f = r_flag_get_by_spaces (core->flags, ptr, R_FLAGS_FS_STRINGS, NULL);
RFlagItem *f = r_flag_get_by_spaces (core->flags, false, ptr, R_FLAGS_FS_STRINGS, NULL);
if (f) {
str_flag = true;
}
Expand Down
10 changes: 5 additions & 5 deletions libr/core/canal.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ static char *get_function_name(RCore *core, const char *fcnpfx, ut64 addr) {
return r_str_newf ("method.%s.%s", sym->classname, sym_name);
}
}
RFlagItem *flag = r_core_flag_get_by_spaces (core->flags, addr);
RFlagItem *flag = r_core_flag_get_by_spaces (core->flags, false, addr);
if (flag) {
return strdup (flag->name);
}
Expand Down Expand Up @@ -993,7 +993,7 @@ static bool __core_anal_fcn(RCore *core, ut64 at, ut64 from, int reftype, int de
continue;
}
}
f = r_core_flag_get_by_spaces (core->flags, fcn->addr);
f = r_core_flag_get_by_spaces (core->flags, false, fcn->addr);
bool renamed = set_fcn_name_from_flag (core, fcn, f, fcnpfx);

if (fcnlen == R_ANAL_RET_ERROR ||
Expand All @@ -1005,7 +1005,7 @@ static bool __core_anal_fcn(RCore *core, ut64 at, ut64 from, int reftype, int de
}
if (fcnlen == R_ANAL_RET_END) { /* Function analysis complete */
if (!renamed) {
f = r_core_flag_get_by_spaces (core->flags, fcn->addr);
f = r_core_flag_get_by_spaces (core->flags, false, fcn->addr);
if (f && f->name && !r_str_startswith (f->name, "sect")) { /* Check if it's already flagged */
char *new_name = strdup (f->name);
if (is_entry_flag (f)) {
Expand Down Expand Up @@ -4488,7 +4488,7 @@ static void add_string_ref(RCore *core, ut64 xref_from, ut64 xref_to) {
r_anal_xrefs_set (core->anal, xref_from, xref_to, reftype);
r_name_filter (str, -1);
if (*str) {
RFlagItem *flag = r_core_flag_get_by_spaces (core->flags, xref_to);
RFlagItem *flag = r_core_flag_get_by_spaces (core->flags, false, xref_to);
if (!flag || !r_str_startswith (flag->name, "str.")) {
r_flag_space_push (core->flags, R_FLAGS_FS_STRINGS);
char *strf = r_str_newf ("str.%s", str);
Expand Down Expand Up @@ -6155,7 +6155,7 @@ R_API void r_core_anal_esil(RCore *core, const char *str /* len */, const char *
if (cfg_anal_strings) {
add_string_ref (core, op.addr, dst);
}
if ((f = r_core_flag_get_by_spaces (core->flags, dst))) {
if ((f = r_core_flag_get_by_spaces (core->flags, false, dst))) {
r_meta_set_string (core->anal, R_META_TYPE_COMMENT, cur, f->name);
} else if ((str = is_string_at (core, dst, NULL))) {
char *str2 = r_str_newf ("esilref: '%s'", str);
Expand Down
6 changes: 3 additions & 3 deletions libr/core/cmd_anal.inc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1658,7 +1658,7 @@ static int cmd_an(RCore *core, const char *name, int mode) {
if (tgt_addr == UT64_MAX) {
tgt_addr = core->offset;
}
RFlagItem *f = r_flag_get_by_spaces (core->flags, tgt_addr, R_FLAGS_FS_SYMBOLS, R_FLAGS_FS_IMPORTS, NULL);
RFlagItem *f = r_flag_get_by_spaces (core->flags, false, tgt_addr, R_FLAGS_FS_SYMBOLS, R_FLAGS_FS_IMPORTS, NULL);
if (!f) {
f = r_flag_get_i (core->flags, tgt_addr);
}
Expand Down Expand Up @@ -4244,7 +4244,7 @@ R_API char *fcnshowr(RAnalFunction *function) {
const char *realname = NULL, *import_substring = NULL;
RStrBuf *sb = r_strbuf_new ("");

RFlagItem *flag = a->flag_get (a->flb.f, function->addr);
RFlagItem *flag = a->flag_get (a->flb.f, false, function->addr);
// Can't access R_FLAGS_FS_IMPORTS, since it is defined in r_core.h
if (flag && flag->space && !strcmp (flag->space->name, "imports")) {
// Get substring after last dot
Expand Down Expand Up @@ -8352,7 +8352,7 @@ static void cmd_aep(RCore *core, const char *input) {
}
// get flag in current offset
// find a pin named like the flag, skip dots if any
RFlagItem *f = r_flag_get_by_spaces (core->flags, addr, R_FLAGS_FS_SYMBOLS, R_FLAGS_FS_IMPORTS, NULL);
RFlagItem *f = r_flag_get_by_spaces (core->flags, false, addr, R_FLAGS_FS_SYMBOLS, R_FLAGS_FS_IMPORTS, NULL);
if (!f) {
f = r_flag_get_i (core->flags, addr);
}
Expand Down
2 changes: 1 addition & 1 deletion libr/core/cmd_debug.inc.c
Original file line number Diff line number Diff line change
Expand Up @@ -3646,7 +3646,7 @@ static void add_breakpoint(RCore *core, const char *input, bool hwbp, bool watch
if (bpi) {
free (bpi->name);
if (!strcmp (DB_ARG (i), "$$")) {
RFlagItem *f = r_core_flag_get_by_spaces (core->flags, addr);
RFlagItem *f = r_core_flag_get_by_spaces (core->flags, false, addr);
if (f) {
if (addr > f->offset) {
bpi->name = r_str_newf ("%s+0x%" PFMT64x, f->name, addr - f->offset);
Expand Down
2 changes: 1 addition & 1 deletion libr/core/cmd_print.inc.c
Original file line number Diff line number Diff line change
Expand Up @@ -3832,7 +3832,7 @@ static void disasm_strings(RCore *core, const char *input, RAnalFunction *fcn) {
ut64 ptr = r_num_math (NULL, str);
RFlagItem *flag = NULL;
if (str) {
flag = r_core_flag_get_by_spaces (core->flags, ptr);
flag = r_core_flag_get_by_spaces (core->flags, false, ptr);
}
if (!flag) {
if (string && r_str_startswith (string, "0x")) {
Expand Down
4 changes: 2 additions & 2 deletions libr/core/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -2380,8 +2380,8 @@ R_API void r_core_autocomplete_reload(RCore *core) {
__init_autocomplete (core);
}

R_API RFlagItem *r_core_flag_get_by_spaces(RFlag *f, ut64 off) {
return r_flag_get_by_spaces (f, off,
R_API RFlagItem *r_core_flag_get_by_spaces(RFlag *f, bool prionospace, ut64 off) {
return r_flag_get_by_spaces (f, prionospace, off,
R_FLAGS_FS_FUNCTIONS,
R_FLAGS_FS_SIGNS,
R_FLAGS_FS_CLASSES,
Expand Down
20 changes: 10 additions & 10 deletions libr/core/disasm.c
Original file line number Diff line number Diff line change
Expand Up @@ -1586,7 +1586,7 @@ static void ds_show_xrefs(RDisasmState *ds) {
}
}
if (ds->asm_demangle) {
f = r_flag_get_by_spaces (core->flags, fun->addr, R_FLAGS_FS_SYMBOLS, NULL);
f = r_flag_get_by_spaces (core->flags, false, fun->addr, R_FLAGS_FS_SYMBOLS, NULL);
if (f && f->demangled && f->realname) {
realname = strdup (f->realname);
}
Expand Down Expand Up @@ -1615,7 +1615,7 @@ static void ds_show_xrefs(RDisasmState *ds) {
if (ds->asm_demangle) {
RFlagItem *f_sym = f;
if (!r_str_startswith (f_sym->name, "sym.")) {
f_sym = r_flag_get_by_spaces (core->flags, f->offset,
f_sym = r_flag_get_by_spaces (core->flags, false, f->offset,
R_FLAGS_FS_SYMBOLS, NULL);
}
if (f_sym && f_sym->demangled && f_sym->realname) {
Expand Down Expand Up @@ -4265,7 +4265,7 @@ static void ds_print_fcn_name(RDisasmState *ds) {
RAnalFunction *f = fcnIn (ds, ds->analop.jump, R_ANAL_FCN_TYPE_NULL);
if (!f && ds->core->flags && (!ds->core->vmode || (!ds->subjmp && !ds->subnames))) {
const char *arch;
RFlagItem *flag = r_flag_get_by_spaces (ds->core->flags, ds->analop.jump,
RFlagItem *flag = r_flag_get_by_spaces (ds->core->flags, false, ds->analop.jump,
R_FLAGS_FS_CLASSES, R_FLAGS_FS_SYMBOLS, NULL);
if (flag && flag->name
&& ds->opstr && !strstr (ds->opstr, flag->name)
Expand All @@ -4276,7 +4276,7 @@ static void ds_print_fcn_name(RDisasmState *ds) {
RFlagItem *flag_sym = flag;
if (ds->core->vmode && ds->asm_demangle
&& (r_str_startswith (flag->name, "sym.")
|| (flag_sym = r_flag_get_by_spaces (ds->core->flags,
|| (flag_sym = r_flag_get_by_spaces (ds->core->flags, false,
ds->analop.jump, R_FLAGS_FS_SYMBOLS, NULL)))
&& flag_sym->demangled) {
return;
Expand Down Expand Up @@ -4311,7 +4311,7 @@ static void ds_print_fcn_name(RDisasmState *ds) {
RFlagItem *flag_sym;
if (ds->core->vmode
&& ds->asm_demangle
&& (flag_sym = r_flag_get_by_spaces (ds->core->flags,
&& (flag_sym = r_flag_get_by_spaces (ds->core->flags, false,
ds->analop.jump,
R_FLAGS_FS_SYMBOLS, NULL))
&& flag_sym->demangled) {
Expand Down Expand Up @@ -4859,7 +4859,7 @@ static void ds_print_ptr(RDisasmState *ds, int len, int idx) {
if (f) {
ut64 subrel_addr = core->rasm->parse->subrel_addr;
if (subrel_addr && subrel_addr != p) {
f2 = r_core_flag_get_by_spaces (core->flags, subrel_addr);
f2 = r_core_flag_get_by_spaces (core->flags, false, subrel_addr);
f2_in_opstr = f2 && ds->opstr && (strstr (ds->opstr, f2->name) || strstr (ds->opstr, f2->realname)) ;
}
refaddr = p;
Expand Down Expand Up @@ -5107,7 +5107,7 @@ static void ds_print_demangled(RDisasmState *ds) {
case R_ANAL_OP_TYPE_JMP:
case R_ANAL_OP_TYPE_UJMP:
case R_ANAL_OP_TYPE_CALL:
f = r_flag_get_by_spaces (core->flags, ds->analop.jump, R_FLAGS_FS_SYMBOLS, NULL);
f = r_flag_get_by_spaces (core->flags, false, ds->analop.jump, R_FLAGS_FS_SYMBOLS, NULL);
if (f && f->demangled && f->realname && ds->opstr && !strstr (ds->opstr, f->realname)) {
ds_begin_nl_comment (ds);
ds_comment (ds, true, "%s %s", ds->cmtoken, f->realname);
Expand Down Expand Up @@ -6138,7 +6138,7 @@ static bool set_jump_realname(RDisasmState *ds, ut64 addr, const char **kw, cons
// nothing to do, neither demangled nor regular realnames should be shown
return false;
}
RFlagItem *flag_sym = r_flag_get_by_spaces (f, addr, R_FLAGS_FS_SYMBOLS, NULL);
RFlagItem *flag_sym = r_flag_get_by_spaces (f, false, addr, R_FLAGS_FS_SYMBOLS, NULL);
if (!flag_sym || !flag_sym->realname) {
// nothing to replace
return false;
Expand All @@ -6148,7 +6148,7 @@ static bool set_jump_realname(RDisasmState *ds, ut64 addr, const char **kw, cons
return false;
}
*name = flag_sym->realname;
RFlagItem *flag_mthd = r_flag_get_by_spaces (f, addr, R_FLAGS_FS_CLASSES, NULL);
RFlagItem *flag_mthd = r_flag_get_by_spaces (f, false, addr, R_FLAGS_FS_CLASSES, NULL);
if (!f->realnames) {
// for asm.flags.real, we don't want these prefixes
if (flag_mthd && flag_mthd->name && r_str_startswith (flag_mthd->name, "method.")) {
Expand Down Expand Up @@ -6202,7 +6202,7 @@ static char *ds_sub_jumps(RDisasmState *ds, char *str) {
}
} else {
if (!set_jump_realname (ds, addr, &kw, &name)) {
RFlagItem *flag = r_core_flag_get_by_spaces (f, addr);
RFlagItem *flag = r_core_flag_get_by_spaces (f, false, addr);
if (flag && strchr (flag->name, '.')) {
name = flag->name;
if (f->realnames && flag->realname) {
Expand Down
6 changes: 5 additions & 1 deletion libr/flag/flag.c
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,7 @@ R_API RFlagItem *r_flag_get_i(RFlag *f, ut64 off) {
/* return the first flag that matches an offset ordered by the order of
* operands to the function.
* Pass in the name of each space, in order, followed by a NULL */
R_API RFlagItem *r_flag_get_by_spaces(RFlag *f, ut64 off, ...) {
R_API RFlagItem *r_flag_get_by_spaces(RFlag *f, bool prionospace, ut64 off, ...) {
R_RETURN_VAL_IF_FAIL (f, NULL);
if (f->mask) {
off &= f->mask;
Expand Down Expand Up @@ -573,6 +573,10 @@ R_API RFlagItem *r_flag_get_by_spaces(RFlag *f, ut64 off, ...) {
r_list_foreach (list, iter, flg) {
// get the "priority" of the flag flagspace and
// check if better than what we found so far
if (prionospace && !flg->space) {
ret = flg;
break;
}
for (i = 0; i < n_spaces; i++) {
if (flg->space == spaces[i]) {
break;
Expand Down
2 changes: 1 addition & 1 deletion libr/include/r_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,7 @@ R_API int r_core_cmd(RCore *core, const char *cmd, bool log);
R_API int r_core_cmd_task_sync(RCore *core, const char *cmd, bool log);
R_API char *r_core_editor(const RCore *core, const char *file, const char *str);
R_API int r_core_fgets(char *buf, int len);
R_API RFlagItem *r_core_flag_get_by_spaces(RFlag *f, ut64 off);
R_API RFlagItem *r_core_flag_get_by_spaces(RFlag *f, bool prionospace, ut64 off);
R_API int r_core_cmdf(RCore *core, const char *fmt, ...) R_PRINTF_CHECK(2, 3);
R_API int r_core_cmdf_at(RCore *core, ut64 addr, const char *fmt, ...) R_PRINTF_CHECK(3, 4);
R_API int r_core_cmd0(RCore *core, const char *cmd);
Expand Down
4 changes: 2 additions & 2 deletions libr/include/r_flag.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ typedef struct r_flag_t {

typedef bool (*RFlagExistAt)(RFlag *f, const char *flag_prefix, ut16 fp_size, ut64 off);
typedef RFlagItem* (*RFlagGet)(RFlag *f, const char *name);
typedef RFlagItem* (*RFlagGetAtAddr) (RFlag *f, ut64);
typedef RFlagItem* (*RFlagGetAtAddr) (RFlag *f, bool prionospace, ut64);
typedef RFlagItem* (*RFlagGetAt)(RFlag *f, ut64 addr, bool closest);
typedef const RList* (*RFlagGetList)(RFlag *f, ut64 addr);
typedef RFlagItem* (*RFlagSet)(RFlag *f, const char *name, ut64 addr, ut32 size);
Expand Down Expand Up @@ -107,7 +107,7 @@ R_API void r_flag_list(RFlag *f, int rad, const char *pfx);
R_API bool r_flag_exist_at(RFlag *f, const char *flag_prefix, ut16 fp_size, ut64 off);
R_API RFlagItem *r_flag_get(RFlag *f, const char *name);
R_API RFlagItem *r_flag_get_i(RFlag *f, ut64 off);
R_API RFlagItem *r_flag_get_by_spaces(RFlag *f, ut64 off, ...);
R_API RFlagItem *r_flag_get_by_spaces(RFlag *f, bool prionospace, ut64 off, ...);
R_API RFlagItem *r_flag_get_at(RFlag *f, ut64 off, bool closest);
R_API RList *r_flag_all_list(RFlag *f, bool by_space);
R_API const RList* /*<RFlagItem*>*/ r_flag_get_list(RFlag *f, ut64 off);
Expand Down
6 changes: 3 additions & 3 deletions test/unit/test_flags.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,15 @@ bool test_r_flag_by_spaces(void) {
r_flag_space_set (flags, "sp4");
r_flag_set (flags, "foo7", 1024, 50);

fi = r_flag_get_by_spaces (flags, 1024, "sp2", "sp4", NULL);
fi = r_flag_get_by_spaces (flags, false, 1024, "sp2", "sp4", NULL);
mu_assert_notnull (fi, "should be retrieved");
mu_assert_streq (fi->name, "foo3", "first defined in sp2 should be get");

fi = r_flag_get_by_spaces (flags, 1024, NULL);
fi = r_flag_get_by_spaces (flags, false, 1024, NULL);
mu_assert_notnull (fi, "something should be retrieved");
mu_assert_streq (fi->name, "foo1", "a random one should be get (the first)");

fi = r_flag_get_by_spaces (flags, 1024, "sp5", "sp8", "sp1", "sp3", "sp10", NULL);
fi = r_flag_get_by_spaces (flags, false, 1024, "sp5", "sp8", "sp1", "sp3", "sp10", NULL);
mu_assert_notnull (fi, "something should be retrieved");
mu_assert_streq (fi->name, "foo1", "first defined in sp1 should be get");

Expand Down

0 comments on commit 9fd64ee

Please sign in to comment.