Skip to content

Commit

Permalink
Fixes editing of files that does not end on EOL.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
dmsc committed Jul 25, 2024
1 parent 6db31a9 commit d5a8aee
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions src/cmdline.bas
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions src/editor.bas
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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 )
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit d5a8aee

Please sign in to comment.