From 9e6818d894d08819fc71166b7eba6abe1beea1f4 Mon Sep 17 00:00:00 2001 From: Ingo Schwarze Date: Sun, 19 Jan 2020 16:16:34 +0000 Subject: Align to the new, sane behaviour of the groff_mdoc(7) .Dd macro: without an argument, use the empty string, and always concatenate all arguments, no matter their number. This allows reducing the number of arguments of mandoc_normdate() and some other simplifications, at the same time polishing some error messages by adding the name of the macro in question. --- regress/usr.bin/mandoc/man/TH/baddate.out_lint | 2 +- regress/usr.bin/mandoc/man/TH/emptydate.out_lint | 2 +- regress/usr.bin/mandoc/man/TH/longdate.out_lint | 2 +- regress/usr.bin/mandoc/man/TH/noTH.out_lint | 2 +- regress/usr.bin/mandoc/man/TH/noarg.out_lint | 2 +- regress/usr.bin/mandoc/man/TH/onearg.out_lint | 2 +- regress/usr.bin/mandoc/man/TH/twoargs.out_lint | 2 +- regress/usr.bin/mandoc/mdoc/Dd/Makefile | 16 ++----- regress/usr.bin/mandoc/mdoc/Dd/badarg.out_lint | 2 +- regress/usr.bin/mandoc/mdoc/Dd/dupe.out_lint | 2 +- regress/usr.bin/mandoc/mdoc/Dd/long.out_lint | 2 +- regress/usr.bin/mandoc/mdoc/Dd/manarg.out_lint | 2 +- regress/usr.bin/mandoc/mdoc/Dd/noarg.out_ascii | 9 ++++ regress/usr.bin/mandoc/mdoc/Dd/noarg.out_lint | 2 +- regress/usr.bin/mandoc/mdoc/Dd/noarg.out_markdown | 11 +++++ regress/usr.bin/mandoc/mdoc/Dd/order.out_lint | 2 +- regress/usr.bin/mandoc/mdoc/Os/dupe.out_lint | 4 +- usr.bin/mandoc/libmandoc.h | 7 +-- usr.bin/mandoc/man_validate.c | 17 +++---- usr.bin/mandoc/mandoc.1 | 6 +-- usr.bin/mandoc/mandoc.c | 56 ++++++++++++++--------- usr.bin/mandoc/mandoc.h | 6 +-- usr.bin/mandoc/mandoc_msg.c | 6 +-- usr.bin/mandoc/mdoc_macro.c | 4 +- usr.bin/mandoc/mdoc_validate.c | 15 +++--- 25 files changed, 102 insertions(+), 81 deletions(-) create mode 100644 regress/usr.bin/mandoc/mdoc/Dd/noarg.out_ascii create mode 100644 regress/usr.bin/mandoc/mdoc/Dd/noarg.out_markdown diff --git a/regress/usr.bin/mandoc/man/TH/baddate.out_lint b/regress/usr.bin/mandoc/man/TH/baddate.out_lint index 6785463dfc7..eed40c2811b 100644 --- a/regress/usr.bin/mandoc/man/TH/baddate.out_lint +++ b/regress/usr.bin/mandoc/man/TH/baddate.out_lint @@ -1 +1 @@ -mandoc: baddate.in:2:18: WARNING: cannot parse date, using it verbatim: three bad words +mandoc: baddate.in:2:18: WARNING: cannot parse date, using it verbatim: TH three bad words diff --git a/regress/usr.bin/mandoc/man/TH/emptydate.out_lint b/regress/usr.bin/mandoc/man/TH/emptydate.out_lint index dba0e545881..15f4f171751 100644 --- a/regress/usr.bin/mandoc/man/TH/emptydate.out_lint +++ b/regress/usr.bin/mandoc/man/TH/emptydate.out_lint @@ -1 +1 @@ -mandoc: emptydate.in:2:20: WARNING: missing date, using today's date: TH +mandoc: emptydate.in:2:20: WARNING: missing date, using "": TH diff --git a/regress/usr.bin/mandoc/man/TH/longdate.out_lint b/regress/usr.bin/mandoc/man/TH/longdate.out_lint index 3006dad3132..45d0ef0bff0 100644 --- a/regress/usr.bin/mandoc/man/TH/longdate.out_lint +++ b/regress/usr.bin/mandoc/man/TH/longdate.out_lint @@ -1 +1 @@ -mandoc: longdate.in:2:19: WARNING: cannot parse date, using it verbatim: 1234567890123456789012345678901234567890123456789012345678901234567890123456789012 +mandoc: longdate.in:2:19: WARNING: cannot parse date, using it verbatim: TH 1234567890123456789012345678901234567890123456789012345678901234567890123456789012 diff --git a/regress/usr.bin/mandoc/man/TH/noTH.out_lint b/regress/usr.bin/mandoc/man/TH/noTH.out_lint index 01b7b045d95..407308cb862 100644 --- a/regress/usr.bin/mandoc/man/TH/noTH.out_lint +++ b/regress/usr.bin/mandoc/man/TH/noTH.out_lint @@ -1,2 +1,2 @@ mandoc: noTH.in: WARNING: missing manual title, using "" -mandoc: noTH.in: WARNING: missing date, using today's date +mandoc: noTH.in: WARNING: missing date, using "" diff --git a/regress/usr.bin/mandoc/man/TH/noarg.out_lint b/regress/usr.bin/mandoc/man/TH/noarg.out_lint index f4273215b1c..fb9940990cb 100644 --- a/regress/usr.bin/mandoc/man/TH/noarg.out_lint +++ b/regress/usr.bin/mandoc/man/TH/noarg.out_lint @@ -1,3 +1,3 @@ mandoc: noarg.in:2:2: WARNING: missing manual title, using "": TH mandoc: noarg.in:2:2: WARNING: missing manual section, using "": TH -mandoc: noarg.in:2:2: WARNING: missing date, using today's date: TH +mandoc: noarg.in:2:2: WARNING: missing date, using "": TH diff --git a/regress/usr.bin/mandoc/man/TH/onearg.out_lint b/regress/usr.bin/mandoc/man/TH/onearg.out_lint index 65062684f17..e86ec4e25c5 100644 --- a/regress/usr.bin/mandoc/man/TH/onearg.out_lint +++ b/regress/usr.bin/mandoc/man/TH/onearg.out_lint @@ -1,2 +1,2 @@ mandoc: onearg.in:2:2: WARNING: missing manual section, using "": TH TH-ONEARG -mandoc: onearg.in:2:2: WARNING: missing date, using today's date: TH +mandoc: onearg.in:2:2: WARNING: missing date, using "": TH diff --git a/regress/usr.bin/mandoc/man/TH/twoargs.out_lint b/regress/usr.bin/mandoc/man/TH/twoargs.out_lint index 3cd469f5865..0211ddfac82 100644 --- a/regress/usr.bin/mandoc/man/TH/twoargs.out_lint +++ b/regress/usr.bin/mandoc/man/TH/twoargs.out_lint @@ -1,2 +1,2 @@ mandoc: twoargs.in:2:2: WARNING: missing manual section, using "": TH TH-TWOARGS -mandoc: twoargs.in:2:2: WARNING: missing date, using today's date: TH +mandoc: twoargs.in:2:2: WARNING: missing date, using "": TH diff --git a/regress/usr.bin/mandoc/mdoc/Dd/Makefile b/regress/usr.bin/mandoc/mdoc/Dd/Makefile index e31b2730bc8..9c48fd4ecfa 100644 --- a/regress/usr.bin/mandoc/mdoc/Dd/Makefile +++ b/regress/usr.bin/mandoc/mdoc/Dd/Makefile @@ -1,20 +1,12 @@ -# $OpenBSD: Makefile,v 1.5 2020/01/08 10:17:15 schwarze Exp $ +# $OpenBSD: Makefile,v 1.6 2020/01/19 16:16:33 schwarze Exp $ REGRESS_TARGETS = badarg dupe late long manarg noarg order LINT_TARGETS = badarg dupe late long manarg noarg order -# noarg output contains the date when the file is formatted +# groff-1.22.4 prints footer fields of excessive length on top of +# each other rather than breaking the output line. -SKIP_ASCII ?= noarg -SKIP_MARKDOWN ?= noarg - -# If groff finds exactly three arguments, it assumes they are month, -# day and year without further checking. If there are no arguments, -# groff uses the string "Epoch". Otherwise, it silently falls back -# to today's date. -# That is not at all sane behaviour, we are not going to imitate it. - -SKIP_GROFF = badarg long manarg noarg +SKIP_GROFF = long # Autodetection fails for late .Dd, so specify -mdoc explicitly. diff --git a/regress/usr.bin/mandoc/mdoc/Dd/badarg.out_lint b/regress/usr.bin/mandoc/mdoc/Dd/badarg.out_lint index f463d7758b3..70b82a40f26 100644 --- a/regress/usr.bin/mandoc/mdoc/Dd/badarg.out_lint +++ b/regress/usr.bin/mandoc/mdoc/Dd/badarg.out_lint @@ -1,2 +1,2 @@ -mandoc: badarg.in:2:2: WARNING: cannot parse date, using it verbatim: bad date +mandoc: badarg.in:2:5: WARNING: cannot parse date, using it verbatim: Dd bad date mandoc: badarg.in:2:5: STYLE: Mdocdate missing: Dd bad date (OpenBSD) diff --git a/regress/usr.bin/mandoc/mdoc/Dd/dupe.out_lint b/regress/usr.bin/mandoc/mdoc/Dd/dupe.out_lint index 72ccde415ea..8cb4ba96ccf 100644 --- a/regress/usr.bin/mandoc/mdoc/Dd/dupe.out_lint +++ b/regress/usr.bin/mandoc/mdoc/Dd/dupe.out_lint @@ -1,3 +1,3 @@ -mandoc: dupe.in:2:5: STYLE: Mdocdate missing: Dd August (OpenBSD) +mandoc: dupe.in:2:5: STYLE: Mdocdate missing: Dd August 1, 2014 (OpenBSD) mandoc: dupe.in:5:2: ERROR: duplicate prologue macro: Dd mandoc: dupe.in:11:2: ERROR: duplicate prologue macro: Dd diff --git a/regress/usr.bin/mandoc/mdoc/Dd/long.out_lint b/regress/usr.bin/mandoc/mdoc/Dd/long.out_lint index a189560da64..11597144c55 100644 --- a/regress/usr.bin/mandoc/mdoc/Dd/long.out_lint +++ b/regress/usr.bin/mandoc/mdoc/Dd/long.out_lint @@ -1,2 +1,2 @@ -mandoc: long.in:2:2: WARNING: cannot parse date, using it verbatim: 1234567890123456789012345678901234567890123456789012345678901234567890123456789 +mandoc: long.in:2:5: WARNING: cannot parse date, using it verbatim: Dd 1234567890123456789012345678901234567890123456789012345678901234567890123456789 mandoc: long.in:2:5: STYLE: Mdocdate missing: Dd 1234567890123456789012345678901234567890123456789012345678901234567890123456789 (OpenBSD) diff --git a/regress/usr.bin/mandoc/mdoc/Dd/manarg.out_lint b/regress/usr.bin/mandoc/mdoc/Dd/manarg.out_lint index a8f48f44a42..9fe5e21efe6 100644 --- a/regress/usr.bin/mandoc/mdoc/Dd/manarg.out_lint +++ b/regress/usr.bin/mandoc/mdoc/Dd/manarg.out_lint @@ -1,2 +1,2 @@ -mandoc: manarg.in:2:2: STYLE: legacy man(7) date format: Dd 2014-08-07 +mandoc: manarg.in:2:5: STYLE: legacy man(7) date format: Dd 2014-08-07 mandoc: manarg.in:2:5: STYLE: Mdocdate missing: Dd 2014-08-07 (OpenBSD) diff --git a/regress/usr.bin/mandoc/mdoc/Dd/noarg.out_ascii b/regress/usr.bin/mandoc/mdoc/Dd/noarg.out_ascii new file mode 100644 index 00000000000..e9206d098cf --- /dev/null +++ b/regress/usr.bin/mandoc/mdoc/Dd/noarg.out_ascii @@ -0,0 +1,9 @@ +DD-NOARG(1) General Commands Manual DD-NOARG(1) + +NNAAMMEE + DDdd--nnooaarrgg - date macro without an argument + +DDEESSCCRRIIPPTTIIOONN + some text + +OpenBSD OpenBSD diff --git a/regress/usr.bin/mandoc/mdoc/Dd/noarg.out_lint b/regress/usr.bin/mandoc/mdoc/Dd/noarg.out_lint index e6ccd352c12..7202e12d5a7 100644 --- a/regress/usr.bin/mandoc/mdoc/Dd/noarg.out_lint +++ b/regress/usr.bin/mandoc/mdoc/Dd/noarg.out_lint @@ -1 +1 @@ -mandoc: noarg.in:2:2: WARNING: missing date, using today's date +mandoc: noarg.in:2:2: WARNING: missing date, using "": Dd diff --git a/regress/usr.bin/mandoc/mdoc/Dd/noarg.out_markdown b/regress/usr.bin/mandoc/mdoc/Dd/noarg.out_markdown new file mode 100644 index 00000000000..b5af6385ea8 --- /dev/null +++ b/regress/usr.bin/mandoc/mdoc/Dd/noarg.out_markdown @@ -0,0 +1,11 @@ +DD-NOARG(1) - General Commands Manual + +# NAME + +**Dd-noarg** - date macro without an argument + +# DESCRIPTION + +some text + +OpenBSD - diff --git a/regress/usr.bin/mandoc/mdoc/Dd/order.out_lint b/regress/usr.bin/mandoc/mdoc/Dd/order.out_lint index 4eb9d3bdf32..6cecfa13e49 100644 --- a/regress/usr.bin/mandoc/mdoc/Dd/order.out_lint +++ b/regress/usr.bin/mandoc/mdoc/Dd/order.out_lint @@ -1,2 +1,2 @@ mandoc: order.in:3:2: WARNING: prologue macros out of order: Dd after Dt -mandoc: order.in:3:5: STYLE: Mdocdate missing: Dd August (OpenBSD) +mandoc: order.in:3:5: STYLE: Mdocdate missing: Dd August 5, 2014 (OpenBSD) diff --git a/regress/usr.bin/mandoc/mdoc/Os/dupe.out_lint b/regress/usr.bin/mandoc/mdoc/Os/dupe.out_lint index 63b9dfd2fc6..5cdd9ee5e51 100644 --- a/regress/usr.bin/mandoc/mdoc/Os/dupe.out_lint +++ b/regress/usr.bin/mandoc/mdoc/Os/dupe.out_lint @@ -1,9 +1,9 @@ mandoc: dupe.in:3:5: STYLE: operating system explicitly specified: Os NetBSD (NetBSD) -mandoc: dupe.in:2:5: STYLE: Mdocdate found: Dd $Mdocdate: (NetBSD) +mandoc: dupe.in:2:5: STYLE: Mdocdate found: Dd $Mdocdate: January 19 2020 $ (NetBSD) mandoc: dupe.in:4:2: WARNING: prologue macros out of order: Dt after Os mandoc: dupe.in:5:2: ERROR: duplicate prologue macro: Os mandoc: dupe.in:5:5: STYLE: operating system explicitly specified: Os FreeBSD (NetBSD) -mandoc: dupe.in:2:5: STYLE: Mdocdate found: Dd $Mdocdate: (NetBSD) +mandoc: dupe.in:2:5: STYLE: Mdocdate found: Dd $Mdocdate: January 19 2020 $ (NetBSD) mandoc: dupe.in:11:2: ERROR: duplicate prologue macro: Os mandoc: dupe.in:11:5: STYLE: operating system explicitly specified: Os OpenBSD (NetBSD) mandoc: dupe.in: STYLE: RCS id missing: (NetBSD) diff --git a/usr.bin/mandoc/libmandoc.h b/usr.bin/mandoc/libmandoc.h index ace4ec25f31..5e263721fce 100644 --- a/usr.bin/mandoc/libmandoc.h +++ b/usr.bin/mandoc/libmandoc.h @@ -1,7 +1,7 @@ -/* $OpenBSD: libmandoc.h,v 1.62 2018/12/21 16:58:49 schwarze Exp $ */ +/* $OpenBSD: libmandoc.h,v 1.63 2020/01/19 16:16:32 schwarze Exp $ */ /* * Copyright (c) 2009, 2010, 2011, 2012 Kristaps Dzonsons - * Copyright (c) 2013,2014,2015,2017,2018 Ingo Schwarze + * Copyright (c) 2013-2015,2017,2018,2020 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 @@ -47,8 +47,9 @@ struct buf { struct roff; struct roff_man; +struct roff_node; -char *mandoc_normdate(struct roff_man *, char *, int, int); +char *mandoc_normdate(struct roff_node *, struct roff_node *); int mandoc_eos(const char *, size_t); int mandoc_strntoi(const char *, size_t, int); const char *mandoc_a2msec(const char*); diff --git a/usr.bin/mandoc/man_validate.c b/usr.bin/mandoc/man_validate.c index 870064019a2..897fead07cf 100644 --- a/usr.bin/mandoc/man_validate.c +++ b/usr.bin/mandoc/man_validate.c @@ -1,7 +1,7 @@ -/* $OpenBSD: man_validate.c,v 1.119 2019/06/27 15:05:14 schwarze Exp $ */ +/* $OpenBSD: man_validate.c,v 1.120 2020/01/19 16:16:32 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons - * Copyright (c) 2010, 2012-2018 Ingo Schwarze + * Copyright (c) 2010, 2012-2020 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 @@ -183,7 +183,7 @@ check_root(CHKARGS) man->meta.title = mandoc_strdup(""); man->meta.msec = mandoc_strdup(""); - man->meta.date = mandoc_normdate(man, NULL, n->line, n->pos); + man->meta.date = mandoc_normdate(NULL, NULL); } if (man->meta.os_e && @@ -399,15 +399,10 @@ post_TH(CHKARGS) if (n != NULL) n = n->next; - if (n != NULL && n->string != NULL && n->string[0] != '\0') - man->meta.date = mandoc_normdate(man, - n->string, n->line, n->pos); - else { + if (man->quick && n != NULL) man->meta.date = mandoc_strdup(""); - mandoc_msg(MANDOCERR_DATE_MISSING, - n == NULL ? nb->line : n->line, - n == NULL ? nb->pos : n->pos, "TH"); - } + else + man->meta.date = mandoc_normdate(n, nb); /* TITLE MSEC DATE ->OS<- VOL */ diff --git a/usr.bin/mandoc/mandoc.1 b/usr.bin/mandoc/mandoc.1 index 79ef8b019b2..0c796bd68ee 100644 --- a/usr.bin/mandoc/mandoc.1 +++ b/usr.bin/mandoc/mandoc.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: mandoc.1,v 1.164 2019/07/10 19:38:56 schwarze Exp $ +.\" $OpenBSD: mandoc.1,v 1.165 2020/01/19 16:16:32 schwarze Exp $ .\" .\" Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons .\" Copyright (c) 2012, 2014-2019 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: July 10 2019 $ +.Dd $Mdocdate: January 19 2020 $ .Dt MANDOC 1 .Os .Sh NAME @@ -1073,7 +1073,7 @@ macro lacks the mandatory section argument. The section number in a .Ic \&Dt line is invalid, but still used. -.It Sy "missing date, using today's date" +.It Sy "missing date, using \(dq\(dq" .Pq mdoc, man The document was parsed as .Xr mdoc 7 diff --git a/usr.bin/mandoc/mandoc.c b/usr.bin/mandoc/mandoc.c index fa1ec14220a..0b2d301dba7 100644 --- a/usr.bin/mandoc/mandoc.c +++ b/usr.bin/mandoc/mandoc.c @@ -1,7 +1,7 @@ -/* $OpenBSD: mandoc.c,v 1.84 2019/06/27 15:05:14 schwarze Exp $ */ +/* $OpenBSD: mandoc.c,v 1.85 2020/01/19 16:16:32 schwarze Exp $ */ /* * Copyright (c) 2008-2011, 2014 Kristaps Dzonsons - * Copyright (c) 2011-2015, 2017, 2018 Ingo Schwarze + * Copyright (c) 2011-2015, 2017-2020 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 @@ -531,45 +531,59 @@ fail: } char * -mandoc_normdate(struct roff_man *man, char *in, int ln, int pos) +mandoc_normdate(struct roff_node *nch, struct roff_node *nbl) { char *cp; time_t t; - if (man->quick) - return mandoc_strdup(in == NULL ? "" : in); + /* No date specified. */ - /* No date specified: use today's date. */ - - if (in == NULL || *in == '\0') - mandoc_msg(MANDOCERR_DATE_MISSING, ln, pos, NULL); - if (in == NULL || *in == '\0' || strcmp(in, "$" "Mdocdate$") == 0) + if (nch == NULL) { + if (nbl == NULL) + mandoc_msg(MANDOCERR_DATE_MISSING, 0, 0, NULL); + else + mandoc_msg(MANDOCERR_DATE_MISSING, nbl->line, + nbl->pos, "%s", roff_name[nbl->tok]); + return mandoc_strdup(""); + } + if (*nch->string == '\0') { + mandoc_msg(MANDOCERR_DATE_MISSING, nch->line, + nch->pos, "%s", roff_name[nbl->tok]); + return mandoc_strdup(""); + } + if (strcmp(nch->string, "$" "Mdocdate$") == 0) return time2a(time(NULL)); /* Valid mdoc(7) date format. */ - if (a2time(&t, "$" "Mdocdate: %b %d %Y $", in) || - a2time(&t, "%b %d, %Y", in)) { + if (a2time(&t, "$" "Mdocdate: %b %d %Y $", nch->string) || + a2time(&t, "%b %d, %Y", nch->string)) { cp = time2a(t); if (t > time(NULL) + 86400) - mandoc_msg(MANDOCERR_DATE_FUTURE, ln, pos, "%s", cp); - else if (*in != '$' && strcmp(in, cp) != 0) - mandoc_msg(MANDOCERR_DATE_NORM, ln, pos, "%s", cp); + mandoc_msg(MANDOCERR_DATE_FUTURE, nch->line, + nch->pos, "%s %s", roff_name[nbl->tok], cp); + else if (*nch->string != '$' && + strcmp(nch->string, cp) != 0) + mandoc_msg(MANDOCERR_DATE_NORM, nch->line, + nch->pos, "%s %s", roff_name[nbl->tok], cp); return cp; } /* In man(7), do not warn about the legacy format. */ - if (a2time(&t, "%Y-%m-%d", in) == 0) - mandoc_msg(MANDOCERR_DATE_BAD, ln, pos, "%s", in); + if (a2time(&t, "%Y-%m-%d", nch->string) == 0) + mandoc_msg(MANDOCERR_DATE_BAD, nch->line, nch->pos, + "%s %s", roff_name[nbl->tok], nch->string); else if (t > time(NULL) + 86400) - mandoc_msg(MANDOCERR_DATE_FUTURE, ln, pos, "%s", in); - else if (man->meta.macroset == MACROSET_MDOC) - mandoc_msg(MANDOCERR_DATE_LEGACY, ln, pos, "Dd %s", in); + mandoc_msg(MANDOCERR_DATE_FUTURE, nch->line, nch->pos, + "%s %s", roff_name[nbl->tok], nch->string); + else if (nbl->tok == MDOC_Dd) + mandoc_msg(MANDOCERR_DATE_LEGACY, nch->line, nch->pos, + "Dd %s", nch->string); /* Use any non-mdoc(7) date verbatim. */ - return mandoc_strdup(in); + return mandoc_strdup(nch->string); } int diff --git a/usr.bin/mandoc/mandoc.h b/usr.bin/mandoc/mandoc.h index c78ae335eb1..12fe018ecd9 100644 --- a/usr.bin/mandoc/mandoc.h +++ b/usr.bin/mandoc/mandoc.h @@ -1,7 +1,7 @@ -/* $OpenBSD: mandoc.h,v 1.206 2019/07/14 18:14:27 schwarze Exp $ */ +/* $OpenBSD: mandoc.h,v 1.207 2020/01/19 16:16:33 schwarze Exp $ */ /* * Copyright (c) 2010, 2011, 2014 Kristaps Dzonsons - * Copyright (c) 2012-2019 Ingo Schwarze + * Copyright (c) 2012-2020 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 @@ -83,7 +83,7 @@ enum mandocerr { MANDOCERR_TH_NOTITLE, /* missing manual title, using "": [macro] */ MANDOCERR_MSEC_MISSING, /* missing manual section, using "": macro */ MANDOCERR_MSEC_BAD, /* unknown manual section: Dt ... section */ - MANDOCERR_DATE_MISSING, /* missing date, using today's date */ + MANDOCERR_DATE_MISSING, /* missing date, using "": [macro] */ MANDOCERR_DATE_BAD, /* cannot parse date, using it verbatim: date */ MANDOCERR_DATE_FUTURE, /* date in the future, using it anyway: date */ MANDOCERR_OS_MISSING, /* missing Os macro, using "" */ diff --git a/usr.bin/mandoc/mandoc_msg.c b/usr.bin/mandoc/mandoc_msg.c index a7e71859cc2..769ed617dfb 100644 --- a/usr.bin/mandoc/mandoc_msg.c +++ b/usr.bin/mandoc/mandoc_msg.c @@ -1,7 +1,7 @@ -/* $OpenBSD: mandoc_msg.c,v 1.6 2019/07/14 18:14:27 schwarze Exp $ */ +/* $OpenBSD: mandoc_msg.c,v 1.7 2020/01/19 16:16:33 schwarze Exp $ */ /* * Copyright (c) 2010, 2011 Kristaps Dzonsons - * Copyright (c) 2014-2019 Ingo Schwarze + * Copyright (c) 2014-2020 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 @@ -81,7 +81,7 @@ static const char *const type_message[MANDOCERR_MAX] = { "missing manual title, using \"\"", "missing manual section, using \"\"", "unknown manual section", - "missing date, using today's date", + "missing date, using \"\"", "cannot parse date, using it verbatim", "date in the future, using it anyway", "missing Os macro, using \"\"", diff --git a/usr.bin/mandoc/mdoc_macro.c b/usr.bin/mandoc/mdoc_macro.c index 8ed4f0df380..b86e469162e 100644 --- a/usr.bin/mandoc/mdoc_macro.c +++ b/usr.bin/mandoc/mdoc_macro.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mdoc_macro.c,v 1.189 2019/01/07 06:51:37 schwarze Exp $ */ +/* $OpenBSD: mdoc_macro.c,v 1.190 2020/01/19 16:16:33 schwarze Exp $ */ /* * Copyright (c) 2008-2012 Kristaps Dzonsons * Copyright (c) 2010, 2012-2019 Ingo Schwarze @@ -59,7 +59,7 @@ static void rew_pending(struct roff_man *, const struct roff_node *); static const struct mdoc_macro mdoc_macros[MDOC_MAX - MDOC_Dd] = { - { in_line_eoln, MDOC_PROLOGUE }, /* Dd */ + { in_line_eoln, MDOC_PROLOGUE | MDOC_JOIN }, /* Dd */ { in_line_eoln, MDOC_PROLOGUE }, /* Dt */ { in_line_eoln, MDOC_PROLOGUE }, /* Os */ { blk_full, MDOC_PARSED | MDOC_JOIN }, /* Sh */ diff --git a/usr.bin/mandoc/mdoc_validate.c b/usr.bin/mandoc/mdoc_validate.c index 0d14812760a..243326aa3be 100644 --- a/usr.bin/mandoc/mdoc_validate.c +++ b/usr.bin/mandoc/mdoc_validate.c @@ -1,7 +1,7 @@ -/* $OpenBSD: mdoc_validate.c,v 1.290 2019/09/13 19:18:48 schwarze Exp $ */ +/* $OpenBSD: mdoc_validate.c,v 1.291 2020/01/19 16:16:33 schwarze Exp $ */ /* * Copyright (c) 2008-2012 Kristaps Dzonsons - * Copyright (c) 2010-2019 Ingo Schwarze + * Copyright (c) 2010-2020 Ingo Schwarze * Copyright (c) 2010 Joerg Sonnenberger * * Permission to use, copy, modify, and distribute this software for any @@ -1894,7 +1894,7 @@ post_root(POST_ARGS) /* Add missing prologue data. */ if (mdoc->meta.date == NULL) - mdoc->meta.date = mandoc_normdate(mdoc, NULL, 0, 0); + mdoc->meta.date = mandoc_normdate(NULL, NULL); if (mdoc->meta.title == NULL) { mandoc_msg(MANDOCERR_DT_NOTITLE, 0, 0, "EOF"); @@ -2492,7 +2492,6 @@ static void post_dd(POST_ARGS) { struct roff_node *n; - char *datestr; n = mdoc->last; n->flags |= NODE_NOPRT; @@ -2509,10 +2508,10 @@ post_dd(POST_ARGS) mandoc_msg(MANDOCERR_PROLOG_ORDER, n->line, n->pos, "Dd after Os"); - datestr = NULL; - deroff(&datestr, n); - mdoc->meta.date = mandoc_normdate(mdoc, datestr, n->line, n->pos); - free(datestr); + if (mdoc->quick && n != NULL) + mdoc->meta.date = mandoc_strdup(""); + else + mdoc->meta.date = mandoc_normdate(n->child, n); } static void -- cgit v1.2.3