* mdocml: Allow bad -man dates to flow verbatim into the front-ends.
@ 2010-05-26 14:03 kristaps
0 siblings, 0 replies; only message in thread
From: kristaps @ 2010-05-26 14:03 UTC (permalink / raw)
To: source
Log Message:
-----------
Allow bad -man dates to flow verbatim into the front-ends. Noted by
Ulrich Spoerlein.
Modified Files:
--------------
mdocml:
man.7
man.c
man.h
man_action.c
man_html.c
man_term.c
Revision Data
-------------
Index: man.7
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/man.7,v
retrieving revision 1.73
retrieving revision 1.74
diff -Lman.7 -Lman.7 -u -p -r1.73 -r1.74
--- man.7
+++ man.7
@@ -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.
Index: man_term.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/man_term.c,v
retrieving revision 1.71
retrieving revision 1.72
diff -Lman_term.c -Lman_term.c -u -p -r1.71 -r1.72
--- man_term.c
+++ man_term.c
@@ -864,7 +864,10 @@ print_man_foot(struct termp *p, const st
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);
Index: man_html.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/man_html.c,v
retrieving revision 1.35
retrieving revision 1.36
diff -Lman_html.c -Lman_html.c -u -p -r1.35 -r1.36
--- man_html.c
+++ man_html.c
@@ -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%");
Index: man.h
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/man.h,v
retrieving revision 1.35
retrieving revision 1.36
diff -Lman.h -Lman.h -u -p -r1.35 -r1.36
--- man.h
+++ man.h
@@ -71,6 +71,7 @@ enum man_type {
struct man_meta {
char *msec;
time_t date;
+ char *rawdate;
char *vol;
char *title;
char *source;
Index: man_action.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/man_action.c,v
retrieving revision 1.38
retrieving revision 1.39
diff -Lman_action.c -Lman_action.c -u -p -r1.38 -r1.39
--- man_action.c
+++ man_action.c
@@ -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);
Index: man.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/man.c,v
retrieving revision 1.74
retrieving revision 1.75
diff -Lman.c -Lman.c -u -p -r1.74 -r1.75
--- man.c
+++ man.c
@@ -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)
--
To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2010-05-26 14:03 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-05-26 14:03 mdocml: Allow bad -man dates to flow verbatim into the front-ends kristaps
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).