=================================================================== RCS file: /cvs/mandoc/mandoc.c,v retrieving revision 1.113 retrieving revision 1.116 diff -u -p -r1.113 -r1.116 --- mandoc/mandoc.c 2018/12/18 22:00:02 1.113 +++ mandoc/mandoc.c 2019/06/27 15:07:30 1.116 @@ -1,4 +1,4 @@ -/* $Id: mandoc.c,v 1.113 2018/12/18 22:00:02 schwarze Exp $ */ +/* $Id: mandoc.c,v 1.116 2019/06/27 15:07:30 schwarze Exp $ */ /* * Copyright (c) 2008-2011, 2014 Kristaps Dzonsons * Copyright (c) 2011-2015, 2017, 2018 Ingo Schwarze @@ -32,6 +32,7 @@ #include "mandoc.h" #include "roff.h" #include "libmandoc.h" +#include "roff_int.h" static int a2time(time_t *, const char *, const char *); static char *time2a(time_t); @@ -493,9 +494,10 @@ time2a(time_t t) size_t ssz; int isz; + buf = NULL; tm = localtime(&t); if (tm == NULL) - return NULL; + goto fail; /* * Reserve space: @@ -519,7 +521,8 @@ time2a(time_t t) * of looking at LC_TIME. */ - if ((isz = snprintf(p, 4 + 1, "%d, ", tm->tm_mday)) == -1) + isz = snprintf(p, 4 + 1, "%d, ", tm->tm_mday); + if (isz < 0 || isz > 4) goto fail; p += isz; @@ -529,7 +532,7 @@ time2a(time_t t) fail: free(buf); - return NULL; + return mandoc_strdup(""); } char * @@ -538,12 +541,15 @@ mandoc_normdate(struct roff_man *man, char *in, int ln char *cp; time_t t; + if (man->quick) + return mandoc_strdup(in == NULL ? "" : in); + /* No date specified: use today's date. */ - if (in == NULL || *in == '\0' || strcmp(in, "$" "Mdocdate$") == 0) { + if (in == NULL || *in == '\0') mandoc_msg(MANDOCERR_DATE_MISSING, ln, pos, NULL); + if (in == NULL || *in == '\0' || strcmp(in, "$" "Mdocdate$") == 0) return time2a(time(NULL)); - } /* Valid mdoc(7) date format. */ @@ -563,7 +569,7 @@ mandoc_normdate(struct roff_man *man, char *in, int ln mandoc_msg(MANDOCERR_DATE_BAD, ln, pos, "%s", in); else if (t > time(NULL) + 86400) mandoc_msg(MANDOCERR_DATE_FUTURE, ln, pos, "%s", in); - else if (man->macroset == MACROSET_MDOC) + else if (man->meta.macroset == MACROSET_MDOC) mandoc_msg(MANDOCERR_DATE_LEGACY, ln, pos, "Dd %s", in); /* Use any non-mdoc(7) date verbatim. */