From b746353a05b8aa9d139a3058dfc846eb7c978997 Mon Sep 17 00:00:00 2001 From: Ingo Schwarze Date: Tue, 23 Dec 2014 09:31:46 +0000 Subject: 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 --- mdoc_term.c | 27 +++++++++------------------ 1 file changed, 9 insertions(+), 18 deletions(-) (limited to 'mdoc_term.c') 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 * Copyright (c) 2010, 2012, 2013, 2014 Ingo Schwarze @@ -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 *, @@ -526,26 +525,12 @@ print_mdoc_head(struct termp *p, const void *arg) free(volume); } -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; -- cgit v1.2.3