Hi Larry, At 2026-09-08T09:35:22-0400, kollar wrote: > Following up. > > > … I’m getting nowhere with GNU deroff. In an up to date Kubuntu, it > > compiled with a few warnings but produces garbled output. On my old > > iMac (running Catalina/10.15.8), attempting to compile throws > > errors.… > > Taking a closer look at the error, it wasn’t picking up <string.h> > like it should have. I added that at the top of deroff.c, and it > compiled and ran on my iMac. I still get garbled output if I include > the -i option (ignore .so/.nx). Without it, I get clear output, but > with a lot of string things from utp.mac. > > There are a couple of deroff forks on GitHub, I’ll check them out > later today.
I think every implementation of deroff breaks itself on the shoals of
the fact that the *roff language can't be statically, deterministically
processed. As I understand it there are multiple reasons for this, but
some of the simplest are the following facts.
1. Macros can test properties of the rendered document, like the page
number, and change their behavior accordingly.
2. Macros can overwrite, append to, and delete their own definitions,
and those of other macros.
Further, *roff is a Turing-complete language, which might be a corollary
of, or equivalent in some way to, point (2).
I refer the reader, as I often do, to:
https://www.cs.dartmouth.edu/doug/barem4.txt
Consequently, the only truly reliable way to strip a *roff document of
all formatting is, funnily enough...to format it with *roff.
This is a point I have struggled to make to Alex Colomar.[1] I guess
I'll have to come up with a convincing demonstration. My idea is to
write a macro that tests its integer argument for primality, initially
calling another macro that uses the Sieve of Eratosthenes to compute
composite numbers and then deletes itself having populated a list
thereof (a technique related to the hideously named "memoization"). If
anyone wants to beat me to this exercise, feel free.
As I have said before,[2] "groff -a" does what "deroff" and "unroff"
programs do, does it better, and is very close to what users of such
tools want anyway.
I have mooted the idea of an alternative output format that really does
render only text glyphs,[3] which would obviate the need to strip out ad
hoc markers like the "<beginning of page>" notation "groff -a" currently
produces. Other problems need solutions, like whether and how to deal
with drawing and device extension commands, and how to render special
characters with no ISO Basic Latin representation.
I encourage anyone with ideas to pitch them to Savannah #66242.
Regards,
Branden
[1] https://lists.gnu.org/archive/html/groff/2026-08/msg00099.html
[2] https://lists.gnu.org/archive/html/groff/2024-05/msg00036.html
[3] https://savannah.gnu.org/bugs/?66242
signature.asc
Description: PGP signature
