aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/term.c
diff options
context:
space:
mode:
authorJoerg Sonnenberger <joerg@netbsd.org>2010-05-15 16:18:23 +0000
committerJoerg Sonnenberger <joerg@netbsd.org>2010-05-15 16:18:23 +0000
commitcb574fba99de6900929ef272a818f2b4c756abbd (patch)
tree36624b5c75ad51535c0692a957c0c0eb058b142d /term.c
parent23ae8ccb1b52134baac639bb4490d75fd11c858e (diff)
downloadmandoc-cb574fba99de6900929ef272a818f2b4c756abbd.tar.gz
mandoc-cb574fba99de6900929ef272a818f2b4c756abbd.tar.zst
mandoc-cb574fba99de6900929ef272a818f2b4c756abbd.zip
Make the output width an option for ascii_alloc and use that to compute
the default margin. Hard-code 80 chars/line for now.
Diffstat (limited to 'term.c')
-rw-r--r--term.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/term.c b/term.c
index be1ffcc7..e43d9692 100644
--- a/term.c
+++ b/term.c
@@ -1,4 +1,4 @@
-/* $Id: term.c,v 1.133 2010/05/12 16:01:01 kristaps Exp $ */
+/* $Id: term.c,v 1.134 2010/05/15 16:18:23 joerg Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -34,7 +34,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);
@@ -45,10 +45,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));
}
@@ -74,7 +74,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;
@@ -84,6 +84,10 @@ term_alloc(enum termenc enc)
exit(EXIT_FAILURE);
}
p->enc = enc;
+ /* Enforce some lower boundary. */
+ if (width < 60)
+ width = 60;
+ p->defrmargin = width - 2;
return(p);
}