summaryrefslogtreecommitdiffstats
path: root/mdoc_validate.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2017-06-11 19:37:00 +0000
committerIngo Schwarze <schwarze@openbsd.org>2017-06-11 19:37:00 +0000
commitb96c4feac3240b0841c9ecf67b07da0607aa27b5 (patch)
tree60b7e6d126c09cb88522d0f68c4e6410e0d6f9de /mdoc_validate.c
parent5e455d86a5a5d8a59d1be5988f9769217208b603 (diff)
downloadmandoc-b96c4feac3240b0841c9ecf67b07da0607aa27b5.tar.gz
Style message about legacy man(7) date format in mdoc(7) documents
and operating system dependent messages about missing or unexpected Mdocdate; inspired by mdoclint(1).
Diffstat (limited to 'mdoc_validate.c')
-rw-r--r--mdoc_validate.c32
1 files changed, 27 insertions, 5 deletions
diff --git a/mdoc_validate.c b/mdoc_validate.c
index 36c1b6ce..8d7cc1c9 100644
--- a/mdoc_validate.c
+++ b/mdoc_validate.c
@@ -1790,9 +1790,8 @@ post_root(POST_ARGS)
/* Add missing prologue data. */
if (mdoc->meta.date == NULL)
- mdoc->meta.date = mdoc->quick ?
- mandoc_strdup("") :
- mandoc_normdate(mdoc->parse, NULL, 0, 0);
+ mdoc->meta.date = mdoc->quick ? mandoc_strdup("") :
+ mandoc_normdate(mdoc, NULL, 0, 0);
if (mdoc->meta.title == NULL) {
mandoc_msg(MANDOCERR_DT_NOTITLE,
@@ -2348,7 +2347,7 @@ post_dd(POST_ARGS)
if (n->child == NULL || n->child->string[0] == '\0') {
mdoc->meta.date = mdoc->quick ? mandoc_strdup("") :
- mandoc_normdate(mdoc->parse, NULL, n->line, n->pos);
+ mandoc_normdate(mdoc, NULL, n->line, n->pos);
return;
}
@@ -2357,7 +2356,7 @@ post_dd(POST_ARGS)
if (mdoc->quick)
mdoc->meta.date = datestr;
else {
- mdoc->meta.date = mandoc_normdate(mdoc->parse,
+ mdoc->meta.date = mandoc_normdate(mdoc,
datestr, n->line, n->pos);
free(datestr);
}
@@ -2569,6 +2568,29 @@ post_os(POST_ARGS)
out: mdoc->meta.os_e = strstr(mdoc->meta.os, "OpenBSD") != NULL ?
MDOC_OS_OPENBSD : strstr(mdoc->meta.os, "NetBSD") != NULL ?
MDOC_OS_NETBSD : MDOC_OS_OTHER;
+
+ /*
+ * This is the earliest point where we can check
+ * Mdocdate conventions because we don't know
+ * the operating system earlier.
+ */
+
+ while (n->tok != MDOC_Dd)
+ if ((n = n->prev) == NULL)
+ return;
+ if ((n = n->child) == NULL)
+ return;
+ if (strcmp(n->string, "$" "Mdocdate")) {
+ if (mdoc->meta.os_e == MDOC_OS_OPENBSD)
+ mandoc_vmsg(MANDOCERR_MDOCDATE_MISSING,
+ mdoc->parse, n->line, n->pos,
+ "Dd %s", n->string);
+ } else {
+ if (mdoc->meta.os_e == MDOC_OS_NETBSD)
+ mandoc_vmsg(MANDOCERR_MDOCDATE,
+ mdoc->parse, n->line, n->pos,
+ "Dd %s", n->string);
+ }
}
enum roff_sec