=================================================================== RCS file: /cvs/mandoc/mdoc_man.c,v retrieving revision 1.94 retrieving revision 1.98 diff -u -p -r1.94 -r1.98 --- mandoc/mdoc_man.c 2015/10/06 18:32:19 1.94 +++ mandoc/mdoc_man.c 2017/01/10 13:47:00 1.98 @@ -1,6 +1,6 @@ -/* $Id: mdoc_man.c,v 1.94 2015/10/06 18:32:19 schwarze Exp $ */ +/* $Id: mdoc_man.c,v 1.98 2017/01/10 13:47:00 schwarze Exp $ */ /* - * Copyright (c) 2011-2015 Ingo Schwarze + * Copyright (c) 2011-2017 Ingo Schwarze * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -575,17 +575,20 @@ print_node(DECL_ARGS) struct roff_node *sub; int cond, do_sub; + if (n->flags & NODE_NOPRT) + return; + /* * Break the line if we were parsed subsequent the current node. * This makes the page structure be more consistent. */ - if (MMAN_spc & outflags && MDOC_LINE & n->flags) + if (MMAN_spc & outflags && NODE_LINE & n->flags) outflags |= MMAN_nl; act = NULL; cond = 0; do_sub = 1; - n->flags &= ~MDOC_ENDED; + n->flags &= ~NODE_ENDED; if (n->type == ROFFT_TEXT) { /* @@ -598,10 +601,10 @@ print_node(DECL_ARGS) printf("\\&"); outflags &= ~MMAN_spc; } - if (outflags & MMAN_Sm && ! (n->flags & MDOC_DELIMC)) + if (outflags & MMAN_Sm && ! (n->flags & NODE_DELIMC)) outflags |= MMAN_spc_force; print_word(n->string); - if (outflags & MMAN_Sm && ! (n->flags & MDOC_DELIMO)) + if (outflags & MMAN_Sm && ! (n->flags & NODE_DELIMO)) outflags |= MMAN_spc; } else { /* @@ -610,7 +613,8 @@ print_node(DECL_ARGS) */ act = manacts + n->tok; cond = act->cond == NULL || (*act->cond)(meta, n); - if (cond && act->pre && (n->end == ENDBODY_NOT || n->nchild)) + if (cond && act->pre != NULL && + (n->end == ENDBODY_NOT || n->child != NULL)) do_sub = (*act->pre)(meta, n); } @@ -626,14 +630,14 @@ print_node(DECL_ARGS) /* * Lastly, conditionally run the post-node handler. */ - if (MDOC_ENDED & n->flags) + if (NODE_ENDED & n->flags) return; if (cond && act->post) (*act->post)(meta, n); if (ENDBODY_NOT != n->end) - n->body->flags |= MDOC_ENDED; + n->body->flags |= NODE_ENDED; if (ENDBODY_NOSPACE == n->end) outflags &= ~(MMAN_spc | MMAN_nl); @@ -681,30 +685,29 @@ post_enc(DECL_ARGS) static int pre_ex(DECL_ARGS) { - int nchild; + struct roff_node *nch; outflags |= MMAN_br | MMAN_nl; print_word("The"); - nchild = n->nchild; - for (n = n->child; n; n = n->next) { + for (nch = n->child; nch != NULL; nch = nch->next) { font_push('B'); - print_word(n->string); + print_word(nch->string); font_pop(); - if (n->next == NULL) + if (nch->next == NULL) continue; - if (nchild > 2) { + if (nch->prev != NULL || nch->next->next != NULL) { outflags &= ~MMAN_spc; print_word(","); } - if (n->next->next == NULL) + if (nch->next->next == NULL) print_word("and"); } - if (nchild > 1) + if (n->child != NULL && n->child->next != NULL) print_word("utilities exit\\~0"); else print_word("utility exits\\~0"); @@ -805,7 +808,7 @@ static void pre_syn(const struct roff_node *n) { - if (NULL == n->prev || ! (MDOC_SYNPRETTY & n->flags)) + if (NULL == n->prev || ! (NODE_SYNPRETTY & n->flags)) return; if (n->prev->tok == n->tok && @@ -818,13 +821,9 @@ pre_syn(const struct roff_node *n) switch (n->prev->tok) { case MDOC_Fd: - /* FALLTHROUGH */ case MDOC_Fn: - /* FALLTHROUGH */ case MDOC_Fo: - /* FALLTHROUGH */ case MDOC_In: - /* FALLTHROUGH */ case MDOC_Vt: outflags |= MMAN_sp; break; @@ -877,7 +876,7 @@ static int pre_aq(DECL_ARGS) { - print_word(n->nchild == 1 && + print_word(n->child != NULL && n->child->next == NULL && n->child->tok == MDOC_Mt ? "<" : "\\(la"); outflags &= ~MMAN_spc; return 1; @@ -888,7 +887,7 @@ post_aq(DECL_ARGS) { outflags &= ~(MMAN_spc | MMAN_nl); - print_word(n->nchild == 1 && + print_word(n->child != NULL && n->child->next == NULL && n->child->tok == MDOC_Mt ? ">" : "\\(ra"); } @@ -1004,7 +1003,7 @@ pre_bl(DECL_ARGS) return 1; } - if (n->nchild) { + if (n->child != NULL) { print_line(".TS", MMAN_nl); for (icol = 0; icol < n->norm->Bl.ncols; icol++) print_word("l"); @@ -1020,7 +1019,7 @@ post_bl(DECL_ARGS) switch (n->norm->Bl.type) { case LIST_column: - if (n->nchild) + if (n->child != NULL) print_line(".TE", 0); break; case LIST_enum: @@ -1177,7 +1176,7 @@ pre_fa(DECL_ARGS) while (NULL != n) { font_push('I'); - if (am_Fa || MDOC_SYNPRETTY & n->flags) + if (am_Fa || NODE_SYNPRETTY & n->flags) outflags |= MMAN_nbrword; print_node(meta, n); font_pop(); @@ -1218,7 +1217,7 @@ pre_fl(DECL_ARGS) font_push('B'); print_word("\\-"); - if (n->nchild) + if (n->child != NULL) outflags &= ~MMAN_spc; return 1; } @@ -1228,10 +1227,10 @@ post_fl(DECL_ARGS) { font_pop(); - if ( ! (n->nchild || + if (!(n->child != NULL || n->next == NULL || n->next->type == ROFFT_TEXT || - n->next->flags & MDOC_LINE)) + n->next->flags & NODE_LINE)) outflags &= ~MMAN_spc; } @@ -1245,7 +1244,7 @@ pre_fn(DECL_ARGS) if (NULL == n) return 0; - if (MDOC_SYNPRETTY & n->flags) + if (NODE_SYNPRETTY & n->flags) print_block(".HP 4n", MMAN_nl); font_push('B'); @@ -1266,7 +1265,7 @@ post_fn(DECL_ARGS) { print_word(")"); - if (MDOC_SYNPRETTY & n->flags) { + if (NODE_SYNPRETTY & n->flags) { print_word(";"); outflags |= MMAN_PP; } @@ -1283,7 +1282,7 @@ pre_fo(DECL_ARGS) case ROFFT_HEAD: if (n->child == NULL) return 0; - if (MDOC_SYNPRETTY & n->flags) + if (NODE_SYNPRETTY & n->flags) print_block(".HP 4n", MMAN_nl); font_push('B'); break; @@ -1328,7 +1327,7 @@ static int pre_in(DECL_ARGS) { - if (MDOC_SYNPRETTY & n->flags) { + if (NODE_SYNPRETTY & n->flags) { pre_syn(n); font_push('B'); print_word("#include <"); @@ -1345,7 +1344,7 @@ static void post_in(DECL_ARGS) { - if (MDOC_SYNPRETTY & n->flags) { + if (NODE_SYNPRETTY & n->flags) { outflags &= ~MMAN_spc; print_word(">"); font_pop(); @@ -1375,9 +1374,7 @@ pre_it(DECL_ARGS) case LIST_item: return 0; case LIST_inset: - /* FALLTHROUGH */ case LIST_diag: - /* FALLTHROUGH */ case LIST_ohang: if (bln->norm->Bl.type == LIST_diag) print_line(".B \"", 0); @@ -1386,9 +1383,7 @@ pre_it(DECL_ARGS) outflags &= ~MMAN_spc; return 1; case LIST_bullet: - /* FALLTHROUGH */ case LIST_dash: - /* FALLTHROUGH */ case LIST_hyphen: print_width(&bln->norm->Bl, NULL); TPremain = 0; @@ -1478,15 +1473,10 @@ post_it(DECL_ARGS) case ROFFT_BODY: switch (bln->norm->Bl.type) { case LIST_bullet: - /* FALLTHROUGH */ case LIST_dash: - /* FALLTHROUGH */ case LIST_hyphen: - /* FALLTHROUGH */ case LIST_enum: - /* FALLTHROUGH */ case LIST_hang: - /* FALLTHROUGH */ case LIST_tag: assert(Bl_stack_len); Bl_stack[--Bl_stack_len] = 0; @@ -1600,7 +1590,6 @@ post_nm(DECL_ARGS) outflags &= ~MMAN_Bk; break; case ROFFT_HEAD: - /* FALLTHROUGH */ case ROFFT_ELEM: if (n->child != NULL || meta->name != NULL) font_pop(); @@ -1630,7 +1619,7 @@ static void post_pf(DECL_ARGS) { - if ( ! (n->next == NULL || n->next->flags & MDOC_LINE)) + if ( ! (n->next == NULL || n->next->flags & NODE_LINE)) outflags &= ~MMAN_spc; } @@ -1659,34 +1648,33 @@ pre_rs(DECL_ARGS) static int pre_rv(DECL_ARGS) { - int nchild; + struct roff_node *nch; outflags |= MMAN_br | MMAN_nl; - nchild = n->nchild; - if (nchild > 0) { + if (n->child != NULL) { print_word("The"); - for (n = n->child; n; n = n->next) { + for (nch = n->child; nch != NULL; nch = nch->next) { font_push('B'); - print_word(n->string); + print_word(nch->string); font_pop(); outflags &= ~MMAN_spc; print_word("()"); - if (n->next == NULL) + if (nch->next == NULL) continue; - if (nchild > 2) { + if (nch->prev != NULL || nch->next->next != NULL) { outflags &= ~MMAN_spc; print_word(","); } - if (n->next->next == NULL) + if (nch->next->next == NULL) print_word("and"); } - if (nchild > 1) + if (n->child != NULL && n->child->next != NULL) print_word("functions return"); else print_word("function returns"); @@ -1763,7 +1751,7 @@ static int pre_vt(DECL_ARGS) { - if (MDOC_SYNPRETTY & n->flags) { + if (NODE_SYNPRETTY & n->flags) { switch (n->type) { case ROFFT_BLOCK: pre_syn(n); @@ -1782,7 +1770,7 @@ static void post_vt(DECL_ARGS) { - if (n->flags & MDOC_SYNPRETTY && n->type != ROFFT_BODY) + if (n->flags & NODE_SYNPRETTY && n->type != ROFFT_BODY) return; font_pop(); }