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