On 3/27/19 12:26 AM, Ted Unangst wrote:
Karl Williamson wrote:
This has been reported from multiple sources, and we at Perl 5 have
diagnosed the problem
If LC_CTYPE is set to C.UTF-8, it is not possible to set any other
category independently to either C or C.UTF-8 without inadvertently
setting LC_CTYPE back to C. The attached program demonstrates the problem.
Thanks for a very thorough report. I believe your guesses about the
implementation were quite accurate. :)
This should fix things.
Does it work if 'oldloc' is 0? a legal value
Index: newlocale.c
===================================================================
RCS file: /home/cvs/src/lib/libc/locale/newlocale.c,v
retrieving revision 1.1
diff -u -p -r1.1 newlocale.c
--- newlocale.c 5 Sep 2017 03:16:13 -0000 1.1
+++ newlocale.c 27 Mar 2019 06:25:01 -0000
@@ -22,8 +22,7 @@
#include "rune.h"
locale_t
-newlocale(int mask, const char *locname,
- locale_t oldloc __attribute__((__unused__)))
+newlocale(int mask, const char *locname, locale_t oldloc)
{
int ic, flag;
@@ -45,7 +44,7 @@ newlocale(int mask, const char *locname,
/* Only character encoding has thread-specific effects. */
if ((mask & LC_CTYPE_MASK) == 0)
- return _LOCALE_C;
+ return oldloc;
/* The following may initialize UTF-8 for later use. */
if ((locname = _get_locname(LC_CTYPE, locname)) == NULL) {