aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorB. Watson <urchlay@slackware.uk>2024-07-08 15:39:34 -0400
committerB. Watson <urchlay@slackware.uk>2024-07-08 15:39:34 -0400
commitbc4cdded94c05495dde65e388ba618114c999ba1 (patch)
tree4f0fd4e7146a9cd9b8f9d7ae97e3f649d97dc6f6
parent96354d1cace50a70322f96418677a2ab2a8333c0 (diff)
downloadbw-atari8-tools-bc4cdded94c05495dde65e388ba618114c999ba1.tar.gz
whichbas: detect (some) uses of 2D arrays in BXL/BXE; silence warning in print_result().
-rw-r--r--whichbas.c28
1 files changed, 24 insertions, 4 deletions
diff --git a/whichbas.c b/whichbas.c
index 8a0b335..2b39a44 100644
--- a/whichbas.c
+++ b/whichbas.c
@@ -64,13 +64,13 @@ void print_result(void) {
name = "Unknown variant: Not Atari BASIC, Turbo, BXL, or BXE";
} else if(bas_type & BT_ATARI) {
name = "Atari BASIC";
- } else if(bas_type == BT_TURBO) {
- name = "Turbo BASIC XL";
} else if(bas_type & BT_TURBO) {
if(bas_type & BT_BXL) {
name = "Either Turbo BASIC XL or OSS BASIC XL";
} else if(bas_type & BT_BXE) {
name = "Either Turbo BASIC XL or OSS BASIC XE";
+ } else { /* bas_type == BT_TURBO */
+ name = "Turbo BASIC XL";
}
} else if(bas_type == BT_BXL || bas_type == (BT_BXL | BT_BXE)) {
name = "OSS BASIC XL";
@@ -91,8 +91,8 @@ void remove_type(int type) {
if(keep_going) return;
- /* without -k, stop if it gets narrowed down to one of these two. */
- if(bas_type == BT_TURBO || bas_type == BT_BXE)
+ /* 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)
print_result();
}
@@ -309,6 +309,26 @@ CALLBACK(handle_op) {
print_result();
}
+ /* attempt to detect BXL/BXE DIM for 2D string arrays.
+ DIM A$(10,10) is illegal in Atari/Turbo.
+ partial: this only works if the first dimension is either a
+ constant or a scalar variable (not an array element or an
+ expression).
+ */
+ if(tok == OP_DIM_STR_LPAR) {
+ int str2d = 0;
+ if(nexttok >= 0x80 && nexttok2 == OP_ARR_COMMA) {
+ str2d = 1;
+ } else if(nexttok == OP_NUMCONST || nexttok == OP_HEXCONST) {
+ str2d = (program[pos + 8] == OP_ARR_COMMA);
+ }
+ if(str2d) {
+ if(verbose)
+ fprintf(stderr, "===> found 2d string array at line %d\n", lineno);
+ remove_type(BT_ATARI | BT_TURBO);
+ }
+ }
+
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);