Package: libpaper
Version: 1.1.23
Without being configured paperconf will default to "letter" if there is
no configuration data. This patch will use LC_PAPER if it exists to make
a better last-ditch default for paper size before going to "letter" i.e.
grep "^width *216$" /usr/share/i18n/locales/* are the "letter" ones if
there is no override.
C.
diff -ru libpaper-1.1.23.orig/lib/paper.c libpaper-1.1.23/lib/paper.c
--- libpaper-1.1.23.orig/lib/paper.c 2008-05-14 12:41:53.000000000 +0100
+++ libpaper-1.1.23/lib/paper.c 2008-05-14 17:04:17.000000000 +0100
@@ -22,6 +22,8 @@
#include <stdlib.h>
+#include <locale.h>
+
#include "paper.h"
struct paper {
@@ -110,6 +112,22 @@
}
const char* defaultpapername(void) {
+#ifdef LC_PAPER
+ char *locale = setlocale(LC_PAPER, "");
+
+ if (locale) {
+ if ( (strlen(locale) >= 5) &&
+ ( !strncmp(locale, "en_US", 5) ||
+ !strncmp(locale, "en_CA", 5) ||
+ !strncmp(locale, "es_PR", 5) ||
+ !strncmp(locale, "es_US", 5) ) ) {
+ return "letter";
+ }
+ else
+ return "a4";
+ }
+#endif
+
return PAPERSIZE;
}
diff -ru libpaper-1.1.23.orig/man/paperconf.1.in libpaper-1.1.23/man/paperconf.1.in
--- libpaper-1.1.23.orig/man/paperconf.1.in 2008-05-14 12:41:52.000000000 +0100
+++ libpaper-1.1.23/man/paperconf.1.in 2008-05-14 12:47:01.000000000 +0100
@@ -48,10 +48,13 @@
.B @PAPERSIZEVAR@
environment variable, at the contents of the file specified by the
.B @PAPERCONFVAR@
-environment variable, at the contects of
+environment variable, at the contents of
.B @PAPERCONF@
-or by using
-.B letter
+at the
+.B LC_PAPER
+environment variable, where en_US, en_CA, es_PR, es_US mean letter
+any everything else as A4, or by using
+.B @PAPERSIZE@
as a fall-back value if none of the other alternatives are successful.
By default, width and height of the paper are printed in PostScript points.
.SH OPTIONS
diff -ru libpaper-1.1.23.orig/src/paperconf.c libpaper-1.1.23/src/paperconf.c
--- libpaper-1.1.23.orig/src/paperconf.c 2008-05-14 12:41:52.000000000 +0100
+++ libpaper-1.1.23/src/paperconf.c 2008-05-14 17:03:36.000000000 +0100
@@ -11,6 +11,7 @@
#include <stdlib.h>
#include <string.h>
#include <errno.h>
+#include <locale.h>
#include <paper.h>
@@ -99,6 +100,8 @@
const char* progname;
+ setlocale(LC_ALL, NULL);
+
progname = strrchr(*argv, '/');
if (progname) {
++progname;