From b60ba6ca9977be25652b93385dcf1bfc4171e370 Mon Sep 17 00:00:00 2001 From: "B. Watson" Date: Tue, 9 Jul 2024 00:40:31 -0400 Subject: whichbas: detect INPUT without args, caused by buggy Rev A BASIC. --- whichbas.c | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/whichbas.c b/whichbas.c index a64ea00..d9b85dc 100644 --- a/whichbas.c +++ b/whichbas.c @@ -118,8 +118,8 @@ void remove_type(int type) { if(keep_going) return; - /* without -k, stop if it gets narrowed down to one of these 3. */ - if(bas_type == BT_TURBO || bas_type == BT_BXE || bas_type == BT_BXL) + /* without -k, stop if it gets narrowed down to one of these 4. */ + if(bas_type == BT_ATARI || bas_type == BT_TURBO || bas_type == BT_BXE || bas_type == BT_BXL) print_result(); } @@ -157,19 +157,24 @@ CALLBACK(handle_cmd) { case CMD_INPUT: /* TB, BXL, BXE all support INPUT "Prompt",VAR with the same tokenized form. Atari BASIC doesn't allow string constants in INPUT args. */ - if(nexttok == OP_STRCONST) { - int pos_after_string; - remove_type(BT_ATARI); - /* TB only: INPUT "Prompt";VAR is also supported (not in BXL/BXE) */ - pos_after_string = pos + 3 + program[pos + 2]; - if(verbose) - fprintf(stderr, - "===> INPUT with string prompt at line %d, " - "pos %04x, pos_after_string %04x (token %02x)\n", - lineno, pos, pos_after_string, program[pos_after_string]); - if(program[pos_after_string] == OP_SEMICOLON) { - remove_type(BT_BXL_BXE); + if(has_args) { + if(nexttok == OP_STRCONST) { + int pos_after_string; + remove_type(BT_ATARI); + /* TB only: INPUT "Prompt";VAR is also supported (not in BXL/BXE) */ + pos_after_string = pos + 3 + program[pos + 2]; + if(verbose) + fprintf(stderr, + "===> INPUT with string prompt at line %d, " + "pos %04x, pos_after_string %04x (token %02x)\n", + lineno, pos, pos_after_string, program[pos_after_string]); + if(program[pos_after_string] == OP_SEMICOLON) { + remove_type(BT_BXL_BXE); + } } + } else { /* has_args is false, oh shit! */ + fprintf(stderr, "*** INPUT without variable at line %d.\n*** Rev A BASIC bug, program will crash, better fix it!\n", lineno); + remove_type(BT_TURBO | BT_BXL_BXE); } break; case CMD_GET: -- cgit v1.2.3