diff options
author | Ingo Schwarze <schwarze@cvs.openbsd.org> | 2010-05-15 21:09:54 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@cvs.openbsd.org> | 2010-05-15 21:09:54 +0000 |
commit | 891288ca199a2ca5b7e63cce216e3b787acee9a1 (patch) | |
tree | 9fbabc36bcf5fcbe7d36a2beb2d3ce125dacca2b | |
parent | a86b8c718ed5aa62b68637b33de2c8db5d4a1f45 (diff) |
More systematic output width handling by Joerg Sonnenberger:
* save and restore the output width when switching to MANT_LITERAL
* add an argument to ascii_alloc to specify the output width
* set the default output width to 80 minus 2 characters
* OpenBSD local: set the output width to 65 characters for -man
-rw-r--r-- | usr.bin/mandoc/main.c | 4 | ||||
-rw-r--r-- | usr.bin/mandoc/main.h | 4 | ||||
-rw-r--r-- | usr.bin/mandoc/man_term.c | 16 | ||||
-rw-r--r-- | usr.bin/mandoc/mdoc_term.c | 4 | ||||
-rw-r--r-- | usr.bin/mandoc/term.c | 14 | ||||
-rw-r--r-- | usr.bin/mandoc/term.h | 3 |
6 files changed, 30 insertions, 15 deletions
diff --git a/usr.bin/mandoc/main.c b/usr.bin/mandoc/main.c index 071bbcb7cd9..8e152f2fea6 100644 --- a/usr.bin/mandoc/main.c +++ b/usr.bin/mandoc/main.c @@ -1,4 +1,4 @@ -/* $Id: main.c,v 1.27 2010/05/15 17:32:25 schwarze Exp $ */ +/* $Id: main.c,v 1.28 2010/05/15 21:09:53 schwarze Exp $ */ /* * Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se> * @@ -473,7 +473,7 @@ fdesc(struct curparse *curp) case (OUTT_LINT): break; default: - curp->outdata = ascii_alloc(); + curp->outdata = ascii_alloc(80); curp->outman = terminal_man; curp->outmdoc = terminal_mdoc; curp->outfree = terminal_free; diff --git a/usr.bin/mandoc/main.h b/usr.bin/mandoc/main.h index f29c8d57dc2..933b7272681 100644 --- a/usr.bin/mandoc/main.h +++ b/usr.bin/mandoc/main.h @@ -1,4 +1,4 @@ -/* $Id: main.h,v 1.2 2010/02/18 02:11:26 schwarze Exp $ */ +/* $Id: main.h,v 1.3 2010/05/15 21:09:53 schwarze Exp $ */ /* * Copyright (c) 2009 Kristaps Dzonsons <kristaps@kth.se> * @@ -38,7 +38,7 @@ void html_free(void *); void tree_mdoc(void *, const struct mdoc *); void tree_man(void *, const struct man *); -void *ascii_alloc(void); +void *ascii_alloc(size_t); void terminal_mdoc(void *, const struct mdoc *); void terminal_man(void *, const struct man *); void terminal_free(void *); diff --git a/usr.bin/mandoc/man_term.c b/usr.bin/mandoc/man_term.c index 9036b670dba..89d47ae139d 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.31 2010/05/15 18:06:03 schwarze Exp $ */ +/* $Id: man_term.c,v 1.32 2010/05/15 21:09:53 schwarze Exp $ */ /* * Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se> * @@ -161,8 +161,14 @@ terminal_man(void *arg, const struct man *man) p = (struct termp *)arg; + /* + * XXX + * Hardcode the -man output width for now; + * it is not yet externally configurable, anyway. + */ + p->defrmargin = 65; + p->maxrmargin = p->defrmargin; p->overstep = 0; - p->maxrmargin = 65; if (NULL == p->symtab) switch (p->enc) { @@ -802,6 +808,7 @@ post_RS(DECL_ARGS) static void print_man_node(DECL_ARGS) { + size_t rm, rmax; int c; c = 1; @@ -818,10 +825,13 @@ print_man_node(DECL_ARGS) /* FIXME: this means that macro lines are munged! */ if (MANT_LITERAL & mt->fl) { + rm = p->rmargin; + rmax = p->maxrmargin; p->rmargin = p->maxrmargin = TERM_MAXMARGIN; p->flags |= TERMP_NOSPACE; term_flushln(p); - p->rmargin = p->maxrmargin = 65; + p->rmargin = rm; + p->maxrmargin = rmax; } break; default: diff --git a/usr.bin/mandoc/mdoc_term.c b/usr.bin/mandoc/mdoc_term.c index 4c828cd1d7f..8b06e3f54e2 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.79 2010/05/15 18:25:51 schwarze Exp $ */ +/* $Id: mdoc_term.c,v 1.80 2010/05/15 21:09:53 schwarze Exp $ */ /* * Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se> * @@ -269,7 +269,7 @@ terminal_mdoc(void *arg, const struct mdoc *mdoc) p = (struct termp *)arg; p->overstep = 0; - p->maxrmargin = 78; + p->maxrmargin = p->defrmargin; p->tabwidth = 5; if (NULL == p->symtab) diff --git a/usr.bin/mandoc/term.c b/usr.bin/mandoc/term.c index 55b7593942b..84fd27e0ddf 100644 --- a/usr.bin/mandoc/term.c +++ b/usr.bin/mandoc/term.c @@ -1,4 +1,4 @@ -/* $Id: term.c,v 1.31 2010/05/14 19:52:43 schwarze Exp $ */ +/* $Id: term.c,v 1.32 2010/05/15 21:09:53 schwarze Exp $ */ /* * Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se> * @@ -30,7 +30,7 @@ #include "mdoc.h" #include "main.h" -static struct termp *term_alloc(enum termenc); +static struct termp *term_alloc(enum termenc, size_t); static void term_free(struct termp *); static void spec(struct termp *, const char *, size_t); static void res(struct termp *, const char *, size_t); @@ -41,10 +41,10 @@ static void encode(struct termp *, const char *, size_t); void * -ascii_alloc(void) +ascii_alloc(size_t width) { - return(term_alloc(TERMENC_ASCII)); + return(term_alloc(TERMENC_ASCII, width)); } @@ -70,7 +70,7 @@ term_free(struct termp *p) static struct termp * -term_alloc(enum termenc enc) +term_alloc(enum termenc enc, size_t width) { struct termp *p; @@ -81,6 +81,10 @@ term_alloc(enum termenc enc) } p->tabwidth = 5; p->enc = enc; + /* Enforce some lower boundary. */ + if (width < 60) + width = 60; + p->defrmargin = width - 2; return(p); } diff --git a/usr.bin/mandoc/term.h b/usr.bin/mandoc/term.h index e497fba1512..3e5a49c854a 100644 --- a/usr.bin/mandoc/term.h +++ b/usr.bin/mandoc/term.h @@ -1,4 +1,4 @@ -/* $Id: term.h,v 1.18 2010/05/14 19:52:43 schwarze Exp $ */ +/* $Id: term.h,v 1.19 2010/05/15 21:09:53 schwarze Exp $ */ /* * Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se> * @@ -32,6 +32,7 @@ enum termfont { #define TERM_MAXMARGIN 100000 /* FIXME */ struct termp { + size_t defrmargin; /* Right margin of the device.. */ size_t rmargin; /* Current right margin. */ size_t maxrmargin; /* Max right margin. */ size_t maxcols; /* Max size of buf. */ |