about summary refs log tree commit diff stats
path: root/apps
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2020-10-13 10:15:23 -0700
committerKartik Agaram <vc@akkartik.com>2020-10-13 10:15:23 -0700
commit6310b0c44da0d5316e21e175c08d96f200272271 (patch)
tree601e66bb798eeaacd6a2e47dd16a3b5247786824 /apps
parentaf52cb8d1fe6b523cd733c699f72508509be45cc (diff)
downloadmu-6310b0c44da0d5316e21e175c08d96f200272271.tar.gz
7016 - raw addrs shouldn't escape functions
We don't have the static checks for this yet, but discovering I've not
been following my own rules bumps the priority on it.
Diffstat (limited to 'apps')
-rw-r--r--apps/browse/main.mu14
1 files changed, 5 insertions, 9 deletions
diff --git a/apps/browse/main.mu b/apps/browse/main.mu
index 3736c1f4..3a397ee0 100644
--- a/apps/browse/main.mu
+++ b/apps/browse/main.mu
@@ -26,10 +26,12 @@ fn main args-on-stack: (addr array addr array byte) -> exit-status/ebx: int {
   }
 }
 
-fn interactive args: (addr array addr array byte) -> exit-status/ebx: int {
+fn interactive _args: (addr array addr array byte) -> exit-status/ebx: int {
 $interactive:body: {
   # initialize fs from args[1]
-  var filename/eax: (addr array byte) <- first-arg args
+  var args/eax: (addr array addr array byte) <- copy _args
+  var arg/eax: (addr addr array byte) <- index args, 1
+  var filename/eax: (addr array byte) <- copy *arg
   var file-storage: (handle buffered-file)
   var file-storage-addr/esi: (addr handle buffered-file) <- address file-storage
   open filename, 0, file-storage-addr
@@ -54,7 +56,7 @@ $interactive:body: {
   #
   {
     render paginated-screen, fs
-    var key/eax: byte <- read-key-from-real-keyboard
+    var key/eax: grapheme <- read-key-from-real-keyboard
     compare key, 0x71  # 'q'
     loop-if-!=
   }
@@ -395,12 +397,6 @@ fn render-until-underscore screen: (addr paginated-screen), fs: (addr buffered-f
   }
 }
 
-fn first-arg args-on-stack: (addr array addr array byte) -> out/eax: (addr array byte) {
-  var args/eax: (addr array addr array byte) <- copy args-on-stack
-  var result/eax: (addr addr array byte) <- index args, 1
-  out <- copy *result
-}
-
 fn normal-text screen: (addr paginated-screen) {
   reset-formatting-on-paginated-screen screen
   start-color-on-paginated-screen screen, 0xec, 7  # 236 = darkish gray