ref: 327b03d58b8ba6d5d928c338ea8c32e27a2f9c94
parent: e0614afe4458a7fdabc4da686bae925552e4be3e
author: Roberto E. Vargas Caballero <[email protected]>
date: Tue Apr 22 04:32:14 EDT 2014
Eval expressions in arithmetic arithmetic cannot deals with comparisions, so they must be evaluated before of doing anything.
--- a/expr.c
+++ b/expr.c
@@ -59,6 +59,14 @@
}
static Node *
+eval(Node *np)
+{
+ if (!ISNODECMP(np))
+ return np;
+ return ternarycode(np, symcode(one), symcode(zero));
+}
+
+static Node *
integerop(char op, Node *np1, Node *np2)
{
if (np1->typeop != INT || np2->typeop != INT)
@@ -172,6 +180,8 @@
static Node *
arithmetic(char op, Node *np1, Node *np2)
{
+ np1 = eval(np1);
+ np2 = eval(np2);
switch (np1->typeop) {
case INT: case FLOAT:
switch (np2->typeop) {
@@ -293,14 +303,6 @@
if (ISNODECMP(np))
return np;
return compare(ONE, np, symcode(zero));
-}
-
-static Node *
-eval(Node *np)
-{
- if (!ISNODECMP(np))
- return np;
- return ternarycode(np, symcode(one), symcode(zero));
}
static Node *