-/* $OpenBSD: libmandoc.h,v 1.52 2017/04/29 12:43:55 schwarze Exp $ */
+/* $OpenBSD: libmandoc.h,v 1.53 2017/06/11 19:36:31 schwarze Exp $ */
/*
* Copyright (c) 2009, 2010, 2011, 2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2013, 2014, 2015 Ingo Schwarze <schwarze@openbsd.org>
int, int, const char *, ...)
__attribute__((__format__ (__printf__, 5, 6)));
char *mandoc_getarg(struct mparse *, char **, int, int *);
-char *mandoc_normdate(struct mparse *, char *, int, int);
+char *mandoc_normdate(struct roff_man *, char *, int, int);
int mandoc_eos(const char *, size_t);
int mandoc_strntoi(const char *, size_t, int);
const char *mandoc_a2msec(const char*);
-/* $OpenBSD: man_validate.c,v 1.98 2017/05/05 15:16:25 schwarze Exp $ */
+/* $OpenBSD: man_validate.c,v 1.99 2017/06/11 19:36:31 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010, 2012-2017 Ingo Schwarze <schwarze@openbsd.org>
man->meta.title = mandoc_strdup("");
man->meta.msec = mandoc_strdup("");
man->meta.date = man->quick ? mandoc_strdup("") :
- mandoc_normdate(man->parse, NULL, n->line, n->pos);
+ mandoc_normdate(man, NULL, n->line, n->pos);
}
}
if (n && n->string && '\0' != n->string[0]) {
man->meta.date = man->quick ?
mandoc_strdup(n->string) :
- mandoc_normdate(man->parse, n->string,
- n->line, n->pos);
+ mandoc_normdate(man, n->string, n->line, n->pos);
} else {
man->meta.date = mandoc_strdup("");
mandoc_msg(MANDOCERR_DATE_MISSING, man->parse,
-/* $OpenBSD: mandoc.c,v 1.68 2017/06/02 19:21:03 schwarze Exp $ */
+/* $OpenBSD: mandoc.c,v 1.69 2017/06/11 19:36:31 schwarze Exp $ */
/*
* Copyright (c) 2008-2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2011-2015, 2017 Ingo Schwarze <schwarze@openbsd.org>
#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 *);
}
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));
}
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. */
-/* $OpenBSD: mandoc.h,v 1.170 2017/06/11 17:16:36 schwarze Exp $ */
+/* $OpenBSD: mandoc.h,v 1.171 2017/06/11 19:36:31 schwarze Exp $ */
/*
* Copyright (c) 2010, 2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2017 Ingo Schwarze <schwarze@openbsd.org>
MANDOCERR_STYLE, /* ===== start of style suggestions ===== */
+ MANDOCERR_MDOCDATE, /* Mdocdate found: Dd ... */
+ MANDOCERR_MDOCDATE_MISSING, /* Mdocdate missing: Dd ... */
+ MANDOCERR_DATE_LEGACY, /* legacy man(7) date format: Dd ... */
MANDOCERR_MACRO_USELESS, /* useless macro: macro */
MANDOCERR_BX, /* consider using OS macro: macro */
MANDOCERR_ER_ORDER, /* errnos out of order: Er ... */
-/* $OpenBSD: mdoc_validate.c,v 1.251 2017/06/11 17:16:36 schwarze Exp $ */
+/* $OpenBSD: mdoc_validate.c,v 1.252 2017/06/11 19:36:31 schwarze Exp $ */
/*
* Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2017 Ingo Schwarze <schwarze@openbsd.org>
/* 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,
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;
}
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);
}
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
-/* $OpenBSD: read.c,v 1.147 2017/06/11 17:16:36 schwarze Exp $ */
+/* $OpenBSD: read.c,v 1.148 2017/06/11 19:36:31 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2017 Ingo Schwarze <schwarze@openbsd.org>
"generic style suggestion",
+ "Mdocdate found",
+ "Mdocdate missing",
+ "legacy man(7) date format",
"useless macro",
"consider using OS macro",
"errnos out of order",