aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--libmandoc.h8
-rw-r--r--main.c5
-rw-r--r--man.746
-rw-r--r--man.c8
-rw-r--r--man.h7
-rw-r--r--man_html.c12
-rw-r--r--man_term.c12
-rw-r--r--man_validate.c40
-rw-r--r--mandoc.c75
-rw-r--r--mandoc.h5
-rw-r--r--mdoc.782
-rw-r--r--mdoc.c9
-rw-r--r--mdoc.h6
-rw-r--r--mdoc_html.c7
-rw-r--r--mdoc_term.c16
-rw-r--r--mdoc_validate.c28
-rw-r--r--out.h4
17 files changed, 172 insertions, 198 deletions
diff --git a/libmandoc.h b/libmandoc.h
index 0e9a7492..3a8559b9 100644
--- a/libmandoc.h
+++ b/libmandoc.h
@@ -1,4 +1,4 @@
-/* $Id: libmandoc.h,v 1.10 2011/01/03 22:42:37 schwarze Exp $ */
+/* $Id: libmandoc.h,v 1.11 2011/03/07 01:35:51 schwarze Exp $ */
/*
* Copyright (c) 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -25,11 +25,7 @@ char *mandoc_strdup(const char *);
void *mandoc_malloc(size_t);
void *mandoc_realloc(void *, size_t);
char *mandoc_getarg(char **, mandocmsg, void *, int, int *);
-time_t mandoc_a2time(int, const char *);
-#define MTIME_CANONICAL (1 << 0)
-#define MTIME_REDUCED (1 << 1)
-#define MTIME_MDOCDATE (1 << 2)
-#define MTIME_ISO_8601 (1 << 3)
+char *mandoc_normdate(char *, mandocmsg, void *, int, int);
int mandoc_eos(const char *, size_t, int);
int mandoc_hyph(const char *, const char *);
diff --git a/main.c b/main.c
index f369dc1b..ca7eb35b 100644
--- a/main.c
+++ b/main.c
@@ -1,4 +1,4 @@
-/* $Id: main.c,v 1.146 2011/02/09 09:33:43 kristaps Exp $ */
+/* $Id: main.c,v 1.147 2011/03/07 01:35:51 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010, 2011 Ingo Schwarze <schwarze@openbsd.org>
@@ -128,7 +128,8 @@ static const char * const mandocerrs[MANDOCERR_MAX] = {
"no title in document",
"document title should be all caps",
"unknown manual section",
- "cannot parse date argument",
+ "date missing, using today's date",
+ "cannot parse date, using it verbatim",
"prologue macros out of order",
"duplicate prologue macro",
"macro not allowed in prologue",
diff --git a/man.7 b/man.7
index 82ff2710..876f32a3 100644
--- a/man.7
+++ b/man.7
@@ -1,4 +1,4 @@
-.\" $Id: man.7,v 1.98 2011/02/09 10:03:02 kristaps Exp $
+.\" $Id: man.7,v 1.99 2011/03/07 01:35:51 schwarze Exp $
.\"
.\" Copyright (c) 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv>
.\"
@@ -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: February 9 2011 $
+.Dd $Mdocdate: March 7 2011 $
.Dt MAN 7
.Os
.Sh NAME
@@ -118,15 +118,6 @@ rendered as an empty line.
.Pp
In macro lines, whitespace delimits arguments and is discarded.
If arguments are quoted, whitespace within the quotes is retained.
-.Ss Dates
-The
-.Sx \&TH
-macro is the only
-.Nm
-macro that requires a date.
-The form for this date is the ISO-8601
-standard
-.Cm YYYY-MM-DD .
.Ss Scaling Widths
Many macros support scaled widths for their arguments, such as
stipulating a two-inch paragraph indentation with the following:
@@ -763,26 +754,27 @@ The paragraph left-margin width is reset to the default.
Sets the title of the manual page with the following syntax:
.Bd -filled -offset indent
.Pf \. Sx \&TH
-.Cm title section
-.Op Cm date Op Cm source Op Cm volume
+.Ar title section date
+.Op Ar source Op Ar volume
.Ed
.Pp
-At least the upper-case document
-.Cm title
-and the manual
-.Cm section
-arguments must be provided.
-The
-.Cm date
-argument should be formatted as described in
-.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
+Conventionally, the document
+.Ar title
+is given in all caps.
+The recommended
+.Ar date
+format is
+.Sy YYYY-MM-DD
+as specified in the ISO-8601 standard;
+if the argument does not conform, it is printed verbatim.
+If the
+.Ar date
+is empty or not specified, the current date is used.
+The optional
+.Ar source
string specifies the organisation providing the utility.
The
-.Cm volume
+.Ar volume
string replaces the default rendered volume, which is dictated by the
manual section.
.Pp
diff --git a/man.c b/man.c
index 1ee3e1ff..8bcb7070 100644
--- a/man.c
+++ b/man.c
@@ -1,6 +1,6 @@
-/* $Id: man.c,v 1.101 2011/02/09 09:18:15 kristaps Exp $ */
+/* $Id: man.c,v 1.102 2011/03/07 01:35:51 schwarze Exp $ */
/*
- * Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv>
+ * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -146,8 +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.date)
+ free(man->meta.date);
if (man->meta.vol)
free(man->meta.vol);
if (man->meta.msec)
diff --git a/man.h b/man.h
index 04d50929..6aa744c3 100644
--- a/man.h
+++ b/man.h
@@ -1,6 +1,6 @@
-/* $Id: man.h,v 1.53 2011/02/09 09:18:15 kristaps Exp $ */
+/* $Id: man.h,v 1.54 2011/03/07 01:35:51 schwarze Exp $ */
/*
- * Copyright (c) 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv>
+ * Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -76,8 +76,7 @@ enum man_type {
*/
struct man_meta {
char *msec; /* `TH' section (1, 3p, etc.) */
- time_t date; /* `TH' normalised date */
- char *rawdate; /* raw `TH' date */
+ char *date; /* `TH' normalised date */
char *vol; /* `TH' volume */
char *title; /* `TH' title (e.g., FOO) */
char *source; /* `TH' source (e.g., GNU) */
diff --git a/man_html.c b/man_html.c
index 357ae420..610e58fd 100644
--- a/man_html.c
+++ b/man_html.c
@@ -1,6 +1,6 @@
-/* $Id: man_html.c,v 1.69 2011/02/09 09:52:47 kristaps Exp $ */
+/* $Id: man_html.c,v 1.70 2011/03/07 01:35:51 schwarze Exp $ */
/*
- * Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv>
+ * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -352,12 +352,6 @@ man_root_post(MAN_ARGS)
{
struct htmlpair tag[3];
struct tag *t, *tt;
- char b[DATESIZ];
-
- if (m->rawdate)
- strlcpy(b, m->rawdate, DATESIZ);
- else
- time2a(m->date, b, DATESIZ);
PAIR_SUMMARY_INIT(&tag[0], "Document Footer");
PAIR_CLASS_INIT(&tag[1], "foot");
@@ -375,7 +369,7 @@ man_root_post(MAN_ARGS)
PAIR_CLASS_INIT(&tag[0], "foot-date");
print_otag(h, TAG_TD, 1, tag);
- print_text(h, b);
+ print_text(h, m->date);
print_stagq(h, tt);
PAIR_CLASS_INIT(&tag[0], "foot-os");
diff --git a/man_term.c b/man_term.c
index 82af7018..bb526aac 100644
--- a/man_term.c
+++ b/man_term.c
@@ -1,4 +1,4 @@
-/* $Id: man_term.c,v 1.103 2011/02/09 09:52:47 kristaps Exp $ */
+/* $Id: man_term.c,v 1.104 2011/03/07 01:35:51 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010, 2011 Ingo Schwarze <schwarze@openbsd.org>
@@ -946,24 +946,18 @@ print_man_nodelist(DECL_ARGS)
static void
print_man_foot(struct termp *p, const void *arg)
{
- char buf[DATESIZ];
const struct man_meta *meta;
meta = (const struct man_meta *)arg;
term_fontrepl(p, TERMFONT_NONE);
- if (meta->rawdate)
- strlcpy(buf, meta->rawdate, DATESIZ);
- else
- time2a(meta->date, buf, DATESIZ);
-
term_vspace(p);
term_vspace(p);
term_vspace(p);
p->flags |= TERMP_NOSPACE | TERMP_NOBREAK;
- p->rmargin = p->maxrmargin - term_strlen(p, buf);
+ p->rmargin = p->maxrmargin - term_strlen(p, meta->date);
p->offset = 0;
/* term_strlen() can return zero. */
@@ -981,7 +975,7 @@ print_man_foot(struct termp *p, const void *arg)
p->rmargin = p->maxrmargin;
p->flags &= ~TERMP_NOBREAK;
- term_word(p, buf);
+ term_word(p, meta->date);
term_flushln(p);
}
diff --git a/man_validate.c b/man_validate.c
index d98862e9..c09ab36c 100644
--- a/man_validate.c
+++ b/man_validate.c
@@ -1,6 +1,7 @@
-/* $Id: man_validate.c,v 1.62 2011/02/09 09:18:15 kristaps Exp $ */
+/* $Id: man_validate.c,v 1.63 2011/03/07 01:35:51 schwarze Exp $ */
/*
- * Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv>
+ * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
+ * Copyright (c) 2010 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
@@ -194,8 +195,9 @@ check_root(CHKARGS)
*/
m->meta.title = mandoc_strdup("unknown");
- m->meta.date = time(NULL);
m->meta.msec = mandoc_strdup("1");
+ m->meta.date = mandoc_normdate(NULL,
+ m->msg, m->data, n->line, n->pos);
}
return(1);
@@ -298,7 +300,7 @@ check_ft(CHKARGS)
}
if (0 == ok) {
- man_vmsg(m, MANDOCERR_BADFONT,
+ man_vmsg(m, MANDOCERR_BADFONT,
n->line, n->pos, "%s", cp);
*cp = '\0';
}
@@ -377,6 +379,7 @@ static int
post_TH(CHKARGS)
{
const char *p;
+ int line, pos;
if (m->meta.title)
free(m->meta.title);
@@ -386,12 +389,13 @@ post_TH(CHKARGS)
free(m->meta.source);
if (m->meta.msec)
free(m->meta.msec);
- if (m->meta.rawdate)
- free(m->meta.rawdate);
+ if (m->meta.date)
+ free(m->meta.date);
- m->meta.title = m->meta.vol = m->meta.rawdate =
+ line = n->line;
+ pos = n->pos;
+ m->meta.title = m->meta.vol = m->meta.date =
m->meta.msec = m->meta.source = NULL;
- m->meta.date = 0;
/* ->TITLE<- MSEC DATE SOURCE VOL */
@@ -419,24 +423,12 @@ post_TH(CHKARGS)
/* 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.
- */
-
if (n)
n = n->next;
- if (n && n->string && *n->string) {
- m->meta.date = mandoc_a2time
- (MTIME_ISO_8601, n->string);
- if (0 == m->meta.date) {
- man_nmsg(m, n, MANDOCERR_BADDATE);
- m->meta.rawdate = mandoc_strdup(n->string);
- }
- } else
- m->meta.date = time(NULL);
+ if (n)
+ pos = n->pos;
+ m->meta.date = mandoc_normdate(n ? n->string : NULL,
+ m->msg, m->data, line, pos);
/* TITLE MSEC DATE ->SOURCE<- VOL */
diff --git a/mandoc.c b/mandoc.c
index 4faa5a78..5cebd7e2 100644
--- a/mandoc.c
+++ b/mandoc.c
@@ -1,4 +1,4 @@
-/* $Id: mandoc.c,v 1.36 2011/01/03 22:42:37 schwarze Exp $ */
+/* $Id: mandoc.c,v 1.37 2011/03/07 01:35:51 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2011 Ingo Schwarze <schwarze@openbsd.org>
@@ -31,8 +31,10 @@
#include "mandoc.h"
#include "libmandoc.h"
-static int a2time(time_t *, const char *, const char *);
+#define DATESIZE 32
+static int a2time(time_t *, const char *, const char *);
+static char *time2a(time_t);
int
mandoc_special(char *p)
@@ -380,38 +382,55 @@ a2time(time_t *t, const char *fmt, const char *p)
}
-/*
- * Convert from a manual date string (see mdoc(7) and man(7)) into a
- * date according to the stipulated date type.
- */
-time_t
-mandoc_a2time(int flags, const char *p)
+static char *
+time2a(time_t t)
{
- time_t t;
+ struct tm tm;
+ char buf[DATESIZE];
+ char *p;
+ size_t nsz, rsz;
+ int isz;
- if (MTIME_MDOCDATE & flags) {
- if (0 == strcmp(p, "$" "Mdocdate$"))
- return(time(NULL));
- if (a2time(&t, "$" "Mdocdate: %b %d %Y $", p))
- return(t);
- }
+ localtime_r(&t, &tm);
- if (MTIME_CANONICAL & flags || MTIME_REDUCED & flags)
- if (a2time(&t, "%b %d, %Y", p))
- return(t);
+ p = buf;
+ rsz = DATESIZE;
- if (MTIME_ISO_8601 & flags)
- if (a2time(&t, "%Y-%m-%d", p))
- return(t);
+ if (0 == (nsz = strftime(p, rsz, "%B ", &tm)))
+ return(NULL);
- if (MTIME_REDUCED & flags) {
- if (a2time(&t, "%d, %Y", p))
- return(t);
- if (a2time(&t, "%Y", p))
- return(t);
- }
+ p += (int)nsz;
+ rsz -= nsz;
- return(0);
+ if (-1 == (isz = snprintf(p, rsz, "%d, ", tm.tm_mday)))
+ return(NULL);
+
+ p += isz;
+ rsz -= isz;
+
+ return(strftime(p, rsz, "%Y", &tm) ? buf : NULL);
+}
+
+
+char *
+mandoc_normdate(char *in, mandocmsg msg, void *data, int ln, int pos)
+{
+ char *out;
+ time_t t;
+
+ if (NULL == in || '\0' == *in ||
+ 0 == strcmp(in, "$" "Mdocdate$")) {
+ (*msg)(MANDOCERR_NODATE, data, ln, pos, NULL);
+ time(&t);
+ }
+ else if (!a2time(&t, "$" "Mdocdate: %b %d %Y $", in) &&
+ !a2time(&t, "%b %d, %Y", in) &&
+ !a2time(&t, "%Y-%m-%d", in)) {
+ (*msg)(MANDOCERR_BADDATE, data, ln, pos, NULL);
+ t = 0;
+ }
+ out = t ? time2a(t) : NULL;
+ return(mandoc_strdup(out ? out : in));
}
diff --git a/mandoc.h b/mandoc.h
index 7cb37f35..b5984b26 100644
--- a/mandoc.h
+++ b/mandoc.h
@@ -1,4 +1,4 @@
-/* $Id: mandoc.h,v 1.57 2011/02/09 09:05:52 kristaps Exp $ */
+/* $Id: mandoc.h,v 1.58 2011/03/07 01:35:51 schwarze Exp $ */
/*
* Copyright (c) 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -50,7 +50,8 @@ enum mandocerr {
MANDOCERR_NOTITLE, /* no title in document */
MANDOCERR_UPPERCASE, /* document title should be all caps */
MANDOCERR_BADMSEC, /* unknown manual section */
- MANDOCERR_BADDATE, /* cannot parse date argument */
+ MANDOCERR_NODATE, /* date missing, using today's date */
+ MANDOCERR_BADDATE, /* cannot parse date, using it verbatim */
MANDOCERR_PROLOGOOO, /* prologue macros out of order */
MANDOCERR_PROLOGREP, /* duplicate prologue macro */
MANDOCERR_BADPROLOG, /* macro not allowed in prologue */
diff --git a/mdoc.7 b/mdoc.7
index 09e4716e..ee685016 100644
--- a/mdoc.7
+++ b/mdoc.7
@@ -1,4 +1,4 @@
-.\" $Id: mdoc.7,v 1.180 2011/02/09 10:03:02 kristaps Exp $
+.\" $Id: mdoc.7,v 1.181 2011/03/07 01:35:51 schwarze Exp $
.\"
.\" Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
.\" Copyright (c) 2010 Ingo Schwarze <schwarze@openbsd.org>
@@ -15,7 +15,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: February 9 2011 $
+.Dd $Mdocdate: March 7 2011 $
.Dt MDOC 7
.Os
.Sh NAME
@@ -197,34 +197,6 @@ Thus, the following produces
.Ed
.Pp
In free-form mode, quotes are regarded as opaque text.
-.Ss Dates
-There are several macros in
-.Nm
-that require a date argument.
-The canonical form for dates is the American format:
-.Pp
-.D1 Cm Month Day , Year
-.Pp
-The
-.Cm Day
-value is an optionally zero-padded numeral.
-The
-.Cm Month
-value is the full month name.
-The
-.Cm Year
-value is the full four-digit year.
-.Pp
-Reduced form dates are broken-down canonical form dates:
-.Pp
-.D1 Cm Month , Year
-.D1 Cm Year
-.Pp
-Some examples of valid dates follow:
-.Pp
-.D1 "May, 2009" Pq reduced form
-.D1 "2009" Pq reduced form
-.D1 "May 20, 2009" Pq canonical form
.Ss Scaling Widths
Many macros support scaled widths for their arguments, such as
stipulating a two-inch list indentation with the following:
@@ -886,8 +858,10 @@ block.
Publication date of an
.Sx \&Rs
block.
-This should follow the reduced or canonical form syntax described in
-.Sx Dates .
+Recommended formats of arguments are
+.Ar month day , year
+or just
+.Ar year .
.Ss \&%I
Publisher or issuer name of an
.Sx \&Rs
@@ -1469,17 +1443,36 @@ This is the mandatory first macro of any
manual.
Its syntax is as follows:
.Pp
-.D1 Pf \. Sx \&Dd Op Ar date
+.D1 Pf \. Sx \&Dd Ar month day , year
.Pp
The
-.Ar date
-may be either
-.Ar $\&Mdocdate$ ,
-which signifies the current manual revision date dictated by
+.Ar month
+is the full English month name, the
+.Ar day
+is an optionally zero-padded numeral, and the
+.Ar year
+is the full four-digit year.
+.Pp
+Other arguments are not portable; the
+.Xr mandoc 1
+utility handles them as follows:
+.Bl -dash -offset 3n -compact
+.It
+To have the date automatically filled in by the
+.Ox
+version of
.Xr cvs 1 ,
-or instead a valid canonical date as specified by
-.Sx Dates .
-If a date does not conform or is empty, the current date is used.
+the special string
+.Dq $\&Mdocdate$
+can be given as an argument.
+.It
+A few alternative date formats are accepted as well
+and converted to the standard form.
+.It
+If a date string cannot be parsed, it is used verbatim.
+.It
+If no date string is given, the current date is used.
+.El
.Pp
Examples:
.Dl \&.Dd $\&Mdocdate$
@@ -2771,9 +2764,12 @@ does not start a new line.
\*[hist]
.It
.Sx \&Dd
-without an argument prints
-.Dq Epoch .
-In mandoc, it resolves to the current date.
+with non-standard arguments behaves very strangely.
+When there are three arguments, they are printed verbatim.
+Any other number of arguments is replaced by the current date,
+but without any arguments the string
+.Dq Epoch
+is printed.
.It
.Sx \&Fl
does not print a dash for an empty argument.
diff --git a/mdoc.c b/mdoc.c
index 7e8e8bec..36fd735c 100644
--- a/mdoc.c
+++ b/mdoc.c
@@ -1,6 +1,6 @@
-/* $Id: mdoc.c,v 1.181 2011/02/09 09:05:52 kristaps Exp $ */
+/* $Id: mdoc.c,v 1.182 2011/03/07 01:35:51 schwarze Exp $ */
/*
- * Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv>
+ * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010 Ingo Schwarze <schwarze@openbsd.org>
*
* Permission to use, copy, modify, and distribute this software for any
@@ -342,8 +342,9 @@ mdoc_macro(MACRO_PROT_ARGS)
m->meta.vol = mandoc_strdup("LOCAL");
if (NULL == m->meta.os)
m->meta.os = mandoc_strdup("LOCAL");
- if (0 == m->meta.date)
- m->meta.date = time(NULL);
+ if (NULL == m->meta.date)
+ m->meta.date = mandoc_normdate(NULL,
+ m->msg, m->data, line, ppos);
m->flags |= MDOC_PBODY;
}
diff --git a/mdoc.h b/mdoc.h
index 071ce31d..84fa3160 100644
--- a/mdoc.h
+++ b/mdoc.h
@@ -1,6 +1,6 @@
-/* $Id: mdoc.h,v 1.117 2011/02/09 09:05:52 kristaps Exp $ */
+/* $Id: mdoc.h,v 1.118 2011/03/07 01:35:51 schwarze Exp $ */
/*
- * Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv>
+ * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -232,7 +232,7 @@ struct mdoc_meta {
char *msec; /* `Dt' section (1, 3p, etc.) */
char *vol; /* `Dt' volume (implied) */
char *arch; /* `Dt' arch (i386, etc.) */
- time_t date; /* `Dd' normalised date */
+ char *date; /* `Dd' normalised date */
char *title; /* `Dt' title (FOO, etc.) */
char *os; /* `Os' system (OpenBSD, etc.) */
char *name; /* leading `Nm' name */
diff --git a/mdoc_html.c b/mdoc_html.c
index 712cd92a..89949737 100644
--- a/mdoc_html.c
+++ b/mdoc_html.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_html.c,v 1.153 2011/02/09 09:52:47 kristaps Exp $ */
+/* $Id: mdoc_html.c,v 1.154 2011/03/07 01:35:51 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -500,9 +500,6 @@ mdoc_root_post(MDOC_ARGS)
{
struct htmlpair tag[3];
struct tag *t, *tt;
- char b[DATESIZ];
-
- time2a(m->date, b, DATESIZ);
PAIR_SUMMARY_INIT(&tag[0], "Document Footer");
PAIR_CLASS_INIT(&tag[1], "foot");
@@ -522,7 +519,7 @@ mdoc_root_post(MDOC_ARGS)
PAIR_CLASS_INIT(&tag[0], "foot-date");
print_otag(h, TAG_TD, 1, tag);
- print_text(h, b);
+ print_text(h, m->date);
print_stagq(h, tt);
PAIR_CLASS_INIT(&tag[0], "foot-os");
diff --git a/mdoc_term.c b/mdoc_term.c
index a6d6dd89..8d7a331a 100644
--- a/mdoc_term.c
+++ b/mdoc_term.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_term.c,v 1.219 2011/02/09 09:52:47 kristaps Exp $ */
+/* $Id: mdoc_term.c,v 1.220 2011/03/07 01:35:51 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010 Ingo Schwarze <schwarze@openbsd.org>
@@ -413,7 +413,6 @@ print_mdoc_node(DECL_ARGS)
static void
print_mdoc_foot(struct termp *p, const void *arg)
{
- char buf[DATESIZ], os[BUFSIZ];
const struct mdoc_meta *m;
m = (const struct mdoc_meta *)arg;
@@ -428,24 +427,21 @@ print_mdoc_foot(struct termp *p, const void *arg)
* SYSTEM DATE SYSTEM
*/
- time2a(m->date, buf, DATESIZ);
- strlcpy(os, m->os, BUFSIZ);
-
term_vspace(p);
p->offset = 0;
p->rmargin = (p->maxrmargin -
- term_strlen(p, buf) + term_len(p, 1)) / 2;
+ term_strlen(p, m->date) + term_len(p, 1)) / 2;
p->flags |= TERMP_NOSPACE | TERMP_NOBREAK;
- term_word(p, os);
+ term_word(p, m->os);
term_flushln(p);
p->offset = p->rmargin;
- p->rmargin = p->maxrmargin - term_strlen(p, os);
+ p->rmargin = p->maxrmargin - term_strlen(p, m->os);
p->flags |= TERMP_NOLPAD | TERMP_NOSPACE;
- term_word(p, buf);
+ term_word(p, m->date);
term_flushln(p);
p->offset = p->rmargin;
@@ -453,7 +449,7 @@ print_mdoc_foot(struct termp *p, const void *arg)
p->flags &= ~TERMP_NOBREAK;
p->flags |= TERMP_NOLPAD | TERMP_NOSPACE;
- term_word(p, os);
+ term_word(p, m->os);
term_flushln(p);
p->offset = 0;
diff --git a/mdoc_validate.c b/mdoc_validate.c
index 31002d99..58677062 100644
--- a/mdoc_validate.c
+++ b/mdoc_validate.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_validate.c,v 1.157 2011/02/09 09:18:15 kristaps Exp $ */
+/* $Id: mdoc_validate.c,v 1.158 2011/03/07 01:35:51 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010, 2011 Ingo Schwarze <schwarze@openbsd.org>
@@ -140,7 +140,7 @@ static v_post posts_bx[] = { post_bx, NULL };
static v_post posts_bool[] = { ebool, NULL };
static v_post posts_eoln[] = { post_eoln, NULL };
static v_post posts_defaults[] = { post_defaults, NULL };
-static v_post posts_dd[] = { ewarn_ge1, post_dd, post_prol, NULL };
+static v_post posts_dd[] = { post_dd, post_prol, NULL };
static v_post posts_dl[] = { post_literal, bwarn_ge1, NULL };
static v_post posts_dt[] = { post_dt, post_prol, NULL };
static v_post posts_fo[] = { hwarn_eq1, bwarn_ge1, NULL };
@@ -221,7 +221,7 @@ const struct valids mdoc_valids[MDOC_MAX] = {
{ NULL, posts_text }, /* Xr */
{ NULL, posts_text }, /* %A */
{ NULL, posts_text }, /* %B */ /* FIXME: can be used outside Rs/Re. */
- { NULL, posts_text }, /* %D */ /* FIXME: check date with mandoc_a2time(). */
+ { NULL, posts_text }, /* %D */
{ NULL, posts_text }, /* %I */
{ NULL, posts_text }, /* %J */
{ NULL, posts_text }, /* %N */
@@ -919,7 +919,7 @@ static int
pre_dt(PRE_ARGS)
{
- if (0 == mdoc->meta.date || mdoc->meta.os)
+ if (NULL == mdoc->meta.date || mdoc->meta.os)
mdoc_nmsg(mdoc, n, MANDOCERR_PROLOGOOO);
if (mdoc->meta.title)
@@ -932,7 +932,7 @@ static int
pre_os(PRE_ARGS)
{
- if (NULL == mdoc->meta.title || 0 == mdoc->meta.date)
+ if (NULL == mdoc->meta.title || NULL == mdoc->meta.date)
mdoc_nmsg(mdoc, n, MANDOCERR_PROLOGOOO);
if (mdoc->meta.os)
@@ -1971,23 +1971,21 @@ post_dd(POST_ARGS)
char buf[DATESIZE];
struct mdoc_node *n;
- n = mdoc->last;
+ if (mdoc->meta.date)
+ free(mdoc->meta.date);
- if (NULL == n->child) {
- mdoc->meta.date = time(NULL);
+ n = mdoc->last;
+ if (NULL == n->child || '\0' == n->child->string[0]) {
+ mdoc->meta.date = mandoc_normdate(NULL,
+ mdoc->msg, mdoc->data, n->line, n->pos);
return(1);
}
if ( ! concat(mdoc, buf, n->child, DATESIZE))
return(0);
- mdoc->meta.date = mandoc_a2time
- (MTIME_MDOCDATE | MTIME_CANONICAL, buf);
-
- if (0 == mdoc->meta.date) {
- mdoc_nmsg(mdoc, n, MANDOCERR_BADDATE);
- mdoc->meta.date = time(NULL);
- }
+ mdoc->meta.date = mandoc_normdate(buf,
+ mdoc->msg, mdoc->data, n->line, n->pos);
return(1);
}
diff --git a/out.h b/out.h
index ebd70188..425c727b 100644
--- a/out.h
+++ b/out.h
@@ -1,4 +1,4 @@
-/* $Id: out.h,v 1.16 2011/01/30 16:05:37 schwarze Exp $ */
+/* $Id: out.h,v 1.17 2011/03/07 01:35:51 schwarze Exp $ */
/*
* Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -17,8 +17,6 @@
#ifndef OUT_H
#define OUT_H
-#define DATESIZ 24
-
__BEGIN_DECLS
struct roffcol {