aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/os
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2018-12-27 22:49:44 +0100
committerJustin M. Keyes <justinkz@gmail.com>2018-12-27 22:49:44 +0100
commitc1015121ec626cab6cb384f544bc0be1a1760c0e (patch)
tree6cc9a5d1899a4486a24c491e07d17a7dd01f9503 /src/nvim/os
parent4f030ec24e0e148bbb83aedaef7dd629e5fef130 (diff)
parente1876c7ad1b5e30c0a9919e2c4587d11550c8507 (diff)
downloadrneovim-c1015121ec626cab6cb384f544bc0be1a1760c0e.tar.gz
rneovim-c1015121ec626cab6cb384f544bc0be1a1760c0e.tar.bz2
rneovim-c1015121ec626cab6cb384f544bc0be1a1760c0e.zip
Merge 'upstream/master' into pr-win-erw7
Diffstat (limited to 'src/nvim/os')
-rw-r--r--src/nvim/os/fs.c21
-rw-r--r--src/nvim/os/lang.c34
-rw-r--r--src/nvim/os/pty_process_unix.c2
3 files changed, 49 insertions, 8 deletions
diff --git a/src/nvim/os/fs.c b/src/nvim/os/fs.c
index cf00fd4f82..9a4391a0ae 100644
--- a/src/nvim/os/fs.c
+++ b/src/nvim/os/fs.c
@@ -110,7 +110,7 @@ bool os_isrealdir(const char *name)
/// Check if the given path is a directory or not.
///
-/// @return `true` if `fname` is a directory.
+/// @return `true` if `name` is a directory.
bool os_isdir(const char_u *name)
FUNC_ATTR_NONNULL_ALL
{
@@ -126,6 +126,25 @@ bool os_isdir(const char_u *name)
return true;
}
+/// Check if the given path is a directory and is executable.
+/// Gives the same results as `os_isdir()` on Windows.
+///
+/// @return `true` if `name` is a directory and executable.
+bool os_isdir_executable(const char *name)
+ FUNC_ATTR_NONNULL_ALL
+{
+ int32_t mode = os_getperm((const char *)name);
+ if (mode < 0) {
+ return false;
+ }
+
+#ifdef WIN32
+ return (S_ISDIR(mode));
+#else
+ return (S_ISDIR(mode) && (S_IXUSR & mode));
+#endif
+}
+
/// Check what `name` is:
/// @return NODE_NORMAL: file or directory (or doesn't exist)
/// NODE_WRITABLE: writable device, socket, fifo, etc.
diff --git a/src/nvim/os/lang.c b/src/nvim/os/lang.c
index 6b2a54ddbe..108a9c6c39 100644
--- a/src/nvim/os/lang.c
+++ b/src/nvim/os/lang.c
@@ -17,14 +17,31 @@ void lang_init(void)
{
#ifdef __APPLE__
if (os_getenv("LANG") == NULL) {
+ const char *lang_region = NULL;
+ CFTypeRef cf_lang_region = NULL;
+
CFLocaleRef cf_locale = CFLocaleCopyCurrent();
- CFTypeRef cf_lang_region = CFLocaleGetValue(cf_locale,
- kCFLocaleIdentifier);
- CFRetain(cf_lang_region);
- CFRelease(cf_locale);
+ if (cf_locale) {
+ cf_lang_region = CFLocaleGetValue(cf_locale, kCFLocaleIdentifier);
+ CFRetain(cf_lang_region);
+ lang_region = CFStringGetCStringPtr(cf_lang_region,
+ kCFStringEncodingUTF8);
+ CFRelease(cf_locale);
+ } else {
+ // Use the primary language defined in Preferences -> Language & Region
+ CFArrayRef cf_langs = CFLocaleCopyPreferredLanguages();
+ if (cf_langs && CFArrayGetCount(cf_langs) > 0) {
+ cf_lang_region = CFArrayGetValueAtIndex(cf_langs, 0);
+ CFRetain(cf_lang_region);
+ CFRelease(cf_langs);
+ lang_region = CFStringGetCStringPtr(cf_lang_region,
+ kCFStringEncodingUTF8);
+ } else {
+ ELOG("$LANG is empty and your primary language cannot be inferred.");
+ return;
+ }
+ }
- const char *lang_region = CFStringGetCStringPtr(cf_lang_region,
- kCFStringEncodingUTF8);
if (lang_region) {
os_setenv("LANG", lang_region, true);
} else {
@@ -37,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/src/nvim/os/pty_process_unix.c b/src/nvim/os/pty_process_unix.c
index bafbfe1e4b..bcf57e1b5b 100644
--- a/src/nvim/os/pty_process_unix.c
+++ b/src/nvim/os/pty_process_unix.c
@@ -12,7 +12,7 @@
#include <sys/ioctl.h>
// forkpty is not in POSIX, so headers are platform-specific
-#if defined(__FreeBSD__) || defined (__DragonFly__)
+#if defined(__FreeBSD__) || defined(__DragonFly__)
# include <libutil.h>
#elif defined(__OpenBSD__) || defined(__NetBSD__) || defined(__APPLE__)
# include <util.h>