Blame SOURCES/psutils-p17-paper.patch

67b279
--- psutils/pstops.man.paper	Tue Mar 11 23:53:04 1997
67b279
+++ psutils/pstops.man	Thu Jul 19 15:21:51 2001
67b279
@@ -108,10 +108,11 @@
67b279
 The 
67b279
 .I \-p
67b279
 option can be used as an alternative, to set the paper size to
67b279
-.B a3, a4, a5, b5, letter, legal, tabloid, statement, executive, folio, quarto
67b279
+.B a3, a4, a5, b5, letter, legal, tabloid, statement, executive, folio, quarto, 10x14
67b279
 or
67b279
-.B 10x14.
67b279
-The default paper size is
67b279
+.B _glibc,
67b279
+where latter one means the format of the current locale. The default
67b279
+paper size is
67b279
 .B @PAPER@.
67b279
 .PP
67b279
 The
67b279
@@ -154,6 +155,12 @@
67b279
 4:1L@.7(21cm,0)+-2L@.7(21cm,14.85cm)
67b279
 .sp
67b279
 for the reverse sides (or join them with a comma for duplex printing).
67b279
+.SH "ENVIRONMENT VARIABLES"
67b279
+.TP
67b279
+.B LC_ALL, LC_PAPER
67b279
+These variables are specifying the papertype when used paper is
67b279
+.B _glibc.
67b279
+For details see the locale(7) manpage.
67b279
 .SH AUTHOR
67b279
 Copyright (C) Angus J. C. Duggan 1991-1995
67b279
 .SH "SEE ALSO"
67b279
--- psutils/psutil.c.paper	Tue Mar 11 23:53:04 1997
67b279
+++ psutils/psutil.c	Thu Jul 19 15:21:51 2001
67b279
@@ -21,6 +21,11 @@
67b279
 #include <sys/types.h>
67b279
 #include <sys/stat.h>
67b279
 
67b279
+#ifdef HAVE_LANGINFO_H
67b279
+#  include <langinfo.h>
67b279
+#  include <locale.h>
67b279
+#endif
67b279
+
67b279
 #define iscomment(x,y) (strncmp(x,y,strlen(y)) == 0)
67b279
 
67b279
 extern char *program ;
67b279
@@ -31,6 +36,16 @@
67b279
 extern char pagelabel[BUFSIZ];
67b279
 extern int pageno;
67b279
 
67b279
+#ifdef HAVE_LANGINFO_H
67b279
+/* When using papertype _glibc we are comparing floating point values. Therefore
67b279
+ * and because values in the papersize table are not exactly we are needing an
67b279
+ * epsilon value. */
67b279
+static float PT_EPSILON = 2.0;
67b279
+
67b279
+/* The factor needed to convert lengths given in mm to length in pt.*/
67b279
+static float MM_TO_PT_FACTOR = 72/25.4;
67b279
+#endif /* HAVE_LANGINFO_H */
67b279
+
67b279
 static char buffer[BUFSIZ];
67b279
 static long bytes = 0;
67b279
 static long pagescmt = 0;
67b279
@@ -64,16 +79,52 @@
67b279
    { NULL, 0, 0 }
67b279
 };
67b279
 
