aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/nvim/os/lang.c5
-rw-r--r--test/functional/viml/lang_spec.lua9
2 files changed, 14 insertions, 0 deletions
diff --git a/src/nvim/os/lang.c b/src/nvim/os/lang.c
index 900cd1f53a..108a9c6c39 100644
--- a/src/nvim/os/lang.c
+++ b/src/nvim/os/lang.c
@@ -54,6 +54,11 @@ void lang_init(void)
CFRelease(cf_lang_region);
# ifdef HAVE_LOCALE_H
setlocale(LC_ALL, "");
+
+# ifdef LC_NUMERIC
+ // Make sure strtod() uses a decimal point, not a comma.
+ setlocale(LC_NUMERIC, "C");
+# endif
# endif
}
#endif
diff --git a/test/functional/viml/lang_spec.lua b/test/functional/viml/lang_spec.lua
index 3ba9221aef..6d603b8822 100644
--- a/test/functional/viml/lang_spec.lua
+++ b/test/functional/viml/lang_spec.lua
@@ -18,4 +18,13 @@ describe('viml', function()
]])
eq(nil, string.find(eval('v:errmsg'), '^E129'))
end)
+
+ it('str2float is not affected by locale', function()
+ if exc_exec('lang ctype sv_SE.UTF-8') ~= 0 then
+ pending("Locale sv_SE.UTF-8 not supported")
+ return
+ end
+ clear{env={LANG="", LC_NUMERIC="sv_SE.UTF-8"}}
+ eq(2.2, eval('str2float("2.2")'))
+ end)
end)