2828#include "vim.h"
2929
3030#if defined(FEAT_CMDL_COMPL ) || defined(FEAT_LISTCMDS ) || defined(FEAT_EVAL ) || defined(FEAT_PERL )
31- static char_u * buflist_match __ARGS ((regprog_T * prog , buf_T * buf , int ignore_case ));
31+ static char_u * buflist_match __ARGS ((regmatch_T * rmp , buf_T * buf , int ignore_case ));
3232# define HAVE_BUFLIST_MATCH
33- static char_u * fname_match __ARGS ((regprog_T * prog , char_u * name , int ignore_case ));
33+ static char_u * fname_match __ARGS ((regmatch_T * rmp , char_u * name , int ignore_case ));
3434#endif
3535static void buflist_setfpos __ARGS ((buf_T * buf , win_T * win , linenr_T lnum , colnr_T col , int copy_options ));
3636static wininfo_T * find_wininfo __ARGS ((buf_T * buf , int skip_diff_buffer ));
@@ -2220,7 +2220,6 @@ buflist_findpat(pattern, pattern_end, unlisted, diffmode, curtab_only)
22202220 int curtab_only ; /* find buffers in current tab only */
22212221{
22222222 buf_T * buf ;
2223- regprog_T * prog ;
22242223 int match = -1 ;
22252224 int find_listed ;
22262225 char_u * pat ;
@@ -2265,14 +2264,16 @@ buflist_findpat(pattern, pattern_end, unlisted, diffmode, curtab_only)
22652264 {
22662265 for (attempt = 0 ; attempt <= 3 ; ++ attempt )
22672266 {
2267+ regmatch_T regmatch ;
2268+
22682269 /* may add '^' and '$' */
22692270 if (toggledollar )
22702271 * patend = (attempt < 2 ) ? NUL : '$' ; /* add/remove '$' */
22712272 p = pat ;
22722273 if (* p == '^' && !(attempt & 1 )) /* add/remove '^' */
22732274 ++ p ;
2274- prog = vim_regcomp (p , p_magic ? RE_MAGIC : 0 );
2275- if (prog == NULL )
2275+ regmatch . regprog = vim_regcomp (p , p_magic ? RE_MAGIC : 0 );
2276+ if (regmatch . regprog == NULL )
22762277 {
22772278 vim_free (pat );
22782279 return -1 ;
@@ -2283,7 +2284,7 @@ buflist_findpat(pattern, pattern_end, unlisted, diffmode, curtab_only)
22832284#ifdef FEAT_DIFF
22842285 && (!diffmode || diff_mode_buf (buf ))
22852286#endif
2286- && buflist_match (prog , buf , FALSE) != NULL )
2287+ && buflist_match (& regmatch , buf , FALSE) != NULL )
22872288 {
22882289 if (curtab_only )
22892290 {
@@ -2310,7 +2311,7 @@ buflist_findpat(pattern, pattern_end, unlisted, diffmode, curtab_only)
23102311 match = buf -> b_fnum ; /* remember first match */
23112312 }
23122313
2313- vim_regfree (prog );
2314+ vim_regfree (regmatch . regprog );
23142315 if (match >= 0 ) /* found one match */
23152316 break ;
23162317 }
@@ -2352,7 +2353,6 @@ ExpandBufnames(pat, num_file, file, options)
23522353 int round ;
23532354 char_u * p ;
23542355 int attempt ;
2355- regprog_T * prog ;
23562356 char_u * patc ;
23572357
23582358 * num_file = 0 ; /* return values in case of FAIL */
@@ -2376,10 +2376,12 @@ ExpandBufnames(pat, num_file, file, options)
23762376 */
23772377 for (attempt = 0 ; attempt <= 1 ; ++ attempt )
23782378 {
2379+ regmatch_T regmatch ;
2380+
23792381 if (attempt > 0 && patc == pat )
23802382 break ; /* there was no anchor, no need to try again */
2381- prog = vim_regcomp (patc + attempt * 11 , RE_MAGIC );
2382- if (prog == NULL )
2383+ regmatch . regprog = vim_regcomp (patc + attempt * 11 , RE_MAGIC );
2384+ if (regmatch . regprog == NULL )
23832385 {
23842386 if (patc != pat )
23852387 vim_free (patc );
@@ -2397,7 +2399,7 @@ ExpandBufnames(pat, num_file, file, options)
23972399 {
23982400 if (!buf -> b_p_bl ) /* skip unlisted buffers */
23992401 continue ;
2400- p = buflist_match (prog , buf , p_wic );
2402+ p = buflist_match (& regmatch , buf , p_wic );
24012403 if (p != NULL )
24022404 {
24032405 if (round == 1 )
@@ -2419,14 +2421,14 @@ ExpandBufnames(pat, num_file, file, options)
24192421 * file = (char_u * * )alloc ((unsigned )(count * sizeof (char_u * )));
24202422 if (* file == NULL )
24212423 {
2422- vim_regfree (prog );
2424+ vim_regfree (regmatch . regprog );
24232425 if (patc != pat )
24242426 vim_free (patc );
24252427 return FAIL ;
24262428 }
24272429 }
24282430 }
2429- vim_regfree (prog );
2431+ vim_regfree (regmatch . regprog );
24302432 if (count ) /* match(es) found, break here */
24312433 break ;
24322434 }
@@ -2445,17 +2447,17 @@ ExpandBufnames(pat, num_file, file, options)
24452447 * Check for a match on the file name for buffer "buf" with regprog "prog".
24462448 */
24472449 static char_u *
2448- buflist_match (prog , buf , ignore_case )
2449- regprog_T * prog ;
2450+ buflist_match (rmp , buf , ignore_case )
2451+ regmatch_T * rmp ;
24502452 buf_T * buf ;
24512453 int ignore_case ; /* when TRUE ignore case, when FALSE use 'fic' */
24522454{
24532455 char_u * match ;
24542456
24552457 /* First try the short file name, then the long file name. */
2456- match = fname_match (prog , buf -> b_sfname , ignore_case );
2458+ match = fname_match (rmp , buf -> b_sfname , ignore_case );
24572459 if (match == NULL )
2458- match = fname_match (prog , buf -> b_ffname , ignore_case );
2460+ match = fname_match (rmp , buf -> b_ffname , ignore_case );
24592461
24602462 return match ;
24612463}
@@ -2465,27 +2467,25 @@ buflist_match(prog, buf, ignore_case)
24652467 * Return "name" when there is a match, NULL when not.
24662468 */
24672469 static char_u *
2468- fname_match (prog , name , ignore_case )
2469- regprog_T * prog ;
2470+ fname_match (rmp , name , ignore_case )
2471+ regmatch_T * rmp ;
24702472 char_u * name ;
24712473 int ignore_case ; /* when TRUE ignore case, when FALSE use 'fic' */
24722474{
24732475 char_u * match = NULL ;
24742476 char_u * p ;
2475- regmatch_T regmatch ;
24762477
24772478 if (name != NULL )
24782479 {
2479- regmatch .regprog = prog ;
24802480 /* Ignore case when 'fileignorecase' or the argument is set. */
2481- regmatch . rm_ic = p_fic || ignore_case ;
2482- if (vim_regexec (& regmatch , name , (colnr_T )0 ))
2481+ rmp -> rm_ic = p_fic || ignore_case ;
2482+ if (vim_regexec (rmp , name , (colnr_T )0 ))
24832483 match = name ;
24842484 else
24852485 {
24862486 /* Replace $(HOME) with '~' and try matching again. */
24872487 p = home_replace_save (NULL , name );
2488- if (p != NULL && vim_regexec (& regmatch , p , (colnr_T )0 ))
2488+ if (p != NULL && vim_regexec (rmp , p , (colnr_T )0 ))
24892489 match = name ;
24902490 vim_free (p );
24912491 }
0 commit comments