comparison src/quickfix.c @ 34540:9e093c96dff6 v9.1.0172

patch 9.1.0172: More code can use ml_get_buf_len() instead of STRLEN() Commit: https://github.com/vim/vim/commit/94b7c3233ef534acc669b3083ed1fe59cf3a090b Author: zeertzjq <zeertzjq@outlook.com> Date: Tue Mar 12 21:50:32 2024 +0100 patch 9.1.0172: More code can use ml_get_buf_len() instead of STRLEN() Problem: More code can use ml_get_buf_len() instead of STRLEN(). Solution: Change more STRLEN() calls to ml_get_buf_len(). Also do not set ml_line_textlen in ml_replace_len() if "has_props" is set, because "len_arg" also includes the size of text properties in that case. (zeertzjq) closes: #14183 Signed-off-by: zeertzjq <zeertzjq@outlook.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
author Christian Brabandt <cb@256bit.org>
date Tue, 12 Mar 2024 22:00:04 +0100
parents 4da97f213d15
children fd15dc02c223
comparison
equal deleted inserted replaced
34539:0dbb6f014f5e 34540:9e093c96dff6
778 // Get the next line from the supplied buffer 778 // Get the next line from the supplied buffer
779 if (state->buflnum > state->lnumlast) 779 if (state->buflnum > state->lnumlast)
780 return QF_END_OF_INPUT; 780 return QF_END_OF_INPUT;
781 781
782 p_buf = ml_get_buf(state->buf, state->buflnum, FALSE); 782 p_buf = ml_get_buf(state->buf, state->buflnum, FALSE);
783 len = ml_get_buf_len(state->buf, state->buflnum);
783 state->buflnum += 1; 784 state->buflnum += 1;
784 785
785 len = (int)STRLEN(p_buf);
786 if (len > IOSIZE - 2) 786 if (len > IOSIZE - 2)
787 { 787 {
788 state->linebuf = qf_grow_linebuf(state, len); 788 state->linebuf = qf_grow_linebuf(state, len);
789 if (state->linebuf == NULL) 789 if (state->linebuf == NULL)
790 return QF_NOMEM; 790 return QF_NOMEM;
6194 if ((flags & VGR_GLOBAL) == 0 6194 if ((flags & VGR_GLOBAL) == 0
6195 || regmatch->endpos[0].lnum > 0) 6195 || regmatch->endpos[0].lnum > 0)
6196 break; 6196 break;
6197 col = regmatch->endpos[0].col 6197 col = regmatch->endpos[0].col
6198 + (col == regmatch->endpos[0].col); 6198 + (col == regmatch->endpos[0].col);
6199 if (col > (colnr_T)STRLEN(ml_get_buf(buf, lnum, FALSE))) 6199 if (col > ml_get_buf_len(buf, lnum))
6200 break; 6200 break;
6201 } 6201 }
6202 } 6202 }
6203 else 6203 else
6204 { 6204 {
6205 char_u *str = ml_get_buf(buf, lnum, FALSE); 6205 char_u *str = ml_get_buf(buf, lnum, FALSE);
6206 int line_len = ml_get_buf_len(buf, lnum);
6206 int score; 6207 int score;
6207 int_u matches[MAX_FUZZY_MATCHES]; 6208 int_u matches[MAX_FUZZY_MATCHES];
6208 int_u sz = ARRAY_LENGTH(matches); 6209 int_u sz = ARRAY_LENGTH(matches);
6209 6210
6210 // Fuzzy string match 6211 // Fuzzy string match
6239 if (--*tomatch == 0) 6240 if (--*tomatch == 0)
6240 break; 6241 break;
6241 if ((flags & VGR_GLOBAL) == 0) 6242 if ((flags & VGR_GLOBAL) == 0)
6242 break; 6243 break;
6243 col = matches[pat_len - 1] + col + 1; 6244 col = matches[pat_len - 1] + col + 1;
6244 if (col > (colnr_T)STRLEN(str)) 6245 if (col > line_len)
6245 break; 6246 break;
6246 } 6247 }
6247 } 6248 }
6248 line_breakcheck(); 6249 line_breakcheck();
6249 if (got_int) 6250 if (got_int)