summaryrefslogtreecommitdiffstats
path: root/mdoc_term.c
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2009-10-18 19:03:36 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2009-10-18 19:03:36 +0000
commitb24acbb5f3ae16c8a4e9645043803117dda71323 (patch)
tree1a7428e9636ad90860f62860b0e85c725e8cb556 /mdoc_term.c
parentd6c7a4661f77e1989e0da0c6d16c039362c1d97d (diff)
downloadmandoc-b24acbb5f3ae16c8a4e9645043803117dda71323.tar.gz
Made sure devices and formats recognise that -man and -mdoc have different syntax for scaling widths: -mdoc assumes no unit means that the value is a string literal while -man instead uses the default vertical/horizontal scale.
Diffstat (limited to 'mdoc_term.c')
-rw-r--r--mdoc_term.c29
1 files changed, 13 insertions, 16 deletions
diff --git a/mdoc_term.c b/mdoc_term.c
index 21c0ef7c..5457836d 100644
--- a/mdoc_term.c
+++ b/mdoc_term.c
@@ -23,6 +23,7 @@
#include <stdlib.h>
#include <string.h>
+#include "out.h"
#include "term.h"
#include "mdoc.h"
#include "chars.h"
@@ -475,31 +476,27 @@ print_head(DECL_ARGS)
static size_t
arg2height(const struct mdoc_node *n)
{
- int r;
+ struct roffsu su;
assert(MDOC_TEXT == n->type);
assert(n->string);
+ if ( ! a2roffsu(n->string, &su, SCALE_VS))
+ SCALE_VS_INIT(&su, strlen(n->string));
- if ((r = a2height(n->string)) < 0)
- return(1);
-
- return((size_t)r);
+ return(term_vspan(&su));
}
static size_t
arg2width(const struct mdoc_argv *arg, int pos)
{
- int r;
+ struct roffsu su;
assert(arg->value[pos]);
- if ('\0' == arg->value[pos][0])
- return(2);
-
- if ((r = a2width(arg->value[pos])) >= 0)
- return((size_t)r);
+ if ( ! a2roffsu(arg->value[pos], &su, SCALE_MAX))
+ SCALE_HS_INIT(&su, strlen(arg->value[pos]) + 2);
- return(strlen(arg->value[pos]) + 2);
+ return(term_hspan(&su));
}
@@ -548,7 +545,7 @@ arg_listtype(const struct mdoc_node *n)
static size_t
arg2offs(const struct mdoc_argv *arg)
{
- int r;
+ struct roffsu su;
if ('\0' == arg->value[0][0])
return(0);
@@ -558,10 +555,10 @@ arg2offs(const struct mdoc_argv *arg)
return(INDENT + 1);
else if (0 == strcmp(arg->value[0], "indent-two"))
return((INDENT + 1) * 2);
- else if ((r = a2width(arg->value[0])) >= 0)
- return((size_t)r);
+ else if ( ! a2roffsu(arg->value[0], &su, SCALE_MAX))
+ SCALE_HS_INIT(&su, strlen(arg->value[0]));
- return(strlen(arg->value[0]));
+ return(term_hspan(&su));
}