From b281bf7d9ee53e4585210bb8461d78bb2f386a21 Mon Sep 17 00:00:00 2001 From: kitty Date: Wed, 4 Mar 2026 14:34:13 +1100 Subject: buffer-key none of this is tested yet need to do ACCEPT then REFILL then LOAD i guess? --- jefs.fs | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/jefs.fs b/jefs.fs index d7782cb..23cde43 100644 --- a/jefs.fs +++ b/jefs.fs @@ -290,21 +290,15 @@ make buffers /buffer #buffers * allot make buffers-used #buffers cells allot make buffers->in #buffers cells allot -\ how to handle EOF? : cbuffer include-depth /buffer * buffers + ; : cbuffer-used include-depth cells buffers-used + ; : cbuffer->in include-depth cells buffers->in + ; : buffer-refill ( u|0 ) cbuffer /buffer stdin read-file 0<> if 0 then 0 cbuffer->in ! dup cbuffer-used ! ; \ returns zero on error or nothing read. -\ : buffer-key current-buffer current-buffer-used ( TODO ) ; : buffer-remaining? cbuffer->in @ cbuffer-used @ >= ; -: buffer-key ( -- key|-1 ) buffer-remaining? not if - buffer-refill 0<> if -1 [ ret, ] else 0= if -1 [ ret, ] then then then - ; -( check if remaining buffer is empty ) -( if it is, try to fill it ) -( if it doesn't work then the file has ended, yield -1 ) -( otherwise get the next char, add one to the buffer's >in, yield char ) +: buffer-key buffer-remaining? not if buffer-refill 0= if -1 [ ret, ] then then + cbuffer cbuffer->in @ + c@ + cbuffer->in @ 1+ cbuffer->in ! ; \ i think i'll just take the wonkiness of \ 'if you use LOAD or something like that you lose the rest of that line' -- cgit v1.2.3