=================================================================== RCS file: /cvs/mandoc/Attic/mdoc_action.c,v retrieving revision 1.48 retrieving revision 1.56 diff -u -p -r1.48 -r1.56 --- mandoc/Attic/mdoc_action.c 2009/10/31 06:10:58 1.48 +++ mandoc/Attic/mdoc_action.c 2010/05/14 15:26:39 1.56 @@ -1,4 +1,4 @@ -/* $Id: mdoc_action.c,v 1.48 2009/10/31 06:10:58 kristaps Exp $ */ +/* $Id: mdoc_action.c,v 1.56 2010/05/14 15:26:39 kristaps Exp $ */ /* * Copyright (c) 2008, 2009 Kristaps Dzonsons * @@ -14,6 +14,10 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #ifndef OSNAME #include #endif @@ -40,12 +44,8 @@ struct actions { static int concat(struct mdoc *, char *, const struct mdoc_node *, size_t); -static inline int order_rs(int); +static inline int order_rs(enum mdoct); -#ifdef __linux__ -extern size_t strlcat(char *, const char *, size_t); -#endif - static int post_ar(POST_ARGS); static int post_at(POST_ARGS); static int post_bl(POST_ARGS); @@ -196,7 +196,7 @@ static const struct actions mdoc_actions[MDOC_MAX] = { #define RSORD_MAX 14 -static const int rsord[RSORD_MAX] = { +static const enum mdoct rsord[RSORD_MAX] = { MDOC__A, MDOC__T, MDOC__B, @@ -366,9 +366,10 @@ post_st(POST_ARGS) assert(MDOC_TEXT == n->child->type); p = mdoc_a2st(n->child->string); - assert(p); - free(n->child->string); - n->child->string = mandoc_strdup(p); + if (p != NULL) { + free(n->child->string); + n->child->string = mandoc_strdup(p); + } return(1); } @@ -419,8 +420,12 @@ post_sh(POST_ARGS) if ( ! concat(m, buf, n->child, BUFSIZ)) return(0); - sec = mdoc_atosec(buf); - if (SEC_CUSTOM != sec) + sec = mdoc_str2sec(buf); + /* + * The first section should always make us move into a non-new + * state. + */ + if (SEC_NONE == m->lastnamed || SEC_CUSTOM != sec) m->lastnamed = sec; /* Some sections only live in certain manual sections. */ @@ -647,7 +652,8 @@ static int post_bl_width(POST_ARGS) { size_t width; - int i, tok; + int i; + enum mdoct tok; char buf[NUMSIZ]; char *p; @@ -724,7 +730,7 @@ post_bl_head(POST_ARGS) nn->string = NULL; nnp = nn; nn = nn->next; - mdoc_node_free(nnp); + mdoc_node_delete(NULL, nnp); } n->nchild = 0; @@ -818,8 +824,7 @@ post_ar(POST_ARGS) /* - * Parse the date field in `Dd', primarily through mdoc_atotime(). - * FIXME: push mdoc_atotime() into here. + * Parse the date field in `Dd'. */ static int post_dd(POST_ARGS) @@ -829,7 +834,9 @@ post_dd(POST_ARGS) if ( ! concat(m, buf, n->child, DATESIZ)) return(0); - m->meta.date = mdoc_atotime(buf); + m->meta.date = mandoc_a2time + (MTIME_MDOCDATE | MTIME_CANONICAL, buf); + if (0 == m->meta.date) { if ( ! mdoc_nwarn(m, n, EBADDATE)) return(0); @@ -848,29 +855,10 @@ post_dd(POST_ARGS) static int post_prol(POST_ARGS) { - struct mdoc_node *np; - if (n->parent->child == n) - n->parent->child = n->prev; - if (n->prev) - n->prev->next = NULL; - - np = n; - assert(NULL == n->next); - - if (n->prev) { - m->last = n->prev; - m->next = MDOC_NEXT_SIBLING; - } else { - m->last = n->parent; - m->next = MDOC_NEXT_CHILD; - } - - mdoc_node_freelist(np); - + mdoc_node_delete(m, n); if (m->meta.title && m->meta.date && m->meta.os) m->flags |= MDOC_PBODY; - return(1); } @@ -958,11 +946,11 @@ post_display(POST_ARGS) static inline int -order_rs(int t) +order_rs(enum mdoct t) { int i; - for (i = 0; i < RSORD_MAX; i++) + for (i = 0; i < (int)RSORD_MAX; i++) if (rsord[i] == t) return(i);