Bug#582421: [Patch] Floating point is broken if :lang is called in gvim

2010-05-21 Thread Bram Moolenaar

James -

 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.

OK, that simplifies things.  Looks a bit risky, but in the 7.3 branch we
have time to try it out for everyone.

- Bram

-- 
hundred-and-one symptoms of being an internet addict:
87. Everyone you know asks why your phone line is always busy ...and
you tell them to send an e-mail.

 /// Bram Moolenaar -- b...@moolenaar.net -- http://www.Moolenaar.net   \\\
///sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\download, build and distribute -- http://www.A-A-P.org///
 \\\help me help AIDS victims -- http://ICCF-Holland.org///



-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



Bug#582421: [Patch] Floating point is broken if :lang is called in gvim

2010-05-20 Thread James Vega
Bram,

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.

-- 
James
GPG Key: 1024D/61326D40 2003-09-02 James Vega james...@debian.org


float.diff
Description: Binary data


Bug#582421: [Patch] Floating point is broken if :lang is called in gvim

2010-05-20 Thread Bram Moolenaar

James -

 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.

- Bram

-- 
hundred-and-one symptoms of being an internet addict:
85. Choice between paying Compuserve bill and paying for kids education
is a no brainer -- although a bit painful for your kids.

 /// Bram Moolenaar -- b...@moolenaar.net -- http://www.Moolenaar.net   \\\
///sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\download, build and distribute -- http://www.A-A-P.org///
 \\\help me help AIDS victims -- http://ICCF-Holland.org///



-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



Bug#582421: [Patch] Floating point is broken if :lang is called in gvim

2010-05-20 Thread James Vega
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.

-- 
James
GPG Key: 1024D/61326D40 2003-09-02 James Vega james...@debian.org


signature.asc
Description: Digital signature


Bug#582421: [Patch] Floating point is broken if :lang is called in gvim

2010-05-20 Thread James Vega
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 james...@debian.org
diff --git a/src/ex_cmds2.c b/src/ex_cmds2.c
--- a/src/ex_cmds2.c
+++ b/src/ex_cmds2.c
@@ -4159,18 +4159,6 @@
 		set_helplang_default(mname);
 #endif
 		}
-
-		/* Set $LC_CTYPE, because it overrules $LANG, and
-		 * gtk_set_locale() calls setlocale() again.  gnome_init()
-		 * sets $LC_CTYPE to en_US (that's a bug!). */
-		if (what != VIM_LC_MESSAGES)
-		vim_setenv((char_u *)LC_CTYPE, name);
-# ifdef FEAT_GUI_GTK
-		/* Let GTK know what locale we're using.  Not sure this is
-		 * really needed... */
-		if (gui.in_use)
-		(void)gtk_set_locale();
-# endif
 	}
 
 # ifdef FEAT_EVAL
diff --git a/src/main.c b/src/main.c
--- a/src/main.c
+++ b/src/main.c
@@ -377,10 +377,6 @@
 	if (params.evim_mode)
 		mch_exit(1);
 	}
-#  if defined(HAVE_LOCALE_H) || defined(X_LOCALE)
-	/* Re-initialize locale, it may have been altered by gui_init_check() */
-	init_locale();
-#  endif
 }
 # endif
 #endif
@@ -1400,6 +1396,10 @@
 {
 setlocale(LC_ALL, );
 
+# ifdef FEAT_GUI_GTK
+/* Tell Gtk not to change our locale settings. */
+gtk_disable_setlocale();
+# endif
 # if defined(FEAT_FLOAT)  defined(LC_NUMERIC)
 /* Make sure strtod() uses a decimal point, not a comma. */
 setlocale(LC_NUMERIC, C);


signature.asc
Description: Digital signature