From 272c07d0a63c40597372467a13556e3b197e0b03 Mon Sep 17 00:00:00 2001 From: "B. Watson" Date: Sat, 15 Nov 2025 14:20:06 -0500 Subject: Special case underscores in filenames, in sanity check. --- TODO.txt | 4 ---- src/extract.c | 8 +++++++- src/unalf.1 | 7 ++++++- src/unalf.rst | 5 +++++ 4 files changed, 18 insertions(+), 6 deletions(-) diff --git a/TODO.txt b/TODO.txt index a504eca..b60ad6e 100644 --- a/TODO.txt +++ b/TODO.txt @@ -1,7 +1,3 @@ -- sanity-check the filenames and alf headers. Atari filenames - can't be lowercase, start with a number, have two dots... these would - be warnings, not fatal errors. - - create some alf archives and hexedit them to introduce errors, make sure unalf doesn't segfault or get stuck in a loop (it should *always* exit cleanly). diff --git a/src/extract.c b/src/extract.c index af3efeb..f945ca6 100644 --- a/src/extract.c +++ b/src/extract.c @@ -43,7 +43,7 @@ static void bad_atari_filename(const char *msg) { versions. */ static void sanity_check_filename(void) { u8 c; - unsigned int i, bad = 0, dots = 0; + unsigned int i, bad = 0, dots = 0, uscore = 0; c = out_filename[0]; if(!c) { @@ -58,6 +58,10 @@ static void sanity_check_filename(void) { continue; if(c >= '0' && c <= '9') continue; + if(c == '_') { + uscore++; + continue; + } if(c == '.') { dots++; continue; @@ -73,6 +77,8 @@ static void sanity_check_filename(void) { if(bad) bad_atari_filename("invalid characters. corrupt ALF file?"); + else if(uscore) + fprintf(stderr, "%s: filename has underscore, OK on Sparta/MyDOS, not Atari DOS 2.x\n", self); } void fix_filename(void) { diff --git a/src/unalf.1 b/src/unalf.1 index b2f918f..27d9522 100644 --- a/src/unalf.1 +++ b/src/unalf.1 @@ -277,8 +277,13 @@ any unprintable characters as hex values (e.g. \fB$01\fP). Followed by "impossibly large", "suspiciously large", or "too large to fit on a floppy disk". May indicate a corrupt archive, or someone really might have created an ALF file with files this big... though -"impossibly large" means >16MB. \fBunalf\fP can\(aqt extract a file +"impossibly large" means >=16MB. \fBunalf\fP can\(aqt extract a file that big. +.TP +.B \fBfilename has underscore, OK on Sparta/MyDOS, not Atari DOS 2.x\fP +Not an actual problem, unless you try to extract this ALF file on +an Atari running Atari DOS 2.0/2.5, or any other DOS that doesn\(aqt +allow underscores in filenames. .UNINDENT .SH NOTES .sp diff --git a/src/unalf.rst b/src/unalf.rst index 2e716a1..ec5e1e6 100644 --- a/src/unalf.rst +++ b/src/unalf.rst @@ -234,6 +234,11 @@ Besides the standard error messages such as "no such file or directory": "impossibly large" means >=16MB. **unalf** can't extract a file that big. +**filename has underscore, OK on Sparta/MyDOS, not Atari DOS 2.x** + Not an actual problem, unless you try to extract this ALF file on + an Atari running Atari DOS 2.0/2.5, or any other DOS that doesn't + allow underscores in filenames. + NOTES ===== -- cgit v1.2.3