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.

When matching a string (as in "if string_var =~# pattern_var | DoSomething
| else | DoSomethingElse | endif"), in order to match an empty string you
need to test that there is nothing between beginning and end of the string,
so the matching pattern is indeed '^$'

T'ain't a bug, it's a feature.


Best regards,
Tony.

-- 
-- 
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.

Raspunde prin e-mail lui