rzyns / macvim

Automatically exported from code.google.com/p/macvim
0 stars 0 forks source link

float and str2float support broken for french (and probably every locale that use a comma as the decimal separator) #511

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

Set either language to French or the region to France in the Preferences.

Type the following commands in Macvim's console ( lines prefixed by >> are the 
answer, E123 are error codes):

:let a=0.5
>> E806 + E15
:let a=0,5
>> E806 + E15 + E15
:let a=str2float('0.5')
:let a
>> 0,0
:let a=str2float('0,5')
:let a
>> 0,5

What is the expected output? What do you see instead?

Here's what I should get:

:let a=0.5
:let a
>> 0.5
:let a=0,5
>> E15
:let a=str2float('0.5')
:let a
>> 0.5
:let a=str2float('0,5')
:let a
>> 0.0

Note that I was able to get the expected result when I started 
/Applications/MacVim.app/Contents/MacOS/MacVim from the Terminal with no LC_* 
env variables. The problem only exist when the app is started from the finder, 
the dock or Alfred.

What version of MacVim and OS X are you using (see "MacVim->About MacVim"
and  "Apple Menu->About This Mac" menu items, e.g. "Snapshot 40, 10.5.6
Intel")?

Tested with both snapshots 69 and release 73 (which I hoped would fix the 
issue), under Mavericks 10.9.4

Original issue reported on code.google.com by yann.cou...@gmail.com on 9 Sep 2014 at 1:45

GoogleCodeExporter commented 9 years ago
I made some progress on identifying the problem.

After adding some debugging code in src/eval.c to dump the current locale (via 
getlocale) in string2float I see it's different when launched via the command 
line (it's C as it should, even if I force it to another value from the shell) 
whereas it's fr_FR when launched from the finder. I have no explanation yet, 
but I guess it helps to explain the difference in behavior.

Attached, is the butt-ugly debug code I used

Original comment by yann.cou...@gmail.com on 19 Nov 2014 at 6:18

Attachments: