mirror of
https://github.com/radareorg/radare2.git
synced 2025-01-19 04:12:46 +00:00
Remove search.count in favor of search.maxhits in /A , /R , and everywhere (#8538)
This commit is contained in:
parent
030a22ca6b
commit
d190effb26
@ -109,7 +109,7 @@ static int rafind_open(char *file) {
|
||||
int ret;
|
||||
|
||||
if (identify) {
|
||||
char *cmd = r_str_newf ("r2 -e search.show=false -e search.count=1 -nqcpm '%s'", file);
|
||||
char *cmd = r_str_newf ("r2 -e search.show=false -e search.maxhits=1 -nqcpm '%s'", file);
|
||||
r_sandbox_system (cmd, 1);
|
||||
free (cmd);
|
||||
return 0;
|
||||
|
@ -2638,7 +2638,6 @@ R_API int r_core_config_init(RCore *core) {
|
||||
SETICB ("search.align", 0, &cb_searchalign, "Only catch aligned search hits");
|
||||
SETI ("search.chunk", 0, "Chunk size for /+ (default size is asm.bits/8");
|
||||
SETI ("search.esilcombo", 8, "Stop search after N consecutive hits");
|
||||
SETI ("search.count", 0, "Start index number at search hits");
|
||||
SETI ("search.distance", 0, "Search string distance");
|
||||
SETPREF ("search.flags", "true", "All search results are flagged, otherwise only printed");
|
||||
SETPREF ("search.overlap", "false", "Look for overlapped search hits");
|
||||
|
@ -3567,21 +3567,21 @@ static int cmd_print(void *data, const char *input) {
|
||||
break;
|
||||
case 'A': // "pA"
|
||||
{
|
||||
ut64 from = r_config_get_i (core->config, "search.from");
|
||||
ut64 to = r_config_get_i (core->config, "search.to");
|
||||
int count = r_config_get_i (core->config, "search.count");
|
||||
const ut64 saved_from = r_config_get_i (core->config, "search.from"),
|
||||
saved_to = r_config_get_i (core->config, "search.to"),
|
||||
saved_maxhits = r_config_get_i (core->config, "search.maxhits");
|
||||
|
||||
int want = r_num_math (core->num, input + 1);
|
||||
if (input[1] == '?') {
|
||||
r_core_cmd0 (core, "/A?");
|
||||
} else {
|
||||
r_config_set_i (core->config, "search.count", want);
|
||||
r_config_set_i (core->config, "search.maxhits", want);
|
||||
r_config_set_i (core->config, "search.from", core->offset);
|
||||
r_config_set_i (core->config, "search.to", core->offset + core->blocksize);
|
||||
r_core_cmd0 (core, "/A");
|
||||
r_config_set_i (core->config, "search.count", count);
|
||||
r_config_set_i (core->config, "search.from", from);
|
||||
r_config_set_i (core->config, "search.to", to);
|
||||
r_config_set_i (core->config, "search.maxhits", saved_maxhits);
|
||||
r_config_set_i (core->config, "search.from", saved_from);
|
||||
r_config_set_i (core->config, "search.to", saved_to);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -1174,7 +1174,7 @@ static int r_core_search_rop(RCore *core, RAddrInterval search_itv, int opt, con
|
||||
const char *smode = r_config_get (core->config, "search.in");
|
||||
const char *arch = r_config_get (core->config, "asm.arch");
|
||||
ut64 from = search_itv.addr, to = r_itv_end (search_itv);
|
||||
int max_count = r_config_get_i (core->config, "search.count");
|
||||
int max_count = r_config_get_i (core->config, "search.maxhits");
|
||||
int i = 0, end = 0, mode = 0, increment = 1, ret;
|
||||
RList /*<endlist_pair>*/ *end_list = r_list_newf (free);
|
||||
RList /*<intptr_t>*/ *badstart = r_list_new ();
|
||||
@ -1531,7 +1531,7 @@ static void do_esil_search(RCore *core, struct search_parameters *param, const c
|
||||
kw.type = 0; // R_SEARCH_TYPE_ESIL;
|
||||
kw.kwidx = search->n_kws;
|
||||
kw.count++;
|
||||
eprintf ("Hits: %d\r", kw.count);
|
||||
eprintf ("hits: %d\r", kw.count);
|
||||
kw.keyword_length = 0;
|
||||
hit_happens = true;
|
||||
}
|
||||
@ -1569,7 +1569,8 @@ static void do_anal_search(RCore *core, struct search_parameters *param, const c
|
||||
int mode = 0;
|
||||
int i, ret, bsize = R_MIN (64, core->blocksize);
|
||||
int kwidx = core->search->n_kws;
|
||||
int maxhits, count = 0;
|
||||
int count = 0;
|
||||
int maxhits = (int)r_config_get_i (core->config, "search.maxhits");
|
||||
bool firstItem = true;
|
||||
|
||||
if (*input == 'f') {
|
||||
@ -1618,7 +1619,6 @@ static void do_anal_search(RCore *core, struct search_parameters *param, const c
|
||||
eprintf ("Cannot allocate %d bytes\n", bsize);
|
||||
return;
|
||||
}
|
||||
maxhits = (int) r_config_get_i (core->config, "search.count");
|
||||
r_cons_break_push (NULL, NULL);
|
||||
RIOMap* map;
|
||||
RListIter *iter;
|
||||
@ -1728,7 +1728,7 @@ static void do_asm_search(RCore *core, struct search_parameters *param, const ch
|
||||
|
||||
r_list_free (param->boundaries);
|
||||
param->boundaries = r_core_get_boundaries (core, param->mode);
|
||||
maxhits = (int) r_config_get_i (core->config, "search.count");
|
||||
maxhits = (int) r_config_get_i (core->config, "search.maxhits");
|
||||
filter = (int) r_config_get_i (core->config, "asm.filter");
|
||||
|
||||
if (!param->boundaries) {
|
||||
@ -1861,6 +1861,7 @@ static void do_string_search(RCore *core, RAddrInterval search_itv, struct searc
|
||||
if (!r_itv_overlap (search_itv, map->itv)) {
|
||||
continue;
|
||||
}
|
||||
const ut64 saved_nhits = search->nhits;
|
||||
RAddrInterval itv = r_itv_intersect (search_itv, map->itv);
|
||||
searchhits = 0;
|
||||
if (r_cons_is_breaked ()) {
|
||||
@ -1923,7 +1924,7 @@ static void do_string_search(RCore *core, RAddrInterval search_itv, struct searc
|
||||
print_search_progress (at, to1, search->nhits);
|
||||
r_cons_clear_line (1);
|
||||
core->num->value = search->nhits;
|
||||
eprintf ("hits: %" PFMT64d "\n", search->nhits);
|
||||
eprintf ("hits: %" PFMT64d "\n", search->nhits - saved_nhits);
|
||||
}
|
||||
r_cons_break_pop ();
|
||||
free (buf);
|
||||
@ -2845,9 +2846,9 @@ again:
|
||||
{
|
||||
RSearchKeyword *kw = r_search_keyword_new_hexmask ("00", NULL);
|
||||
kw->type = R_SEARCH_KEYWORD_TYPE_STRING;
|
||||
r_search_kw_add (core->search, kw);
|
||||
r_search_kw_add (search, kw);
|
||||
}
|
||||
r_search_begin (core->search);
|
||||
r_search_begin (search);
|
||||
dosearch = true;
|
||||
}
|
||||
break;
|
||||
@ -2858,7 +2859,7 @@ again:
|
||||
eprintf ("See /? for help.\n");
|
||||
break;
|
||||
}
|
||||
r_config_set_i (core->config, "search.kwidx", core->search->n_kws);
|
||||
r_config_set_i (core->config, "search.kwidx", search->n_kws);
|
||||
if (dosearch) {
|
||||
do_string_search (core, search_itv, ¶m);
|
||||
}
|
||||
|
@ -354,7 +354,8 @@ static int cmd_seek(void *data, const char *input) {
|
||||
case '/': // "s/"
|
||||
{
|
||||
const char *pfx = r_config_get (core->config, "search.prefix");
|
||||
ut64 from = r_config_get_i (core->config, "search.from");
|
||||
const ut64 saved_from = r_config_get_i (core->config, "search.from"),
|
||||
saved_maxhits = r_config_get_i (core->config, "search.maxhits");
|
||||
// kwidx cfg var is ignored
|
||||
int kwidx = core->search->n_kws; // (int)r_config_get_i (core->config, "search.kwidx")-1;
|
||||
if (kwidx < 0) {
|
||||
@ -378,11 +379,11 @@ static int cmd_seek(void *data, const char *input) {
|
||||
case '/':
|
||||
case 'x':
|
||||
r_config_set_i (core->config, "search.from", core->offset + 1);
|
||||
r_config_set_i (core->config, "search.count", 1);
|
||||
r_config_set_i (core->config, "search.maxhits", 1);
|
||||
r_core_cmdf (core, "s+1; %s; s-1; s %s%d_0; f-%s%d_0",
|
||||
input, pfx, kwidx, pfx, kwidx, pfx, kwidx);
|
||||
r_config_set_i (core->config, "search.from", from);
|
||||
r_config_set_i (core->config, "search.count", 0);
|
||||
r_config_set_i (core->config, "search.from", saved_from);
|
||||
r_config_set_i (core->config, "search.maxhits", saved_maxhits);
|
||||
break;
|
||||
case '?':
|
||||
eprintf ("Usage: s/.. arg.\n");
|
||||
|
Loading…
x
Reference in New Issue
Block a user