groff
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

mdoc patch: accept any number of arguments for .Dd


From: Ingo Schwarze
Subject: mdoc patch: accept any number of arguments for .Dd
Date: Thu, 16 Jan 2020 18:56:09 +0100
User-agent: Mutt/1.12.2 (2019-09-21)

Hi,

seeing that Branden is currently working actively on groff, is anyone
willing to provide an OK for https://savannah.gnu.org/bugs/?57485 ?

TLDR: The point is that i have seen several manuals in a number of
different operating systems, both historical (around 1990) and modern
(around 2020) that give one or two arguments to .Dd.  From the
content of these arguments, it is obvious that they all expect the
date to be passed through unchanged.  I don't recall ever having
seen a manual page that passes one, two, or four arguments and
expects the current behaviour of replacing the arguments with the
date of formatting.

So for the vast majority of manuals, the patch changes nothing
except simplifying the code, and for the much smaller rest, the
patch is required for correct rendering.  It only makes results
better, for all real-world manual pages i'm aware of.

Patch rebased to master and appended below for convenience.

OK?
  Ingo


commit bd438b53cb657e0512517f58292244ac1533ceb8
Author: Ingo Schwarze <address@hidden>
Date:   Sun Dec 15 13:29:11 2019 +0100

    Accept any number of arguments for .Dd in the groff_mdoc(7) macros.
    
    * tmac/doc-common-u:
    The .Dd macro behaved in a weird way:
    Without arguments, it printed the string "Epoch".
    With one, two, four, or more arguments, it ignored all arguments
    and used the current date instead.
    Only for exactly three arguments, it printed the arguments.
    None of this made sense.  Giving the date as "Epoch" is
    absurd, and printing the current date is just misleading:
    why should a document be considered up-to-date when the author
    did not even bother to state the date of the last change?
    Admittedly, the behaviour for 0 and 4 or more arguments
    already appeared 4.3BSD-Reno, and the behaviour for 2 or 3
    arguments in 4.4BSD.  But it was already wrong even in those
    days: several manual pages in 4.4BSD gave .Dd a single, quoted
    argument, e.g. .Dd "June 9, 1993": cap_mkdb(1), id(1), sed(1),
    err(3), getcap(3), sysctl(3), amd(8), disklabel(8), and others.
    Consequently, simply print all the arguments, no matter how
    many there are.
    
    This bug was found by Jonathan Gray <address@hidden>
    while he looked at 4.xBSD manual pages.

diff --git a/ChangeLog b/ChangeLog
index 18951b14..aadb97a9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,28 @@
+2019-12-26  Ingo Schwarze  <address@hidden>
+
+       Accept any number of arguments for .Dd in the groff_mdoc(7) macros.
+
+       * tmac/doc-common-u: The .Dd macro behaved in a weird way:
+       Without arguments, it printed the string "Epoch".
+       With one, two, four, or more arguments, it ignored all arguments
+       and used the current date instead.
+       Only for exactly three arguments, it printed the arguments.
+       None of this made sense.  Giving the date as "Epoch" is
+       absurd, and printing the current date is just misleading:
+       why should a document be considered up-to-date when the author
+       did not even bother to state the date of the last change?
+       Admittedly, the behaviour for 0 and 4 or more arguments
+       already appeared 4.3BSD-Reno, and the behaviour for 2 or 3
+       arguments in 4.4BSD.  But it was already wrong even in those
+       days: several manual pages in 4.4BSD gave .Dd a single, quoted
+       argument, e.g. .Dd "June 9, 1993": cap_mkdb(1), id(1), sed(1),
+       err(3), getcap(3), sysctl(3), amd(8), disklabel(8), and others.
+       Consequently, simply print all the arguments, no matter how
+       many there are.
+
+       This bug was found by Jonathan Gray <address@hidden>
+       while he looked at 4.xBSD manual pages.
+
 2020-01-17  G. Branden Robinson <address@hidden>
 
        * tmac/tests/an-old_AT_and_UC_footer_saved_and_restored.sh: Add
diff --git a/tmac/doc-common-u b/tmac/doc-common-u
index 648926c6..dc20552f 100644
--- a/tmac/doc-common-u
+++ b/tmac/doc-common-u
@@ -900,39 +900,12 @@
 .\" NS   doc-date-string
 .\" NS   doc-command-name
 .\" NS
-.\" NS local variables:
-.\" NS   doc-date-XXX
-.\" NS
 .\" NS width register 'Dd' set above
 .
-.ds doc-date-1  January
-.ds doc-date-2  February
-.ds doc-date-3  March
-.ds doc-date-4  April
-.ds doc-date-5  May
-.ds doc-date-6  June
-.ds doc-date-7  July
-.ds doc-date-8  August
-.ds doc-date-9  September
-.ds doc-date-10 October
-.ds doc-date-11 November
-.ds doc-date-12 December
-.
 .de Dd
 .  ds doc-command-name
-.
-.  ie \n[.$] \{\
-.    ie "\$1"$Mdocdate:" \
-.      ds doc-date-string \$2\~\$3, \$4
-.    el \{ .ie (\n[.$] == 3) \
-.      ds doc-date-string \$1\~\$2 \$3
-.    el \{\
-.      ds doc-date-string "\*[doc-date-\n[mo]]
-.      as doc-date-string \~\n[dy], \n[year]
-.    \}\}
-.  \}
-.  el \
-.    ds doc-date-string Epoch
+.  ie "\$1"$Mdocdate:"  .ds doc-date-string \$2\~\$3, \$4
+.  el                   .ds doc-date-string \$*
 ..
 .
 .



reply via email to

[Prev in Thread] Current Thread [Next in Thread]