summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorMarc Espie <espie@cvs.openbsd.org>2017-11-10 14:16:29 +0000
committerMarc Espie <espie@cvs.openbsd.org>2017-11-10 14:16:29 +0000
commit21bc5b225b21d667b38df2afed6cbb1ae68eca4e (patch)
tree26a07958c2de0819937183327b5b8eb94c68ed43 /usr.bin
parenta7e0f9f7479a745597fd997b19c765e50331e34c (diff)
streamline termp allocation. this will allow the init function to
do things differently in the ps vs pdf case. okay schwarze@
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/mandoc/term_ps.c21
1 files changed, 6 insertions, 15 deletions
diff --git a/usr.bin/mandoc/term_ps.c b/usr.bin/mandoc/term_ps.c
index 4894f64fc2d..9460c888536 100644
--- a/usr.bin/mandoc/term_ps.c
+++ b/usr.bin/mandoc/term_ps.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: term_ps.c,v 1.54 2017/11/01 10:14:53 espie Exp $ */
+/* $OpenBSD: term_ps.c,v 1.55 2017/11/10 14:16:28 espie Exp $ */
/*
* Copyright (c) 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2014, 2015, 2016, 2017 Ingo Schwarze <schwarze@openbsd.org>
@@ -107,7 +107,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);
/*
@@ -510,27 +510,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;
@@ -540,6 +530,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,