=================================================================== RCS file: /cvs/mandoc/Attic/man_action.c,v retrieving revision 1.35 retrieving revision 1.41 diff -u -p -r1.35 -r1.41 --- mandoc/Attic/man_action.c 2010/05/17 10:50:32 1.35 +++ mandoc/Attic/man_action.c 2010/07/31 23:52:58 1.41 @@ -1,6 +1,6 @@ -/* $Id: man_action.c,v 1.35 2010/05/17 10:50:32 joerg Exp $ */ +/* $Id: man_action.c,v 1.41 2010/07/31 23:52:58 schwarze Exp $ */ /* - * Copyright (c) 2008, 2009 Kristaps Dzonsons + * Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -22,6 +22,7 @@ #include #include +#include "mandoc.h" #include "libman.h" #include "libmandoc.h" @@ -72,6 +73,7 @@ const struct actions man_actions[MAN_MAX] = { { post_nf }, /* Vb */ { post_fi }, /* Ve */ { post_AT }, /* AT */ + { NULL }, /* in */ }; @@ -103,7 +105,7 @@ post_fi(struct man *m) { if ( ! (MAN_LITERAL & m->flags)) - if ( ! man_nwarn(m, m->last, WNLITERAL)) + if ( ! man_nmsg(m, m->last, MANDOCERR_NOSCOPE)) return(0); m->flags &= ~MAN_LITERAL; return(1); @@ -115,7 +117,7 @@ post_nf(struct man *m) { if (MAN_LITERAL & m->flags) - if ( ! man_nwarn(m, m->last, WOLITERAL)) + if ( ! man_nmsg(m, m->last, MANDOCERR_SCOPEREP)) return(0); m->flags |= MAN_LITERAL; return(1); @@ -135,8 +137,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; @@ -154,14 +158,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_nwarn(m, n, WDATE)) + 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); @@ -218,6 +229,9 @@ post_AT(struct man *m) p = unix_versions[0]; } + if (m->meta.source) + free(m->meta.source); + m->meta.source = mandoc_strdup(p); return(1); @@ -257,6 +271,9 @@ post_UC(struct man *m) else p = bsd_versions[0]; } + + if (m->meta.source) + free(m->meta.source); m->meta.source = mandoc_strdup(p);