=================================================================== RCS file: /cvs/mandoc/mdoc_man.c,v retrieving revision 1.81 retrieving revision 1.85 diff -u -p -r1.81 -r1.85 --- mandoc/mdoc_man.c 2014/12/24 23:32:42 1.81 +++ mandoc/mdoc_man.c 2015/02/06 03:38:45 1.85 @@ -1,6 +1,6 @@ -/* $Id: mdoc_man.c,v 1.81 2014/12/24 23:32:42 schwarze Exp $ */ +/* $Id: mdoc_man.c,v 1.85 2015/02/06 03:38:45 schwarze Exp $ */ /* - * Copyright (c) 2011, 2012, 2013, 2014 Ingo Schwarze + * Copyright (c) 2011-2015 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 @@ -879,8 +879,8 @@ static int pre_aq(DECL_ARGS) { - print_word(n->parent->prev != NULL && - n->parent->prev->tok == MDOC_An ? "<" : "\\(la"); + print_word(n->nchild == 1 && + n->child->tok == MDOC_Mt ? "<" : "\\(la"); outflags &= ~MMAN_spc; return(1); } @@ -890,8 +890,8 @@ post_aq(DECL_ARGS) { outflags &= ~(MMAN_spc | MMAN_nl); - print_word(n->parent->prev != NULL && - n->parent->prev->tok == MDOC_An ? ">" : "\\(ra"); + print_word(n->nchild == 1 && + n->child->tok == MDOC_Mt ? ">" : "\\(ra"); } static int @@ -1006,10 +1006,12 @@ pre_bl(DECL_ARGS) return(1); } - print_line(".TS", MMAN_nl); - for (icol = 0; icol < n->norm->Bl.ncols; icol++) - print_word("l"); - print_word("."); + if (n->nchild) { + print_line(".TS", MMAN_nl); + for (icol = 0; icol < n->norm->Bl.ncols; icol++) + print_word("l"); + print_word("."); + } outflags |= MMAN_nl; return(1); } @@ -1020,7 +1022,8 @@ post_bl(DECL_ARGS) switch (n->norm->Bl.type) { case LIST_column: - print_line(".TE", 0); + if (n->nchild) + print_line(".TE", 0); break; case LIST_enum: n->norm->Bl.count = 0; @@ -1131,16 +1134,38 @@ static int pre_eo(DECL_ARGS) { - outflags &= ~(MMAN_spc | MMAN_nl); + if (n->end == ENDBODY_NOT && + n->parent->head->child == NULL && + n->child != NULL && + n->child->end != ENDBODY_NOT) + print_word("\\&"); + else if (n->end != ENDBODY_NOT ? n->child != NULL : + n->parent->head->child != NULL && + (n->parent->body->child != NULL || + n->parent->tail->child != NULL)) + outflags &= ~(MMAN_spc | MMAN_nl); return(1); } static void post_eo(DECL_ARGS) { + int body, tail; - if (n->end != ENDBODY_SPACE) + if (n->end != ENDBODY_NOT) { + outflags |= MMAN_spc; + return; + } + + body = n->child != NULL || n->parent->head->child != NULL; + tail = n->parent->tail != NULL && n->parent->tail->child != NULL; + + if (body && tail) outflags &= ~MMAN_spc; + else if ( ! (body || tail)) + print_word("\\&"); + else if ( ! tail) + outflags |= MMAN_spc; } static int @@ -1259,12 +1284,14 @@ pre_fo(DECL_ARGS) pre_syn(n); break; case MDOC_HEAD: + if (n->child == NULL) + return(0); if (MDOC_SYNPRETTY & n->flags) print_block(".HP 4n", MMAN_nl); font_push('B'); break; case MDOC_BODY: - outflags &= ~MMAN_spc; + outflags &= ~(MMAN_spc | MMAN_nl); print_word("("); outflags &= ~MMAN_spc; break; @@ -1280,7 +1307,8 @@ post_fo(DECL_ARGS) switch (n->type) { case MDOC_HEAD: - font_pop(); + if (n->child != NULL) + font_pop(); break; case MDOC_BODY: post_fn(meta, n);