aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorB. Watson <urchlay@slackware.uk>2024-07-09 04:41:53 -0400
committerB. Watson <urchlay@slackware.uk>2024-07-09 04:41:53 -0400
commitc77d95741b40b691d87a92c66f8f8da591af0a5c (patch)
tree73fc6ca3180d9e089372a1d7f5e3491b9bf71311
parentbdbb23afce79df0bf6a13c7d56b053180b090a71 (diff)
downloadbw-atari8-tools-c77d95741b40b691d87a92c66f8f8da591af0a5c.tar.gz
whichbas: handle (rare) case where -- (Turbo cmd 0x54) occurs as the 2nd or later statement on a line.
-rw-r--r--whichbas.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/whichbas.c b/whichbas.c
index f086689..ce2f88a 100644
--- a/whichbas.c
+++ b/whichbas.c
@@ -343,10 +343,18 @@ CALLBACK(handle_cmd) {
break;
case 0x54: /* -- in TB, LVAR in BXL/BXE */
/* COMPLETE */
- /* we can tell these apart because TB gives us a next-statement offset of 5
- when we use this (normally, the minimum offset is 6, but there's no OP_EOS
- after this token for some reason). */
- if(program[pos - 1] == 0x05) {
+ /* We can tell these apart because:
+ 1. TB gives us a next-statement offset of 5 if -- is the first (or
+ actually only) statement on a line. Normally, the minimum offset
+ is 6, but there's no OP_EOL after this token for some reason.
+ 2. If -- is the 2nd or or later statement on a line (after a colon)
+ it *does* get a statement terminator, but it's 0x9b (ATASCII EOL,
+ like a REM or DATA gets).
+ Note that it's impossible to put more statements *after* the --,
+ they just get ignored if you type them. This doesn't help us
+ here, but it's interesting anyway.
+ The explanation is a lot longer than the code... */
+ if(program[pos - 1] == 0x05 || nexttok == 0x9b) {
bas_type = BT_TURBO;
print_result();
} else {