aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/term.c
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2010-06-08 13:22:37 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2010-06-08 13:22:37 +0000
commitc3a38b374a5f4635f91f2b980e43da5b27e0d36a (patch)
tree5dd86d80c83deb56e6fbdf3b8bae2d5caa355827 /term.c
parent7e3debcee89f432bd9db276d89ee6030b30a9479 (diff)
downloadmandoc-c3a38b374a5f4635f91f2b980e43da5b27e0d36a.tar.gz
mandoc-c3a38b374a5f4635f91f2b980e43da5b27e0d36a.tar.zst
mandoc-c3a38b374a5f4635f91f2b980e43da5b27e0d36a.zip
No functionality changes: just restructuring. Deprecated
terminal_free() in favour of ps_free() and ascii_free(). Moved ps_*() functions into term_ps.c so that they don't clutter up term.c.
Diffstat (limited to 'term.c')
-rw-r--r--term.c65
1 files changed, 29 insertions, 36 deletions
diff --git a/term.c b/term.c
index b92eadc9..f95eeeaf 100644
--- a/term.c
+++ b/term.c
@@ -1,4 +1,4 @@
-/* $Id: term.c,v 1.144 2010/06/08 09:20:08 kristaps Exp $ */
+/* $Id: term.c,v 1.145 2010/06/08 13:22:37 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -45,8 +45,6 @@
#define PS_CHAR_BOTMARG 24
#define PS_CHAR_BOT (PS_CHAR_BOTMARG + 36)
-static struct termp *alloc(char *, enum termenc, enum termtype);
-static void term_free(struct termp *);
static void spec(struct termp *, const char *, size_t);
static void res(struct termp *, const char *, size_t);
static void buffera(struct termp *, const char *, size_t);
@@ -62,28 +60,44 @@ static void pageopen(struct termp *);
void *
ascii_alloc(char *outopts)
{
+ struct termp *p;
+ const char *toks[2];
+ char *v;
- return(alloc(outopts, TERMENC_ASCII, TERMTYPE_CHAR));
-}
+ if (NULL == (p = term_alloc(TERMENC_ASCII)))
+ return(NULL);
+ p->type = TERMTYPE_CHAR;
-void *
-ps_alloc(void)
-{
+ toks[0] = "width";
+ toks[1] = NULL;
+
+ while (outopts && *outopts)
+ switch (getsubopt(&outopts, UNCONST(toks), &v)) {
+ case (0):
+ p->defrmargin = (size_t)atoi(v);
+ break;
+ default:
+ break;
+ }
- return(alloc(NULL, TERMENC_ASCII, TERMTYPE_PS));
+ /* Enforce a lower boundary. */
+ if (p->defrmargin < 58)
+ p->defrmargin = 58;
+
+ return(p);
}
void
-terminal_free(void *arg)
+ascii_free(void *arg)
{
term_free((struct termp *)arg);
}
-static void
+void
term_free(struct termp *p)
{
@@ -91,6 +105,7 @@ term_free(struct termp *p)
free(p->buf);
if (p->symtab)
chars_free(p->symtab);
+
free(p);
}
@@ -290,16 +305,10 @@ advance(struct termp *p, size_t len)
}
-static struct termp *
-alloc(char *outopts, enum termenc enc, enum termtype type)
+struct termp *
+term_alloc(enum termenc enc)
{
struct termp *p;
- const char *toks[2];
- char *v;
- size_t width;
-
- toks[0] = "width";
- toks[1] = NULL;
p = calloc(1, sizeof(struct termp));
if (NULL == p) {
@@ -307,25 +316,9 @@ alloc(char *outopts, enum termenc enc, enum termtype type)
exit(EXIT_FAILURE);
}
- p->type = type;
p->tabwidth = 5;
p->enc = enc;
-
- width = 80;
-
- while (outopts && *outopts)
- switch (getsubopt(&outopts, UNCONST(toks), &v)) {
- case (0):
- width = (size_t)atoi(v);
- break;
- default:
- break;
- }
-
- /* Enforce some lower boundary. */
- if (width < 60)
- width = 60;
- p->defrmargin = width - 2;
+ p->defrmargin = 78;
return(p);
}