summaryrefslogtreecommitdiff
path: root/usr/src/cmd/mandoc/mandoc.c
diff options
context:
space:
mode:
Diffstat (limited to 'usr/src/cmd/mandoc/mandoc.c')
-rw-r--r--usr/src/cmd/mandoc/mandoc.c46
1 files changed, 35 insertions, 11 deletions
diff --git a/usr/src/cmd/mandoc/mandoc.c b/usr/src/cmd/mandoc/mandoc.c
index d265463b4e..3e16d2c64f 100644
--- a/usr/src/cmd/mandoc/mandoc.c
+++ b/usr/src/cmd/mandoc/mandoc.c
@@ -1,7 +1,7 @@
-/* $Id: mandoc.c,v 1.98 2015/11/12 22:44:27 schwarze Exp $ */
+/* $Id: mandoc.c,v 1.103 2017/07/03 13:40:19 schwarze Exp $ */
/*
* Copyright (c) 2008-2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
- * Copyright (c) 2011-2015 Ingo Schwarze <schwarze@openbsd.org>
+ * Copyright (c) 2011-2015, 2017 Ingo Schwarze <schwarze@openbsd.org>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -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 *);
@@ -95,6 +96,8 @@ mandoc_escape(const char **end, const char **start, int *sz)
case ',':
case '/':
return ESCAPE_IGNORE;
+ case 'p':
+ return ESCAPE_BREAK;
/*
* The \z escape is supposed to output the following
@@ -175,7 +178,17 @@ mandoc_escape(const char **end, const char **start, int *sz)
++*end;
return ESCAPE_ERROR;
}
- gly = ESCAPE_IGNORE;
+ switch ((*start)[-1]) {
+ case 'h':
+ gly = ESCAPE_HORIZ;
+ break;
+ case 'l':
+ gly = ESCAPE_HLINE;
+ break;
+ default:
+ gly = ESCAPE_IGNORE;
+ break;
+ }
term = **start;
*start = ++*end;
break;
@@ -508,27 +521,38 @@ 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)
{
+ char *cp;
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));
}
/* Valid mdoc(7) date format. */
if (a2time(&t, "$" "Mdocdate: %b %d %Y $", in) ||
- a2time(&t, "%b %d, %Y", in))
- return time2a(t);
+ a2time(&t, "%b %d, %Y", in)) {
+ cp = time2a(t);
+ if (t > time(NULL) + 86400)
+ mandoc_msg(MANDOCERR_DATE_FUTURE, man->parse,
+ ln, pos, cp);
+ return cp;
+ }
- /* 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 (t > time(NULL) + 86400)
+ mandoc_msg(MANDOCERR_DATE_FUTURE, 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. */