diff options
-rw-r--r-- | mdoc_term.c | 43 | ||||
-rw-r--r-- | term.c | 2 |
2 files changed, 28 insertions, 17 deletions
diff --git a/mdoc_term.c b/mdoc_term.c index 8e37cbc1..a23bb33a 100644 --- a/mdoc_term.c +++ b/mdoc_term.c @@ -517,28 +517,26 @@ print_head(struct termp *p, const struct mdoc_meta *meta) static size_t arg_width(const struct mdoc_argv *arg, int pos) { - size_t v; int i, len; + const char *p; assert(pos < (int)arg->sz && pos >= 0); assert(arg->value[pos]); - if (0 == (len = (int)strlen(arg->value[pos]))) + p = arg->value[pos]; + + if (0 == (len = (int)strlen(p))) return(0); for (i = 0; i < len - 1; i++) - if ( ! isdigit((u_char)arg->value[pos][i])) + if ( ! isdigit((u_char)p[i])) break; - if (i == len - 1) { - if ('n' == arg->value[pos][len - 1] || - 'm' == arg->value[pos][len - 1]) { - v = (size_t)atoi(arg->value[pos]); - return(v + 2); - } + if (i == len - 1) + if ('n' == p[len - 1] || 'm' == p[len - 1]) + return((size_t)atoi(p) + 2); - } - return(strlen(arg->value[pos]) + 2); + return((size_t)len + 2); } @@ -586,18 +584,31 @@ arg_listtype(const struct mdoc_node *n) static size_t arg_offset(const struct mdoc_argv *arg) { + int len, i; + const char *p; assert(*arg->value); - if (0 == strcmp(*arg->value, "left")) + p = *arg->value; + + if (0 == strcmp(p, "left")) return(0); - if (0 == strcmp(*arg->value, "indent")) + if (0 == strcmp(p, "indent")) return(INDENT + 1); - if (0 == strcmp(*arg->value, "indent-two")) + if (0 == strcmp(p, "indent-two")) return((INDENT + 1) * 2); - /* FIXME: needs to support field-widths (10n, etc.). */ + if (0 == (len = (int)strlen(p))) + return(0); + + for (i = 0; i < len - 1; i++) + if ( ! isdigit((u_char)p[i])) + break; + + if (i == len - 1) + if ('n' == p[len - 1] || 'm' == p[len - 1]) + return((size_t)atoi(p)); - return(strlen(*arg->value)); + return((size_t)len); } @@ -315,7 +315,7 @@ term_flushln(struct termp *p) putchar(' '); } if (TERMP_HANG & p->flags) - sv = vis - maxvis; + sv = (int)(vis - maxvis); p->col = 0; return; } |