libpaper-useglibcfallback.patch 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. diff -ru libpaper-1.1.23.orig/lib/paper.c libpaper-1.1.23/lib/paper.c
  2. --- libpaper-1.1.23.orig/lib/paper.c 2008-08-12 13:20:48.000000000 +0100
  3. +++ libpaper-1.1.23/lib/paper.c 2008-08-12 14:26:44.000000000 +0100
  4. @@ -22,6 +22,9 @@
  5. #include <stdlib.h>
  6. +#include <locale.h>
  7. +#include <langinfo.h>
  8. +
  9. #include "paper.h"
  10. struct paper {
  11. @@ -110,6 +113,27 @@
  12. }
  13. const char* defaultpapername(void) {
  14. +#if defined(LC_PAPER) && defined(_GNU_SOURCE)
  15. +
  16. +#define NL_PAPER_GET(x) \
  17. + ((union { char *string; unsigned int word; })nl_langinfo(x)).word
  18. +
  19. +#define PT_TO_MM(v) (unsigned int)((v * 2.54 * 10 / 72) + 0.5)
  20. +
  21. + const struct paper* pp;
  22. +
  23. + unsigned int w = NL_PAPER_GET(_NL_PAPER_WIDTH);
  24. + unsigned int h = NL_PAPER_GET(_NL_PAPER_HEIGHT);
  25. +
  26. + for (pp = paperfirst(); pp; pp = papernext(pp)) {
  27. + if (
  28. + PT_TO_MM(pp->pswidth) == w &&
  29. + PT_TO_MM(pp->psheight) == h
  30. + ) {
  31. + return pp->name;
  32. + }
  33. + }
  34. +#endif
  35. return PAPERSIZE;
  36. }
  37. diff -ru libpaper-1.1.23.orig/man/paperconf.1.in libpaper-1.1.23/man/paperconf.1.in
  38. --- libpaper-1.1.23.orig/man/paperconf.1.in 2008-08-12 13:20:48.000000000 +0100
  39. +++ libpaper-1.1.23/man/paperconf.1.in 2008-08-12 14:34:06.000000000 +0100
  40. @@ -48,10 +48,12 @@
  41. .B @PAPERSIZEVAR@
  42. environment variable, at the contents of the file specified by the
  43. .B @PAPERCONFVAR@
  44. -environment variable, at the contects of
  45. +environment variable, at the contents of the file
  46. .B @PAPERCONF@
  47. -or by using
  48. -.B letter
  49. +, consulting the values controlled by the
  50. +.B LC_PAPER
  51. +locale setting, or by using
  52. +.B @PAPERSIZE@
  53. as a fall-back value if none of the other alternatives are successful.
  54. By default, width and height of the paper are printed in PostScript points.
  55. .SH OPTIONS
  56. diff -ru libpaper-1.1.23.orig/src/paperconf.c libpaper-1.1.23/src/paperconf.c
  57. --- libpaper-1.1.23.orig/src/paperconf.c 2008-08-12 13:20:48.000000000 +0100
  58. +++ libpaper-1.1.23/src/paperconf.c 2008-08-12 14:13:33.000000000 +0100
  59. @@ -13,6 +13,7 @@
  60. #include <errno.h>
  61. #include <paper.h>
  62. +#include <locale.h>
  63. /* needed for GNU/Hurd */
  64. @@ -99,6 +100,8 @@
  65. const char* progname;
  66. + setlocale(LC_ALL, "");
  67. +
  68. progname = strrchr(*argv, '/');
  69. if (progname) {
  70. ++progname;