Blame SOURCES/libpaper-useglibcfallback.patch

28546a
diff -up libpaper-1.1.24+nmu3/lib/paper.c.useglibcfallback libpaper-1.1.24+nmu3/lib/paper.c
28546a
--- libpaper-1.1.24+nmu3/lib/paper.c.useglibcfallback	2010-04-24 08:12:11.000000000 -0400
28546a
+++ libpaper-1.1.24+nmu3/lib/paper.c	2014-04-22 15:58:33.120039001 -0400
28546a
@@ -20,6 +20,9 @@
28546a
 
28546a
 #include <unistd.h>
28546a
 
28546a
+#include <locale.h>
28546a
+#include <langinfo.h>
28546a
+
28546a
 #include "paper.h"
28546a
 
28546a
 struct paper {
28546a
@@ -108,6 +111,27 @@ in PAPERCONFVAR, fall-back to the old be
28546a
 }
28546a
 
28546a
 const char* defaultpapername(void) {
28546a
+#if defined(LC_PAPER) && defined(_GNU_SOURCE)
28546a
+
28546a
+#define NL_PAPER_GET(x)         \
28546a
+  ((union { char *string; unsigned int word; })nl_langinfo(x)).word
28546a
+
28546a
+#define PT_TO_MM(v) (unsigned int)((v * 2.54 * 10 / 72) + 0.5)
28546a
+
28546a
+    const struct paper* pp;
28546a
+
28546a
+    unsigned int w = NL_PAPER_GET(_NL_PAPER_WIDTH);
28546a
+    unsigned int h = NL_PAPER_GET(_NL_PAPER_HEIGHT);
28546a
+
28546a
+    for (pp = paperfirst(); pp; pp = papernext(pp)) {
28546a
+	if (
28546a
+             PT_TO_MM(pp->pswidth) == w &&
28546a
+             PT_TO_MM(pp->psheight) == h
28546a
+           ) {
28546a
+	    return pp->name;
28546a
+	}
28546a
+    }
28546a
+#endif
28546a
     return PAPERSIZE;
28546a
 }
28546a
 
28546a
diff -up libpaper-1.1.24+nmu3/man/paperconf.1.in.useglibcfallback libpaper-1.1.24+nmu3/man/paperconf.1.in
28546a
--- libpaper-1.1.24+nmu3/man/paperconf.1.in.useglibcfallback	2014-04-22 15:58:33.121038995 -0400
28546a
+++ libpaper-1.1.24+nmu3/man/paperconf.1.in	2014-04-22 16:00:15.973428376 -0400
28546a
@@ -48,10 +48,12 @@ looking in order at the
28546a
 .B @PAPERSIZEVAR@
28546a
 environment variable, at the contents of the file specified by the
28546a
 .B @PAPERCONFVAR@
28546a
-environment variable, at the contents of
28546a
+environment variable, at the contents of the file
28546a
 .B @PAPERCONF@
28546a
-or by using
28546a
-.B letter
28546a
+, consulting the values controlled by the
28546a
+.B LC_PAPER
28546a
+locale setting, or by using
28546a
+.B @PAPERSIZE@
28546a
 as a fall-back value if none of the other alternatives are successful.
28546a
 By default, width and height of the paper are printed in PostScript points.
28546a
 .SH OPTIONS
28546a
diff -up libpaper-1.1.24+nmu3/src/paperconf.c.useglibcfallback libpaper-1.1.24+nmu3/src/paperconf.c
28546a
--- libpaper-1.1.24+nmu3/src/paperconf.c.useglibcfallback	2012-05-03 15:05:12.000000000 -0400
28546a
+++ libpaper-1.1.24+nmu3/src/paperconf.c	2014-04-22 15:58:33.121038995 -0400
28546a
@@ -13,6 +13,7 @@
28546a
 #include <errno.h>
28546a
 
28546a
 #include <paper.h>
28546a
+#include <locale.h>
28546a
 
28546a
 
28546a
 /* needed for GNU/Hurd */
28546a
@@ -99,6 +100,8 @@ int main(int argc, char** argv)
28546a
 
28546a
     const char* progname;
28546a
 
28546a
+    setlocale(LC_ALL, "");
28546a
+
28546a
     progname = strrchr(*argv, '/');
28546a
     if (progname) {
28546a
 	++progname;