man-db-2.6.1-locale-fallback.patch 965 B

1234567891011121314151617181920212223242526272829303132
  1. diff -upr man-db-2.6.1.orig/lib/encodings.c man-db-2.6.1/lib/encodings.c
  2. --- man-db-2.6.1.orig/lib/encodings.c 2011-05-31 02:03:02.000000000 +0200
  3. +++ man-db-2.6.1/lib/encodings.c 2012-06-15 18:32:37.393496286 +0200
  4. @@ -585,14 +585,23 @@ char *find_charset_locale (const char *c
  5. if (STREQ (charset, get_locale_charset ()))
  6. return NULL;
  7. - supported = fopen (supported_path, "r");
  8. - if (!supported)
  9. - return NULL;
  10. -
  11. saved_locale = setlocale (LC_CTYPE, NULL);
  12. if (saved_locale)
  13. saved_locale = xstrdup (saved_locale);
  14. + supported = fopen (supported_path, "r");
  15. + if (!supported) {
  16. + if (strlen (charset) >= (size_t) 5
  17. + && strncmp (charset, "UTF-8", (size_t) 5) == 0) {
  18. + locale = xstrdup("en_US.UTF-8");
  19. + if (setlocale (LC_CTYPE, locale)) {
  20. + setlocale (LC_CTYPE, saved_locale);
  21. + return locale;
  22. + }
  23. + }
  24. + return NULL;
  25. + }
  26. +
  27. while (getline (&line, &n, supported) >= 0) {
  28. const char *space = strchr (line, ' ');
  29. if (space) {