Fix comparison commands ??, ?!, ?+ and ?-

This commit is contained in:
pancake 2012-12-01 00:15:19 +01:00
parent e367b93e93
commit 0b5d2ef737
4 changed files with 31 additions and 11 deletions

12
TODO.md
View File

@ -1,10 +1,18 @@
<pre>
____ ___ ___ ___ ____ ___ _____ ____
| _ \/ \| \/ \ _ \/ _ \ \__ \ / \
| ( V \ | ) V \ ( __/ .-` _/| () |
|__\__|_|__|___/__|__|_\__\___\ |____(_)____/
</pre>
Broken stuff to fixe before release
===================================
- conditionals doesnt work
- java
- dalvik
- dwarf
- rar asm/dis
0.9.4
=====

View File

@ -83,7 +83,7 @@ R_API int r_config_swap(RConfig *cfg, const char *name) {
R_API ut64 r_config_get_i(RConfig *cfg, const char *name) {
RConfigNode *node = r_config_node_get (cfg, name);
if (node) {
if (node->i_value != 0)
if (node->i_value != 0 || !strcmp (node->value, "false"))
return node->i_value;
return (ut64)r_num_math (cfg->num, node->value);
}

View File

@ -96,26 +96,31 @@ static int cmd_help(void *data, const char *input) {
if (input[1] == 'i' || input[1]=='d')
r_cons_printf ("%"PFMT64d"\n", n);
else r_cons_printf ("0x%"PFMT64x"\n", n);
core->num->value = n;
core->num->value = n; // redundant
break;
case '=':
r_num_math (core->num, input+1);
case '=': // set num->value
if (input[1]) {
r_num_math (core->num, input+1);
} else r_cons_printf ("0x%"PFMT64x"\n", core->num->value);
break;
case '+':
//eprintf ("NUMVAL %llx\n", core->num->value);
if (input[1]) {
if (core->num->value & UT64_GT0)
r_core_cmd (core, input+1, 0);
st64 n = (st64)core->num->value;
if (n>0) r_core_cmd (core, input+1, 0);
} else r_cons_printf ("0x%"PFMT64x"\n", core->num->value);
break;
case '-':
//eprintf ("NUMVAL %llx\n", core->num->value);
if (input[1]) {
if (core->num->value & UT64_LT0)
r_core_cmd (core, input+1, 0);
st64 n = (st64)core->num->value;
if (n<0) r_core_cmd (core, input+1, 0);
} else r_cons_printf ("0x%"PFMT64x"\n", core->num->value);
break;
case '!': // ??
//eprintf ("NUMVAL %llx\n", core->num->value);
if (input[1]) {
if (core->num->value != UT64_MIN)
if (!core->num->value)
r_core_cmd (core, input+1, 0);
} else r_cons_printf ("0x%"PFMT64x"\n", core->num->value);
break;
@ -294,6 +299,11 @@ static int cmd_help(void *data, const char *input) {
} break;
case '?': // ???
if (input[1]=='?') {
if (input[2]) {
if (core->num->value)
r_core_cmd (core, input+1, 0);
break;
}
r_cons_printf (
"Usage: ?[?[?]] expression\n"
" ? eip-0x804800 ; show hex and dec result for this math expr\n"

View File

@ -180,6 +180,8 @@ 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;
return ret;
#else
ut64 ret = 0LL;