about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2020-06-15 22:48:07 -0700
committerKartik Agaram <vc@akkartik.com>2020-06-15 22:48:07 -0700
commiteeb250a7461165225f8cc28c3d2bf95d21124cf8 (patch)
tree986ab527219cd2ab61e8919c9575ea73957d6f66
parent9f0e69f19b462f2d9cbff784790e8b411e427492 (diff)
downloadmu-eeb250a7461165225f8cc28c3d2bf95d21124cf8.tar.gz
6536
Cleaner way to handle EOF.
-rw-r--r--apps/arith.mu15
1 files changed, 7 insertions, 8 deletions
diff --git a/apps/arith.mu b/apps/arith.mu
index 4eef6127..7d6c76b4 100644
--- a/apps/arith.mu
+++ b/apps/arith.mu
@@ -24,14 +24,7 @@ fn simplify -> result/eax: int, look/esi: byte {
     look <- get-char  # prime the pump
     # first arg
     look <- skip-spaces look
-    {
-      {
-        var is-digit?/eax: boolean <- is-decimal-digit? look
-        compare is-digit?, 0  # false
-        break-if-= $simplify:body
-      }
-      result, look <- num look
-    }
+    result, look <- num look
     # operator
     var op/ecx: byte <- copy 0
     look <- skip-spaces look
@@ -106,4 +99,10 @@ fn skip-spaces _look: byte -> look/esi: byte {
 fn get-char -> look/esi: byte {
   var tmp/eax: byte <- read-key
   look <- copy tmp
+  compare look, 0
+  {
+    break-if-!=
+    print-string "^D\n"
+    syscall_exit
+  }
 }