=================================================================== RCS file: /cvs/mandoc/term_ps.c,v retrieving revision 1.90 retrieving revision 1.92 diff -u -p -r1.90 -r1.92 --- mandoc/term_ps.c 2017/11/02 14:53:02 1.90 +++ mandoc/term_ps.c 2020/09/06 14:45:22 1.92 @@ -1,7 +1,7 @@ -/* $Id: term_ps.c,v 1.90 2017/11/02 14:53:02 schwarze Exp $ */ +/* $Id: term_ps.c,v 1.92 2020/09/06 14:45:22 schwarze Exp $ */ /* * Copyright (c) 2010, 2011 Kristaps Dzonsons - * Copyright (c) 2014, 2015, 2016, 2017 Ingo Schwarze + * Copyright (c) 2014,2015,2016,2017,2020 Ingo Schwarze * Copyright (c) 2017 Marc Espie * * Permission to use, copy, modify, and distribute this software for any @@ -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, @@ -1261,7 +1252,10 @@ ps_endline(struct termp *p) ps_closepage(p); - p->tcol->offset -= p->ti; + if ((int)p->tcol->offset > p->ti) + p->tcol->offset -= p->ti; + else + p->tcol->offset = 0; p->ti = 0; }