Hi Matthias,

On Mon, Feb 3, 2020 at 3:31 PM Matthias Kilian <[email protected]> wrote:
> IIRC, the complaint (from that time 10 years ago) was that ghci
> crached at the same moment you enter a character not supported by
> whatever LC_CTYPE contains.
>
> So, yes, if  you have the time to rebuild without that patch and
> test it , I'll love it.

See the attached patch. It removes the three patches with HS_ENCODING
in them and adds a configure option as suggested by Ingo.

So far I confirmed that:
  * getLocaleEncoding is correctly steered by LC_ALL
  * utf8 characters are accepted by ghci and correctly parsed into
String literals
  * utf8 characters are printed back correctly
  * utf8 characters become ? when locale is set to ASCII
By utf8 I mean Cyrillic :)

Thanks
Greg
--
nest.cx is Gmail hosted, use PGP: https://pgp.key-server.io/0x0B1542BD8DF5A1B0
Fingerprint: 5E2B 2D0E 1E03 2046 BEC3  4D50 0B15 42BD 8DF5 A1B0
From f48a1ee1ee02e4b6b6557a0ec2709cb8625b95d0 Mon Sep 17 00:00:00 2001
From: Greg Steuck <[email protected]>
Date: Tue, 4 Feb 2020 07:55:05 -0800
Subject: [PATCH] Remove HS_ENCODING. LC_ALL works now.

---
 lang/ghc/Makefile                             | 15 ++++---
 .../patch-libraries_base_GHC_IO_Encoding_hs   | 15 -------
 .../patches/patch-libraries_base_System_IO_hs | 14 -------
 .../patch-libraries_base_cbits_PrelIOUtils_c  | 40 -------------------
 4 files changed, 9 insertions(+), 75 deletions(-)
 delete mode 100644 lang/ghc/patches/patch-libraries_base_GHC_IO_Encoding_hs
 delete mode 100644 lang/ghc/patches/patch-libraries_base_System_IO_hs
 delete mode 100644 lang/ghc/patches/patch-libraries_base_cbits_PrelIOUtils_c

diff --git lang/ghc/Makefile lang/ghc/Makefile
index 6f8377f5c4e..8358efa3b08 100644
--- lang/ghc/Makefile
+++ lang/ghc/Makefile
@@ -12,6 +12,7 @@ COMMENT =		compiler for the functional language Haskell
 NO_CCACHE =		Yes
 
 DISTNAME =		ghc-${MODGHC_VER}
+REVISION =		0
 CATEGORIES =		lang devel
 HOMEPAGE =		https://www.haskell.org/ghc/
 
@@ -31,7 +32,7 @@ MODPY_VERSION =		${MODPY_DEFAULT_VERSION_3}
 # binaries, with BSD, GPLv2 and Perl artistic license.
 PERMIT_PACKAGE =		Yes
 
-WANTLIB += c charset curses ffi gmp iconv m pthread util
+WANTLIB += c curses ffi gmp iconv m pthread util
 
 LIB_DEPENDS =		converters/libiconv \
 			devel/gmp \
@@ -42,13 +43,13 @@ BUILD_DEPENDS =		archivers/bzip2 \
 			textproc/py-sphinx
 RUN_DEPENDS =
 
-# The bootstrapping compiler needs gcc4, but the new ghc can be built
-# with clang. So we just BUILD_DEPEND on gcc instead of using the gcc4
+# The bootstrapping compiler needs gcc, but the new ghc can be built
+# with clang. So we just BUILD_DEPEND on gcc instead of using the gcc
 # MODULE, because the latter would also add some wrapper scripts
 BUILD_DEPENDS +=	lang/gcc/8>=8,<9
 
 # We can't use the wrapper script, because it then gets hardcoded into
-# the packaged ghc. So we explicitely use -Wl,-z,wxneeded (see
+# the packaged ghc. So we explicitly use -Wl,-z,wxneeded (see
 # CONFIGURE_ENV below)
 USE_WXNEEDED =		special
 
@@ -183,17 +184,19 @@ post-patch:
 		echo 'LD_LIBRARY_PATH=${BOOTSTRAP_SHLIBS} \' && \
 		printf 'exec ${WRKDIR}/bootstrap/bin/%s "$$@"\n' "$$f"; \
 	done
+	cp ${WRKSRC}/mk/build.mk{.sample,}
+	echo libraries/base_CONFIGURE_OPTS+=--configure-option=--with-libcharset=no >> ${WRKSRC}/mk/build.mk
 
 do-test:
 	ulimit -c 0 && \
 	cd ${WRKSRC}/testsuite/tests && \
-	exec ${SETENV} ${MAKE_ENV} HS_ENCODING=utf-8 \
+	exec ${SETENV} ${MAKE_ENV} LC_CTYPE=en_US.UTF-8 \
 		${MAKE_PROGRAM} ${MAKE_FLAGS} \
 		PYTHON="${MODPY_BIN}"
 
 
 
