diff options
| author | Irene Knapp <ireneista@irenes.space> | 2026-09-23 20:36:05 -0700 |
|---|---|---|
| committer | Irene Knapp <ireneista@irenes.space> | 2026-09-23 20:51:14 -0700 |
| commit | 3b565483d9fbf6454d6d0e79a4e8fe1ae6c9eace (patch) | |
| tree | d31964a8f2f10c66b28ecea7f2c2ccf136fc0e79 /input.e | |
| parent | 9806454fbcd9cbb195eb5ef17e0a1d36e06a64f9 (diff) | |
this should be a robust fix for the double-termination issue when compiling Force-Push: yes Change-Id: Ieaacdc232ea7e3036916d81139fc5c5a41087c64
Diffstat (limited to 'input.e')
| -rw-r--r-- | input.e | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/input.e b/input.e index 3d8fabb..16fa836 100644 --- a/input.e +++ b/input.e @@ -134,16 +134,20 @@ swap buffer-logical-start ! ; -~ (metadata pointer -- byte or 0) +~ We use -1 as a return value to indicate end-of-file. This can be +~ distinguished from valid data, because it's a full 64 bits, whereas a byte +~ of 0xFF wouldn't be. +~ +~ (metadata pointer -- byte or -1) : peek-from dup buffer-logical-length @ { ~ If the length is zero, there is no input, but we can still try calling ~ the "refill" word. ~ (metadata pointer) dup input-buffer-refill @ dup { - ~ If the refill word is zero, we can't help, just return null. + ~ If the refill word is zero, we can't help, just return EOF. ~ (metadata pointer, refill word) - drop drop 0 exit + drop drop -1 exit } unless ~ If the refill word is nonzero, call it. It expects a copy of the metadata @@ -153,9 +157,9 @@ ~ (metadata pointer) ~ Now we check if the length is still zero. dup buffer-logical-length @ { - ~ The length is zero even after calling the refill word, so return null. + ~ The length is zero even after calling the refill word, so return EOF. ~ (metadata pointer) - drop 0 exit + drop -1 exit } unless } unless @@ -171,7 +175,9 @@ buffer-logical-start @ 8@ ; -~ (metadata pointer -- byte or 0) +~ Just as with peek-from, we use -1 for EOF. +~ +~ (metadata pointer -- byte or -1) : key-from dup peek-from ~ (metadata pointer, result byte) |