aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorB. Watson <urchlay@slackware.uk>2024-05-31 14:27:19 -0400
committerB. Watson <urchlay@slackware.uk>2024-05-31 14:27:19 -0400
commita8c1bfcea9714014a9d399089a6bb74b02738a5b (patch)
tree54ded27187f93d130b635b06a0dc2a618e8401da
parent8bb878d21591d08ed7a763825fa03abeed384c57 (diff)
downloadbw-atari8-tools-a8c1bfcea9714014a9d399089a6bb74b02738a5b.tar.gz
unprotbas: detect if trailing "garbage" is all the same byte (not just zero).
-rw-r--r--unprotbas.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/unprotbas.c b/unprotbas.c
index c1c0e68..a179a0c 100644
--- a/unprotbas.c
+++ b/unprotbas.c
@@ -235,14 +235,17 @@ int fixcode(void) {
if(verbose) fprintf(stderr, "End program pos $%04x/%d\n", pos, pos);
if(filelen > pos) {
- int i, nonzero = 0;
- for(i = pos; i < filelen; i++)
- if(data[i]) nonzero = 1;
+ int i, same = 1;
+ for(i = pos; i < filelen; i++) {
+ if(data[i] != data[pos]) same = 0;
+ }
if(verbose) {
- fprintf(stderr, "trailing garbage at EOF, %d bytes, %s, %s\n",
- filelen - pos,
- nonzero ? "maybe valid data" : "all zeroes",
- (keepgarbage ? "keeping" : "removing"));
+ fprintf(stderr, "trailing garbage at EOF, %d bytes, ", filelen - pos);
+ if(same)
+ fprintf(stderr, "all $%02x", data[pos]);
+ else
+ fprintf(stderr, "maybe valid data");
+ fprintf(stderr, ", %s\n", (keepgarbage ? "keeping" : "removing"));
}
if(!keepgarbage) filelen = pos;
}