From d43a3b25e58b22f878cf000f42454792b509cd9d Mon Sep 17 00:00:00 2001 From: Kristaps Dzonsons Date: Wed, 26 May 2010 14:03:54 +0000 Subject: Allow bad -man dates to flow verbatim into the front-ends. Noted by Ulrich Spoerlein. --- man.7 | 9 +++++---- man.c | 4 +++- man.h | 3 ++- man_action.c | 17 +++++++++++++---- man_html.c | 7 +++++-- man_term.c | 7 +++++-- 6 files changed, 33 insertions(+), 14 deletions(-) diff --git a/man.7 b/man.7 index d24d4369..39006ef3 100644 --- a/man.7 +++ b/man.7 @@ -1,4 +1,4 @@ -.\" $Id: man.7,v 1.73 2010/05/25 22:48:04 kristaps Exp $ +.\" $Id: man.7,v 1.74 2010/05/26 14:03:54 kristaps Exp $ .\" .\" Copyright (c) 2009 Kristaps Dzonsons .\" @@ -14,7 +14,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: May 25 2010 $ +.Dd $Mdocdate: May 26 2010 $ .Dt MAN 7 .Os .Sh NAME @@ -809,8 +809,9 @@ arguments must be provided. The .Cm date argument should be formatted as described in -.Sx Dates : -if it does not conform, the current date is used instead. +.Sx Dates , +but will be printed verbatim if it is not. +If the date is not specified, the current date is used. The .Cm source string specifies the organisation providing the utility. diff --git a/man.c b/man.c index 4a4b27b2..4270a57e 100644 --- a/man.c +++ b/man.c @@ -1,4 +1,4 @@ -/* $Id: man.c,v 1.74 2010/05/17 22:11:42 kristaps Exp $ */ +/* $Id: man.c,v 1.75 2010/05/26 14:03:54 kristaps Exp $ */ /* * Copyright (c) 2008, 2009 Kristaps Dzonsons * @@ -146,6 +146,8 @@ man_free1(struct man *man) free(man->meta.title); if (man->meta.source) free(man->meta.source); + if (man->meta.rawdate) + free(man->meta.rawdate); if (man->meta.vol) free(man->meta.vol); if (man->meta.msec) diff --git a/man.h b/man.h index c6976f3a..6f8fa013 100644 --- a/man.h +++ b/man.h @@ -1,4 +1,4 @@ -/* $Id: man.h,v 1.35 2010/05/17 22:11:42 kristaps Exp $ */ +/* $Id: man.h,v 1.36 2010/05/26 14:03:54 kristaps Exp $ */ /* * Copyright (c) 2009 Kristaps Dzonsons * @@ -71,6 +71,7 @@ enum man_type { struct man_meta { char *msec; time_t date; + char *rawdate; char *vol; char *title; char *source; diff --git a/man_action.c b/man_action.c index a397b29c..e63d342b 100644 --- a/man_action.c +++ b/man_action.c @@ -1,4 +1,4 @@ -/* $Id: man_action.c,v 1.38 2010/05/24 13:36:53 kristaps Exp $ */ +/* $Id: man_action.c,v 1.39 2010/05/26 14:03:54 kristaps Exp $ */ /* * Copyright (c) 2008, 2009 Kristaps Dzonsons * @@ -136,8 +136,10 @@ post_TH(struct man *m) free(m->meta.source); if (m->meta.msec) free(m->meta.msec); + if (m->meta.rawdate) + free(m->meta.rawdate); - m->meta.title = m->meta.vol = + m->meta.title = m->meta.vol = m->meta.rawdate = m->meta.msec = m->meta.source = NULL; m->meta.date = 0; @@ -155,14 +157,21 @@ post_TH(struct man *m) /* TITLE MSEC ->DATE<- SOURCE VOL */ + /* + * Try to parse the date. If this works, stash the epoch (this + * is optimal because we can reformat it in the canonical form). + * If it doesn't parse, isn't specified at all, or is an empty + * string, then use the current date. + */ + n = n->next; - if (n) { + if (n && n->string && *n->string) { m->meta.date = mandoc_a2time (MTIME_ISO_8601, n->string); if (0 == m->meta.date) { if ( ! man_nmsg(m, n, MANDOCERR_BADDATE)) return(0); - m->meta.date = time(NULL); + m->meta.rawdate = mandoc_strdup(n->string); } } else m->meta.date = time(NULL); diff --git a/man_html.c b/man_html.c index abb1d442..80635464 100644 --- a/man_html.c +++ b/man_html.c @@ -1,4 +1,4 @@ -/* $Id: man_html.c,v 1.35 2010/05/17 22:11:42 kristaps Exp $ */ +/* $Id: man_html.c,v 1.36 2010/05/26 14:03:54 kristaps Exp $ */ /* * Copyright (c) 2008, 2009 Kristaps Dzonsons * @@ -308,7 +308,10 @@ man_root_post(MAN_ARGS) struct tag *t, *tt; char b[DATESIZ]; - time2a(m->date, b, DATESIZ); + if (m->rawdate) + strlcpy(b, m->rawdate, DATESIZ); + else + time2a(m->date, b, DATESIZ); PAIR_CLASS_INIT(&tag[0], "footer"); bufcat_style(h, "width", "100%"); diff --git a/man_term.c b/man_term.c index c6b3dc06..c637a309 100644 --- a/man_term.c +++ b/man_term.c @@ -1,4 +1,4 @@ -/* $Id: man_term.c,v 1.71 2010/05/17 22:11:42 kristaps Exp $ */ +/* $Id: man_term.c,v 1.72 2010/05/26 14:03:54 kristaps Exp $ */ /* * Copyright (c) 2008, 2009 Kristaps Dzonsons * @@ -864,7 +864,10 @@ print_man_foot(struct termp *p, const struct man_meta *meta) term_fontrepl(p, TERMFONT_NONE); - time2a(meta->date, buf, DATESIZ); + if (meta->rawdate) + strlcpy(buf, meta->rawdate, DATESIZ); + else + time2a(meta->date, buf, DATESIZ); term_vspace(p); term_vspace(p); -- cgit v1.2.3