Fix #203 - Call to a section + some more work on utf8
This commit is contained in:
parent
3ff36c3965
commit
302328a76c
1
TODO.md
1
TODO.md
|
@ -15,7 +15,6 @@ Broken stuff to fixe before release
|
|||
=====
|
||||
* use __unused if available
|
||||
* rafind2 : add support for unicode/widestring search
|
||||
* e dbg.hwbp para evitar q use hwbps
|
||||
* .dr- # documented... but not working
|
||||
* libr/debug/p/drx.c <- not used .. debug must have a hw reg api for drx and gpio
|
||||
* ah -> add hint to define calls that do not return
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
#include <signal.h>
|
||||
#endif
|
||||
|
||||
R_LIB_VERSION(r_cons);
|
||||
R_LIB_VERSION (r_cons);
|
||||
|
||||
static RCons r_cons_instance;
|
||||
#define I r_cons_instance
|
||||
|
@ -199,6 +199,7 @@ R_API void r_cons_gotoxy(int x, int y) {
|
|||
R_API void r_cons_print_clear() {
|
||||
// xlr8!
|
||||
r_cons_write ("\x1b[0;0H", 6);
|
||||
r_cons_write ("\x1b[0m", 4);
|
||||
//r_cons_memcat ("\x1b[2J", 4);
|
||||
}
|
||||
|
||||
|
|
|
@ -43,6 +43,19 @@ void w32_gotoxy(int x, int y) {
|
|||
SetConsoleCursorPosition (hStdout, coord);
|
||||
}
|
||||
|
||||
static int wrapline (const char *s, int len) {
|
||||
const char *p = s;
|
||||
int l, n = 0;
|
||||
for (; n<len; ) {
|
||||
l = r_str_len_utf8char (s+n, (len-n));
|
||||
n += l;
|
||||
}
|
||||
if (n>len)
|
||||
n -= l;
|
||||
else n--;
|
||||
return n;
|
||||
}
|
||||
|
||||
R_API int r_cons_w32_print(ut8 *ptr, int empty) {
|
||||
HANDLE hConsole = GetStdHandle (STD_OUTPUT_HANDLE);
|
||||
int esc = 0;
|
||||
|
@ -63,6 +76,7 @@ R_API int r_cons_w32_print(ut8 *ptr, int empty) {
|
|||
if (ll<1)
|
||||
continue;
|
||||
if (empty) {
|
||||
// TODO: Fix utf8 chop
|
||||
/* only chop columns if necessary */
|
||||
if (linelen+ll>cols) {
|
||||
// chop line if too long
|
||||
|
@ -101,12 +115,15 @@ R_API int r_cons_w32_print(ut8 *ptr, int empty) {
|
|||
}
|
||||
}
|
||||
write (1, "\n\r", 2);
|
||||
//write (1, "\r\n", 2);
|
||||
//lines--;
|
||||
linelen = 0;
|
||||
}
|
||||
if (linelen+ll>cols) {
|
||||
// chop line if too long
|
||||
ll = (cols-linelen)-1;
|
||||
// fix utf8 len here
|
||||
ll = wrapline (str, cols-linelen-1);
|
||||
}
|
||||
if (ll>0) {
|
||||
write (1, str, ll);
|
||||
|
|
|
@ -363,7 +363,7 @@ R_API int r_core_anal_fcn(RCore *core, ut64 at, ut64 from, int reftype, int dept
|
|||
(fcnlen == R_ANAL_RET_END && fcn->size < 1)) { /* Error analyzing function */
|
||||
goto error;
|
||||
} else if (fcnlen == R_ANAL_RET_END) { /* Function analysis complete */
|
||||
RFlagItem *f = r_flag_get_i (core->flags, at);
|
||||
RFlagItem *f = r_flag_get_i2 (core->flags, at);
|
||||
if (f) { /* Check if it's already flagged */
|
||||
fcn->name = strdup (f->name); // memleak here?
|
||||
} else {
|
||||
|
|
|
@ -10,6 +10,11 @@ static int cmd_flag(void *data, const char *input) {
|
|||
if (*input)
|
||||
str = strdup (input+1);
|
||||
switch (*input) {
|
||||
case '2':
|
||||
{
|
||||
r_flag_get_i2 (core->flags, r_num_math (core->num, input+1));
|
||||
}
|
||||
break;
|
||||
case 'R':
|
||||
{
|
||||
char *p = strchr (str+1, ' ');
|
||||
|
|
|
@ -92,8 +92,28 @@ R_API RFlagItem *r_flag_get(RFlag *f, const char *name) {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
#define R_FLAG_TEST 0
|
||||
|
||||
R_API RFlagItem *r_flag_get_i2(RFlag *f, ut64 off) {
|
||||
RFlagItem *oitem = NULL;
|
||||
RFlagItem *item = NULL;
|
||||
RList *list = r_hashtable64_lookup (f->ht_off, off);
|
||||
if (list) {
|
||||
RListIter *iter;
|
||||
r_list_foreach (list, iter, item) {
|
||||
// XXX: hack, because some times the hashtable is poluted by ghost values
|
||||
if (item->offset != off)
|
||||
continue;
|
||||
if (!strchr (item->name, '.'))
|
||||
oitem = item;
|
||||
if (strlen (item->name) < 5 || item->name[3]!='.')
|
||||
continue;
|
||||
oitem = item;
|
||||
}
|
||||
}
|
||||
return oitem;
|
||||
}
|
||||
|
||||
#define R_FLAG_TEST 0
|
||||
R_API RFlagItem *r_flag_get_i(RFlag *f, ut64 off) {
|
||||
RList *list = r_hashtable64_lookup (f->ht_off, off);
|
||||
if (list) {
|
||||
|
@ -118,6 +138,7 @@ R_API int r_flag_set(RFlag *f, const char *name, ut64 off, ut32 size, int dup) {
|
|||
if (!name || !*name)
|
||||
return R_FALSE;
|
||||
if (dup) {
|
||||
// XXX: doesnt works well
|
||||
item = R_NEW0 (RFlagItem);
|
||||
if (!r_flag_item_set_name (item, name)) {
|
||||
eprintf ("Invalid flag name '%s'.\n", name);
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -58,6 +58,7 @@ R_API RFlag * r_flag_free(RFlag *f);
|
|||
R_API void r_flag_list(RFlag *f, int rad);
|
||||
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_i2(RFlag *f, ut64 off);
|
||||
R_API int r_flag_unset(RFlag *f, const char *name, RFlagItem *p);
|
||||
R_API int r_flag_unset_i(RFlag *f, ut64 addr, RFlagItem *p);
|
||||
R_API int r_flag_set(RFlag *fo, const char *name, ut64 addr, ut32 size, int dup);
|
||||
|
|
|
@ -338,6 +338,7 @@ R_API int r_base64_decode(ut8 *bout, const ut8 *bin, int len);
|
|||
R_API const char *r_str_rchr(const char *base, const char *p, int ch);
|
||||
R_API void r_str_unescape (char *s);
|
||||
R_API int r_str_len_utf8 (const char *s);
|
||||
R_API int r_str_len_utf8char (const char *s, int left);
|
||||
R_API void r_str_filter_zeroline(char *str, int len);
|
||||
R_API int r_str_write (int fd, const char *b);
|
||||
R_API void r_str_ncpy(char *dst, const char *src, int n);
|
||||
|
|
|
@ -953,6 +953,16 @@ R_API const char *r_str_lastbut (const char *s, char ch, const char *but) {
|
|||
}
|
||||
|
||||
// Must be merged inside strlen
|
||||
R_API int r_str_len_utf8char (const char *s, int left) {
|
||||
int i = 1;
|
||||
while (s[i] && (!left || i<left)) {
|
||||
if ((s[i] & 0xc0) != 0x80) {
|
||||
i++;
|
||||
} else break;
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
R_API int r_str_len_utf8 (const char *s) {
|
||||
int i = 0, j = 0;
|
||||
while (s[i]) {
|
||||
|
|
Loading…
Reference in New Issue