mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
glob2regpat(): handle empty string.
This commit is contained in:
parent
765d394f18
commit
894fcb778e
@ -10792,7 +10792,7 @@ static void f_glob2regpat(typval_T *argvars, typval_T *rettv)
|
|||||||
char_u *pat = get_tv_string_chk(&argvars[0]); // NULL on type error
|
char_u *pat = get_tv_string_chk(&argvars[0]); // NULL on type error
|
||||||
|
|
||||||
rettv->v_type = VAR_STRING;
|
rettv->v_type = VAR_STRING;
|
||||||
rettv->vval.v_string = (pat == NULL)
|
rettv->vval.v_string = (pat == NULL || *pat == NUL)
|
||||||
? NULL
|
? NULL
|
||||||
: file_pat_to_reg_pat(pat, NULL, NULL, false);
|
: file_pat_to_reg_pat(pat, NULL, NULL, false);
|
||||||
}
|
}
|
||||||
|
@ -7106,6 +7106,7 @@ char_u * file_pat_to_reg_pat(
|
|||||||
char *allow_dirs, // Result passed back out in here
|
char *allow_dirs, // Result passed back out in here
|
||||||
int no_bslash // Don't use a backward slash as pathsep
|
int no_bslash // Don't use a backward slash as pathsep
|
||||||
)
|
)
|
||||||
|
FUNC_ATTR_NONNULL_ARG(1)
|
||||||
{
|
{
|
||||||
const char_u *endp;
|
const char_u *endp;
|
||||||
char_u *reg_pat;
|
char_u *reg_pat;
|
||||||
|
@ -12,6 +12,9 @@ describe('glob2regpat()', function()
|
|||||||
helpers.feed('<cr>')
|
helpers.feed('<cr>')
|
||||||
neq(nil, string.find(eval('v:errmsg'), '^E806:'))
|
neq(nil, string.find(eval('v:errmsg'), '^E806:'))
|
||||||
end)
|
end)
|
||||||
|
it('returns empty string for empty input', function()
|
||||||
|
eq('', eval("glob2regpat('')"))
|
||||||
|
end)
|
||||||
it('handles valid input', function()
|
it('handles valid input', function()
|
||||||
eq('^foo\\.', eval("glob2regpat('foo.*')"))
|
eq('^foo\\.', eval("glob2regpat('foo.*')"))
|
||||||
eq('\\.vim$', eval("glob2regpat('*.vim')"))
|
eq('\\.vim$', eval("glob2regpat('*.vim')"))
|
||||||
|
Loading…
Reference in New Issue
Block a user