aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorB. Watson <urchlay@slackware.uk>2025-11-27 16:24:22 -0500
committerB. Watson <urchlay@slackware.uk>2025-11-27 16:24:22 -0500
commitb0892ba48c5eae7e8e0cca5f269d7b81e19b71ac (patch)
treebf5b1047bc6fc1b9804a219a2159db77ab2418bd
parenta5e791a9a6c36dab74e10c648403b0538f7e6fb5 (diff)
downloadunalf-b0892ba48c5eae7e8e0cca5f269d7b81e19b71ac.tar.gz
Generate alf usage from rst.
-rw-r--r--src/Makefile7
-rw-r--r--src/alf.18
-rw-r--r--src/alf.c9
-rw-r--r--src/alf.rst4
-rw-r--r--src/alfusage.c5
-rw-r--r--src/mkusage.pl1
-rw-r--r--src/unalf.14
-rw-r--r--src/unalf.rst2
8 files changed, 35 insertions, 5 deletions
diff --git a/src/Makefile b/src/Makefile
index 161376b..ed5f4d0 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -41,7 +41,7 @@ CFLAGS=-DVERSION='"$(VERSION)"' -Wall -I../f65 $(COPT)
UNALF_OBJS=unalf.o io.o listalf.o extract.o f65.o glob.o opts.o usage.o self.o asmcode.o
ALFSUM_OBJS=alfsum.o self.o
-ALF_OBJS=alf.o self.o
+ALF_OBJS=alf.o self.o alfusage.o
.PHONY: all clean install crosswin windows windows-upload realclean
@@ -61,12 +61,17 @@ alf: $(ALF_OBJS)
usage.o: usage.c
+alfusage.o: usage.c
+
f65.o: ../f65/f65.c ../f65/f65.h
$(CC) $(CFLAGS) -c -o f65.o ../f65/f65.c
usage.c: mkusage.pl unalf.rst
perl mkusage.pl unalf.rst > usage.c
+alfusage.c: mkusage.pl unalf.rst
+ perl mkusage.pl alf.rst > alfusage.c
+
unalf.o: unalf.c unalf.h ../f65/f65.h
glob.o: glob.c unalf.h
diff --git a/src/alf.1 b/src/alf.1
index 7436c88..2266526 100644
--- a/src/alf.1
+++ b/src/alf.1
@@ -27,7 +27,7 @@ level margin: \\n[rst2man-indent\\n[rst2man-indent-level]]
.\" new: \\n[rst2man-indent\\n[rst2man-indent-level]]
.in \\n[rst2man-indent\\n[rst2man-indent-level]]u
..
-.TH "ALF" 1 "2025-11-26" "0.2.0" "Urchlay's Atari 8-bit Tools"
+.TH "ALF" 1 "2025-11-27" "0.2.0" "Urchlay's Atari 8-bit Tools"
.SH NAME
alf \- create Atari 8-bit ALF archives
.\" RST source for alf(1) man page. Convert with:
@@ -64,10 +64,16 @@ Append to \fIalf\-file\fP\&. The files are added to the end of the archive. Be
careful not to add a file with the same name as as existing member of
the archive. If \fIalf\-file\fP doesn\(aqt exist, it will be created. No backup
is made with \fB\-a\fP\&.
+.UNINDENT
+.\" append to alf file.
+.
+.INDENT 0.0
.TP
.B \-o
Overwrite \fIalf\-file\fP if it exists; do not make a \fB~\fP backup.
.UNINDENT
+.\" overwrite alf file if exists (do not create file~ backup).
+.
.SH EXIT STATUS
.INDENT 0.0
.TP
diff --git a/src/alf.c b/src/alf.c
index 3492720..d294378 100644
--- a/src/alf.c
+++ b/src/alf.c
@@ -335,11 +335,16 @@ void crunch_file(const char *filename) {
}
void usage(void) {
+ extern char *usage_msg[];
+ char **line;
+
puts("alf (ALF compressor) v" VERSION " by B. Watson, WTFPL.");
printf("Usage: %s [-a|-o] archive.alf file [file ...]\n", self);
puts("Options:");
- puts(" -a: append to archive");
- puts(" -o: overwrite archive (don't make backup with ~)");
+
+ for(line = usage_msg; *line; line++)
+ puts(*line);
+
exit(0);
}
diff --git a/src/alf.rst b/src/alf.rst
index 08af9c2..898efb3 100644
--- a/src/alf.rst
+++ b/src/alf.rst
@@ -53,9 +53,13 @@ OPTIONS
the archive. If *alf-file* doesn't exist, it will be created. No backup
is made with **-a**.
+.. append to alf file.
+
-o
Overwrite *alf-file* if it exists; do not make a **~** backup.
+.. overwrite alf file if exists (do not create file~ backup).
+
EXIT STATUS
===========
diff --git a/src/alfusage.c b/src/alfusage.c
new file mode 100644
index 0000000..c8f973d
--- /dev/null
+++ b/src/alfusage.c
@@ -0,0 +1,5 @@
+const char *usage_msg[] = {
+ " -a: append to alf file.",
+ " -o: overwrite alf file if exists (do not create file~ backup).",
+ (const char*)0
+};
diff --git a/src/mkusage.pl b/src/mkusage.pl
index d8a5c77..e2274c2 100644
--- a/src/mkusage.pl
+++ b/src/mkusage.pl
@@ -5,6 +5,7 @@ print "const char *usage_msg[] = {\n";
while(<>) {
chomp;
next if /^---/;
+ last if /^\.\. ENFOPTS/;
if(/^-[-a-zA-Z\d]/) {
$opt = $_;
next;
diff --git a/src/unalf.1 b/src/unalf.1
index 1708a4b..396a5f6 100644
--- a/src/unalf.1
+++ b/src/unalf.1
@@ -27,7 +27,7 @@ level margin: \\n[rst2man-indent\\n[rst2man-indent-level]]
.\" new: \\n[rst2man-indent\\n[rst2man-indent-level]]
.in \\n[rst2man-indent\\n[rst2man-indent-level]]u
..
-.TH "UNALF" 1 "2025-11-26" "0.2.0" "Urchlay's Atari 8-bit Tools"
+.TH "UNALF" 1 "2025-11-27" "0.2.0" "Urchlay's Atari 8-bit Tools"
.SH NAME
unalf \- extract Atari 8-bit ALF archives
.\" RST source for unalf(1) man page. Convert with:
@@ -208,6 +208,8 @@ to exclude multiple patterns.
.UNINDENT
.\" exclude <wildcard>. may be given multiple times.
.
+.\" ENDOPTS
+.
.SH WILDCARDS
.sp
Wildcard (aka glob) matching works like it does on the Atari: \fI*.*\fP
diff --git a/src/unalf.rst b/src/unalf.rst
index bee3046..24774e6 100644
--- a/src/unalf.rst
+++ b/src/unalf.rst
@@ -168,6 +168,8 @@ OPTIONS
.. exclude <wildcard>. may be given multiple times.
+.. ENDOPTS
+
WILDCARDS
=========