diff options
author | 2017-06-08 12:54:58 +0000 | |
---|---|---|
committer | 2017-06-08 12:54:58 +0000 | |
commit | 789580a2a2366243d622766fdadd094931ca6596 (patch) | |
tree | 60a78614bcfb83b55ebd45464a5bc77e4c61c98c /mdoc_man.c | |
parent | 76a6887f123b221e7a8851c1b0d0008119492613 (diff) | |
download | mandoc-789580a2a2366243d622766fdadd094931ca6596.tar.gz mandoc-789580a2a2366243d622766fdadd094931ca6596.tar.zst mandoc-789580a2a2366243d622766fdadd094931ca6596.zip |
make the internal a2roffsu() interface more powerful by returning
a pointer to the end of the parsed data, making it easier to
parse subsequent bytes
Diffstat (limited to 'mdoc_man.c')
-rw-r--r-- | mdoc_man.c | 24 |
1 files changed, 15 insertions, 9 deletions
@@ -1,4 +1,4 @@ -/* $Id: mdoc_man.c,v 1.118 2017/06/06 15:01:04 schwarze Exp $ */ +/* $Id: mdoc_man.c,v 1.119 2017/06/08 12:54:58 schwarze Exp $ */ /* * Copyright (c) 2011-2017 Ingo Schwarze <schwarze@openbsd.org> * @@ -476,6 +476,7 @@ print_offs(const char *v, int keywords) { char buf[24]; struct roffsu su; + const char *end; int sz; print_line(".RS", MMAN_Bk_susp); @@ -487,8 +488,11 @@ print_offs(const char *v, int keywords) sz = 6; else if (keywords && !strcmp(v, "indent-two")) sz = 12; - else if (a2roffsu(v, &su, SCALE_EN) > 1) { - if (SCALE_EN == su.unit) + else { + end = a2roffsu(v, &su, SCALE_EN); + if (end == NULL || *end != '\0') + sz = man_strlen(v); + else if (SCALE_EN == su.unit) sz = su.scale; else { /* @@ -502,8 +506,7 @@ print_offs(const char *v, int keywords) outflags |= MMAN_nl; return; } - } else - sz = man_strlen(v); + } /* * We are inside an enclosing list. @@ -525,6 +528,7 @@ print_width(const struct mdoc_bl *bl, const struct roff_node *child) { char buf[24]; struct roffsu su; + const char *end; int numeric, remain, sz, chsz; numeric = 1; @@ -533,15 +537,17 @@ print_width(const struct mdoc_bl *bl, const struct roff_node *child) /* Convert the width into a number (of characters). */ if (bl->width == NULL) sz = (bl->type == LIST_hang) ? 6 : 0; - else if (a2roffsu(bl->width, &su, SCALE_MAX) > 1) { - if (SCALE_EN == su.unit) + else { + end = a2roffsu(bl->width, &su, SCALE_MAX); + if (end == NULL || *end != '\0') + sz = man_strlen(bl->width); + else if (SCALE_EN == su.unit) sz = su.scale; else { sz = 0; numeric = 0; } - } else - sz = man_strlen(bl->width); + } /* XXX Rough estimation, might have multiple parts. */ if (bl->type == LIST_enum) |