develooper Front page | perl.perl5.porters | Postings from July 2013

[perl #96240] locale and LC_ALL on NetBSD

From:
Karl Williamson via RT
Date:
July 8, 2013 00:10
Subject:
[perl #96240] locale and LC_ALL on NetBSD
Message ID:
rt-3.6.HEAD-2552-1373242235-1755.96240-15-0@perl.org
On Thu Aug 04 03:57:22 2011, tonyc wrote:
> On Wed, Aug 03, 2011 at 06:54:50PM -0700, msporleder@gmail.com (via
> RT) wrote:
> > Setting LC_ALL causes the locale warning.  My system has locale
> files
> > and I see perl reading them.  How can I troubleshoot this more?
> >
> > d_setlocale='define';
> >
> > ~ $ export LC_ALL=fr_FR.ISO8859-1~ $ perl -e '1;'
> > perl: warning: Setting locale failed.
> > perl: warning: Please check that your locale settings:
> >         LC_ALL = "fr_FR.ISO8859-1",
> >         LANG = (unset)
> >     are supported and installed on your system.
> > perl: warning: Falling back to the standard locale ("C").
> 
> From what I can see in reading locale.c, perl attempts to setlocale()
> for each category.  On NetBSD this fails for LC_COLLATE:
> 
> deimos$ uname -prs
> NetBSD 5.1 x86_64
> deimos$ LC_ALL=fr_FR.ISO8859-1 ./setlocale
> LC_ALL      : C/fr_FR.ISO8859-1/fr_FR.ISO8859-1/fr_FR.ISO8859-
> 1/fr_FR.ISO8859-1/fr_FR.ISO8859-1
> LC_COLLATE  : (null)
> LC_CTYPE    : fr_FR.ISO8859-1
> LC_MESSAGES : fr_FR.ISO8859-1
> LC_MONETARY : fr_FR.ISO8859-1
> LC_NUMERIC  : fr_FR.ISO8859-1
> LC_TIME     : fr_FR.ISO8859-1
> 
> Setting only the categories you need works (as long as they aren't
> LC_COLLATE):
> 
> deimos$ LC_NUMERIC=fr_FR.ISO8859-1 LC_CTYPE=fr_FR.ISO8859-1
> ./setlocale
> LC_ALL      : C/fr_FR.ISO8859-1/C/fr_FR.ISO8859-1/C/C
> LC_COLLATE  : C
> LC_CTYPE    : fr_FR.ISO8859-1
> LC_MESSAGES : C
> LC_MONETARY : C
> LC_NUMERIC  : fr_FR.ISO8859-1
> LC_TIME     : C
> deimos$ LC_COLLATE=fr_FR.ISO8859-1 ./setlocale
> LC_ALL      : C
> LC_COLLATE  : (null)
> LC_CTYPE    : C
> LC_MESSAGES : C
> LC_MONETARY : C
> LC_NUMERIC  : C
> LC_TIME     : C
> 
> 
> The source for the setlocale tool:
> 
> deimos$ cat setlocale.c
> #include <locale.h>
> #include <stdio.h>
> #include <errno.h>
> 
> #define entry(s) { s, #s }
> #define quote_(s) #s
> #define quote(s) quote_(s)
> 
> struct locale_category {
>   int id;
>   char const *name;
> } categories[] = {
>   entry(LC_ALL),
>   entry(LC_COLLATE),
>   entry(LC_CTYPE),
>   entry(LC_MESSAGES),
>   entry(LC_MONETARY),
>   entry(LC_NUMERIC),
>   entry(LC_TIME)
> };
> 
> const int category_count = sizeof(categories) / sizeof(*categories);
> 
> int main() {
>   int i;
>   for (i = 0; i < category_count; ++i)
>     printf("%-12s: %s\n", categories[i].name,
> setlocale(categories[i].id, ""));
> 
>   return 0;
> }
> 

We can't fix the underlying OS.  But there is an undocumented compile
option you can use to get Perl to not try to set LC_COLLATE.  It is
-DNO_LOCALE_COLLATE
This is a C flag, and can be placed into Configure using this parameter
./Configure -Accflags=-DNO_LOCALE_COLLATE ...

You can similarly turn off any other individual category.  

I intend to close this ticket in 30 days unless I hear something to the
contrary
-- 
Karl Williamson

---
via perlbug:  queue: perl5 status: open
https://rt.perl.org:443/rt3/Ticket/Display.html?id=96240



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About