diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2016-08-18 18:53:03 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-08-18 18:53:03 -0400 |
commit | 6f0f8e7f4abd7a238250b71f8de208ff81e78d9c (patch) | |
tree | 62fd524dece5b2b8d1b131f367e6cf2e375eef0e | |
parent | ae6db26b0956f4a30185cfe0294143e73a37052e (diff) | |
parent | ccb6af064fe879dc8e213a582f7f938ad1972ae3 (diff) | |
download | rneovim-6f0f8e7f4abd7a238250b71f8de208ff81e78d9c.tar.gz rneovim-6f0f8e7f4abd7a238250b71f8de208ff81e78d9c.tar.bz2 rneovim-6f0f8e7f4abd7a238250b71f8de208ff81e78d9c.zip |
Merge #5198 from equalsraf/windows-path-is-absolute
Windows: path_is_absolute()
-rw-r--r-- | src/nvim/path.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/nvim/path.c b/src/nvim/path.c index c20dffa9b1..a2617973b1 100644 --- a/src/nvim/path.c +++ b/src/nvim/path.c @@ -2186,9 +2186,16 @@ static int path_get_absolute_path(const char_u *fname, char_u *buf, /// Check if the given file is absolute. /// -/// This just checks if the file name starts with '/' or '~'. /// @return `TRUE` if "fname" is absolute. int path_is_absolute_path(const char_u *fname) { +#ifdef WIN32 + // A name like "d:/foo" and "//server/share" is absolute + return ((isalpha(fname[0]) && fname[1] == ':' + && vim_ispathsep_nocolon(fname[2])) + || (vim_ispathsep_nocolon(fname[0]) && fname[0] == fname[1])); +#else + // UNIX: This just checks if the file name starts with '/' or '~'. return *fname == '/' || *fname == '~'; +#endif } |