summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--main.c2
-rw-r--r--main.h2
-rw-r--r--term_ps.c24
3 files changed, 25 insertions, 3 deletions
diff --git a/main.c b/main.c
index 6d3f2248..dfcc7e23 100644
--- a/main.c
+++ b/main.c
@@ -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 70258d0a..9d51ab15 100644
--- a/main.h
+++ b/main.h
@@ -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 a7ed2e05..15ee7af5 100644
--- a/term_ps.c
+++ b/term_ps.c
@@ -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);