Front page | perl.perl5.porters |
Postings from May 2012
Re: Does anyone know why Perl always calls init_i18nl10n() ?
Thread Previous
From:
Brian Fraser
Date:
May 24, 2012 19:32
Subject:
Re: Does anyone know why Perl always calls init_i18nl10n() ?
Message ID:
CA+nL+nb-=1Tx7=hqWWy7=d3-6OdjhQCbHm3mWp6DkuYR4mbseg@mail.gmail.com
On Thu, Feb 9, 2012 at 7:45 AM, Nicholas Clark <nick@ccl4.org> wrote:
> On Tue, Feb 07, 2012 at 01:05:09PM -0700, Karl Williamson wrote:
> > One of the first things that Perl does at initialization is to call this
> > function, which sets up things in case there is a 'use locale' in the
> > program (or maybe some other reason that I have failed to divine).
> >
> > It seems to me that it should only be called if there is reason to do
> > so, and I don't see a reason to do so if there is neither a 'use locale'
> > in the program, nor a call to POSIX:setlocale() itself.
> >
> > It seems to me that a reasonable implementation would be to call this
> > function only upon first use of either of these.
>
> Well, it will change behavior in a lot more places. One example that
> springs
> to mind because of recent activity is:
>
> $ LANG=de_DE.UTF-8 ./perl -Ilib -MPOSIX -le 'print strftime("%A, %B %d,
> %Y", localtime)'
> Donnerstag, Februar 09, 2012
>
> ...
>
> $ git diff
> diff --git a/perl.c b/perl.c
> index e8a9c23..678568c 100644
> --- a/perl.c
> +++ b/perl.c
> @@ -284,7 +284,7 @@ perl_construct(pTHXx)
> JMPENV_BOOTSTRAP;
> STATUS_ALL_SUCCESS;
>
> - init_i18nl10n(1);
> + /*init_i18nl10n(1);*/
> SET_NUMERIC_STANDARD();
>
> #if defined(LOCAL_PATCH_COUNT)
> $ LANG=de_DE.UTF-8 ./perl -Ilib -MPOSIX -le 'print strftime("%A, %B %d,
> %Y", localtime)'
> Thursday, February 09, 2012
>
> I suspect it would be "hard" to work out all the places that actually end
> up
> depending on the locale.
>
> > If no one can think of a reason for it to be called unconditionally,
> > I'll experiment with changing it early in 5.17.
>
>
> I'm probably telling you something you've already dug into, but the first
> call to setlocale() is part of this commit:
>
> commit 4633a7c4bad06b471d9310620b7fe8ddd158cccd
> Author: Larry Wall <lwall@scalpel.netlabs.com>
> Date: Tue Nov 21 10:01:00 1995 +1200
>
> 5.002 beta 1
>
> If you're adventurous, have a look at
>
> ftp://ftp.sems.com/pub/outgoing/perl5.0/perl5.002beta1.tar.gz
>
> Many thanks to Andy for doing the integration.
>
> Obviously, if you consult the bugs database, you'll note there are
> still plenty of buglets that need fixing, and several enhancements that
> I've intended to put in still haven't made it in (Hi, Tim and Ilya).
> But I think it'll be pretty stable. And you can start to fiddle around
> with prototypes (which are, of course, still totally undocumented).
>
> Packrats, don't worry too much about readvertising this widely.
> Nowadays we're on a T1 here, so our bandwidth is okay.
>
> Have the appropriate amount of jollity.
>
> Larry
>
> and a lot of the POSIX docs have changes like this:
>
> =item lc EXPR
>
> Returns an lowercased version of EXPR. This is the internal function
> -implementing the \L escape in double-quoted strings.
> +implementing the \L escape in double-quoted strings.
> +Should respect any POSIX setlocale() settings.
>
> Nicholas Clark
>
Just a data point, but there's been an open bug about this since 2006:
https://rt.perl.org/rt3/Ticket/Display.html?id=38193
Thread Previous