summaryrefslogtreecommitdiffstats
path: root/mandoc.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 /mandoc.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 'mandoc.c')
-rw-r--r--mandoc.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/mandoc.c b/mandoc.c
index 5f57801d..355e6bfd 100644
--- a/mandoc.c
+++ b/mandoc.c
@@ -28,8 +28,9 @@
#include <string.h>
#include <time.h>
-#include "mandoc.h"
#include "mandoc_aux.h"
+#include "mandoc.h"
+#include "roff.h"
#include "libmandoc.h"
static int a2time(time_t *, const char *, const char *);
@@ -518,14 +519,14 @@ fail:
}
char *
-mandoc_normdate(struct mparse *parse, char *in, int ln, int pos)
+mandoc_normdate(struct roff_man *man, char *in, int ln, int pos)
{
time_t t;
/* No date specified: use today's date. */
if (in == NULL || *in == '\0' || strcmp(in, "$" "Mdocdate$") == 0) {
- mandoc_msg(MANDOCERR_DATE_MISSING, parse, ln, pos, NULL);
+ mandoc_msg(MANDOCERR_DATE_MISSING, man->parse, ln, pos, NULL);
return time2a(time(NULL));
}
@@ -535,10 +536,13 @@ mandoc_normdate(struct mparse *parse, char *in, int ln, int pos)
a2time(&t, "%b %d, %Y", in))
return time2a(t);
- /* Do not warn about the legacy man(7) format. */
+ /* In man(7), do not warn about the legacy format. */
- if ( ! a2time(&t, "%Y-%m-%d", in))
- mandoc_msg(MANDOCERR_DATE_BAD, parse, ln, pos, in);
+ if (a2time(&t, "%Y-%m-%d", in) == 0)
+ mandoc_msg(MANDOCERR_DATE_BAD, man->parse, ln, pos, in);
+ else if (man->macroset == MACROSET_MDOC)
+ mandoc_vmsg(MANDOCERR_DATE_LEGACY, man->parse,
+ ln, pos, "Dd %s", in);
/* Use any non-mdoc(7) date verbatim. */