67b279
+#ifdef HAVE_LANGINFO_H
67b279
+/* Called if papertype is '_glibc'. It uses the current locale to determine the
67b279
+ * height and width of the current LC_PAPER and compares it with the items of
67b279
+ * the 'papersizes' list. */
67b279
+Paper* findpaperglibc()
67b279
+{
67b279
+   float	height, width;
67b279
+   char		*old_locale = setlocale (LC_PAPER, "");
67b279
+   Paper	*result = 0, *pp;
67b279
+  
67b279
+   height = MM_TO_PT_FACTOR * (unsigned int)(nl_langinfo(_NL_PAPER_HEIGHT));
67b279
+   width  = MM_TO_PT_FACTOR * (unsigned int)(nl_langinfo(_NL_PAPER_WIDTH));
67b279
+
67b279
+   for (pp = papersizes; PaperName(pp) && result==0; pp++) {
67b279
+      if ( abs(PaperWidth(pp)-width)
67b279
+	   abs(PaperHeight(pp)-height)
67b279
+	 result = pp;
67b279
+   }
67b279
+
67b279
+   setlocale(LC_PAPER, old_locale);
67b279
+
67b279
+   return result;
67b279
+}
67b279
+#endif /* HAVE_LANGINFO_H */
67b279
+
67b279
 /* return pointer to paper size struct or NULL */
67b279
 Paper* findpaper(char *name)
67b279
 {
67b279
-   Paper *pp;
67b279
-   for (pp = papersizes; PaperName(pp); pp++) {
67b279
-      if (strcmp(PaperName(pp), name) == 0) {
67b279
+   Paper *pp = 0;
67b279
+
67b279
+#ifdef HAVE_LANGINFO_H   
67b279
+   if (strcmp(name, "_glibc") == 0) {
67b279
+      pp = findpaperglibc();
67b279
+      if (pp==0) name = "a4";	/* Paper in C locale */
67b279
+   }
67b279
+#endif /* HAVE_LANGINFO_H */
67b279
+   
67b279
+   if (pp==0) {
67b279
+     for (pp = papersizes; PaperName(pp); pp++) {
67b279
+       if (strcmp(PaperName(pp), name) == 0) {
67b279
 	 return pp;
67b279
-      }
67b279
+       }
67b279
+     }
67b279
    }
67b279
-   return (Paper *)NULL;
67b279
+
67b279
+   return pp;
67b279
 }
67b279
 
67b279
 /* Make a file seekable, using temporary files if necessary */
67b279
--- psutils/psresize.man.paper	Tue Mar 11 23:53:03 1997
67b279
+++ psutils/psresize.man	Thu Jul 19 15:21:51 2001
67b279
@@ -42,10 +42,11 @@
67b279
 The 
67b279
 .I \-p
67b279
 option can be used as an alternative, to set the output paper size to
67b279
-.B a3, a4, a5, b5, letter, legal, tabloid, statement, executive, folio, quarto
67b279
+.B a3, a4, a5, b5, letter, legal, tabloid, statement, executive, folio, quarto, 10x24
67b279
 or
67b279
-.B 10x14.
67b279
-The default output paper size is
67b279
+.B _glibc,
67b279
+where latter one means the format of the current locale. The default
67b279
+output paper size is
67b279
 .B @PAPER@.
67b279
 .PP
67b279
 The
67b279
@@ -69,6 +70,12 @@
67b279
 .sp
67b279
 psresize -PA4 -pletter in.ps out.ps
67b279
 .sp
67b279
+.SH "ENVIRONMENT VARIABLES"
67b279
+.TP
67b279
+.B LC_ALL, LC_PAPER
67b279
+These variables are specifying the papertype when used paper is
67b279
+.B _glibc.
67b279
+For details see the locale(7) manpage.
67b279
 .SH AUTHOR
67b279
 Copyright (C) Angus J. C. Duggan 1991-1995
67b279
 .SH "SEE ALSO"
67b279
--- psutils/psnup.man.paper	Tue Mar 11 23:53:02 1997
67b279
+++ psutils/psnup.man	Thu Jul 19 15:21:51 2001
67b279
@@ -61,9 +61,11 @@
67b279
 The 
67b279
 .I \-p
67b279
 option can be used as an alternative, to set the paper size to
67b279
-.B a3, a4, a5, b5, letter, legal, tabloid, statement, executive, folio, quarto
67b279
+.B a3, a4, a5, b5, letter, legal, tabloid, statement, executive, folio, quarto,
67b279
+.B 10x14
67b279
 or
67b279
-.B 10x14.
67b279
+.B _glibc,
67b279
+where latter one means the format of the current locale.
67b279
 The default paper size is
67b279
 .B @PAPER@.
67b279
 The
67b279
@@ -148,6 +150,12 @@
67b279
 on the first output page and
67b279
 pages 2 then 3 of the input document 
67b279
 on the second output page.
67b279
+.SH "ENVIRONMENT VARIABLES"
67b279
+.TP
67b279
+.B LC_ALL, LC_PAPER
67b279
+These variables are specifying the papertype when used paper is
67b279
+.B _glibc.
67b279
+For details see the locale(7) manpage.
67b279
 .SH AUTHOR
67b279
 Copyright (C) Angus J. C. Duggan 1991-1995
67b279
 .SH "SEE ALSO"
67b279
--- psutils/Makefile.unix.paper	Thu Jul 19 15:21:51 2001
67b279
+++ psutils/Makefile.unix	Thu Jul 19 15:24:07 2001
67b279
@@ -19,7 +19,11 @@
67b279
 # psnup puts multiple logical pages on one physical page
67b279
 # psresize scales and moves pages to fit on different paper sizes
67b279
 
67b279
-PAPER=a4
67b279
+PAPER="_glibc"
67b279
+
67b279
+# Comment it out if your machine does not have the <langutil.h> header
67b279
+# or does not know nl_langinfo()
67b279
+LANGINFO_FLAG = -DHAVE_LANGINFO_H
67b279
 
67b279
 # Makefile for PSUtils under Unix
67b279
 
67b279
@@ -39,7 +43,7 @@
67b279
 MANDIR = $(DESTDIR)/usr/man/man$(MANEXT)
67b279
 
67b279
 CC = gcc
67b279
-CFLAGS = -DPAPER=\"$(PAPER)\" -DUNIX $(RPM_OPT_FLAGS) -Wall
67b279
+CFLAGS = -DPAPER=\"$(PAPER)\" -DUNIX $(RPM_OPT_FLAGS) $(LANGINFO_FLAG) -Wall
67b279
 
67b279
 BIN = psbook psselect pstops epsffit psnup \
67b279
 	psresize