view src/readline-4-locale.patch @ 7186:19a46de50b18 default tip @

* src/jasper.mk: update to v4.2.4
author John Donoghue <john.donoghue@ieee.org>
date Thu, 02 May 2024 09:22:30 -0400
parents a6f1111a9f1d
children
line wrap: on
line source

--- readline-8.2/nls.c.orig	2022-11-22 18:41:48.302144300 +0100
+++ readline-8.2/nls.c	2022-12-03 18:37:54.991412600 +0100
@@ -49,6 +49,11 @@
 
 #include <ctype.h>
 
+#if defined (_WIN32)
+#  include <windows.h>
+#  include <versionhelpers.h>
+#endif
+
 #include "rldefs.h"
 #include "readline.h"
 #include "rlshell.h"
@@ -109,7 +114,11 @@
   char *cp;
   size_t len;
 
-#if HAVE_LANGINFO_CODESET
+#if defined (_WIN32)
+  /* On Windows, the relevant "locale" is the selected codepage of the used
+     console. */
+  return (IsWindows7OrGreater () && (GetConsoleCP () == 65001));
+#elif HAVE_LANGINFO_CODESET
   cp = nl_langinfo (CODESET);
   return (STREQ (cp, "UTF-8") || STREQ (cp, "utf8"));
 #else
@@ -138,11 +147,18 @@
 #if defined (HAVE_SETLOCALE)
   if (lspec == 0 || *lspec == 0)
     lspec = setlocale (LC_CTYPE, (char *)NULL);
+#if defined (_WIN32)
+  /* Setting an UTF-8 locale is not a no-op on Windows.  Instead the
+     information about the locale is lost.  Use whatever we got at this
+     point. */
+  ret = lspec;
+#else
   if (lspec == 0)
     lspec = "";
   ret = setlocale (LC_CTYPE, lspec);	/* ok, since it does not change locale */
   if (ret == 0 || *ret == 0)
     ret = setlocale (LC_CTYPE, (char *)NULL);
+#endif
   if (ret == 0 || *ret == 0)
     ret = RL_DEFAULT_LOCALE;
 #else