]> cloudbase.mooo.com Git - z180-stamp.git/blobdiff - avr/eval_arg.c
Add makefiles (replace Tup)
[z180-stamp.git] / avr / eval_arg.c
index 020dd98369346808dde400ba53ee39c2166f8737..fd8b067acf53bed4339feed7a82045cec96db2c2 100644 (file)
@@ -5,12 +5,10 @@
  */
 
 #include "eval_arg.h"
-#include "common.h"
-#include <stdlib.h>
+#include "command.h"   /* jump_buf */
 #include <ctype.h>
 #include <setjmp.h>
 #include "print-utils.h"
-#include "command.h"   /* jump_buf */
 
 static jmp_buf eval_jbuf;
 static char ch;
@@ -38,7 +36,7 @@ static void next(void)
 {
        do
                ch = *bp++;
-       while (ch == ' ' || ch == '\n');
+       while (isspace(ch));
 }
 
 static long number (void)
@@ -76,10 +74,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 +112,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;