From 4b4fc033f654f41306b66b36e0f95f9fb152b6c5 Mon Sep 17 00:00:00 2001 From: "B. Watson" Date: Fri, 28 Feb 2025 00:23:01 -0500 Subject: listamsb: improve program size mismatch warning, pluralize warning(s) correctly. --- listamsb.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/listamsb.c b/listamsb.c index 2c1a438..eda6d9d 100644 --- a/listamsb.c +++ b/listamsb.c @@ -102,6 +102,8 @@ void die_with(const char *msg, int status) { /* post-processing: print "summary", exit. called by either read_byte() (on 'unexpected EOF'), or main() (on normal exit). */ void finish(int rv, const char *msg) { + int progsize; + if(msg) fprintf(stderr, "%s: %s\n", self, msg); if(verbose) { @@ -114,12 +116,21 @@ void finish(int rv, const char *msg) { warnings++; } - if(proglen == (bytes_read - 3)) { + progsize = bytes_read - 3; + if(proglen == progsize) { if(verbose) fprintf(stderr, "file size matches proglen\n"); } else { - fprintf(stderr, "%s: actual program size doesn't match program size in header\n", self); warnings++; + fprintf(stderr, "%s: actual program size %d " + "doesn't match program size %d in header,\n" + " ", + self, progsize, proglen); + if(proglen > progsize) { + fprintf(stderr, "AMSB will give #136 ERROR and fail to LOAD this file\n"); + } else { + fprintf(stderr, "AMSB will stop LOADing before the end of this file\n"); + } } if(fgetc(infile) != EOF) { @@ -128,7 +139,8 @@ void finish(int rv, const char *msg) { } if(warnings) { - fprintf(stderr, "%s: file has %d warnings\n", self, warnings); + fprintf(stderr, "%s: file has %d warning%s\n", + self, warnings, (warnings == 1 ? "" : "s")); rv = 2; } -- cgit v1.2.3