From 6b214e8597e1e8ef4d319a8ebe1a3a4dffd9d105 Mon Sep 17 00:00:00 2001 From: Kristaps Dzonsons Date: Sun, 4 Jul 2010 19:57:26 +0000 Subject: Suppress printing blank eof pages in -Tps. Delay printing of Page: until actual text is ready to be displayed. --- term_ps.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/term_ps.c b/term_ps.c index c3515e62..5da5a450 100644 --- a/term_ps.c +++ b/term_ps.c @@ -1,4 +1,4 @@ -/* $Id: term_ps.c,v 1.29 2010/07/04 19:42:25 kristaps Exp $ */ +/* $Id: term_ps.c,v 1.30 2010/07/04 19:57:26 kristaps Exp $ */ /* * Copyright (c) 2008, 2009 Kristaps Dzonsons * @@ -580,12 +580,14 @@ ps_end(struct termp *p) * well as just one. */ - assert(0 == p->engine.ps.flags); - assert('\0' == p->engine.ps.last); - assert(p->engine.ps.psmarg && p->engine.ps.psmarg[0]); - printf("%s", p->engine.ps.psmarg); - p->engine.ps.pages++; - printf("showpage\n"); + if ( ! (PS_NEWPAGE & p->engine.ps.flags)) { + assert(0 == p->engine.ps.flags); + assert('\0' == p->engine.ps.last); + assert(p->engine.ps.psmarg && p->engine.ps.psmarg[0]); + printf("%s", p->engine.ps.psmarg); + p->engine.ps.pages++; + printf("showpage\n"); + } printf("%%%%Trailer\n"); printf("%%%%Pages: %zu\n", p->engine.ps.pages); @@ -674,6 +676,11 @@ ps_pletter(struct termp *p, int c) * now at the current cursor. */ + if (PS_NEWPAGE & p->engine.ps.flags) + printf("%%%%Page: %zu %zu\n", + p->engine.ps.pages + 1, + p->engine.ps.pages + 1); + if ( ! (PS_INLINE & p->engine.ps.flags)) { ps_printf(p, "%zu %zu moveto\n(", AFM2PNT(p, p->engine.ps.pscol), @@ -870,9 +877,6 @@ ps_endline(struct termp *p) printf("%s", p->engine.ps.psmarg); printf("showpage\n"); p->engine.ps.pages++; - printf("%%%%Page: %zu %zu\n", - p->engine.ps.pages + 1, - p->engine.ps.pages + 1); p->engine.ps.psrow = p->engine.ps.top; assert( ! (PS_NEWPAGE & p->engine.ps.flags)); p->engine.ps.flags |= PS_NEWPAGE; -- cgit v1.2.3-56-ge451