source@mandoc.bsd.lv
 help / color / mirror / Atom feed
* mandoc: warn about time machines; suggested by Thomas Klausner <wiz @
@ 2017-07-03 13:40 schwarze
  0 siblings, 0 replies; only message in thread
From: schwarze @ 2017-07-03 13:40 UTC (permalink / raw)
  To: source

Log Message:
-----------
warn about time machines; suggested by Thomas Klausner <wiz @ NetBSD>

Modified Files:
--------------
    mandoc:
        mandoc.1
        mandoc.c
        mandoc.h
        read.c

Revision Data
-------------
Index: read.c
===================================================================
RCS file: /home/cvs/mandoc/mandoc/read.c,v
retrieving revision 1.185
retrieving revision 1.186
diff -Lread.c -Lread.c -u -p -r1.185 -r1.186
--- read.c
+++ read.c
@@ -118,6 +118,7 @@ static	const char * const	mandocerrs[MAN
 	"unknown manual section",
 	"missing date, using today's date",
 	"cannot parse date, using it verbatim",
+	"date in the future, using it anyway",
 	"missing Os macro, using \"\"",
 	"duplicate prologue macro",
 	"late prologue macro",
Index: mandoc.c
===================================================================
RCS file: /home/cvs/mandoc/mandoc/mandoc.c,v
retrieving revision 1.102
retrieving revision 1.103
diff -Lmandoc.c -Lmandoc.c -u -p -r1.102 -r1.103
--- mandoc.c
+++ mandoc.c
@@ -523,6 +523,7 @@ fail:
 char *
 mandoc_normdate(struct roff_man *man, char *in, int ln, int pos)
 {
+	char		*cp;
 	time_t		 t;
 
 	/* No date specified: use today's date. */
@@ -535,13 +536,20 @@ mandoc_normdate(struct roff_man *man, ch
 	/* 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;
+	}
 
 	/* In man(7), do not warn about the legacy format. */
 
 	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);
Index: mandoc.h
===================================================================
RCS file: /home/cvs/mandoc/mandoc/mandoc.h,v
retrieving revision 1.239
retrieving revision 1.240
diff -Lmandoc.h -Lmandoc.h -u -p -r1.239 -r1.240
--- mandoc.h
+++ mandoc.h
@@ -76,6 +76,7 @@ enum	mandocerr {
 	MANDOCERR_MSEC_BAD, /* unknown manual section: Dt ... section */
 	MANDOCERR_DATE_MISSING, /* missing date, using today's date */
 	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 "" */
 	MANDOCERR_PROLOG_REP, /* duplicate prologue macro: macro */
 	MANDOCERR_PROLOG_LATE, /* late prologue macro: macro */
Index: mandoc.1
===================================================================
RCS file: /home/cvs/mandoc/mandoc/mandoc.1,v
retrieving revision 1.211
retrieving revision 1.212
diff -Lmandoc.1 -Lmandoc.1 -u -p -r1.211 -r1.212
--- mandoc.1
+++ mandoc.1
@@ -981,6 +981,14 @@ The date given in a
 or
 .Ic \&TH
 macro does not follow the conventional format.
+.It Sy "date in the future, using it anyway"
+.Pq mdoc , man
+The date given in a
+.Ic \&Dd
+or
+.Ic \&TH
+macro is more than a day ahead of the current system
+.Xr time 3 .
 .It Sy "missing Os macro, using \(dq\(dq"
 .Pq mdoc
 The default or current system is not shown in this case.
--
 To unsubscribe send an email to source+unsubscribe@mandoc.bsd.lv

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2017-07-03 13:40 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-07-03 13:40 mandoc: warn about time machines; suggested by Thomas Klausner <wiz @ schwarze

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).