From 420836276d0680ebc2664b6309d32b7528768744 Mon Sep 17 00:00:00 2001 From: Virgil Dupras Date: Sun, 12 Apr 2020 14:01:54 -0400 Subject: [PATCH] readln: rename (c<) to (rdln<) so that it isn't picked up automatically at boot. Only when (c<$) is called do we override (c<). This fixes tricky boot problems. --- forth/readln.fs | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/forth/readln.fs b/forth/readln.fs index 53ae78e..88691e4 100644 --- a/forth/readln.fs +++ b/forth/readln.fs @@ -19,17 +19,6 @@ ( set IN> to IN( and set IN> @ to null ) : (infl) 0 IN( @ DUP IN> ! ! ; -( Initializes the readln subsystem ) -: (c<$) - H@ IN( ! - INBUFSZ ALLOT - H@ IN) ! - ( We need two extra bytes. 1 for the last typed 0x0a and - one for the following NULL. ) - 2 ALLOT - (infl) -; - ( handle backspace: go back one char in IN>, if possible, then emit SPC + BS ) : (inbs) @@ -73,10 +62,23 @@ ; ( And finally, implement a replacement for the (c<) routine ) -: (c<) +: (rdln<) IN> @ C@ ( c ) ( not EOL? good, inc and return ) DUP IF 1 IN> +! EXIT THEN ( c ) ( EOL ? readline. we still return typed char though ) (rdln) ( c ) ; + +( Initializes the readln subsystem ) +: (c<$) + H@ IN( ! + INBUFSZ ALLOT + H@ IN) ! + ( We need two extra bytes. 1 for the last typed 0x0a and + one for the following NULL. ) + 2 ALLOT + (infl) + ['] (rdln<) 0x0c RAM+ ! +; +