bug-gawk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [bug-gawk] Using ENVIRON["LANG"] = "C" instead of --characters-as-by


From: arnold
Subject: Re: [bug-gawk] Using ENVIRON["LANG"] = "C" instead of --characters-as-bytes
Date: Fri, 13 Mar 2015 01:48:53 -0600
User-agent: Heirloom mailx 12.4 7/29/08

Hi all.

I haven't had a chance to chime in, but Eli has pretty much explained
the situation. (Thanks, Eli.)

Hermann - sorry that the code doesn't meet your expectations. They
weren't unreasonable, but things just don't work that way. :-)

Andy - your suggestion would almost be enough. But, gawk caches the value
of MB_CUR_MAX at start-up time and uses that in a number of places;[1]
this variable would have to be reset if setlocale is called and there's
no way to make that accessable to an extension (at the moment).

I also don't think that it's a good idea to do so; changing locale in
the middle of a run seems to me to be a pretty bad idea. It's likely
to have all kinds of unintended side effects, and I thinks it's one of
those dragon-infested places on the map where it's better to stay away
from.

Thanks,

Arnold

[1] MB_CUR_MAX, at least on Linux, expands to a function call. Since,
in any given run of gawk, the locale doesn't (or isn't supposed to)
change, the value returned is always the same. Thus, it's safe and a
big performance win to get the value once and use it throughout the code.

"Andrew J. Schorr" <address@hidden> wrote:

> On Thu, Mar 12, 2015 at 09:47:17PM +0100, Hermann Peifer wrote:
> > On 2015-03-12 21:32, Eli Zaretskii wrote:
> > >
> > >By contrast, in your example the variable is set after Gawk already
> > >started, so nothing guarantees 'setlocale' will be called.
> > >
> > 
> > Thanks for your explanations. I see that my expectations were wrong.
>
> Note that there are a couple of ways to achieve your desired behavior:
>
> 1. Create a shared library extension to provide access to the setlocale
> function
>
> 2. One could imagine patching str_array.c:env_{clear,remove,store} to trigger 
> a
> call to setlocale when the LC_* values are changed.
>
> I suspect that #1 is the better approach...
>
> Regards,
> Andy



reply via email to

[Prev in Thread] Current Thread [Next in Thread]