=================================================================== RCS file: /cvs/mandoc/Attic/mdoc_action.c,v retrieving revision 1.2 retrieving revision 1.10 diff -u -p -r1.2 -r1.10 --- mandoc/Attic/mdoc_action.c 2009/03/31 13:50:19 1.2 +++ mandoc/Attic/mdoc_action.c 2009/06/12 09:18:00 1.10 @@ -1,20 +1,18 @@ -/* $Id: mdoc_action.c,v 1.2 2009/03/31 13:50:19 kristaps Exp $ */ +/* $Id: mdoc_action.c,v 1.10 2009/06/12 09:18:00 kristaps Exp $ */ /* - * Copyright (c) 2008, 2009 Kristaps Dzonsons + * Copyright (c) 2008, 2009 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 copyright notice and this permission notice appear in all - * copies. + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL - * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE - * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL - * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR - * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER - * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #include @@ -58,6 +56,7 @@ static int post_bl_tagwidth(POST_ARGS); static int post_dd(POST_ARGS); static int post_display(POST_ARGS); static int post_dt(POST_ARGS); +static int post_lk(POST_ARGS); static int post_nm(POST_ARGS); static int post_os(POST_ARGS); static int post_prol(POST_ARGS); @@ -181,7 +180,7 @@ const struct actions mdoc_actions[MDOC_MAX] = { { NULL, NULL }, /* Lb */ { NULL, NULL }, /* Ap */ { NULL, NULL }, /* Lp */ - { NULL, NULL }, /* Lk */ + { NULL, post_lk }, /* Lk */ { NULL, NULL }, /* Mt */ { NULL, NULL }, /* Brq */ { NULL, NULL }, /* Bro */ @@ -195,7 +194,6 @@ const struct actions mdoc_actions[MDOC_MAX] = { #ifdef __linux__ -extern size_t strlcpy(char *, const char *, size_t); extern size_t strlcat(char *, const char *, size_t); #endif @@ -213,9 +211,9 @@ mdoc_action_pre(struct mdoc *m, const struct mdoc_node break; } - if (NULL == mdoc_actions[m->last->tok].pre) + if (NULL == mdoc_actions[n->tok].pre) return(1); - return((*mdoc_actions[m->last->tok].pre)(m, n)); + return((*mdoc_actions[n->tok].pre)(m, n)); } @@ -344,8 +342,11 @@ post_nm(POST_ARGS) if (m->meta.name) return(1); + + buf[0] = 0; if ( ! concat(m, m->last->child, buf, sizeof(buf))) return(0); + if (NULL == (m->meta.name = strdup(buf))) return(verr(m, EMALLOC)); @@ -367,6 +368,8 @@ post_sh(POST_ARGS) if (MDOC_HEAD != m->last->type) return(1); + + buf[0] = 0; if ( ! concat(m, m->last->child, buf, sizeof(buf))) return(0); if (SEC_CUSTOM != (sec = mdoc_atosec(buf))) @@ -495,13 +498,15 @@ post_os(POST_ARGS) if (m->meta.os) free(m->meta.os); + + buf[0] = 0; if ( ! concat(m, m->last->child, buf, sizeof(buf))) return(0); if (0 == buf[0]) { if (-1 == uname(&utsname)) return(mdoc_err(m, "utsname")); - if (strlcpy(buf, utsname.sysname, 64) >= 64) + if (strlcat(buf, utsname.sysname, 64) >= 64) return(verr(m, ETOOLONG)); if (strlcat(buf, " ", 64) >= 64) return(verr(m, ETOOLONG)); @@ -609,7 +614,7 @@ post_bl_width(struct mdoc *m) if (0 == strcmp(p, "Ds")) width = 8; - else if (MDOC_MAX == (tok = mdoc_tokhash_find(m->htab, p))) + else if (MDOC_MAX == (tok = mdoc_hash_find(m->htab, p))) return(1); else if (0 == (width = mdoc_macro2len(tok))) return(vwarn(m, WNOWIDTH)); @@ -665,6 +670,27 @@ post_bl(POST_ARGS) static int +post_lk(POST_ARGS) +{ + struct mdoc_node *n; + + if (m->last->child) + return(1); + + n = m->last; + m->next = MDOC_NEXT_CHILD; + /* FIXME: this isn't documented anywhere! */ + if ( ! mdoc_word_alloc(m, m->last->line, + m->last->pos, "~")) + return(0); + + m->last = n; + m->next = MDOC_NEXT_SIBLING; + return(1); +} + + +static int post_ar(POST_ARGS) { struct mdoc_node *n; @@ -693,6 +719,7 @@ post_dd(POST_ARGS) { char buf[64]; + buf[0] = 0; if ( ! concat(m, m->last->child, buf, sizeof(buf))) return(0);