-# It doesn't matter wether this is the actual date of the bootstrapper
+# It doesn't matter whether this is the actual date of the bootstrapper
 # build. It's just used to get different distfiles whenever new
 # bootstrappers have to be built.
 BOOTSTRAP_DATE =	20200103
diff --git lang/ghc/patches/patch-libraries_base_GHC_IO_Encoding_hs lang/ghc/patches/patch-libraries_base_GHC_IO_Encoding_hs
deleted file mode 100644
index 3c53dc0173e..00000000000
--- lang/ghc/patches/patch-libraries_base_GHC_IO_Encoding_hs
+++ /dev/null
@@ -1,15 +0,0 @@
-$OpenBSD: patch-libraries_base_GHC_IO_Encoding_hs,v 1.5 2019/09/30 11:44:18 kili Exp $
-Index: libraries/base/GHC/IO/Encoding.hs
---- libraries/base/GHC/IO/Encoding.hs.orig
-+++ libraries/base/GHC/IO/Encoding.hs
-@@ -102,7 +102,9 @@ utf32le = UTF32.utf32le
- utf32be  :: TextEncoding
- utf32be = UTF32.utf32be
- 
---- | The Unicode encoding of the current locale
-+-- | The Unicode encoding of the current locale. On OpenBSD this is set
-+-- to the value of the environment variable 'HS_ENCODING' or to 'latin1'
-+-- if that variable isn't set.
- --
- -- @since 4.5.0.0
- getLocaleEncoding :: IO TextEncoding
diff --git lang/ghc/patches/patch-libraries_base_System_IO_hs lang/ghc/patches/patch-libraries_base_System_IO_hs
deleted file mode 100644
index 59b02098047..00000000000
--- lang/ghc/patches/patch-libraries_base_System_IO_hs
+++ /dev/null
@@ -1,14 +0,0 @@
-$OpenBSD: patch-libraries_base_System_IO_hs,v 1.5 2014/11/22 20:23:23 kili Exp $
---- libraries/base/System/IO.hs.orig	Thu Jul 10 06:32:11 2014
-+++ libraries/base/System/IO.hs	Sun Nov  2 21:50:32 2014
-@@ -174,7 +174,9 @@ module System.IO (
-     -- on your system, which is also available as 'localeEncoding'.
-     -- (GHC note: on Windows, we currently do not support double-byte
-     -- encodings; if the console\'s code page is unsupported, then
--    -- 'localeEncoding' will be 'latin1'.)
-+    -- 'localeEncoding' will be 'latin1'. On OpenBSD, the default
-+    -- encoding is always 'latin1' but can be overridden with the
-+    -- environment variable `HS_ENCODING')
-     --
-     -- Encoding and decoding errors are always detected and reported,
-     -- except during lazy I/O ('hGetContents', 'getContents', and
diff --git lang/ghc/patches/patch-libraries_base_cbits_PrelIOUtils_c lang/ghc/patches/patch-libraries_base_cbits_PrelIOUtils_c
deleted file mode 100644
index a23eeb7c8f1..00000000000
--- lang/ghc/patches/patch-libraries_base_cbits_PrelIOUtils_c
+++ /dev/null
@@ -1,40 +0,0 @@
-$OpenBSD: patch-libraries_base_cbits_PrelIOUtils_c,v 1.3 2015/09/19 07:42:57 kili Exp $
-
-We have very limited locale support so used latin1 as default codeset
-which can be overridden by the environment variable `HS_ENCODING'.
-
---- libraries/base/cbits/PrelIOUtils.c.orig	Tue Dec 23 03:31:10 2014
-+++ libraries/base/cbits/PrelIOUtils.c	Sun Aug  9 17:35:52 2015
-@@ -19,27 +19,13 @@ void debugBelch2(const char*s, char *t)
-     debugBelch(s,t);
- }
- 
--#if defined(HAVE_LIBCHARSET)
--#  include <libcharset.h>
--#elif defined(HAVE_LANGINFO_H)
--#  include <langinfo.h>
--#endif
--
- #if !defined(mingw32_HOST_OS)
-+#include <stdlib.h>
-+#include <string.h>
- const char* localeEncoding(void)
- {
--#if defined(HAVE_LIBCHARSET)
--    return locale_charset();
--
--#elif defined(HAVE_LANGINFO_H)
--    return nl_langinfo(CODESET);
--
--#else
--#warning Depending on the unportable behavior of GNU iconv due to absence of both libcharset and langinfo.h
--    /* GNU iconv accepts "" to mean the current locale's
--     * encoding. Warning: This isn't portable.
--     */
--    return "";
--#endif
-+	char *l;
-+	l = getenv("HS_ENCODING");
-+	return l != NULL ? l : "latin1";
- }
- #endif
-- 
2.25.0

Reply via email to