Code cleanup

This commit is contained in:
pancake 2013-02-07 09:41:05 +01:00
parent c443ab1f30
commit af2d3de5b4
10 changed files with 140 additions and 246 deletions

View File

@ -70,13 +70,7 @@ static char *r_core_anal_graph_label(RCore *core, RAnalBlock *bb, int opts) {
cmdstr[idx] = 0;
// TODO: optimize all this strcat stuff
strcat (cmdstr, filestr);
if (is_json)
strcat (cmdstr, "\\n");
else
if (is_html)
strcat (cmdstr, "<br />");
else
strcat (cmdstr, "\\l");
strcat (cmdstr, is_json? "\\n": is_html? "<br />": "\\l");
idx += strlen (filestr);
free (filestr);
}
@ -124,10 +118,10 @@ static void r_core_anal_graph_nodes(RCore *core, RAnalFunction *fcn, int opts) {
int is_json = opts & R_CORE_ANAL_JSON;
struct r_anal_bb_t *bbi;
RListIter *iter;
char *str;
int top = 0;
int left = 300;
int count = 0;
int top = 0;
char *str;
if (is_json) {
// TODO: show vars, refs and xrefs
@ -490,18 +484,17 @@ R_API int r_core_anal_fcn_clean(RCore *core, ut64 addr) {
#define FMT_GV 1
#define FMT_JS 2
R_API void r_core_anal_refs(RCore *core, ut64 addr, int fmt) {
const char *font = r_config_get (core->config, "graph.font");
int is_html = r_cons_singleton ()->is_html;
int first, first2, showhdr = 0;
RListIter *iter, *iter2;
const int hideempty = 1;
const int usenames = 1;
int is_html = r_cons_singleton ()->is_html;
const char *font = r_config_get (core->config, "graph.font");
RListIter *iter, *iter2;
RAnalRef *fcnr;
RAnalFunction *fcni;
int showhdr = 0;
int first, first2;
RAnalRef *fcnr;
if (fmt==2) r_cons_printf ("[");
first= 0;
first = 0;
r_list_foreach (core->anal->fcns, iter, fcni) {
if (addr != 0 && addr != fcni->addr)
continue;
@ -593,16 +586,14 @@ static void fcn_list_bbs(RAnalFunction *fcn) {
}
R_API int r_core_anal_fcn_list(RCore *core, const char *input, int rad) {
ut64 addr = r_num_math (core->num, input+1);
RListIter *iter, *iter2;
RAnalFunction *fcn;
RAnalRef *refi;
RAnalVar *vari;
RAnalFunction *fcn;
RListIter *iter, *iter2;
ut64 addr = r_num_math (core->num, input+1);
int bbs;
if (rad==2) {
RListIter *iter;
int bbs;
r_list_foreach (core->anal->fcns, iter, fcn) {
if (input[2]!='*' && !memcmp (fcn->name, "loc.", 4))
continue;
@ -748,14 +739,14 @@ R_API RList* r_core_anal_graph_to(RCore *core, ut64 addr, int n) {
R_API int r_core_anal_graph(RCore *core, ut64 addr, int opts) {
const char *font = r_config_get (core->config, "graph.font");
int count = 0;
int is_html = r_cons_singleton ()->is_html;
int is_json = opts & R_CORE_ANAL_JSON;
int reflines, bytes, dwarf;
RAnalFunction *fcni;
RListIter *iter;
int count = 0;
opts|=R_CORE_ANAL_GRAPHBODY;
opts |= R_CORE_ANAL_GRAPHBODY;
if (r_list_empty (core->anal->fcns))
return R_FALSE;
@ -770,9 +761,8 @@ opts|=R_CORE_ANAL_GRAPHBODY;
"\tgraph [bgcolor=white];\n"
"\tnode [color=lightgray, style=filled shape=box"
" fontname=\"%s\" fontsize=\"8\"];\n", font);
if (is_json) {
if (is_json)
r_cons_printf ("[");
}
r_cons_flush ();
r_list_foreach (core->anal->fcns, iter, fcni) {
if (fcni->type & (R_ANAL_FCN_TYPE_SYM | R_ANAL_FCN_TYPE_FCN)
@ -802,9 +792,7 @@ static int r_core_anal_followptr(RCore *core, ut64 at, ut64 ptr, ut64 ref, int c
}
if (depth < 1)
return R_FALSE;
if (core->bin->cur.o->info->big_endian)
endian = !LIL_ENDIAN;
else endian = LIL_ENDIAN;
endian = (core->bin->cur.o->info->big_endian)? !LIL_ENDIAN: LIL_ENDIAN;
wordsize = (int)(core->anal->bits/8);
if ((dataptr = r_io_read_i (core->io, ptr, wordsize, endian)) == -1) {
return R_FALSE;
@ -828,9 +816,7 @@ R_API int r_core_anal_search(RCore *core, ut64 from, ut64 to, ut64 ref) {
if (ref==0LL)
eprintf ("Null reference search is not supported\n");
else
if (core->blocksize<=OPSZ)
eprintf ("error: block size too small\n");
else
if (core->blocksize>OPSZ) {
for (at = from; at < to; at += core->blocksize - OPSZ) {
if (r_cons_singleton ()->breaked)
break;
@ -860,6 +846,7 @@ R_API int r_core_anal_search(RCore *core, ut64 from, ut64 to, ut64 ref) {
}
}
}
} else eprintf ("error: block size too small\n");
free (buf);
r_anal_op_fini (&op);
return count;
@ -1016,10 +1003,9 @@ R_API RCoreAnalStats* r_core_anal_get_stats (RCore *core, ut64 from, ut64 to, ut
RFlagItem *f;
RAnalFunction *F;
RMetaItem *m;
ut64 addr, at;
RListIter *iter;
RCoreAnalStats *as = R_NEW0 (RCoreAnalStats);
int i, piece, as_size, blocks = (to-from)/step;
int piece, as_size, blocks = (to-from)/step;
as_size = blocks * sizeof (RCoreAnalStatsItem);
as->block = malloc (as_size);
memset (as->block, 0, as_size);

View File

@ -3,27 +3,23 @@
#include <r_core.h>
static int bin_strings (RCore *r, int mode, ut64 baddr, int va) {
int i = 0;
RList *list;
RListIter *iter;
RBinString *string;
int rawstr, hasstr, minstr;
char *p, *q, str[R_FLAG_NAME_SIZE];
RBinSection *section;
char str[R_FLAG_NAME_SIZE];
RBinString *string;
RListIter *iter;
RList *list;
int i = 0;
/* bin str limits */
int hasstr = r_config_get_i (r->config, "bin.strings");
int rawstr = r_config_get_i (r->config, "bin.rawstr");
int minstr = r_config_get_i (r->config, "bin.minstr");
hasstr = r_config_get_i (r->config, "bin.strings");
if (!hasstr) return 0;
if (!r->bin->cur.curplugin) return 0;
rawstr = r_config_get_i (r->config, "bin.rawstr");
if (!rawstr && !r->bin->cur.curplugin->info)
return 0;
if (minstr>0) {
r->bin->minstrlen = minstr;
} else {
r_config_set_i (r->config, "bin.minstr",
r->bin->minstrlen);
}
minstr = r_config_get_i (r->config, "bin.minstr");
if (minstr>0) r->bin->minstrlen = minstr;
else r_config_set_i (r->config, "bin.minstr", r->bin->minstrlen);
if (r->bin->minstrlen==0) return -1;
/* code */
@ -33,21 +29,19 @@ static int bin_strings (RCore *r, int mode, ut64 baddr, int va) {
if ((mode & R_CORE_BIN_JSON)) {
r_cons_printf ("[");
r_list_foreach (list, iter, string) {
char *p, *str = strdup (string->string);
q = strdup (string->string);
//r_name_filter (str, 128);
for (p=str;*p;p++) if(*p=='"')*p='\'';
for (p=q;*p;p++) if(*p=='"')*p='\'';
r_cons_printf ("%s{\"offset\":%"PFMT64d",\"length\":%d,\"string\":\"%s\"}",
iter->p?",":"", va? string->rva:string->offset,
string->size, str);
free (str);
iter->p? ",": "", va? string->rva: string->offset, string->size, q);
free (q);
}
r_cons_printf ("]");
} else
if ((mode & R_CORE_BIN_SIMPLE)) {
r_list_foreach (list, iter, string) {
r_list_foreach (list, iter, string)
r_cons_printf ("%"PFMT64d" %d %s\n",
va? string->rva:string->offset, string->size, string->string);
}
} else
if ((mode & R_CORE_BIN_SET)) {
if (r_config_get_i (r->config, "bin.strings"))
@ -68,25 +62,22 @@ static int bin_strings (RCore *r, int mode, ut64 baddr, int va) {
}
r_cons_break_end ();
} else {
if (mode) r_cons_printf ("fs strings\n");
else r_cons_printf ("[strings]\n");
r_cons_printf (mode?"fs strings\n": "[strings]\n");
r_list_foreach (list, iter, string) {
section = r_bin_get_section_at (r->bin, string->offset, 0);
if (mode) {
r_name_filter (string->string, sizeof (string->string));
r_cons_printf ("f str.%s %"PFMT64d" @ 0x%08"PFMT64x"\n"
"Cs %"PFMT64d" @ 0x%08"PFMT64x"\n",
string->string, string->size, va?baddr+string->rva:string->offset,
string->size, va?baddr+string->rva:string->offset);
"Cs %"PFMT64d" @ 0x%08"PFMT64x"\n",
string->string, string->size, va?baddr+string->rva:string->offset,
string->size, va?baddr+string->rva:string->offset);
} else r_cons_printf ("addr=0x%08"PFMT64x" off=0x%08"PFMT64x" ordinal=%03"PFMT64d" "
"sz=%"PFMT64d" section=%s string=%s\n",
baddr+string->rva, string->offset,
string->ordinal, string->size,
section?section->name:"unknown", string->string);
"sz=%"PFMT64d" section=%s string=%s\n",
baddr+string->rva, string->offset,
string->ordinal, string->size,
section?section->name:"unknown", string->string);
i++;
}
if (!mode) r_cons_printf ("\n%i strings\n", i);
}
return R_TRUE;
@ -178,32 +169,31 @@ static int bin_info (RCore *r, int mode) {
}
} else {
// if type is 'fs' show something different?
r_cons_printf ("[File info]\n");
r_cons_printf ("File=%s\n"
"Type=%s\n"
"PositionIndependent=%s\n"
"HasVA=%s\n"
"RootClass=%s\n"
"Class=%s\n"
"Language=%s\n"
"Arch=%s %i\n"
"Machine=%s\n"
"OS=%s\n"
"Subsystem=%s\n"
"Big endian=%s\n"
"Stripped=%s\n"
"Static=%s\n"
"Line_nums=%s\n"
"Local_syms=%s\n"
"Relocs=%s\n"
"RPath=%s\n",
r_cons_printf ("# File info\n");
r_cons_printf ("file\t%s\n"
"type\t%s\n"
"pic\t%s\n"
"has_va\t%s\n"
"root\t%s\n"
"class\t%s\n"
"lang\t%s\n"
"arch\t%s %i\n"
"machine\t%s\n"
"os\t%s\n"
"subsys\t%s\n"
"endian\t%s\n"
"strip\t%s\n"
"static\t%s\n"
"linenum\t%s\n"
"lsyms\t%s\n"
"relocs\t%s\n"
"rpath\t%s\n",
info->file, info->type,
r_str_bool (info->has_pi),
r_str_bool (info->has_va),
info->rclass, info->bclass, info->lang?info->lang:"unknown",
info->arch, info->bits, info->machine, info->os,
info->subsystem,
r_str_bool (info->big_endian),
info->subsystem, info->big_endian? "big": "little",
r_str_bool (R_BIN_DBG_STRIPPED (info->dbg_info)),
r_str_bool (R_BIN_DBG_STATIC (info->dbg_info)),
r_str_bool (R_BIN_DBG_LINENUMS (info->dbg_info)),

View File

@ -1,4 +1,4 @@
/* radare - LGPL - Copyright 2009-2012 - pancake */
/* radare - LGPL - Copyright 2009-2013 - pancake */
static void r_core_file_info (RCore *core, int mode) {
const char *fn = NULL;
@ -51,6 +51,7 @@ static void r_core_file_info (RCore *core, int mode) {
r_cons_printf (",\"format\":\"%s\"", core->bin->cur.curplugin->name);
r_cons_printf ("}");
} else {
r_cons_printf ("# Core file info\n");
r_cons_printf ("file\t%s\n", fn);
if (dbg) dbg = R_IO_WRITE | R_IO_EXEC;
r_cons_printf ("fd\t%d\n", core->file->fd->fd);
@ -79,40 +80,20 @@ static int cmd_info(void *data, const char *input) {
}
switch (*input) {
case 'o':
if (input[1]==' ')
r_core_bin_load (core, input+1);
else r_core_bin_load (core, core->file->filename);
break;
case 'S':
//r_core_bin_info (core, R_CORE_BIN_ACC_SECTIONS|R_CORE_BIN_ACC_FIELDS, mode, va, NULL, offset);
r_core_bin_info (core, R_CORE_BIN_ACC_SECTIONS, mode, va, NULL, offset);
break;
case 'h':
r_core_bin_info (core, R_CORE_BIN_ACC_FIELDS, mode, va, NULL, offset);
break;
case 'c':
case 'C':
r_core_bin_info (core, R_CORE_BIN_ACC_CLASSES, mode, va, NULL, offset);
break;
case 's':
r_core_bin_info (core, R_CORE_BIN_ACC_SYMBOLS, mode, va, NULL, offset);
break;
case 'd':
r_core_bin_info (core, R_CORE_BIN_ACC_DWARF, mode, va, NULL, offset);
break;
case 'i':
r_core_bin_info (core, R_CORE_BIN_ACC_IMPORTS, mode, va, NULL, offset);
break;
case 'I':
r_core_bin_info (core, R_CORE_BIN_ACC_INFO, mode, va, NULL, offset);
break;
case 'e':
r_core_bin_info (core, R_CORE_BIN_ACC_ENTRIES, mode, va, NULL, offset);
break;
case 'z':
r_core_bin_info (core, R_CORE_BIN_ACC_STRINGS, mode, va, NULL, offset);
break;
//r_core_bin_info (core, R_CORE_BIN_ACC_SECTIONS|R_CORE_BIN_ACC_FIELDS, mode, va, NULL, offset);
case 'S': r_core_bin_info (core, R_CORE_BIN_ACC_SECTIONS, mode, va, NULL, offset); break;
case 'o': r_core_bin_load (core, input[1]==' '? input+1: core->file->filename); break;
case 'h': r_core_bin_info (core, R_CORE_BIN_ACC_FIELDS, mode, va, NULL, offset); break;
case 's': r_core_bin_info (core, R_CORE_BIN_ACC_SYMBOLS, mode, va, NULL, offset); break;
case 'd': r_core_bin_info (core, R_CORE_BIN_ACC_DWARF, mode, va, NULL, offset); break;
case 'i': r_core_bin_info (core, R_CORE_BIN_ACC_IMPORTS, mode, va, NULL, offset); break;
case 'I': r_core_bin_info (core, R_CORE_BIN_ACC_INFO, mode, va, NULL, offset); break;
case 'e': r_core_bin_info (core, R_CORE_BIN_ACC_ENTRIES, mode, va, NULL, offset); break;
case 'z': r_core_bin_info (core, R_CORE_BIN_ACC_STRINGS, mode, va, NULL, offset); break;
case 'a':
if (input[1]=='*') {
cmd_info (core, "I*");
@ -150,23 +131,20 @@ static int cmd_info(void *data, const char *input) {
" iS ; sections\n"
" iz ; strings\n");
break;
case '*':
case 'j':
if (*input== '*') mode = R_CORE_BIN_RADARE;
else if (*input=='j') mode = R_CORE_BIN_JSON;
case '*': mode = R_CORE_BIN_RADARE;
case 'j': if (*input=='j') mode = R_CORE_BIN_JSON;
default:
if (!core->file) {
eprintf ("No selected file\n");
return R_FALSE;
}
if (mode == R_CORE_BIN_JSON)
r_cons_printf ("{\"bin\":");
r_core_bin_info (core, R_CORE_BIN_ACC_INFO, mode, va, NULL, offset);
if (mode == R_CORE_BIN_JSON)
r_cons_printf (",\"core\":");
r_core_file_info (core, mode);
if (mode == R_CORE_BIN_JSON)
r_cons_printf ("}\n");
if (core->file) {
if (mode == R_CORE_BIN_JSON)
r_cons_printf ("{\"bin\":");
r_core_bin_info (core, R_CORE_BIN_ACC_INFO,
mode, va, NULL, offset);
if (mode == R_CORE_BIN_JSON)
r_cons_printf (",\"core\":");
r_core_file_info (core, mode);
if (mode == R_CORE_BIN_JSON)
r_cons_printf ("}\n");
} else eprintf ("No selected file\n");
}
return 0;
}

View File

@ -1,4 +1,4 @@
/* radare - LGPL - Copyright 2009-2012 - pancake */
/* radare - LGPL - Copyright 2009-2013 - pancake */
#include <r_core.h>
@ -136,7 +136,10 @@ R_API char *r_core_sysenv_begin(RCore *core, const char *cmd) {
}
R_API int r_core_bin_load(RCore *r, const char *file) {
int va = r->io->va || r->io->debug;
int i, va = r->io->va || r->io->debug;
RListIter *iter;
ut64 offset;
RIOMap *im;
if (file == NULL || !r->file || !*file) {
if (!r->file || !r->file->filename)
@ -145,7 +148,6 @@ R_API int r_core_bin_load(RCore *r, const char *file) {
}
if (r_bin_load (r->bin, file, R_FALSE)) {
if (r->bin->narch>1 && r_config_get_i (r->config, "scr.prompt")) {
int i;
RBinObject *o = r->bin->cur.o;
eprintf ("NOTE: Fat binary found. Selected sub-bin is: -a %s -b %d\n",
r->assembler->cur->arch, r->assembler->bits);
@ -163,9 +165,6 @@ R_API int r_core_bin_load(RCore *r, const char *file) {
}
r_bin_select (r->bin, r->assembler->cur->arch, r->assembler->bits, NULL);//"x86_32");
{
RIOMap *im;
RListIter *iter;
/* Fix for fat bins */
r_list_foreach (r->io->maps, iter, im) {
if (r->bin->cur.size > 0) {
@ -173,27 +172,24 @@ R_API int r_core_bin_load(RCore *r, const char *file) {
im->to = im->from + r->bin->cur.size;
}
}
}
} else if (!r_bin_load (r->bin, file, R_TRUE))
return R_FALSE;
r->file->obj = r_bin_get_object (r->bin, 0);
if (r->file->obj->info != NULL) {
r_config_set_i (r->config, "io.va", r->file->obj->info->has_va);
} else r_config_set_i (r->config, "io.va", 0);
{
ut64 offset = r_bin_get_offset (r->bin);
r_core_bin_info (r, R_CORE_BIN_ACC_ALL, R_CORE_BIN_SET, va, NULL, offset);
}
r_config_set_i (r->config, "io.va",
(r->file->obj->info)? r->file->obj->info->has_va: 0);
offset = r_bin_get_offset (r->bin);
r_core_bin_info (r, R_CORE_BIN_ACC_ALL, R_CORE_BIN_SET, va, NULL, offset);
if (r_config_get_i (r->config, "file.analyze"))
r_core_cmd0 (r, "aa");
return R_TRUE;
}
R_API RCoreFile *r_core_file_open(RCore *r, const char *file, int mode, ut64 loadaddr) {
RCoreFile *fh;
const char *cp;
char *p;
RCoreFile *fh;
RIODesc *fd;
char *p;
if (!strcmp (file, "-")) {
file = "malloc://512";
mode = 4|2;
@ -308,10 +304,10 @@ R_API int r_core_file_close_fd(RCore *core, int fd) {
}
R_API int r_core_hash_load(RCore *r, const char *file) {
ut8 *buf = NULL;
int i, buf_len = 0;
const ut8 *md5, *sha1;
char hash[128], *p;
int i, buf_len = 0;
ut8 *buf = NULL;
RHash *ctx;
ut64 limit;

View File

@ -5,10 +5,6 @@
#include <r_flags.h>
#include <r_core.h>
#ifndef O_BINARY
#define O_BINARY 0
#endif
static char *r_core_project_file(const char *file) {
char buf[128];
if (!strchr (file, '/')) {
@ -44,31 +40,27 @@ R_API int r_core_project_open(RCore *core, const char *prjfile) {
}
R_API char *r_core_project_info(RCore *core, const char *prjfile) {
char buf[256], *file = NULL;
char *prj = r_core_project_file (prjfile);
FILE *fd;
if (prj && (fd = r_sandbox_fopen (prj, "r"))) {
for (;;) {
fgets (buf, sizeof (buf), fd);
if (feof (fd))
break;
if (!memcmp (buf, "e file.path = ", 14)) {
buf[strlen(buf)-1]=0;
file = r_str_new (buf+14);
break;
}
char buf[256], *file = NULL, *prj = r_core_project_file (prjfile);
FILE *fd = prj? r_sandbox_fopen (prj, "r"): NULL;
for (;fd;) {
fgets (buf, sizeof (buf), fd);
if (feof (fd))
break;
if (!memcmp (buf, "e file.path = ", 14)) {
buf[strlen(buf)-1]=0;
file = r_str_new (buf+14);
break;
}
fclose (fd);
}
fclose (fd);
r_cons_printf ("Project : %s\n", prj);
if (file)
r_cons_printf ("FilePath: %s\n", file);
if (file) r_cons_printf ("FilePath: %s\n", file);
free (prj);
return file;
}
R_API int r_core_project_save(RCore *core, const char *file) {
int fd, tmp, ret = R_TRUE;
int fd, fdold, tmp, ret = R_TRUE;
char *prj;
if (file == NULL || *file == '\0')
@ -78,18 +70,16 @@ R_API int r_core_project_save(RCore *core, const char *file) {
r_core_project_init ();
fd = r_sandbox_open (prj, O_BINARY|O_RDWR|O_CREAT, 0644);
if (fd != -1) {
int fdold = r_cons_singleton ()->fdout;
fdold = r_cons_singleton ()->fdout;
r_cons_singleton ()->fdout = fd;
r_cons_singleton ()->is_interactive = R_FALSE;
r_str_write (fd, "# r2 rdb project file\n");
//--
r_str_write (fd, "# flags\n");
tmp = core->flags->space_idx;
core->flags->space_idx = -1;
r_flag_list (core->flags, R_TRUE);
core->flags->space_idx = tmp;
r_cons_flush ();
//--
r_str_write (fd, "# eval\n");
// TODO: r_str_writef (fd, "e asm.arch=%s", r_config_get ("asm.arch"));
r_config_list (core->config, NULL, R_TRUE);

View File

@ -1,6 +0,0 @@
include ../../../global.mk
.PHONY: all
all:
include $(TOP)/libr/rules.mk

View File

@ -1,14 +0,0 @@
#include <r_core.h>
int main() {
RCore *core = r_core_new ();
r_core_file_open (core, "dbg:///bin/ls", R_FALSE);
r_core_cmd0(core, "e cfg.debug=true");
// r_debug_use (&core->dbg, "native");
// r_core_cmd0(core, "dpf");
// r_core_cmd0(core, "dpf");
r_core_cmd0(core, "dr");
r_core_cmd0(core, ".dr*");
r_core_cmd0(core, "px@esp");
r_cons_flush();
}

View File

@ -1,21 +0,0 @@
#include <stdio.h>
static int show_help(int large)
{
printf("Usage: ragrep2 [-a x86] [-L] [-xsd str] [-ft addr] [file] [...]\n");
if (large) printf(
" -a x86 select architecture for disasm search\n"
" -L list r_asm plugins\n"
" -x 908e search a hexpair string\n"
" -s str search a string\n"
" -d opcode search an opcode\n"
" -f 0x102 'from' address\n"
" -t 0x502 'to' address\n");
return 0;
}
int main(int argc, char **argv)
{
/* TODO t/ragrep2 not implemented */
return show_help(1);
}

View File

@ -23,14 +23,15 @@ static int marks_init = 0;
static ut64 marks[UT8_MAX+1];
static int r_core_visual_hud(RCore *core) {
const char *f = R2_LIBDIR"/radare2/"R2_VERSION"/hud/main";
char *homehud = r_str_home("/.radare2/hud");
char *res = NULL;
char *p = 0;
r_cons_show_cursor (R_TRUE);
char *homehud = r_str_home("/.radare2/hud");
if (homehud)
res = r_cons_hud_file (homehud);
if (!res) {
const char *f = R2_LIBDIR"/radare2/"R2_VERSION"/hud/main";
if (r_file_exists (f))
res = r_cons_hud_file (f);
else r_cons_message ("Cannot find hud file");
@ -205,7 +206,7 @@ static void visual_search (RCore *core) {
R_API int r_core_visual_cmd(RCore *core, int ch) {
RAsmOp op;
char buf[4096];
int i, cols = core->print->cols;
int i, ret, offscreen, cols = core->print->cols;
ch = r_cons_arrow_to_hjkl (ch);
ch = visual_nkey (core, ch);
if (ch<2) return 1;
@ -403,8 +404,7 @@ R_API int r_core_visual_cmd(RCore *core, int ch) {
r_io_sundo_push (core->io, core->offset);
break;
case 'G':
{
int ret = 0;
ret = 0;
if (core->io->va) {
ut64 offset = r_io_section_get_vaddr (core->io, 0);
if (offset == UT64_MAX) {
@ -420,7 +420,6 @@ R_API int r_core_visual_cmd(RCore *core, int ch) {
}
if (ret != -1)
r_io_sundo_push (core->io, core->offset);
}
break;
case 'h':
if (curset) {
@ -460,13 +459,11 @@ R_API int r_core_visual_cmd(RCore *core, int ch) {
if (curset) {
if (ocursor==-1) ocursor=cursor;
cursor++;
{
int offscreen = (core->cons->rows-3)*cols;
if (cursor>=offscreen) {
r_core_seek (core, core->offset+cols, 1);
cursor-=cols;
ocursor-=cols;
}
offscreen = (core->cons->rows-3)*cols;
if (cursor>=offscreen) {
r_core_seek (core, core->offset+cols, 1);
cursor-=cols;
ocursor-=cols;
}
} else r_core_seek_delta (core, 2);
break;
@ -477,13 +474,11 @@ R_API int r_core_visual_cmd(RCore *core, int ch) {
&op, core->block+cursor, 32);
cursor += cols;
ocursor = -1;
{
int offscreen = (core->cons->rows-3)*cols;
if (cursor>=offscreen) {
//ut64 x = core->offset + cols;
r_core_seek (core, core->offset+cols, 1);
cursor-=cols;
}
offscreen = (core->cons->rows-3)*cols;
if (cursor>=offscreen) {
//ut64 x = core->offset + cols;
r_core_seek (core, core->offset+cols, 1);
cursor-=cols;
}
} else {
if (core->printidx == 1 || core->printidx == 2) {
@ -501,13 +496,11 @@ R_API int r_core_visual_cmd(RCore *core, int ch) {
if (curset) {
if (ocursor==-1) ocursor = cursor;
cursor += cols;
{
int offscreen = (core->cons->rows-3)*cols;
if (cursor>=offscreen) {
r_core_seek (core, core->offset+cols, 1);
cursor-=cols;
ocursor-=cols;
}
offscreen = (core->cons->rows-3)*cols;
if (cursor>=offscreen) {
r_core_seek (core, core->offset+cols, 1);
cursor-=cols;
ocursor-=cols;
}
} else r_core_seek (core, core->offset+obs, 1);
break;
@ -524,7 +517,6 @@ R_API int r_core_visual_cmd(RCore *core, int ch) {
}
} else {
if (core->printidx == 1 || core->printidx == 2) {
int i;
cols = core->inc;
for (i = 0; i < R_CORE_ASMSTEPS; i++)
if (core->offset == core->asmsteps[i].offset)

View File

@ -148,6 +148,9 @@ typedef void (*PrintfCallback)(const char *str, ...);
#define PFMT64o "llo"
#endif
#ifndef O_BINARY
#define O_BINARY 0
#endif
#if __APPLE__
# if __i386__