From 7c5d9ba68d782a52ef58e4f2597e27bd7c52cdee Mon Sep 17 00:00:00 2001 From: "B. Watson" Date: Sat, 29 Nov 2025 05:52:13 -0500 Subject: alf: Handle 0-byte input files. --- src/alf.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'src/alf.c') diff --git a/src/alf.c b/src/alf.c index 7559eae..a366a5c 100644 --- a/src/alf.c +++ b/src/alf.c @@ -285,13 +285,14 @@ void crunch(void) { out_bitpos = 0; - store_token(TOK_RESET); + /* 0-byte input files don't get a TOK_RESET */ + if(input_len) + store_token(TOK_RESET); while(in_pos < input_len) { token = match_token(in_pos); store_token(token); new_pos = in_pos + tokentab[token].length; - // printf(" in_pos %d, new_pos %d\n", in_pos, new_pos); if(new_pos < input_len) make_token(in_pos, new_pos); in_pos = new_pos; @@ -332,11 +333,6 @@ void crunch_file(const char *filename) { fprintf(stderr, "%s: %s: this file is too large; only compressing the first 16MB.\n", self, filename); } - if(!input_len) { - fprintf(stderr, "%s: %s: can't compress a 0-byte (empty) file, skipping.\n", self, filename); - return; - } - if(opt_txtconv) convert_eols(); -- cgit v1.2.3