comparison src/search.c @ 26944:8dbdd68627bd v8.2.4001

patch 8.2.4001: insert complete code uses global variables Commit: https://github.com/vim/vim/commit/d94fbfc74a8b8073e7a256c95fa6f39fc527c726 Author: Yegappan Lakshmanan <yegappan@yahoo.com> Date: Tue Jan 4 17:01:44 2022 +0000 patch 8.2.4001: insert complete code uses global variables Problem: Insert complete code uses global variables. Solution: Make variables local to the file and use accessor functions. (Yegappan Lakshmanan, closes #9470)
author Bram Moolenaar <Bram@vim.org>
date Tue, 04 Jan 2022 18:15:03 +0100
parents d4e61d61afd9
children 4c68fb88b73f
comparison
equal deleted inserted replaced
26943:61f686b38df9 26944:8dbdd68627bd
1725 p = skipwhite(ptr); 1725 p = skipwhite(ptr);
1726 pos->col = (colnr_T) (p - ptr); 1726 pos->col = (colnr_T) (p - ptr);
1727 1727
1728 // when adding lines the matching line may be empty but it is not 1728 // when adding lines the matching line may be empty but it is not
1729 // ignored because we are interested in the next line -- Acevedo 1729 // ignored because we are interested in the next line -- Acevedo
1730 if ((compl_cont_status & CONT_ADDING) 1730 if (compl_status_adding() && !compl_status_sol())
1731 && !(compl_cont_status & CONT_SOL))
1732 { 1731 {
1733 if ((p_ic ? MB_STRICMP(p, pat) : STRCMP(p, pat)) == 0) 1732 if ((p_ic ? MB_STRICMP(p, pat) : STRCMP(p, pat)) == 0)
1734 return OK; 1733 return OK;
1735 } 1734 }
1736 else if (*p != NUL) // ignore empty lines 1735 else if (*p != NUL) // ignore empty lines
1737 { // expanding lines or words 1736 { // expanding lines or words
1738 if ((p_ic ? MB_STRNICMP(p, pat, compl_length) 1737 if ((p_ic ? MB_STRNICMP(p, pat, ins_compl_len())
1739 : STRNCMP(p, pat, compl_length)) == 0) 1738 : STRNCMP(p, pat, ins_compl_len())) == 0)
1740 return OK; 1739 return OK;
1741 } 1740 }
1742 } 1741 }
1743 return FAIL; 1742 return FAIL;
1744 } 1743 }
3315 } 3314 }
3316 3315
3317 #if defined(FEAT_FIND_ID) || defined(PROTO) 3316 #if defined(FEAT_FIND_ID) || defined(PROTO)
3318 /* 3317 /*
3319 * Find identifiers or defines in included files. 3318 * Find identifiers or defines in included files.
3320 * If p_ic && (compl_cont_status & CONT_SOL) then ptr must be in lowercase. 3319 * If p_ic && compl_status_sol() then ptr must be in lowercase.
3321 */ 3320 */
3322 void 3321 void
3323 find_pattern_in_path( 3322 find_pattern_in_path(
3324 char_u *ptr, // pointer to search pattern 3323 char_u *ptr, // pointer to search pattern
3325 int dir UNUSED, // direction of expansion 3324 int dir UNUSED, // direction of expansion
3373 file_line = alloc(LSIZE); 3372 file_line = alloc(LSIZE);
3374 if (file_line == NULL) 3373 if (file_line == NULL)
3375 return; 3374 return;
3376 3375
3377 if (type != CHECK_PATH && type != FIND_DEFINE 3376 if (type != CHECK_PATH && type != FIND_DEFINE
3378 // when CONT_SOL is set compare "ptr" with the beginning of the line 3377 // when CONT_SOL is set compare "ptr" with the beginning of the
3379 // is faster than quote_meta/regcomp/regexec "ptr" -- Acevedo 3378 // line is faster than quote_meta/regcomp/regexec "ptr" -- Acevedo
3380 && !(compl_cont_status & CONT_SOL)) 3379 && !compl_status_sol())
3381 { 3380 {
3382 pat = alloc(len + 5); 3381 pat = alloc(len + 5);
3383 if (pat == NULL) 3382 if (pat == NULL)
3384 goto fpip_end; 3383 goto fpip_end;
3385 sprintf((char *)pat, whole ? "\\<%.*s\\>" : "%.*s", len, ptr); 3384 sprintf((char *)pat, whole ? "\\<%.*s\\>" : "%.*s", len, ptr);
3650 * Look for a match. Don't do this if we are looking for a 3649 * Look for a match. Don't do this if we are looking for a
3651 * define and this line didn't match define_prog above. 3650 * define and this line didn't match define_prog above.
3652 */ 3651 */
3653 if (def_regmatch.regprog == NULL || define_matched) 3652 if (def_regmatch.regprog == NULL || define_matched)
3654 { 3653 {
3655 if (define_matched || (compl_cont_status & CONT_SOL)) 3654 if (define_matched || compl_status_sol())
3656 { 3655 {
3657 // compare the first "len" chars from "ptr" 3656 // compare the first "len" chars from "ptr"
3658 startp = skipwhite(p); 3657 startp = skipwhite(p);
3659 if (p_ic) 3658 if (p_ic)
3660 matched = !MB_STRNICMP(startp, ptr, len); 3659 matched = !MB_STRNICMP(startp, ptr, len);
3723 3722
3724 if (depth == -1 && lnum == curwin->w_cursor.lnum) 3723 if (depth == -1 && lnum == curwin->w_cursor.lnum)
3725 break; 3724 break;
3726 found = TRUE; 3725 found = TRUE;
3727 aux = p = startp; 3726 aux = p = startp;
3728 if (compl_cont_status & CONT_ADDING) 3727 if (compl_status_adding())
3729 { 3728 {
3730 p += compl_length; 3729 p += ins_compl_len();
3731 if (vim_iswordp(p)) 3730 if (vim_iswordp(p))
3732 goto exit_matched; 3731 goto exit_matched;
3733 p = find_word_start(p); 3732 p = find_word_start(p);
3734 } 3733 }
3735 p = find_word_end(p); 3734 p = find_word_end(p);
3736 i = (int)(p - aux); 3735 i = (int)(p - aux);
3737 3736
3738 if ((compl_cont_status & CONT_ADDING) && i == compl_length) 3737 if (compl_status_adding() && i == ins_compl_len())
3739 { 3738 {
3740 // IOSIZE > compl_length, so the STRNCPY works 3739 // IOSIZE > compl_length, so the STRNCPY works
3741 STRNCPY(IObuff, aux, i); 3740 STRNCPY(IObuff, aux, i);
3742 3741
3743 // Get the next line: when "depth" < 0 from the current 3742 // Get the next line: when "depth" < 0 from the current
3781 cont_s_ipos = TRUE; 3780 cont_s_ipos = TRUE;
3782 } 3781 }
3783 IObuff[i] = NUL; 3782 IObuff[i] = NUL;
3784 aux = IObuff; 3783 aux = IObuff;
3785 3784
3786 if (i == compl_length) 3785 if (i == ins_compl_len())
3787 goto exit_matched; 3786 goto exit_matched;
3788 } 3787 }
3789 3788
3790 add_r = ins_compl_add_infercase(aux, i, p_ic, 3789 add_r = ins_compl_add_infercase(aux, i, p_ic,
3791 curr_fname == curbuf->b_fname ? NULL : curr_fname, 3790 curr_fname == curbuf->b_fname ? NULL : curr_fname,
3914 matched = FALSE; 3913 matched = FALSE;
3915 // look for other matches in the rest of the line if we 3914 // look for other matches in the rest of the line if we
3916 // are not at the end of it already 3915 // are not at the end of it already
3917 if (def_regmatch.regprog == NULL 3916 if (def_regmatch.regprog == NULL
3918 && action == ACTION_EXPAND 3917 && action == ACTION_EXPAND
3919 && !(compl_cont_status & CONT_SOL) 3918 && !compl_status_sol()
3920 && *startp != NUL 3919 && *startp != NUL
3921 && *(p = startp + mb_ptr2len(startp)) != NUL) 3920 && *(p = startp + mb_ptr2len(startp)) != NUL)
3922 goto search_line; 3921 goto search_line;
3923 } 3922 }
3924 line_breakcheck(); 3923 line_breakcheck();