Hi Doug,

At 2025-02-20T11:56:17-0500, Douglas McIlroy wrote:
> info groff gives semantics for including nonempty files that don't end
> with newline. Such files violate the Posix definition of text file.
>
> Although groff is certainly justified in providing semantics for
> non-Posix text, I suggest that it should warn when it does so.

That's true but I'm hesitant to put groff in the business of wagging its
finger at users feeding it non-strictly-conforming text files when doing
so doesn't cause it any problems.

Where it does, we do complain.

So we have this...

$ printf 'foo' | groff -zww 2>&1 | grep . || echo NO OUTPUT
NO OUTPUT

...but also this.

$ printf 'foo\\' | groff -zww 2>&1 | grep . || echo NO OUTPUT
troff: error: end of input after escape character

The formatter also yells quite a bit when outright garbage is forced
down its throat.

$ file /bin/ls
/bin/ls: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically 
linked, interpreter /lib64/ld-linux-x86-64.so.2, 
BuildID[sha1]=6461a544c35b9dc1d172d1a1c09043e487326966, for GNU/Linux 3.2.0, 
stripped
$ groff -zww /bin/ls 2>&1 | sort -u | head
troff:/bin/ls:100: error: invalid positional argument number in copy mode 'H'
troff:/bin/ls:100: warning [page 4, 2.0i]: cannot adjust line
troff:/bin/ls:100: warning [page 4, 2.2i]: cannot break line
troff:/bin/ls:100: warning [page 4, 2.3i]: cannot adjust line
troff:/bin/ls:100: warning [page 4, 2.5i]: cannot adjust line
troff:/bin/ls:100: warning [page 4, 2.7i]: cannot break line
troff:/bin/ls:100: warning [page 4, 2.8i]: cannot break line
troff:/bin/ls:100: warning: invalid input character code 0
troff:/bin/ls:100: warning: invalid input character code 11
troff:/bin/ls:100: warning: invalid input character code 128

Since 1.22.4, GNU troff specifically gripes a lot more about all sorts
of input validity problems.  It's a hobby horse of mine.

A technique that advanced me a considerable distance down that road was
one I read of at the Bell Labs CSRC: see what a program does when you
feed it itself as input.  If it crashes, you get no lollipop.

Regards,
Branden

Attachment: signature.asc
Description: PGP signature

Reply via email to