man: match the display width to the configured width
Patch 1:
As it stands, this is
⌊line_length*(39/40)⌋ > line_length - 2
which works out to
line_length ≤ 40
Is that obvious? No (I analysed it to line_length < 80),
but the way the result is used makes it equivalent to
line_length ≤ 80
anyway.
This currently blames to commit cac2ef84 ("Update default line length in line with groff 1.18.") dated 2002-07-06 20:30:34 +0000(!) with a diff of
- if (!troff && (line_length < 66 || line_length > 80))
- return line_length * 9 / 10;
+ /* groff >= 1.18 defaults to 78. */
+ if (!troff && line_length != 80) {
+ int length = line_length * 39 / 40;
+ if (length > line_length - 2)
+ return line_length - 2;
+ else
+ return length;
NFC
Patch 2:
man: match the display width to the configured width
Currently, the line length is:
if w ≤ 40: w - 2
else: ⌊w*(39/40)⌋
i.e.
if w ≤ 40: w - 2
else: w - ⌈w/40⌉
(this is equivalent to a ≤80 condition).
This was originally originally introduced in commit
f139e827 ("Add terminal line length
detection to man.") from 2001-06-28, which did
if w ∈ [66, 80]: 80 (via default)
else : ⌊.9w⌋
then tracked the default in
commit cac2ef84 ("Update default
line length in line with groff 1.18.") from 2002-07-06,
which updates it to the current formula,
then commit 39cdee4a ("Always pass a
line length to nroff") from 2023-08-06 removes any defaulting.
This is ideologically quite weird, because this behaves like a stochastic best-effort fit so there is always a blank margin, growing with size, derived from a 21-year-old default which was only relevant because catpages were vaguely relevant, even though we perfectly know how large we need to display the manual by virtue of perfectly knowing the size of the teletype! There is no such margin on the left, and why would there be?
Fixes Debian bug #1059537.
Patch 3:
man: enforce a single-column right margin
Under groff, tbl consistently overruns the page width by one column, so accommodate this.