diff options
author | Ingo Schwarze <schwarze@cvs.openbsd.org> | 2014-03-30 21:28:00 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@cvs.openbsd.org> | 2014-03-30 21:28:00 +0000 |
commit | 4eb2d12b27096ee78c5daf9473a287c1b1ea15f7 (patch) | |
tree | a552e84f6cc04d44eaccee565996dd4a38b28e71 /usr.bin/mandoc | |
parent | f3916529de253ca8e432b5b96de2e02d6e198e2e (diff) |
Support relative arguments to .ll (increase or decrease line length).
Diffstat (limited to 'usr.bin/mandoc')
-rw-r--r-- | usr.bin/mandoc/man_term.c | 4 | ||||
-rw-r--r-- | usr.bin/mandoc/mdoc_term.c | 4 | ||||
-rw-r--r-- | usr.bin/mandoc/term.c | 32 | ||||
-rw-r--r-- | usr.bin/mandoc/term.h | 6 | ||||
-rw-r--r-- | usr.bin/mandoc/term_ascii.c | 20 | ||||
-rw-r--r-- | usr.bin/mandoc/term_ps.c | 13 |
6 files changed, 59 insertions, 20 deletions
diff --git a/usr.bin/mandoc/man_term.c b/usr.bin/mandoc/man_term.c index 5849fecd7eb..1028eabd5c7 100644 --- a/usr.bin/mandoc/man_term.c +++ b/usr.bin/mandoc/man_term.c @@ -1,4 +1,4 @@ -/* $Id: man_term.c,v 1.97 2014/03/30 19:47:32 schwarze Exp $ */ +/* $Id: man_term.c,v 1.98 2014/03/30 21:27:59 schwarze Exp $ */ /* * Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2010-2014 Ingo Schwarze <schwarze@openbsd.org> @@ -238,7 +238,7 @@ static int pre_ll(DECL_ARGS) { - (*p->setwidth)(p, n->nchild ? a2width(p, n->child->string) : 0); + term_setwidth(p, n->nchild ? n->child->string : NULL); return(0); } diff --git a/usr.bin/mandoc/mdoc_term.c b/usr.bin/mandoc/mdoc_term.c index 9c72d0762a2..de7080cc629 100644 --- a/usr.bin/mandoc/mdoc_term.c +++ b/usr.bin/mandoc/mdoc_term.c @@ -1,4 +1,4 @@ -/* $Id: mdoc_term.c,v 1.162 2014/03/30 19:47:32 schwarze Exp $ */ +/* $Id: mdoc_term.c,v 1.163 2014/03/30 21:27:59 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2010, 2012, 2013, 2014 Ingo Schwarze <schwarze@openbsd.org> @@ -618,7 +618,7 @@ static int termp_ll_pre(DECL_ARGS) { - (*p->setwidth)(p, n->nchild ? a2width(p, n->child->string) : 0); + term_setwidth(p, n->nchild ? n->child->string : NULL); return(0); } diff --git a/usr.bin/mandoc/term.c b/usr.bin/mandoc/term.c index 3da0c8fe710..f1809195e9d 100644 --- a/usr.bin/mandoc/term.c +++ b/usr.bin/mandoc/term.c @@ -1,4 +1,4 @@ -/* $Id: term.c,v 1.79 2014/03/21 22:17:01 schwarze Exp $ */ +/* $Id: term.c,v 1.80 2014/03/30 21:27:59 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2010-2014 Ingo Schwarze <schwarze@openbsd.org> @@ -619,6 +619,36 @@ encode(struct termp *p, const char *word, size_t sz) } } +void +term_setwidth(struct termp *p, const char *wstr) +{ + struct roffsu su; + size_t width; + int iop; + + if (NULL != wstr) { + switch (*wstr) { + case ('+'): + iop = 1; + wstr++; + break; + case ('-'): + iop = -1; + wstr++; + break; + default: + iop = 0; + break; + } + if ( ! a2roffsu(wstr, &su, SCALE_MAX)) { + wstr = NULL; + iop = 0; + } + } + width = (NULL != wstr) ? term_hspan(p, &su) : 0; + (*p->setwidth)(p, iop, width); +} + size_t term_len(const struct termp *p, size_t sz) { diff --git a/usr.bin/mandoc/term.h b/usr.bin/mandoc/term.h index f57a201fcf4..6a63dd084e7 100644 --- a/usr.bin/mandoc/term.h +++ b/usr.bin/mandoc/term.h @@ -1,4 +1,4 @@ -/* $Id: term.h,v 1.42 2014/03/30 19:47:32 schwarze Exp $ */ +/* $Id: term.h,v 1.43 2014/03/30 21:27:59 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2011, 2012, 2013, 2014 Ingo Schwarze <schwarze@openbsd.org> @@ -95,7 +95,7 @@ struct termp { void (*end)(struct termp *); void (*endline)(struct termp *); void (*advance)(struct termp *, size_t); - void (*setwidth)(struct termp *, size_t); + void (*setwidth)(struct termp *, int, size_t); size_t (*width)(const struct termp *, int); double (*hspan)(const struct termp *, const struct roffsu *); @@ -114,7 +114,7 @@ void term_begin(struct termp *, term_margin, term_margin, const void *); void term_end(struct termp *); -void term_setwidth(struct termp *, size_t); +void term_setwidth(struct termp *, const char *); size_t term_hspan(const struct termp *, const struct roffsu *); size_t term_vspan(const struct termp *, diff --git a/usr.bin/mandoc/term_ascii.c b/usr.bin/mandoc/term_ascii.c index dc08112d7fb..7deeb630cb6 100644 --- a/usr.bin/mandoc/term_ascii.c +++ b/usr.bin/mandoc/term_ascii.c @@ -1,4 +1,4 @@ -/* $Id: term_ascii.c,v 1.12 2014/03/30 19:47:32 schwarze Exp $ */ +/* $Id: term_ascii.c,v 1.13 2014/03/30 21:27:59 schwarze Exp $ */ /* * Copyright (c) 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2014 Ingo Schwarze <schwarze@openbsd.org> @@ -39,7 +39,7 @@ static void ascii_begin(struct termp *); static void ascii_end(struct termp *); static void ascii_endline(struct termp *); static void ascii_letter(struct termp *, int); -static void ascii_setwidth(struct termp *, size_t); +static void ascii_setwidth(struct termp *, int, size_t); static void locale_advance(struct termp *, size_t); static void locale_endline(struct termp *); @@ -138,14 +138,18 @@ locale_alloc(char *outopts) } static void -ascii_setwidth(struct termp *p, size_t width) +ascii_setwidth(struct termp *p, int iop, size_t width) { - size_t lastwidth; - lastwidth = p->defrmargin; - p->rmargin = p->maxrmargin = p->defrmargin = - width ? width : p->lastrmargin; - p->lastrmargin = lastwidth; + p->rmargin = p->defrmargin; + if (0 < iop) + p->defrmargin += width; + else if (0 > iop) + p->defrmargin -= width; + else + p->defrmargin = width ? width : p->lastrmargin; + p->lastrmargin = p->rmargin; + p->rmargin = p->maxrmargin = p->defrmargin; } /* ARGSUSED */ diff --git a/usr.bin/mandoc/term_ps.c b/usr.bin/mandoc/term_ps.c index 64876299ddd..83ba17bc738 100644 --- a/usr.bin/mandoc/term_ps.c +++ b/usr.bin/mandoc/term_ps.c @@ -1,4 +1,4 @@ -/* $Id: term_ps.c,v 1.22 2014/03/30 19:47:32 schwarze Exp $ */ +/* $Id: term_ps.c,v 1.23 2014/03/30 21:27:59 schwarze Exp $ */ /* * Copyright (c) 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2014 Ingo Schwarze <schwarze@openbsd.org> @@ -99,7 +99,7 @@ static void ps_pletter(struct termp *, int); static void ps_printf(struct termp *, const char *, ...); static void ps_putchar(struct termp *, char); static void ps_setfont(struct termp *, enum termfont); -static void ps_setwidth(struct termp *, size_t); +static void ps_setwidth(struct termp *, int, size_t); static struct termp *pspdf_alloc(char *); static void pdf_obj(struct termp *, size_t); @@ -529,12 +529,17 @@ pspdf_alloc(char *outopts) static void -ps_setwidth(struct termp *p, size_t width) +ps_setwidth(struct termp *p, int iop, size_t width) { size_t lastwidth; lastwidth = p->ps->width; - p->ps->width = width ? width : p->ps->lastwidth; + if (0 < iop) + p->ps->width += width; + else if (0 > iop) + p->ps->width -= width; + else + p->ps->width = width ? width : p->ps->lastwidth; p->ps->lastwidth = lastwidth; } |