Bug#582421: [Patch] Floating point is broken if :lang is called in gvim
James Vega
jamessan at debian.org
Thu May 20 21:49:50 UTC 2010
On Thu, May 20, 2010 at 05:01:01PM -0400, James Vega wrote:
> On Thu, May 20, 2010 at 10:12:50PM +0200, Bram Moolenaar wrote:
> > > If the locale is changed in gvim via ":lang" to a locale which uses
> > > comma for the decimal separator, then floating point numbers are no
> > > longer usable. This only happens with the ":lang $locale" variant,
> > > since that sets $LANG before calling gtk_set_locale().
> > >
> > > env LANG=C gvim
> > > :lang es_ES.UTF-8
> > > :lang messages C " so errors are in English
> > > :echo ceil(1.2)
> > > E806: using Float as a String
> > > E116: Invalid arguments for function ceil(1.2)
> > > E15: Invalid expression: ceil(1.2)
> > > :echo str2float('1.2')
> > > 1,0
> > > :echo str2float('1,2')
> > > 1,2
> > >
> > > Attached patch fixes the issue by ensuring $LC_NUMERIC is set to C if
> > > the LC_ALL version of :lang is called.
> >
> > Thanks. In other places we do this:
> >
> > setlocale(LC_NUMERIC, "C");
> >
> > Thus I think we should do the same in this place.
>
> That won't work here. The issue is specifically to do with the
> environment variables present when gtk_set_locale is called. In fact,
> there's already an instance of “setlocal(LC_NUMERIC, "C");” a few lines
> above the code my patch adds.
Alternatively, it may be simpler to simply tell Gtk not to call
setlocale(LC_ALL, "") at all. This would remove the need for the change
introduced in 7.2.318 as well as the call to gtk_set_locale in
ex_language().
Attached patch does this and appears to work fine. Gtk dialogs created
after running ":lang es_ES.UTF-8" are properly translated.
--
James
GPG Key: 1024D/61326D40 2003-09-02 James Vega <jamessan at debian.org>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: gtk_disable_setlocale.diff
Type: text/x-diff
Size: 1241 bytes
Desc: not available
URL: <http://lists.alioth.debian.org/pipermail/pkg-vim-maintainers/attachments/20100520/1db97a6d/attachment.diff>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://lists.alioth.debian.org/pipermail/pkg-vim-maintainers/attachments/20100520/1db97a6d/attachment.pgp>
More information about the pkg-vim-maintainers
mailing list