aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2010-06-29 14:53:14 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2010-06-29 14:53:14 +0000
commit319d06106e51d11bd2327a59bb1d12d09985421e (patch)
tree7c569f6c6f58f39368d068a473af972d1df85c40
parent2bd10d07080a87c7b6d1e64efa941615ce7144b9 (diff)
downloadmandoc-319d06106e51d11bd2327a59bb1d12d09985421e.tar.gz
mandoc-319d06106e51d11bd2327a59bb1d12d09985421e.tar.zst
mandoc-319d06106e51d11bd2327a59bb1d12d09985421e.zip
Add in -Opaper=xxx support for -Tps postscript. This doesn't have any
functional changes beyond the getsubopt() parse in term_ps.c. If you want to test this (it only does -Opaper=a4 and -Opaper=letter; adding more is trivial), make sure you specify (e.g.) -sPAPERSIZE=a4 to gs(1).
-rw-r--r--main.c4
-rw-r--r--main.h4
-rw-r--r--term_ps.c26
3 files changed, 28 insertions, 6 deletions
diff --git a/main.c b/main.c
index 469dc2ef..f82ef84a 100644
--- a/main.c
+++ b/main.c
@@ -1,4 +1,4 @@
-/* $Id: main.c,v 1.92 2010/06/27 15:52:41 kristaps Exp $ */
+/* $Id: main.c,v 1.93 2010/06/29 14:53:14 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -599,7 +599,7 @@ fdesc(struct curparse *curp)
curp->outfree = ascii_free;
break;
case (OUTT_PS):
- curp->outdata = ps_alloc();
+ curp->outdata = ps_alloc(curp->outopts);
curp->outfree = ps_free;
break;
default:
diff --git a/main.h b/main.h
index c48d0053..c772f102 100644
--- a/main.h
+++ b/main.h
@@ -1,4 +1,4 @@
-/* $Id: main.h,v 1.7 2010/06/19 20:46:28 kristaps Exp $ */
+/* $Id: main.h,v 1.8 2010/06/29 14:53:14 kristaps Exp $ */
/*
* Copyright (c) 2009 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -44,7 +44,7 @@ void tree_man(void *, const struct man *);
void *ascii_alloc(char *);
void ascii_free(void *);
-void *ps_alloc(void);
+void *ps_alloc(char *);
void ps_free(void *);
void terminal_mdoc(void *, const struct mdoc *);
diff --git a/term_ps.c b/term_ps.c
index 617557e2..1f0bc407 100644
--- a/term_ps.c
+++ b/term_ps.c
@@ -1,4 +1,4 @@
-/* $Id: term_ps.c,v 1.16 2010/06/29 14:18:05 kristaps Exp $ */
+/* $Id: term_ps.c,v 1.17 2010/06/29 14:53:14 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -22,6 +22,7 @@
#include <assert.h>
#include <stdarg.h>
+#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -373,14 +374,17 @@ static void ps_setfont(struct termp *, enum termfont);
void *
-ps_alloc(void)
+ps_alloc(char *outopts)
{
struct termp *p;
size_t pagex, pagey, margin;
+ const char *toks[2];
+ char *v;
if (NULL == (p = term_alloc(TERMENC_ASCII)))
return(NULL);
+ /* Default is USA letter. */
pagex = 612;
pagey = 792;
margin = 72;
@@ -393,6 +397,24 @@ ps_alloc(void)
p->endline = ps_endline;
p->width = ps_width;
+ toks[0] = "paper";
+ toks[1] = NULL;
+
+ while (outopts && *outopts)
+ switch (getsubopt(&outopts, UNCONST(toks), &v)) {
+ case (0):
+ if (0 == strcasecmp(v, "a4")) {
+ pagex = 595;
+ pagey = 842;
+ } else if (0 == strcasecmp(v, "letter")) {
+ pagex = 612;
+ pagey = 792;
+ }
+ break;
+ default:
+ break;
+ }
+
assert(margin * 2 < pagex);
assert(margin * 2 < pagey);