summaryrefslogtreecommitdiffstats
path: root/term_ps.c
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2010-07-04 19:57:26 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2010-07-04 19:57:26 +0000
commit52314992a888bfb56c8cb815cf5a9e32b4ad0c50 (patch)
tree6711047a2b5fa6403b1080604360478235a68fbc /term_ps.c
parent00ffe0ee984ad6894a1dbd38ad183cb10dfc2057 (diff)
downloadmandoc-52314992a888bfb56c8cb815cf5a9e32b4ad0c50.tar.gz
Suppress printing blank eof pages in -Tps. Delay printing of Page:
until actual text is ready to be displayed.
Diffstat (limited to 'term_ps.c')
-rw-r--r--term_ps.c22
1 files changed, 13 insertions, 9 deletions
diff --git a/term_ps.c b/term_ps.c
index a1c02efc..180b54b8 100644
--- a/term_ps.c
+++ b/term_ps.c
@@ -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;