From d5a8aee2e07e786b0851546b215120aaa61c29d5 Mon Sep 17 00:00:00 2001 From: Daniel Serpell Date: Wed, 24 Jul 2024 23:51:43 -0400 Subject: [PATCH] Fixes editing of files that does not end on EOL. At load, all files are patched with an EOL at the end. Also, simplify EOL logic now that the parser correctly parses the last line. --- src/cmdline.bas | 6 +++--- src/editor.bas | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/cmdline.bas b/src/cmdline.bas index b195725..3e9d559 100644 --- a/src/cmdline.bas +++ b/src/cmdline.bas @@ -79,7 +79,7 @@ PROC SaveCompiledFile bput #1, @@ZP_INTERP_LOAD, @@ZP_INTERP_SIZE bput #1, @__PREHEAD_RUN__, @COMP_RT_SIZE ' Note, the compiler writes to "NewPtr" the end of program code - bput #1, MemEnd + 1, NewPtr - MemEnd + bput #1, MemEnd, NewPtr - MemEnd if err() < 128 ' Save ok, close close #1 @@ -121,8 +121,8 @@ PROC CompileFile ' Compile main file poke MemEnd, $9B ? "Compiling..." - dpoke @@RELOC_OFFSET, @BYTECODE_ADDR - MemEnd - 1 - if USR( @compile_buffer, Adr(MemStart), MemEnd+1) + dpoke @@RELOC_OFFSET, @BYTECODE_ADDR - MemEnd + if USR( @compile_buffer, Adr(MemStart), MemEnd) ' Parse error, show ? " at line "; dpeek(@@linenum); " column "; peek( @@bmax ) else diff --git a/src/editor.bas b/src/editor.bas index d197d63..c487f3c 100644 --- a/src/editor.bas +++ b/src/editor.bas @@ -149,9 +149,9 @@ ENDPROC PROC CompileAndSave exec ClrTopLine ' Pass the relocation offset, the compiled code - ' is run at "BYTECODE_ADDR" instead of "MemEnd + 1", + ' is run at "BYTECODE_ADDR" instead of "MemEnd", ' the output buffer. - dpoke @@RELOC_OFFSET, @BYTECODE_ADDR - MemEnd - 1 + dpoke @@RELOC_OFFSET, @BYTECODE_ADDR - MemEnd exec CompileFile ENDPROC @@ -160,8 +160,7 @@ ENDPROC PROC CompileFile ' Compile main file ? "Parsing: "; - poke MemEnd, $9B - if USR( @compile_buffer, Adr(MemStart), MemEnd+1) + if USR( @compile_buffer, Adr(MemStart), MemEnd) ' Parse error, go to error line topLine = dpeek(@@linenum) - 11 column = peek( @@bmax ) @@ -645,9 +644,10 @@ ENDPROC '------------------------------------- ' Fix empty buffer PROC CheckEmptyBuf - if MemEnd = adr(MemStart) - poke adr(MemStart), $9b + poke MemEnd, $9B + if peek(MemEnd-1) <> $9B MemEnd = MemEnd + 1 + poke MemEnd, $9b endif ENDPROC