Merge pull request #30798 from zeertzjq/vim-8.2.0985

vim-patch:8.2.{0985,0986}: simplify() does not remove slashes from "///path"
This commit is contained in:
zeertzjq 2024-10-13 19:11:53 +08:00 committed by GitHub
commit 36890824c7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 15 additions and 0 deletions

View File

@ -1538,6 +1538,13 @@ void simplify_filename(char *filename)
} while (vim_ispathsep(*p));
}
char *start = p; // remember start after "c:/" or "/" or "///"
#ifdef UNIX
// Posix says that "//path" is unchanged but "///path" is "/path".
if (start > filename + 2) {
STRMOVE(filename + 1, p);
start = p = filename + 1;
}
#endif
do {
// At this point "p" is pointing to the char following a single "/"

View File

@ -383,6 +383,12 @@ func Test_simplify()
call assert_equal('/', simplify('/.'))
call assert_equal('/', simplify('/..'))
call assert_equal('/...', simplify('/...'))
call assert_equal('//path', simplify('//path'))
if has('unix')
call assert_equal('/path', simplify('///path'))
call assert_equal('/path', simplify('////path'))
endif
call assert_equal('./dir/file', './dir/file'->simplify())
call assert_equal('./dir/file', simplify('.///dir//file'))
call assert_equal('./dir/file', simplify('./dir/./file'))
@ -2069,6 +2075,7 @@ endfunc
" Test for the inputdialog() function
func Test_inputdialog()
set timeout timeoutlen=10
if has('gui_running')
call assert_fails('let v=inputdialog([], "xx")', 'E730:')
call assert_fails('let v=inputdialog("Q", [])', 'E730:')
@ -2078,6 +2085,7 @@ func Test_inputdialog()
call feedkeys(":let v=inputdialog('Q:', 'xx', 'yy')\<CR>\<Esc>", 'xt')
call assert_equal('yy', v)
endif
set timeout& timeoutlen&
endfunc
" Test for inputlist()