Bug 289786 - mdoc footer in stable/15 and main has horrible formatting
Summary: mdoc footer in stable/15 and main has horrible formatting
Status: Closed FIXED
Alias: None
Product: Documentation
Classification: Unclassified
Component: Manual Pages (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: Alexander Ziaee
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-09-23 11:02 UTC by Trond Endrestøl
Modified: 2026-02-06 01:08 UTC (History)
4 users (show)

See Also:


Attachments
mdoc footer from stable/14 with familiar formatting (10.08 KB, image/png)
2025-09-23 11:03 UTC, Trond Endrestøl
no flags Details
mdoc footer from stable/15 with unusual formatting, the main branch is just as bad (11.53 KB, image/png)
2025-09-23 11:04 UTC, Trond Endrestøl
no flags Details
ifconfig(8) rendered as PDF on stable/14 (747.08 KB, application/pdf)
2025-09-24 10:13 UTC, Trond Endrestøl
no flags Details
ifconfig(8) rendered as PDF on stable/15 (773.09 KB, application/pdf)
2025-09-24 10:13 UTC, Trond Endrestøl
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Trond Endrestøl 2025-09-23 11:02:53 UTC
mdoc footer in stable/15 and main doesn't match that of the previous versions, and the formatting isn't the best.
Comment 1 Trond Endrestøl 2025-09-23 11:03:54 UTC
Created attachment 264024 [details]
mdoc footer from stable/14 with familiar formatting
Comment 2 Trond Endrestøl 2025-09-23 11:04:43 UTC
Created attachment 264025 [details]
mdoc footer from stable/15 with unusual formatting, the main branch is just as bad
Comment 3 Alexander Ziaee freebsd_committer freebsd_triage 2025-09-23 11:15:54 UTC
That's interesting. The footer format did change to align more closely with groff.
Comment 4 Trond Endrestøl 2025-09-23 12:40:12 UTC
(In reply to Alexander Ziaee from comment #3)
The year is missing from the date, and the spacing is off.
Comment 5 Alexander Ziaee freebsd_committer freebsd_triage 2025-09-23 19:17:28 UTC
I see that, but I'm unable to reproduce it so far. Mine says "$VERSION $DATE $NAME" (which is the change from familiar "$VERSION $DATE $VERSION"). Can you give me some more details about your setup? What is your TERM? Are you seeing this on all manuals, or just specific ones? Anything else that may possibly be relevant?
Comment 6 Wolfram Schneider freebsd_committer freebsd_triage 2025-09-23 20:05:10 UTC
The footer changed in 15.x and later, but it looks ok.

for i in f{13,14,15,16}; do ssh $i 'man mandoc | tail -n1'; done
FreeBSD 13.5-STABLE             August 14, 2021            FreeBSD 13.5-STABLE
FreeBSD 14.3-STABLE              March 3, 2025             FreeBSD 14.3-STABLE
FreeBSD 15.0-ALPHA2              July 9, 2025                        MANDOC(1)
FreeBSD 16.0-CURRENT             July 9, 2025                        MANDOC(1)
Comment 7 Ingo Schwarze 2025-09-23 21:53:18 UTC
I believe the OP is likely talking about mandoc -T ps or -T pdf output
mode, but chose to not mention that in this bug report.
At least i can reproduce broken formatting of the footer line in roughly the way shown in the two PNG attachments in -T ps and -T pdf output mode on OpenBSD-current.

I suspect this is an unfixed regression caused by the massive reorganization committed on 2025-07-16 14:45 with the commit message starting with "In 2009, kristaps@ decided that using EN as the basic unit for horizontal widths on terminal output devices was the simplest option. [...] Fix this by changing many internal variables in the terminal formatter to store widths in units of BU instead of EN, improving compatibility."  Contrary to what one might expect, the -T ps and -T pdf output modes are actually submodes of the terminal formatter, which means that this reorg *can* cause fallout in these modes, and the symptoms seem broadly consistent with something going awry with width measurements and/or horizontal alignment.

I do not have a fix yet, but i shall investigate, so please bear with me, i hope to provide an update during the next few days.  Files potentially involved are mdoc_term.c, term_ps.c, term.c, and the *time*() functions in mandoc.c, and interactions among the functions in these files.
Comment 8 Trond Endrestøl 2025-09-24 10:11:02 UTC
(In reply to Ingo Schwarze from comment #7)
I'm sorry I forgot to mention I have a script that runs:

mandoc -c -mdoc -O paper=a4 -T pdf
Comment 9 Trond Endrestøl 2025-09-24 10:13:27 UTC
Created attachment 264048 [details]
ifconfig(8) rendered as PDF on stable/14
Comment 10 Trond Endrestøl 2025-09-24 10:13:47 UTC
Created attachment 264049 [details]
ifconfig(8) rendered as PDF on stable/15
Comment 11 Ingo Schwarze 2025-09-26 12:48:44 UTC
I believe  https://cvsweb.bsd.lv/mandoc/term_ps.c revision 1.95  fixes this issue.

Sorry for the disruption.  The patch term.c rev. 1.292 that you already merged into FreeBSD was quite a major reorganization, and it may take a bit of time to get the dust settled, especially in PostScript and PDF output where it appears i slightly underestimated the consequences.  All the same, i counsel against reverting anything because trying to revert such a major change that touched many files would be likely to cause instability, too, and would make it harder for us to coordinate.  While you can selectively merge small, additional patches to fix issues affecting you with little effort and risk, selectively reverting a massive reorganization would not look like a good option, especially since you have already started merging some further development on top of it, causing you to potentially run into both physical and logical conflicts, unless you understand very precisely what the code is doing and are very careful about what you can or cannot merge after reverting the reorg.

I think i'm seeing one additional issue with TERMP_NOBREAK handling in term_ps.c that i need to investigate, but i first wanted to get this hotfix out of the way, such that you can easily pick it up if you want to.
Comment 12 Alexander Ziaee freebsd_committer freebsd_triage 2025-09-26 13:25:50 UTC
Thanks Ingo! I'll merge a fresh mandoc today!
Comment 13 Wolfram Schneider freebsd_committer freebsd_triage 2025-09-27 07:53:38 UTC
(In reply to Alexander Ziaee from comment #12)
I think it is time that we add a version parameter (-v) for mandoc. Otherwise it is hard to know which mandoc snapshot is running on someones -stable machine.

See https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=274246
Comment 14 commit-hook freebsd_committer freebsd_triage 2025-09-29 17:35:06 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=59fc2b0166f71c791113379d16b8cef7039f289d

commit 59fc2b0166f71c791113379d16b8cef7039f289d
Merge: d4cbdd9ad04a 5fe5b2ed2d88
Author:     Alexander Ziaee <ziaee@FreeBSD.org>
AuthorDate: 2025-09-29 17:31:38 +0000
Commit:     Alexander Ziaee <ziaee@FreeBSD.org>
CommitDate: 2025-09-29 17:31:38 +0000

    mandoc: Vendor import of upstream at 2025-09-26

    Interesting changes:
    + mandoc db: Improve case sorting, found by our very own markj
    + history: Add macros for version 8 and 10 AT&T Unix
    + linter: Warn on blank lines in man(7) like mdoc(7)
    + manuals: Improve precision, man(7) syntax table, and roff(7) specifics
    + manuals: Fix PDF/PS footer regression detailed in our PR: 289786

    PR:             289786
    MFC after:      3 days

 contrib/mandoc/Makefile      |  2 +-
 contrib/mandoc/dba.c         |  7 +++---
 contrib/mandoc/main.c        | 52 +++++++++-----------------------------------
 contrib/mandoc/man.c         |  3 ++-
 contrib/mandoc/man.options.1 | 35 +++++++++++++++++++++++++----
 contrib/mandoc/mandoc.1      | 16 ++++++++------
 contrib/mandoc/mdoc.7        | 35 +++++++++++++++++++----------
 contrib/mandoc/roff_term.c   |  2 +-
 contrib/mandoc/term_ps.c     |  6 ++---
 9 files changed, 84 insertions(+), 74 deletions(-)
Comment 15 commit-hook freebsd_committer freebsd_triage 2025-10-02 02:54:14 UTC
A commit in branch stable/15 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=955d9b0a1093131ac18d57d2764ee716fd428dd9

commit 955d9b0a1093131ac18d57d2764ee716fd428dd9
Author:     Alexander Ziaee <ziaee@FreeBSD.org>
AuthorDate: 2025-09-29 17:31:38 +0000
Commit:     Alexander Ziaee <ziaee@FreeBSD.org>
CommitDate: 2025-10-02 02:52:57 +0000

    mandoc: Vendor import of upstream at 2025-09-26

    Interesting changes:
    + mandoc db: Improve case sorting, found by our very own markj
    + history: Add macros for version 8 and 10 AT&T Unix
    + linter: Warn on blank lines in man(7) like mdoc(7)
    + manuals: Improve precision, man(7) syntax table, and roff(7) specifics
    + manuals: Fix PDF/PS footer regression detailed in our PR: 289786

    PR:             289786
    MFC after:      3 days

    (cherry picked from commit 59fc2b0166f71c791113379d16b8cef7039f289d)

 contrib/mandoc/Makefile      |  2 +-
 contrib/mandoc/dba.c         |  7 +++---
 contrib/mandoc/main.c        | 52 +++++++++-----------------------------------
 contrib/mandoc/man.c         |  3 ++-
 contrib/mandoc/man.options.1 | 35 +++++++++++++++++++++++++----
 contrib/mandoc/mandoc.1      | 16 ++++++++------
 contrib/mandoc/mdoc.7        | 35 +++++++++++++++++++----------
 contrib/mandoc/roff_term.c   |  2 +-
 contrib/mandoc/term_ps.c     |  6 ++---
 9 files changed, 84 insertions(+), 74 deletions(-)
Comment 16 commit-hook freebsd_committer freebsd_triage 2026-02-06 00:32:09 UTC
A commit in branch stable/14 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=f763f12ed5eba2c95385dd2f93fc47a66dfa927c

commit f763f12ed5eba2c95385dd2f93fc47a66dfa927c
Author:     Alexander Ziaee <ziaee@FreeBSD.org>
AuthorDate: 2025-09-29 17:31:38 +0000
Commit:     Alexander Ziaee <ziaee@FreeBSD.org>
CommitDate: 2026-02-06 00:31:23 +0000

    mandoc: Vendor import of upstream at 2025-09-26

    Interesting changes:
    + mandoc db: Improve case sorting, found by our very own markj
    + history: Add macros for version 8 and 10 AT&T Unix
    + linter: Warn on blank lines in man(7) like mdoc(7)
    + manuals: Improve precision, man(7) syntax table, and roff(7) specifics
    + manuals: Fix PDF/PS footer regression detailed in our PR: 289786

    PR:             289786
    MFC after:      3 days

    (cherry picked from commit 59fc2b0166f71c791113379d16b8cef7039f289d)

 contrib/mandoc/Makefile      |  2 +-
 contrib/mandoc/dba.c         |  7 +++---
 contrib/mandoc/main.c        | 52 +++++++++-----------------------------------
 contrib/mandoc/man.c         |  3 ++-
 contrib/mandoc/man.options.1 | 35 +++++++++++++++++++++++++----
 contrib/mandoc/mandoc.1      | 16 ++++++++------
 contrib/mandoc/mdoc.7        | 35 +++++++++++++++++++----------
 contrib/mandoc/roff_term.c   |  2 +-
 contrib/mandoc/term_ps.c     |  6 ++---
 9 files changed, 84 insertions(+), 74 deletions(-)
Comment 17 commit-hook freebsd_committer freebsd_triage 2026-02-06 01:08:19 UTC
A commit in branch releng/14.4 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=7fa4ccb8e4e74100583dbddafcb0e1a054963d6e

commit 7fa4ccb8e4e74100583dbddafcb0e1a054963d6e
Author:     Alexander Ziaee <ziaee@FreeBSD.org>
AuthorDate: 2025-09-29 17:31:38 +0000
Commit:     Colin Percival <cperciva@FreeBSD.org>
CommitDate: 2026-02-06 01:07:07 +0000

    mandoc: Vendor import of upstream at 2025-09-26

    Interesting changes:
    + mandoc db: Improve case sorting, found by our very own markj
    + history: Add macros for version 8 and 10 AT&T Unix
    + linter: Warn on blank lines in man(7) like mdoc(7)
    + manuals: Improve precision, man(7) syntax table, and roff(7) specifics
    + manuals: Fix PDF/PS footer regression detailed in our PR: 289786

    Approved by:    re (cperciva)
    PR:             289786
    MFC after:      3 days

    (cherry picked from commit 59fc2b0166f71c791113379d16b8cef7039f289d)
    (cherry picked from commit f763f12ed5eba2c95385dd2f93fc47a66dfa927c)

 contrib/mandoc/Makefile      |  2 +-
 contrib/mandoc/dba.c         |  7 +++---
 contrib/mandoc/main.c        | 52 +++++++++-----------------------------------
 contrib/mandoc/man.c         |  3 ++-
 contrib/mandoc/man.options.1 | 35 +++++++++++++++++++++++++----
 contrib/mandoc/mandoc.1      | 16 ++++++++------
 contrib/mandoc/mdoc.7        | 35 +++++++++++++++++++----------
 contrib/mandoc/roff_term.c   |  2 +-
 contrib/mandoc/term_ps.c     |  6 ++---
 9 files changed, 84 insertions(+), 74 deletions(-)