From c77d95741b40b691d87a92c66f8f8da591af0a5c Mon Sep 17 00:00:00 2001 From: "B. Watson" Date: Tue, 9 Jul 2024 04:41:53 -0400 Subject: whichbas: handle (rare) case where -- (Turbo cmd 0x54) occurs as the 2nd or later statement on a line. --- whichbas.c | 16 ++++++++++++---- 1 file 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 { -- cgit v1.2.3