From: Leo C Date: Tue, 21 Jun 2016 21:14:01 +0000 (+0200) Subject: Expression eval: Repair unary + and - X-Git-Tag: hexrel-6.8.1~1 X-Git-Url: http://cloudbase.mooo.com/gitweb/z180-stamp.git/commitdiff_plain/a11e60da10b1065dfcf57bb742670b74784703e2 Expression eval: Repair unary + and - --- diff --git a/avr/eval_arg.c b/avr/eval_arg.c index 020dd98..b931509 100644 --- a/avr/eval_arg.c +++ b/avr/eval_arg.c @@ -38,7 +38,7 @@ static void next(void) { do ch = *bp++; - while (ch == ' ' || ch == '\n'); + while (isspace(ch)); } static long number (void) @@ -76,10 +76,15 @@ static long factor (void) next(); else error (); + } else { + char sign = ch; + if (sign == '+' || sign == '-') { + next(); + } + f = number(); + if (sign == '-') + f = -f; } - else - f = number (); - return f; } @@ -109,16 +114,7 @@ static long term (void) static long expr(void) { - long e; - - if (ch == '+') { - next(); - e = term (); - } else if (ch == '-') { - next(); - e = - term (); - } else - e = term (); + long e = term (); while (ch == '+' || ch == '-') { char op = ch;