aboutsummaryrefslogtreecommitdiff
path: root/unprotbas.c
diff options
context:
space:
mode:
authorB. Watson <urchlay@slackware.uk>2024-05-24 04:33:33 -0400
committerB. Watson <urchlay@slackware.uk>2024-05-24 04:33:33 -0400
commit59de645bcbc02f4044a697bbcc3a2a2a8523975f (patch)
tree49145cc4027918781445d359a3cad1d48d162eb3 /unprotbas.c
parent71e28b9adcd5fbd74d9cf499e01078bf9d86d8a0 (diff)
downloadbw-atari8-tools-59de645bcbc02f4044a697bbcc3a2a2a8523975f.tar.gz
unprotbas: error if protecting vars but there are none, or protecting code but there is none.
Diffstat (limited to 'unprotbas.c')
-rw-r--r--unprotbas.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/unprotbas.c b/unprotbas.c
index 14fdc63..686b8c3 100644
--- a/unprotbas.c
+++ b/unprotbas.c
@@ -238,9 +238,13 @@ void breakcode(void) {
}
}
- data[oldpos + 2] = 0;
- if(verbose)
- fprintf(stderr, "set invalid line length 0 at line %d, file offset %04x\n", lineno, oldpos + 2);
+ if(!oldpos) {
+ die("can't protect code because there are no lines of code");
+ } else {
+ data[oldpos + 2] = 0;
+ if(verbose)
+ fprintf(stderr, "set invalid line length 0 at line %d, file offset %04x\n", lineno, oldpos + 2);
+ }
}
/* sometimes the variable name table isn't large enough to hold
@@ -581,8 +585,13 @@ void scramble_vars(void) {
for(i = vnstart; i < vvstart - 1; i++)
data[i] = '\x9b';
- if(verbose)
- fprintf(stderr, "replaced %d byte variable name table with EOLs.\n", i);
+ if(verbose) {
+ i -= vnstart;
+ if(i)
+ fprintf(stderr, "replaced %d byte variable name table with EOLs.\n", i);
+ else
+ die("can't protect variables because there are no variables.");
+ }
}
void print_help(void) {