=================================================================== RCS file: /cvs/mandoc/mdoc_term.c,v retrieving revision 1.2 retrieving revision 1.8 diff -u -p -r1.2 -r1.8 --- mandoc/mdoc_term.c 2009/03/26 14:44:41 1.2 +++ mandoc/mdoc_term.c 2009/06/11 07:26:35 1.8 @@ -1,20 +1,18 @@ -/* $Id: mdoc_term.c,v 1.2 2009/03/26 14:44:41 kristaps Exp $ */ +/* $Id: mdoc_term.c,v 1.8 2009/06/11 07:26:35 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 @@ -321,11 +319,11 @@ static int arg_listtype(const struct mdoc_node *); static int fmt_block_vspace(struct termp *, const struct mdoc_node *, const struct mdoc_node *); -static int print_node(DECL_ARGS); -static int print_head(struct termp *, +static void print_node(DECL_ARGS); +static void print_head(struct termp *, const struct mdoc_meta *); -static int print_body(DECL_ARGS); -static int print_foot(struct termp *, +static void print_body(DECL_ARGS); +static void print_foot(struct termp *, const struct mdoc_meta *); static void sanity(const struct mdoc_node *); @@ -334,27 +332,25 @@ int mdoc_run(struct termp *p, const struct mdoc *m) { - if ( ! print_head(p, mdoc_meta(m))) - return(0); - if ( ! print_body(p, NULL, mdoc_meta(m), mdoc_node(m))) - return(0); - return(print_foot(p, mdoc_meta(m))); + print_head(p, mdoc_meta(m)); + print_body(p, NULL, mdoc_meta(m), mdoc_node(m)); + print_foot(p, mdoc_meta(m)); + return(1); } -static int +static void print_body(DECL_ARGS) { - if ( ! print_node(p, pair, meta, node)) - return(0); + print_node(p, pair, meta, node); if ( ! node->next) - return(1); - return(print_body(p, pair, meta, node->next)); + return; + print_body(p, pair, meta, node->next); } -static int +static void print_node(DECL_ARGS) { int dochild; @@ -396,12 +392,10 @@ print_node(DECL_ARGS) if (MDOC_TEXT != node->type) if (termacts[node->tok].post) (*termacts[node->tok].post)(p, &npair, meta, node); - - return(1); } -static int +static void print_foot(struct termp *p, const struct mdoc_meta *meta) { struct tm *tm; @@ -449,12 +443,10 @@ print_foot(struct termp *p, const struct mdoc_meta *me free(buf); free(os); - - return(1); } -static int +static void print_head(struct termp *p, const struct mdoc_meta *meta) { char *buf, *title; @@ -493,7 +485,7 @@ print_head(struct termp *p, const struct mdoc_meta *me meta->title, meta->msec); p->offset = 0; - p->rmargin = (p->maxrmargin - strlen(buf)) / 2; + p->rmargin = (p->maxrmargin - strlen(buf) + 1) / 2; p->flags |= TERMP_NOBREAK | TERMP_NOSPACE; term_word(p, title); @@ -520,8 +512,6 @@ print_head(struct termp *p, const struct mdoc_meta *me free(title); free(buf); - - return(1); } @@ -1435,7 +1425,7 @@ static int termp_d1_pre(DECL_ARGS) { - if (MDOC_BODY != node->type) + if (MDOC_BLOCK != node->type) return(1); term_newln(p); p->offset += (pair->offset = INDENT); @@ -1448,7 +1438,7 @@ static void termp_d1_post(DECL_ARGS) { - if (MDOC_BODY != node->type) + if (MDOC_BLOCK != node->type) return; term_newln(p); p->offset -= pair->offset; @@ -1850,7 +1840,7 @@ termp_ss_pre(DECL_ARGS) break; case (MDOC_HEAD): TERMPAIR_SETFLAG(p, pair, ttypes[TTYPE_SSECTION]); - p->offset = INDENT / 2; + p->offset = HALFINDENT; break; default: break;