aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorB. Watson <urchlay@slackware.uk>2025-11-15 14:20:06 -0500
committerB. Watson <urchlay@slackware.uk>2025-11-15 14:20:06 -0500
commit272c07d0a63c40597372467a13556e3b197e0b03 (patch)
treebf0c02259f03e6cdbd86028546ee5072dd35000f
parent1d45bb35abcac352f916180128bf40622ba0bc11 (diff)
downloadunalf-272c07d0a63c40597372467a13556e3b197e0b03.tar.gz
Special case underscores in filenames, in sanity check.
-rw-r--r--TODO.txt4
-rw-r--r--src/extract.c8
-rw-r--r--src/unalf.17
-rw-r--r--src/unalf.rst5
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
=====