Skip to content

Commit 9373d0a

Browse files
authored
Fix EOF handling in calculator.dana main loop (#81)
Adds the following line at the start of the lines loop in `calculator.dana`: ``` buf[0] := '\0' ``` This ensures the buffer is always null-terminated before reading new input. When `readString` reaches EOF without writing anything, `strlen(buf)` now returns 0 instead of reading stale data from previous iterations.
1 parent 7061b05 commit 9373d0a

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

dana/programs/calculator.dana

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ def main
4646
var op is byte
4747

4848
loop lines:
49+
buf[0] := '\0'
4950
readString: 256, buf
5051

5152
# Stop if we got nothing

0 commit comments

Comments
 (0)