diff options
author | Ingo Schwarze <schwarze@openbsd.org> | 2014-12-23 09:31:46 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@openbsd.org> | 2014-12-23 09:31:46 +0000 |
commit | b746353a05b8aa9d139a3058dfc846eb7c978997 (patch) | |
tree | 148663f150cd664bbc197e0cecd0dbb1c442a185 /mdoc_term.c | |
parent | 5d42210e3b9f8220e4026cbeb581e5953e7bd23d (diff) | |
download | mandoc-b746353a05b8aa9d139a3058dfc846eb7c978997.tar.gz mandoc-b746353a05b8aa9d139a3058dfc846eb7c978997.tar.zst mandoc-b746353a05b8aa9d139a3058dfc846eb7c978997.zip |
some scaling unit fixes:
- .sp with an invalid argument is .sp 1v, not .sp 0v
- in man(1), trailing garbage doesn't make scaling units invalid
Diffstat (limited to 'mdoc_term.c')
-rw-r--r-- | mdoc_term.c | 27 |
1 files changed, 9 insertions, 18 deletions
diff --git a/mdoc_term.c b/mdoc_term.c index 7f57aed3..f6f3eb5e 100644 --- a/mdoc_term.c +++ b/mdoc_term.c @@ -1,4 +1,4 @@ -/* $Id: mdoc_term.c,v 1.299 2014/12/02 10:08:06 schwarze Exp $ */ +/* $Id: mdoc_term.c,v 1.300 2014/12/23 09:31:46 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2010, 2012, 2013, 2014 Ingo Schwarze <schwarze@openbsd.org> @@ -50,7 +50,6 @@ struct termact { }; static size_t a2width(const struct termp *, const char *); -static size_t a2height(const struct termp *, const char *); static void print_bvspace(struct termp *, const struct mdoc_node *, @@ -527,25 +526,11 @@ print_mdoc_head(struct termp *p, const void *arg) } static size_t -a2height(const struct termp *p, const char *v) -{ - struct roffsu su; - - - assert(v); - if ( ! a2roffsu(v, &su, SCALE_VS)) - SCALE_VS_INIT(&su, atoi(v)); - - return(term_vspan(p, &su)); -} - -static size_t a2width(const struct termp *p, const char *v) { struct roffsu su; - assert(v); - if ( ! a2roffsu(v, &su, SCALE_MAX)) { + if (a2roffsu(v, &su, SCALE_MAX) < 2) { SCALE_HS_INIT(&su, term_strlen(p, v)); su.scale /= term_strlen(p, "0"); } @@ -1816,11 +1801,17 @@ termp_in_post(DECL_ARGS) static int termp_sp_pre(DECL_ARGS) { + struct roffsu su; size_t i, len; switch (n->tok) { case MDOC_sp: - len = n->child ? a2height(p, n->child->string) : 1; + if (n->child) { + if ( ! a2roffsu(n->child->string, &su, SCALE_VS)) + su.scale = 1.0; + len = term_vspan(p, &su); + } else + len = 1; break; case MDOC_br: len = 0; |