aboutsummaryrefslogtreecommitdiff
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
parent4f2347c1d8015a092f990db6fa3b53ffbb5b85fd (diff)
downloadalftools-7c5d9ba68d782a52ef58e4f2597e27bd7c52cdee.tar.gz
alf: Handle 0-byte input files.
-rw-r--r--src/alf.16
-rw-r--r--src/alf.c10
-rw-r--r--src/alf.rst6
3 files changed, 9 insertions, 13 deletions
diff --git a/src/alf.1 b/src/alf.1
index e87b333..569e980 100644
--- a/src/alf.1
+++ b/src/alf.1
@@ -169,6 +169,9 @@ must be given as command\-line arguments.
overwrites (making a backup) by default, and can append with the \fB\-a\fP
option.
.IP \(bu 2
+\fBLZ.COM\fP doesn\(aqt handle 0\-byte (empty) files correctly, but \fBalf\fP
+does. Not that this is very useful.
+.IP \(bu 2
Turning the screen off for speed makes no sense on modern operating
systems, so there\(aqs no option for that.
.UNINDENT
@@ -190,9 +193,6 @@ actually can\(aqt handle files above about 15MB, if you compress one with
a pathological case. A real Atari would take hours or even days to
compress/decompress such files, and you\(aqd have to have a hard disk and
a DOS capable of handling multi\-megabyte files...
-.sp
-It\(aqs also impossible to compress empty (0\-byte) files. \fBalf\fP will
-skip them, if any are found.
.SS Performance
.sp
Performance is \fIhorrible\fP\&. This shouldn\(aqt be a real problem on
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();
diff --git a/src/alf.rst b/src/alf.rst
index 4bf2c6c..4d48afc 100644
--- a/src/alf.rst
+++ b/src/alf.rst
@@ -141,6 +141,9 @@ Atari **LZ.COM** aka **ALF.COM**, with the following differences:
overwrites (making a backup) by default, and can append with the **-a**
option.
+- **LZ.COM** doesn't handle 0-byte (empty) files correctly, but **alf**
+ does. Not that this is very useful.
+
- Turning the screen off for speed makes no sense on modern operating
systems, so there's no option for that.
@@ -164,9 +167,6 @@ a pathological case. A real Atari would take hours or even days to
compress/decompress such files, and you'd have to have a hard disk and
a DOS capable of handling multi-megabyte files...
-It's also impossible to compress empty (0-byte) files. **alf** will
-skip them, if any are found.
-
Performance
-----------