镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

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

Closed

Description

@douglaskayama

From @GoogleCodeExporter on March 16, 2015 9:25

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

Copied from original issue: #511

Activity

  1. douglaskayama commented on May 4, 2015

    @douglaskayama
    MemberAuthor

    From @GoogleCodeExporter on March 16, 2015 9:25

    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:

  2. splhack commented on Nov 7, 2015

    @splhack
    Contributor

    It should be reported https://github.com/vim/vim/issues or Vim mailing list.

  3. denisw commented on Sep 23, 2020

    @denisw

    I reported this as vim/vim#7003. However, the bug might still be MacVim-specific.

    Vim tries to guard against this issue by running setlocale(LC_NUMERIC, "C") at startup, which is supposed to make float parsing independent of the system locale. This works fine when running (Mac)Vim from the terminal, but apparently not if MacVim is run from Finder.

  4. denisw commented on Sep 23, 2020

    @denisw

    Bram Moolenaar wrote this in vim/vim#7003:

    The GTK GUI had a similar problem, which was solved by setting LC_NUMERIC in gui_mch_init(). MacVim may need to do the same.

  5. ychin commented on Sep 25, 2020

    @ychin
    Member

    Fixed upstream in vim/vim@509f803

  6. added this to the snapshot-167 milestone on Sep 25, 2020
  7. added 2 commits that reference this issue on Dec 11, 2020
  8. yanncoupin commented on Dec 13, 2020

    @yanncoupin

    Wow, never realized my issue had been exported automatically. Seeing the issue I've had for the past 6 years solved in the latest changelog really made my day. But I had no idea it was based on my initial report that had been migrated. Thank you all for solving this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions