$OpenBSD: patch-src_lTerm_unix_stubs_c,v 1.1 2013/01/10 18:55:30 chrisz Exp $

work around nl_langinfo(CODESET) bug for LC_CTYPE=C
see
http://hackage.haskell.org/trac/ghc/ticket/4080
http://www.haible.de/bruno/packages-libcharset.html

--- src/lTerm_unix_stubs.c.orig	Thu Dec 13 13:06:26 2012
+++ src/lTerm_unix_stubs.c	Thu Dec 13 13:23:28 2012
@@ -29,7 +29,7 @@ CAMLprim value lt_unix_get_system_encoding()
 
 #include <signal.h>
 #include <locale.h>
-#include <langinfo.h>
+#include <localcharset.h>
 
 CAMLprim value lt_unix_get_sigwinch()
 {
@@ -45,9 +45,9 @@ CAMLprim value lt_unix_get_sigwinch()
 CAMLprim value lt_unix_get_system_encoding()
 {
   /* Set the locale according to environment variables: */
-  char *locale = setlocale(LC_CTYPE, "");
+  const char *locale = setlocale(LC_CTYPE, "");
   /* Get the codeset used by current locale: */
-  char *codeset = nl_langinfo(CODESET);
+  const char *codeset = locale_charset();
   /* Reset the locale: */
   setlocale(LC_CTYPE, locale);
   /* If the encoding cannot be determined, just use ascii: */
