diff options
author | 2015-02-01 23:10:15 +0000 | |
---|---|---|
committer | 2015-02-01 23:10:15 +0000 | |
commit | 03ed6ec9385fcd95bb8af5d6753c2358cdf25533 (patch) | |
tree | d1a0b6bd50e426f2a1d084459e604b49f1587ef2 /usr.bin/mandoc/mdoc_html.c | |
parent | free(NULL) works, so stop checking for non-zero length allocation (diff) | |
download | wireguard-openbsd-03ed6ec9385fcd95bb8af5d6753c2358cdf25533.tar.xz wireguard-openbsd-03ed6ec9385fcd95bb8af5d6753c2358cdf25533.zip |
fix .Eo/.Ec spacing
Diffstat (limited to 'usr.bin/mandoc/mdoc_html.c')
-rw-r--r-- | usr.bin/mandoc/mdoc_html.c | 66 |
1 files changed, 52 insertions, 14 deletions
diff --git a/usr.bin/mandoc/mdoc_html.c b/usr.bin/mandoc/mdoc_html.c index e2ead655aa8..5cf4487c581 100644 --- a/usr.bin/mandoc/mdoc_html.c +++ b/usr.bin/mandoc/mdoc_html.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mdoc_html.c,v 1.95 2015/01/30 22:04:15 schwarze Exp $ */ +/* $OpenBSD: mdoc_html.c,v 1.96 2015/02/01 23:10:15 schwarze Exp $ */ /* * Copyright (c) 2008-2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2014, 2015 Ingo Schwarze <schwarze@openbsd.org> @@ -79,6 +79,8 @@ static int mdoc_fl_pre(MDOC_ARGS); static int mdoc_fn_pre(MDOC_ARGS); static int mdoc_ft_pre(MDOC_ARGS); static int mdoc_em_pre(MDOC_ARGS); +static void mdoc_eo_post(MDOC_ARGS); +static int mdoc_eo_pre(MDOC_ARGS); static int mdoc_er_pre(MDOC_ARGS); static int mdoc_ev_pre(MDOC_ARGS); static int mdoc_ex_pre(MDOC_ARGS); @@ -187,7 +189,7 @@ static const struct htmlmdoc mdocs[MDOC_MAX] = { {NULL, NULL}, /* Ec */ /* FIXME: no space */ {NULL, NULL}, /* Ef */ {mdoc_em_pre, NULL}, /* Em */ - {mdoc_quote_pre, mdoc_quote_post}, /* Eo */ + {mdoc_eo_pre, mdoc_eo_post}, /* Eo */ {mdoc_xx_pre, NULL}, /* Fx */ {mdoc_ms_pre, NULL}, /* Ms */ {mdoc_no_pre, NULL}, /* No */ @@ -2110,8 +2112,6 @@ mdoc_quote_pre(MDOC_ARGS) return(1); print_text(h, n->norm->Es->child->string); break; - case MDOC_Eo: - break; case MDOC_Do: /* FALLTHROUGH */ case MDOC_Dq: @@ -2153,9 +2153,7 @@ mdoc_quote_post(MDOC_ARGS) if (n->type != MDOC_BODY && n->type != MDOC_ELEM) return; - if ( ! (n->tok == MDOC_En || - (n->tok == MDOC_Eo && n->end == ENDBODY_SPACE))) - h->flags |= HTML_NOSPACE; + h->flags |= HTML_NOSPACE; switch (n->tok) { case MDOC_Ao: @@ -2179,14 +2177,12 @@ mdoc_quote_post(MDOC_ARGS) print_text(h, "\\(rB"); break; case MDOC_En: - if (NULL != n->norm->Es && - NULL != n->norm->Es->child && - NULL != n->norm->Es->child->next) { - h->flags |= HTML_NOSPACE; + if (n->norm->Es == NULL || + n->norm->Es->child == NULL || + n->norm->Es->child->next == NULL) + h->flags &= ~HTML_NOSPACE; + else print_text(h, n->norm->Es->child->next->string); - } - break; - case MDOC_Eo: break; case MDOC_Qo: /* FALLTHROUGH */ @@ -2214,3 +2210,45 @@ mdoc_quote_post(MDOC_ARGS) /* NOTREACHED */ } } + +static int +mdoc_eo_pre(MDOC_ARGS) +{ + + if (n->type != MDOC_BODY) + return(1); + + if (n->end == ENDBODY_NOT && + n->parent->head->child == NULL && + n->child != NULL && + n->child->end != ENDBODY_NOT) + print_text(h, "\\&"); + else if (n->end != ENDBODY_NOT ? n->child != NULL : + n->parent->head->child != NULL && + (n->parent->body->child != NULL || + n->parent->tail->child != NULL)) + h->flags |= HTML_NOSPACE; + return(1); +} + +static void +mdoc_eo_post(MDOC_ARGS) +{ + int body, tail; + + if (n->type != MDOC_BODY) + return; + + if (n->end != ENDBODY_NOT) { + h->flags &= ~HTML_NOSPACE; + return; + } + + body = n->child != NULL || n->parent->head->child != NULL; + tail = n->parent->tail != NULL && n->parent->tail->child != NULL; + + if (body && tail) + h->flags |= HTML_NOSPACE; + else if ( ! tail) + h->flags &= ~HTML_NOSPACE; +} |