Mercurial > vim
comparison src/search.c @ 23272:a84e7abb0c92 v8.2.2182
patch 8.2.2182: Vim9: value of 'magic' is still relevant
Commit: https://github.com/vim/vim/commit/f4e2099e39ed4d71aed0f9a9579455aed5ec6cc2
Author: Bram Moolenaar <Bram@vim.org>
Date: Mon Dec 21 19:59:08 2020 +0100
patch 8.2.2182: Vim9: value of 'magic' is still relevant
Problem: Vim9: value of 'magic' is still relevant.
Solution: Always behave like 'magic' is on in Vim9 script (closes https://github.com/vim/vim/issues/7509)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Mon, 21 Dec 2020 20:00:06 +0100 |
parents | b545334ae654 |
children | 79fd5217b125 |
comparison
equal
deleted
inserted
replaced
23271:50ebb4982f37 | 23272:a84e7abb0c92 |
---|---|
132 { | 132 { |
133 int magic; | 133 int magic; |
134 int i; | 134 int i; |
135 | 135 |
136 rc_did_emsg = FALSE; | 136 rc_did_emsg = FALSE; |
137 magic = p_magic; | 137 magic = magic_isset(); |
138 | 138 |
139 /* | 139 /* |
140 * If no pattern given, use a previously defined pattern. | 140 * If no pattern given, use a previously defined pattern. |
141 */ | 141 */ |
142 if (pat == NULL || *pat == NUL) | 142 if (pat == NULL || *pat == NUL) |
1339 /* | 1339 /* |
1340 * Find end of regular expression. | 1340 * Find end of regular expression. |
1341 * If there is a matching '/' or '?', toss it. | 1341 * If there is a matching '/' or '?', toss it. |
1342 */ | 1342 */ |
1343 ps = strcopy; | 1343 ps = strcopy; |
1344 p = skip_regexp_ex(pat, search_delim, (int)p_magic, &strcopy, NULL); | 1344 p = skip_regexp_ex(pat, search_delim, magic_isset(), |
1345 &strcopy, NULL); | |
1345 if (strcopy != ps) | 1346 if (strcopy != ps) |
1346 { | 1347 { |
1347 // made a copy of "pat" to change "\?" to "?" | 1348 // made a copy of "pat" to change "\?" to "?" |
1348 searchcmdlen += (int)(STRLEN(pat) - STRLEN(strcopy)); | 1349 searchcmdlen += (int)(STRLEN(pat) - STRLEN(strcopy)); |
1349 pat = strcopy; | 1350 pat = strcopy; |
3383 if (pat == NULL) | 3384 if (pat == NULL) |
3384 goto fpip_end; | 3385 goto fpip_end; |
3385 sprintf((char *)pat, whole ? "\\<%.*s\\>" : "%.*s", len, ptr); | 3386 sprintf((char *)pat, whole ? "\\<%.*s\\>" : "%.*s", len, ptr); |
3386 // ignore case according to p_ic, p_scs and pat | 3387 // ignore case according to p_ic, p_scs and pat |
3387 regmatch.rm_ic = ignorecase(pat); | 3388 regmatch.rm_ic = ignorecase(pat); |
3388 regmatch.regprog = vim_regcomp(pat, p_magic ? RE_MAGIC : 0); | 3389 regmatch.regprog = vim_regcomp(pat, magic_isset() ? RE_MAGIC : 0); |
3389 vim_free(pat); | 3390 vim_free(pat); |
3390 if (regmatch.regprog == NULL) | 3391 if (regmatch.regprog == NULL) |
3391 goto fpip_end; | 3392 goto fpip_end; |
3392 } | 3393 } |
3393 inc_opt = (*curbuf->b_p_inc == NUL) ? p_inc : curbuf->b_p_inc; | 3394 inc_opt = (*curbuf->b_p_inc == NUL) ? p_inc : curbuf->b_p_inc; |
3394 if (*inc_opt != NUL) | 3395 if (*inc_opt != NUL) |
3395 { | 3396 { |
3396 incl_regmatch.regprog = vim_regcomp(inc_opt, p_magic ? RE_MAGIC : 0); | 3397 incl_regmatch.regprog = vim_regcomp(inc_opt, |
3398 magic_isset() ? RE_MAGIC : 0); | |
3397 if (incl_regmatch.regprog == NULL) | 3399 if (incl_regmatch.regprog == NULL) |
3398 goto fpip_end; | 3400 goto fpip_end; |
3399 incl_regmatch.rm_ic = FALSE; // don't ignore case in incl. pat. | 3401 incl_regmatch.rm_ic = FALSE; // don't ignore case in incl. pat. |
3400 } | 3402 } |
3401 if (type == FIND_DEFINE && (*curbuf->b_p_def != NUL || *p_def != NUL)) | 3403 if (type == FIND_DEFINE && (*curbuf->b_p_def != NUL || *p_def != NUL)) |
3402 { | 3404 { |
3403 def_regmatch.regprog = vim_regcomp(*curbuf->b_p_def == NUL | 3405 def_regmatch.regprog = vim_regcomp(*curbuf->b_p_def == NUL |
3404 ? p_def : curbuf->b_p_def, p_magic ? RE_MAGIC : 0); | 3406 ? p_def : curbuf->b_p_def, |
3407 magic_isset() ? RE_MAGIC : 0); | |
3405 if (def_regmatch.regprog == NULL) | 3408 if (def_regmatch.regprog == NULL) |
3406 goto fpip_end; | 3409 goto fpip_end; |
3407 def_regmatch.rm_ic = FALSE; // don't ignore case in define pat. | 3410 def_regmatch.rm_ic = FALSE; // don't ignore case in define pat. |
3408 } | 3411 } |
3409 files = lalloc_clear(max_path_depth * sizeof(SearchedFile), TRUE); | 3412 files = lalloc_clear(max_path_depth * sizeof(SearchedFile), TRUE); |