summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2017-11-10 23:42:52 +0000
committerIngo Schwarze <schwarze@openbsd.org>2017-11-10 23:42:52 +0000
commit9e1ddfbd0a6ec64d7ffed48d4e83ef6b4f33fede (patch)
tree923078f3a8cc02b8195e18d880df4a9859220a77
parent451c91387a4cded19c73e971d3b2ee1bb4c1f53d (diff)
downloadmandoc-9e1ddfbd0a6ec64d7ffed48d4e83ef6b4f33fede.tar.gz
streamline termp allocation: this will allow the init function
to do things differently in the ps vs pdf case; from espie@
-rw-r--r--term_ps.c19
1 files changed, 5 insertions, 14 deletions
diff --git a/term_ps.c b/term_ps.c
index 358ce14a..5bbc3068 100644
--- a/term_ps.c
+++ b/term_ps.c
@@ -111,7 +111,7 @@ 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 *, int, int);
-static struct termp *pspdf_alloc(const struct manoutput *);
+static struct termp *pspdf_alloc(const struct manoutput *, enum termtype);
static void pdf_obj(struct termp *, size_t);
/*
@@ -514,27 +514,17 @@ static const struct font fonts[TERMFONT__MAX] = {
void *
pdf_alloc(const struct manoutput *outopts)
{
- struct termp *p;
-
- if (NULL != (p = pspdf_alloc(outopts)))
- p->type = TERMTYPE_PDF;
-
- return p;
+ return pspdf_alloc(outopts, TERMTYPE_PDF);
}
void *
ps_alloc(const struct manoutput *outopts)
{
- struct termp *p;
-
- if (NULL != (p = pspdf_alloc(outopts)))
- p->type = TERMTYPE_PS;
-
- return p;
+ return pspdf_alloc(outopts, TERMTYPE_PS);
}
static struct termp *
-pspdf_alloc(const struct manoutput *outopts)
+pspdf_alloc(const struct manoutput *outopts, enum termtype type)
{
struct termp *p;
unsigned int pagex, pagey;
@@ -544,6 +534,7 @@ pspdf_alloc(const struct manoutput *outopts)
p = mandoc_calloc(1, sizeof(*p));
p->tcol = p->tcols = mandoc_calloc(1, sizeof(*p->tcol));
p->maxtcol = 1;
+ p->type = type;
p->enc = TERMENC_ASCII;
p->fontq = mandoc_reallocarray(NULL,