aboutsummaryrefslogtreecommitdiff
path: root/src/alf.c
diff options
context:
space:
mode:
authorB. Watson <urchlay@slackware.uk>2025-11-29 05:52:13 -0500
committerB. Watson <urchlay@slackware.uk>2025-11-29 05:52:13 -0500
commit7c5d9ba68d782a52ef58e4f2597e27bd7c52cdee (patch)
tree4a8641331a1c0b3502d0fb5b53a856dc2b99f55b /src/alf.c
parent4f2347c1d8015a092f990db6fa3b53ffbb5b85fd (diff)
downloadalftools-7c5d9ba68d782a52ef58e4f2597e27bd7c52cdee.tar.gz
alf: Handle 0-byte input files.
Diffstat (limited to 'src/alf.c')
-rw-r--r--src/alf.c10
1 files changed, 3 insertions, 7 deletions
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();