patch-libraries_base_cbits_PrelIOUtils_c 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. $OpenBSD: patch-libraries_base_cbits_PrelIOUtils_c,v 1.3 2015/09/19 07:42:57 kili Exp $
  2. We have very limited locale support so used latin1 as default codeset
  3. which can be overridden by the environment variable `HS_ENCODING'.
  4. --- libraries/base/cbits/PrelIOUtils.c.orig Tue Dec 23 03:31:10 2014
  5. +++ libraries/base/cbits/PrelIOUtils.c Sun Aug 9 17:35:52 2015
  6. @@ -19,27 +19,13 @@ void debugBelch2(const char*s, char *t)
  7. debugBelch(s,t);
  8. }
  9. -#if defined(HAVE_LIBCHARSET)
  10. -# include <libcharset.h>
  11. -#elif defined(HAVE_LANGINFO_H)
  12. -# include <langinfo.h>
  13. -#endif
  14. -
  15. #if !defined(mingw32_HOST_OS)
  16. +#include <stdlib.h>
  17. +#include <string.h>
  18. const char* localeEncoding(void)
  19. {
  20. -#if defined(HAVE_LIBCHARSET)
  21. - return locale_charset();
  22. -
  23. -#elif defined(HAVE_LANGINFO_H)
  24. - return nl_langinfo(CODESET);
  25. -
  26. -#else
  27. -#warning Depending on the unportable behavior of GNU iconv due to absence of both libcharset and langinfo.h
  28. - /* GNU iconv accepts "" to mean the current locale's
  29. - * encoding. Warning: This isn't portable.
  30. - */
  31. - return "";
  32. -#endif
  33. + char *l;
  34. + l = getenv("HS_ENCODING");
  35. + return l != NULL ? l : "latin1";
  36. }
  37. #endif