aboutsummaryrefslogtreecommitdiffstats
path: root/print/lprps/files/patch-textps.c
blob: 3e8cfe11dfc3608e1c41dc4b82ed25170e0d83cc (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
--- textps.c.orig   1993-02-22 21:46:10.000000000 +0900
+++ textps.c    2013-04-27 23:04:41.000000000 +0900
@@ -41,10 +41,12 @@
 #endif /* not BOLD_FONT */
 
 #include <stdio.h>
+#include <stdlib.h>
 #include <ctype.h>
 #include <string.h>
 
-extern char *malloc();
+#include <paper.h>
+
 extern char *optarg;
 extern int optind;
 
@@ -86,10 +88,24 @@
   exit(1);
 }
 
+const struct paper *findpaper(char *name)
+{
+   const struct paper *pp;
+
+   paperinit();
+   for (pp = paperfirst(); pp; pp = papernext(pp)) {
+       if (strcmp(name, papername(pp)) == 0)
+           return (pp);
+   }
+   return (NULL);
+}
+
 main(argc, argv)
 int argc;
 char **argv;
 {
+  const struct paper *pp;
+  char *name;
   int bad_files = 0;
   double cpi = 12.0;           /* characters per inch */
   int opt;
@@ -124,6 +140,12 @@
       abort();
     }
 
+  name = (char *)systempapername();
+  if (name == NULL)
+    name = (char *)defaultpapername();
+  if ((pp = findpaper(name)) != NULL)
+   page_length = paperpsheight(pp);
+
   char_width = 72.0/cpi;
   prologue();
   if (optind >= argc)