mirror of
https://github.com/radareorg/radare2.git
synced 2024-11-30 16:40:57 +00:00
Fix #3682 - Handle 'x' char values by RNum
This commit is contained in:
parent
08a4cd1306
commit
a916a735e9
@ -136,7 +136,7 @@ typedef struct r_prof_t {
|
||||
} RProfile;
|
||||
|
||||
/* numbers */
|
||||
#define R_NUMCALC_STRSZ 4096
|
||||
#define R_NUMCALC_STRSZ 1024
|
||||
|
||||
typedef struct {
|
||||
double d;
|
||||
|
@ -171,16 +171,16 @@ static int cin_get(RNum *num, RNumCalc *nc, char *c) {
|
||||
|
||||
static int cin_get_num(RNum *num, RNumCalc *nc, RNumCalcValue *n) {
|
||||
double d;
|
||||
char str[R_NUMCALC_STRSZ];
|
||||
char str[R_NUMCALC_STRSZ]; // TODO: move into the heap?
|
||||
int i = 0;
|
||||
char c;
|
||||
str[0] = 0;
|
||||
while (cin_get (num, nc, &c)) {
|
||||
if (c!=':' && c!='.' && !isalnum ((unsigned char)c)) {
|
||||
if (c!=':' && c!='.' && !isalnum ((ut8)c)) {
|
||||
cin_putback (num, nc, c);
|
||||
break;
|
||||
}
|
||||
if (i<R_NUMCALC_STRSZ) {
|
||||
if (i < R_NUMCALC_STRSZ) {
|
||||
str[i++] = c;
|
||||
}
|
||||
}
|
||||
@ -215,6 +215,7 @@ static int cin_get_num(RNum *num, RNumCalc *nc, RNumCalcValue *n) {
|
||||
|
||||
static RNumCalcToken get_token(RNum *num, RNumCalc *nc) {
|
||||
char ch = 0, c = 0;
|
||||
int quote = 0;
|
||||
|
||||
do { if (!cin_get (num, nc, &ch)) return nc->curr_tok = RNCEND;
|
||||
} while (ch!='\n' && isspace ((unsigned char)ch));
|
||||
@ -288,7 +289,8 @@ static RNumCalcToken get_token(RNum *num, RNumCalc *nc) {
|
||||
}
|
||||
}
|
||||
nc->string_value[i] = 0;
|
||||
cin_putback (num, nc, ch);
|
||||
if (ch!='\'')
|
||||
cin_putback (num, nc, ch);
|
||||
return nc->curr_tok = RNCNAME;
|
||||
}
|
||||
/*
|
||||
|
@ -142,6 +142,9 @@ R_API ut64 r_num_get(RNum *num, const char *str) {
|
||||
}
|
||||
sscanf (str, "0x%"PFMT64x, &ret);
|
||||
} else
|
||||
if (str[0]=='\'') {
|
||||
ret = str[1] & 0xff;
|
||||
} else
|
||||
if (str[0]=='0' && str[1]=='x') {
|
||||
#if __WINDOWS__ && MINGW32 && !__CYGWIN__
|
||||
ret = _strtoui64 (str+2, NULL, 16);
|
||||
@ -189,8 +192,7 @@ R_API ut64 r_num_get(RNum *num, const char *str) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (num != NULL)
|
||||
num->value = ret;
|
||||
if (num) num->value = ret;
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -245,8 +247,7 @@ R_API ut64 r_num_math(RNum *num, const char *str) {
|
||||
ret = r_num_calc (num, str, &err);
|
||||
if (err) eprintf ("r_num_calc error: (%s) in (%s)\n", err, str);
|
||||
else if (num) num->value = ret;
|
||||
if (num != NULL)
|
||||
num->value = ret;
|
||||
if (num) num->value = ret;
|
||||
return ret;
|
||||
#else
|
||||
ut64 ret = 0LL;
|
||||
|
Loading…
Reference in New Issue
Block a user