Skip to content

Instantly share code, notes, and snippets.

@Milly
Last active November 11, 2015 16:39
Show Gist options
  • Save Milly/b403b935d3f0e5c4bb7b to your computer and use it in GitHub Desktop.
Save Milly/b403b935d3f0e5c4bb7b to your computer and use it in GitHub Desktop.
diff --git a/src/os_unix.c b/src/os_unix.c
index 8f059be..f7f4115 100644
--- a/src/os_unix.c
+++ b/src/os_unix.c
@@ -2498,6 +2498,14 @@ mch_FullName(fname, buf, len, force)
# else
cygwin_conv_to_posix_path(fname, posix_fname);
# endif
+ if (STRCMP(fname, posix_fname) != 0)
+ {
+ l = STRLEN(posix_fname);
+ while (0 < --l && posix_fname[l] == '/')
+ {
+ posix_fname[l] = NUL;
+ }
+ }
fname = posix_fname;
#endif
set nocompatible
function s:test()
let r = []
for s in [
\ '.',
\ './',
\ './/',
\ '..',
\ '../',
\ '..//',
\ 'file',
\ 'file/',
\ 'file//',
\ 'dir',
\ 'dir/',
\ 'dir//',
\ 'notexists',
\ 'notexists/',
\ 'notexists//',
\ ]
call add(r, printf('%-16s -> %s', s, fnamemodify(s, ':.')))
endfor
call writefile(r, '/tmp/out.txt')
endfunction
cd /tmp
call mkdir('/tmp/dir')
call writefile([], '/tmp/file')
call s:test()
quit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment