aboutsummaryrefslogtreecommitdiff
path: root/unprotbas.c
diff options
context:
space:
mode:
authorB. Watson <urchlay@slackware.uk>2024-05-22 16:00:57 -0400
committerB. Watson <urchlay@slackware.uk>2024-05-22 16:00:57 -0400
commit7fc45e8ac37dde5026a8b6bc1e8190e69107f94a (patch)
tree1eaedb8a91d8e3ab66a2b0b71aba48352dce755f /unprotbas.c
parenta1144de8efebc414c33a0df9b8fccd758a242586 (diff)
downloadbw-atari8-tools-7fc45e8ac37dde5026a8b6bc1e8190e69107f94a.tar.gz
unprotbas: handle corner case where 129 vars are in the table.
Diffstat (limited to 'unprotbas.c')
-rw-r--r--unprotbas.c31
1 files changed, 17 insertions, 14 deletions
diff --git a/unprotbas.c b/unprotbas.c
index 5ad483b..5748461 100644
--- a/unprotbas.c
+++ b/unprotbas.c
@@ -30,7 +30,7 @@ unsigned char data[65536];
/* for the -r option */
unsigned char varnames[65536];
-unsigned char *varmap[128];
+unsigned char *varmap[129];
int varmap_count;
/* BASIC 14-byte header values */
@@ -351,17 +351,10 @@ int rebuild_vntable(int write) {
}
/* there's supposed to be a null byte at the end of the table, unless
- all 128 table slots are used. */
- if(write) {
- if(varnum < 128) data[vp] = 0;
- /* fixup the VNTD pointer */
- /*
- vntd = vntp + (vp - vnstart);
- fprintf(stderr, "%04x\n", vntd);
- data[4] = vntd & 0xff;
- data[5] = vntd >> 8;
- */
- }
+ all 128 table slots are used... except really, there can be 129
+ entries, and there's always a null byte. */
+ if(write) data[vp] = 0;
+ size++;
return size;
}
@@ -439,7 +432,12 @@ void check_varname(const unsigned char *name, int line) {
c = name[i];
if(c >= 'A' && c <= 'Z') continue;
if(c >= '0' && c <= '9') continue;
- if(i == (len - 1) && ((c == '$') || (c == '('))) continue;
+ if(c == '$' || c == '(') {
+ if(i == (len - 1))
+ continue;
+ else
+ die_mapfile("invalid variable name: $ and ( only allowed at end", line);
+ }
die_mapfile("invalid character in variable name", line);
}
@@ -506,6 +504,7 @@ void read_var_map(void) {
fprintf(stderr, MAP_FILE ": too many variables (have %d, need %d).\n", count, vvcount);
exit(1);
}
+
#if 0
for(count = 0; varmap[count] != NULL; count++) {
fprintf(stderr, "\t%02d %s\n", count, varmap[count]);
@@ -520,6 +519,9 @@ void apply_var_map(void) {
int i, newp = 0;
unsigned char *v;
+ if(verbose)
+ fprintf(stderr, "using variable names from " MAP_FILE "\n");
+
for(i = 0; i < varmap_count; i++) {
v = varmap[i];
while(*v) {
@@ -529,7 +531,8 @@ void apply_var_map(void) {
new_vntable[newp - 1] |= 0x80;
}
- if(varmap_count < 128) new_vntable[newp++] = '\0';
+ /* if(varmap_count < 128) */
+ new_vntable[newp++] = '\0';
i = vvstart - vnstart;
adjust_vntable_size(i, newp);