This commit is contained in:
Álvaro Felipe Melchor 2015-03-30 16:03:11 +02:00 committed by pancake
parent 6612a3e796
commit 2afcbbaee0
2 changed files with 20 additions and 3 deletions

View File

@ -282,8 +282,16 @@ R_API RList *r_anal_var_list(RAnal *a, RAnalFunction *fcn, int kind) {
return list;
}
static int var_comparator (const RAnalVar *a, const RAnalVar *b){
//avoid NULL dereference
if ( a && b)
return a->delta > b->delta;
return R_FALSE;
}
R_API void r_anal_var_list_show(RAnal *anal, RAnalFunction *fcn, int kind) {
RList *list = r_anal_var_list(anal, fcn, kind);
r_list_sort (list, var_comparator);
RAnalVar *var;
RListIter *iter;
r_list_foreach (list, iter, var) {

View File

@ -731,6 +731,14 @@ static void handle_print_show_cursor (RCore *core, RDisasmState *ds) {
r_cons_printf (p&&q?"b*":p? "b ":q?"* ":" ");
}
static int var_comparator (const RAnalVar *a, const RAnalVar *b){
//avoid NULL dereference
if ( a && b)
return a->delta > b->delta;
return R_FALSE;
}
static void handle_show_functions (RCore *core, RDisasmState *ds) {
RAnalFunction *f;
char *sign;
@ -789,11 +797,12 @@ static void handle_show_functions (RCore *core, RDisasmState *ds) {
char spaces[32];
RList *args = r_anal_var_list (core->anal, f, 'a');
RList *vars = r_anal_var_list (core->anal, f, 'v');
r_list_join (vars, args);
r_list_sort (args, var_comparator);
r_list_sort (vars, var_comparator);
r_list_join (args, vars);
RAnalVar *var;
RListIter *iter;
// TODO: show first args, and then vars
r_list_foreach (vars, iter, var) {
r_list_foreach (args, iter, var) {
int idx;
memset (spaces, ' ', sizeof(spaces));
idx = 12-strlen (var->name);