On Wed, Jan 27, 2016 at 11:40 PM, Tony Mechelynck <[email protected]> wrote: > On Thu, Jan 28, 2016 at 4:45 AM, Justin M. Keyes <[email protected]> > wrote: >> >> glob2regpat("") returns "^$", but that not the regex equivalent of an >> empty wildcard pattern. It should probably return empty string instead. >> Here's a patch: >> >> diff --git a/src/eval.c b/src/eval.c >> index 5f05c3d..b68d086 100644 >> --- a/src/eval.c >> +++ b/src/eval.c >> @@ -12993,7 +12993,7 @@ f_glob2regpat(argvars, rettv) >> char_u> *pat = get_tv_string_chk(&argvars[0]); >> - >> rettv->v_type = VAR_STRING; >> - rettv->vval.v_string = (pat == NULL) >> + rettv->vval.v_string = (pat == NULL || *pat == NUL) >> > > > ? NULL : file_pat_to_reg_pat(pat, NULL, NULL, >> FALSE); >> } >> >> > An empty regpat matches everywhere.
Yes. Why wouldn't an empty glob pattern be interpreted as an empty regex pattern? > When matching a string (as in "if string_var =~# pattern_var | DoSomething | > else | DoSomethingElse | endif"), in order to match an empty string you need You mean an empty *line*. That's very different than an empty string, and I don't see how an empty glob pattern would imply that only empty lines should be matched. I'm not intending to be pedantic, but this should at least be documented if it's intended. --- Justin M. Keyes -- -- You received this message from the "vim_dev" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php --- You received this message because you are subscribed to the Google Groups "vim_dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
