aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorB. Watson <urchlay@slackware.uk>2024-07-07 03:25:17 -0400
committerB. Watson <urchlay@slackware.uk>2024-07-07 03:25:17 -0400
commit6754521ed4202c1286b0526da98ffdef0d2e70c2 (patch)
treeefda782e26601160afa9981c09918a0a7dfd5d3f
parentb274f894c0d18a722b04f942bb403d39aa2e41da (diff)
downloadbw-atari8-tools-6754521ed4202c1286b0526da98ffdef0d2e70c2.tar.gz
whichbas: immediately choke & die on invalid tokens.
-rw-r--r--whichbas.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/whichbas.c b/whichbas.c
index f2b1f4d..8f0e258 100644
--- a/whichbas.c
+++ b/whichbas.c
@@ -7,6 +7,7 @@
#include "bas.h"
+#define BT_INVALID 0
#define BT_ATARI 1
#define BT_TURBO 2
#define BT_BXL 4
@@ -56,7 +57,9 @@ void add_type(int type) {
void print_result(void) {
const char *name;
- if(bas_type & BT_ATARI) {
+ if(bas_type == BT_INVALID) {
+ name = "Unknown variant: Not Atari BASIC, Turbo, BXL, or BXE";
+ } else if(bas_type & BT_ATARI) {
name = "Atari BASIC";
} else if(bas_type == BT_BXL || bas_type == (BT_BXL | BT_BXE)) {
name = "OSS BASIC XL";
@@ -100,6 +103,12 @@ CALLBACK(handle_cmd) {
remove_type(BT_ATARI);
if(tok >= 0x59) remove_type(BT_BXL);
+ if(tok >= 0x65) {
+ fprintf(stderr, "handle_cmd: invalid command %02x\n", tok);
+ bas_type = BT_INVALID;
+ print_result();
+ }
+
nexttok = program[pos + 1];
has_args = !(nexttok == OP_EOS || nexttok == OP_EOL);
@@ -226,7 +235,7 @@ CALLBACK(handle_op) {
if(verbose) fprintf(stderr, "handle_op: lineno %d, tok $%02x, comma_count %d, bas_type was %02x\n", lineno, tok, comma_count, bas_type);
- if(tok == 0x0d) remove_type(BT_ATARI); /* hex const (turbo *and* bxl/xe) */
+ if(tok == OP_HEXCONST) remove_type(BT_ATARI); /* hex const (turbo *and* bxl/xe) */
if(tok <= OP_FUNC_STRIG) {
if(verbose) fprintf(stderr, " bas_type now %02x\n", bas_type);
return; /* legal in BASIC, ignore */
@@ -237,6 +246,12 @@ CALLBACK(handle_op) {
remove_type(BT_BXL_BXE);
}
+ if(tok >= 0x6E) {
+ fprintf(stderr, "handle_op: invalid operator %02x\n", tok);
+ bas_type = BT_INVALID;
+ print_result();
+ }
+
if(tok == 0x55) {
/* DPEEK (function) TB, USING (infix, not a function) in BXL/BXE */
if(nexttok == OP_FUNC_LPAR) {