Skip to content

Commit fa99243

Browse files
committed
Fix end of file handling
1 parent 2455eef commit fa99243

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

third_party/lbforth/lbforth.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@ void fillFileBuffer(void)
200200
if(cpm_read_sequential(&startupFile)) {
201201
cpm_close_file(&startupFile);
202202
fileDoneFlag = true;
203+
cpm_printstring("END OF FILE\r\n OK\r\n");
203204
}
204205
filebuffer_pos = (char *)fileBuffer;
205206
}
@@ -221,7 +222,7 @@ int llkey()
221222
return *(filebuffer_pos++);
222223
if (!(*filebuffer_pos) && fileFlag && !fileDoneFlag) {
223224
fillFileBuffer();
224-
return *(filebuffer_pos++);
225+
if(!fileDoneFlag) return *(filebuffer_pos++);
225226
}
226227

227228
return cpm_conin();
@@ -251,6 +252,11 @@ int getkey()
251252
lineBuffer[charsInLineBuffer]=0;
252253
if(charsInLineBuffer > 0) charsInLineBuffer--;
253254
}
255+
if (c == 0x1a || c == 0x00) {
256+
c = ' ';
257+
lineBuffer[charsInLineBuffer++] = c;
258+
}
259+
254260
else lineBuffer[charsInLineBuffer++] = c;
255261
if (c == '\n' || c == '\r') break;
256262
}

0 commit comments

Comments
 (0)