On 04/10/11 14:52, Bram Moolenaar wrote:

Tony Mechelynck wrote:

Vim does explicitly set LC_NUMERIC to "C".  And that's what happens for
me.  I can't guess why it's different for you.


Neither can I; but adding a few :echomsg commands shows the following:

- $LC_NUMERIC is "C" on entry to the vimrc
- it is still "C" while sourcing the last global after-plugin
- it has become empty (and is listed as "en_US.UTF-8" in the output of
:lang with no arguments) at the GUIEnter event in gvim with GTK2/Gnome2 GUI
- it remains set to "C" if I run the same Vim executable in console mode.

I suspect the line marked below with<----- at line 1467 of main.c but I
don't know GTK well enough to be sure. Do you think it would be worth
swapping the two ifdef blocks to see if it changes anything? (Not this
second, I'm going to bed.)

/*
   * Setup to use the current locale (for ctype() and many other things).
   */
      static void
init_locale()
{
      setlocale(LC_ALL, "");

# ifdef FEAT_GUI_GTK
      /* Tell Gtk not to change our locale settings. */
      gtk_disable_setlocale();<----- this line
# endif
# if defined(FEAT_FLOAT)&&  defined(LC_NUMERIC)
      /* Make sure strtod() uses a decimal point, not a comma. */
      setlocale(LC_NUMERIC, "C");
# endif

I hope you are not checking the $LC_NUMERIC environment variable, it is
only used when calling setlocale(), not by the library functions where
the value of the locale matters.

You need to use setlocale(LC_NUMERIC, NULL) to check the actual value.


Swapping the blocks didn't change anything.

I remain with the observation that, in gvim with GTK2/Gnome2 GUI, $LC_NUMERIC is reset when starting the GUI, as shown by the following (when in gvim running in GUI mode):

- In the reply to :lang with no arguments, $LC_NUMERIC is set to the default value, in my case en_US.UTF-8 - when invoking a shell from within gvim, set|more shows that $LC_NUMERIC is not set

On the contrary, when running in console mode, $LC_NUMERIC is set to C in the output of :lang but not in a subshell.

Running gvim in a "decimal-point is comma" locale, as follows (in bash):

        LANG=fr_BE.UTF-8 gvim

gives the following:

:echo acos(0)
1,570796
(with a comma)

:echo 1.2 + 3.4
E806: using Float as a String
E15: Invalid expression: 1.2 + 3.4

:echo 1,2 + 3,4
1
E15: Invalid expression: ,2 + 3,4
E15: Invalid expression: ,2 + 3,4

while on my usual (en_US.UTF-8) locale the results are (in a different instance of the same gvim executable)

:echo acos(0)
1.570796
(with a dot)

:echo 1.2 + 3.4
4.6

:echo 1,2 + 3,4
1
E15: Invalid expression: ,2 + 3,4
E15: Invalid expression: ,2 + 3,4

In console mode, the results are correct (as in en_US.UTF-8 gvim), even in fr_BE.UTF-8 vim.


Best regards,
Tony.
--
If you're not part of the solution, you're part of the precipitate.

--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Raspunde prin e-mail lui