mirror of
https://github.com/neovim/neovim.git
synced 2024-12-24 13:15:09 -07:00
vim-patch:8.2.0985: simplify() does not remove slashes from "///path"
Problem: Simplify() does not remove slashes from "///path".
Solution: Reduce > 2 slashes to one. (closes vim/vim#6263)
fdcbe3c3fe
Omit Test_readdirex() change: changed again in patch 9.0.0323.
Co-authored-by: Bram Moolenaar <Bram@vim.org>
This commit is contained in:
parent
2d24558c28
commit
8c8c6fb05a
@ -1538,6 +1538,13 @@ void simplify_filename(char *filename)
|
|||||||
} while (vim_ispathsep(*p));
|
} while (vim_ispathsep(*p));
|
||||||
}
|
}
|
||||||
char *start = p; // remember start after "c:/" or "/" or "///"
|
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 {
|
do {
|
||||||
// At this point "p" is pointing to the char following a single "/"
|
// At this point "p" is pointing to the char following a single "/"
|
||||||
|
@ -383,6 +383,10 @@ func Test_simplify()
|
|||||||
call assert_equal('/', simplify('/.'))
|
call assert_equal('/', simplify('/.'))
|
||||||
call assert_equal('/', simplify('/..'))
|
call assert_equal('/', simplify('/..'))
|
||||||
call assert_equal('/...', simplify('/...'))
|
call assert_equal('/...', simplify('/...'))
|
||||||
|
call assert_equal('//path', simplify('//path'))
|
||||||
|
call assert_equal('/path', simplify('///path'))
|
||||||
|
call assert_equal('/path', simplify('////path'))
|
||||||
|
|
||||||
call assert_equal('./dir/file', './dir/file'->simplify())
|
call assert_equal('./dir/file', './dir/file'->simplify())
|
||||||
call assert_equal('./dir/file', simplify('.///dir//file'))
|
call assert_equal('./dir/file', simplify('.///dir//file'))
|
||||||
call assert_equal('./dir/file', simplify('./dir/./file'))
|
call assert_equal('./dir/file', simplify('./dir/./file'))
|
||||||
@ -2069,6 +2073,7 @@ endfunc
|
|||||||
|
|
||||||
" Test for the inputdialog() function
|
" Test for the inputdialog() function
|
||||||
func Test_inputdialog()
|
func Test_inputdialog()
|
||||||
|
set timeout timeoutlen=10
|
||||||
if has('gui_running')
|
if has('gui_running')
|
||||||
call assert_fails('let v=inputdialog([], "xx")', 'E730:')
|
call assert_fails('let v=inputdialog([], "xx")', 'E730:')
|
||||||
call assert_fails('let v=inputdialog("Q", [])', 'E730:')
|
call assert_fails('let v=inputdialog("Q", [])', 'E730:')
|
||||||
@ -2078,6 +2083,7 @@ func Test_inputdialog()
|
|||||||
call feedkeys(":let v=inputdialog('Q:', 'xx', 'yy')\<CR>\<Esc>", 'xt')
|
call feedkeys(":let v=inputdialog('Q:', 'xx', 'yy')\<CR>\<Esc>", 'xt')
|
||||||
call assert_equal('yy', v)
|
call assert_equal('yy', v)
|
||||||
endif
|
endif
|
||||||
|
set timeout& timeoutlen&
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
" Test for inputlist()
|
" Test for inputlist()
|
||||||
|
Loading…
Reference in New Issue
Block a user