From 7674a4360d6c26a789ab62ef0ed916622cae1cc3 Mon Sep 17 00:00:00 2001 From: schwarze Date: Sat, 28 Jul 2018 18:32:30 +0000 Subject: [PATCH] Issue a STYLE message when normalizing the date format in .Dd/.TH. Leah Neukirchen pointed out that mdoclint(1) used to warn about a leading zero before the day number, so we know that both NetBSD and Void Linux want the message. It does no harm on OpenBSD because Mdocdate always does the right thing anyway. jmc@ agrees that it makes sense in contexts not using Mdocdate. --- share/man/man7/mdoc.7 | 12 ++++++------ usr.bin/mandoc/mandoc.1 | 14 ++++++++++++-- usr.bin/mandoc/mandoc.c | 7 +++++-- usr.bin/mandoc/mandoc.h | 5 +++-- usr.bin/mandoc/read.c | 5 +++-- 5 files changed, 29 insertions(+), 14 deletions(-) diff --git a/share/man/man7/mdoc.7 b/share/man/man7/mdoc.7 index 78f7aaec91f..6422c3695bc 100644 --- a/share/man/man7/mdoc.7 +++ b/share/man/man7/mdoc.7 @@ -1,7 +1,7 @@ -.\" $OpenBSD: mdoc.7,v 1.158 2017/10/23 13:52:33 schwarze Exp $ +.\" $OpenBSD: mdoc.7,v 1.159 2018/07/28 18:32:30 schwarze Exp $ .\" .\" Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons -.\" Copyright (c) 2010, 2011, 2013-2017 Ingo Schwarze +.\" Copyright (c) 2010, 2011, 2013-2018 Ingo Schwarze .\" .\" Permission to use, copy, modify, and distribute this software for any .\" purpose with or without fee is hereby granted, provided that the above @@ -15,7 +15,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: October 23 2017 $ +.Dd $Mdocdate: July 28 2018 $ .Dt MDOC 7 .Os .Sh NAME @@ -1234,7 +1234,7 @@ The .Ar month is the full English month name, the .Ar day -is an optionally zero-padded numeral, and the +is an integer number, and the .Ar year is the full four-digit year. .Pp @@ -1264,8 +1264,8 @@ If no date string is given, the current date is used. .Pp Examples: .Dl \&.Dd $\&Mdocdate$ -.Dl \&.Dd $\&Mdocdate: July 21 2007$ -.Dl \&.Dd July 21, 2007 +.Dl \&.Dd $\&Mdocdate: July 2 2018$ +.Dl \&.Dd July 2, 2018 .Pp See also .Sx \&Dt diff --git a/usr.bin/mandoc/mandoc.1 b/usr.bin/mandoc/mandoc.1 index bfc3425deaf..7873440fbca 100644 --- a/usr.bin/mandoc/mandoc.1 +++ b/usr.bin/mandoc/mandoc.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: mandoc.1,v 1.149 2018/05/03 14:21:20 schwarze Exp $ +.\" $OpenBSD: mandoc.1,v 1.150 2018/07/28 18:32:30 schwarze Exp $ .\" .\" Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons .\" Copyright (c) 2012, 2014-2018 Ingo Schwarze @@ -15,7 +15,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: May 3 2018 $ +.Dd $Mdocdate: July 28 2018 $ .Dt MANDOC 1 .Os .Sh NAME @@ -853,6 +853,16 @@ Consider using the conventional date format .Dq "Month dd, yyyy" instead. +.It Sy "normalizing date format to" : No ... +.Pq mdoc , man +The +.Ic \&Dd +or +.Ic \&TH +macro provides an abbreviated month name or a day number with a +leading zero. +In the formatted output, the month name is written out in full +and the leading zero is omitted. .It Sy "lower case character in document title" .Pq mdoc , man The title is still used as given in the diff --git a/usr.bin/mandoc/mandoc.c b/usr.bin/mandoc/mandoc.c index 92637e41d93..81a658fad92 100644 --- a/usr.bin/mandoc/mandoc.c +++ b/usr.bin/mandoc/mandoc.c @@ -1,7 +1,7 @@ -/* $OpenBSD: mandoc.c,v 1.71 2017/07/03 13:40:00 schwarze Exp $ */ +/* $OpenBSD: mandoc.c,v 1.72 2018/07/28 18:32:30 schwarze Exp $ */ /* * Copyright (c) 2008-2011, 2014 Kristaps Dzonsons - * Copyright (c) 2011-2015, 2017 Ingo Schwarze + * Copyright (c) 2011-2015, 2017, 2018 Ingo Schwarze * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -536,6 +536,9 @@ mandoc_normdate(struct roff_man *man, char *in, int ln, int pos) if (t > time(NULL) + 86400) mandoc_msg(MANDOCERR_DATE_FUTURE, man->parse, ln, pos, cp); + else if (*in != '$' && strcmp(in, cp) != 0) + mandoc_msg(MANDOCERR_DATE_NORM, man->parse, + ln, pos, cp); return cp; } diff --git a/usr.bin/mandoc/mandoc.h b/usr.bin/mandoc/mandoc.h index 74907eeb5cd..50b2c285b31 100644 --- a/usr.bin/mandoc/mandoc.h +++ b/usr.bin/mandoc/mandoc.h @@ -1,7 +1,7 @@ -/* $OpenBSD: mandoc.h,v 1.189 2018/03/16 15:05:33 schwarze Exp $ */ +/* $OpenBSD: mandoc.h,v 1.190 2018/07/28 18:32:30 schwarze Exp $ */ /* * Copyright (c) 2010, 2011, 2014 Kristaps Dzonsons - * Copyright (c) 2010-2017 Ingo Schwarze + * Copyright (c) 2010-2018 Ingo Schwarze * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -56,6 +56,7 @@ enum mandocerr { MANDOCERR_STYLE, /* ===== start of style suggestions ===== */ MANDOCERR_DATE_LEGACY, /* legacy man(7) date format: Dd ... */ + MANDOCERR_DATE_NORM, /* normalizing date format to: ... */ MANDOCERR_TITLE_CASE, /* lower case character in document title */ MANDOCERR_RCS_REP, /* duplicate RCS id: ... */ MANDOCERR_SEC_TYPO, /* possible typo in section name: Sh ... */ diff --git a/usr.bin/mandoc/read.c b/usr.bin/mandoc/read.c index 07e891de527..0d119023ce5 100644 --- a/usr.bin/mandoc/read.c +++ b/usr.bin/mandoc/read.c @@ -1,7 +1,7 @@ -/* $OpenBSD: read.c,v 1.167 2018/03/16 15:05:33 schwarze Exp $ */ +/* $OpenBSD: read.c,v 1.168 2018/07/28 18:32:30 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons - * Copyright (c) 2010-2017 Ingo Schwarze + * Copyright (c) 2010-2018 Ingo Schwarze * Copyright (c) 2010, 2012 Joerg Sonnenberger * * Permission to use, copy, modify, and distribute this software for any @@ -92,6 +92,7 @@ static const char * const mandocerrs[MANDOCERR_MAX] = { "generic style suggestion", "legacy man(7) date format", + "normalizing date format to", "lower case character in document title", "duplicate RCS id", "possible typo in section name", -- 2.20.1