mirror of
https://github.com/neovim/neovim.git
synced 2025-09-07 20:08:17 +00:00
search: Fix PVS/V547: allocator never returns NULL now
This commit is contained in:
@@ -1493,39 +1493,35 @@ static int check_prevcol(char_u *linep, int col, int ch, int *prevcol)
|
|||||||
* Raw string start is found at linep[startpos.col - 1].
|
* Raw string start is found at linep[startpos.col - 1].
|
||||||
* Return true if the matching end can be found between startpos and endpos.
|
* Return true if the matching end can be found between startpos and endpos.
|
||||||
*/
|
*/
|
||||||
static int find_rawstring_end(char_u *linep, pos_T *startpos, pos_T *endpos)
|
static bool find_rawstring_end(char_u *linep, pos_T *startpos, pos_T *endpos)
|
||||||
{
|
{
|
||||||
char_u *p;
|
char_u *p;
|
||||||
char_u *delim_copy;
|
char_u *delim_copy;
|
||||||
size_t delim_len;
|
size_t delim_len;
|
||||||
linenr_T lnum;
|
linenr_T lnum;
|
||||||
int found = false;
|
|
||||||
|
|
||||||
for (p = linep + startpos->col + 1; *p && *p != '('; ++p) {}
|
for (p = linep + startpos->col + 1; *p && *p != '('; p++) {}
|
||||||
|
|
||||||
delim_len = (p - linep) - startpos->col - 1;
|
delim_len = (p - linep) - startpos->col - 1;
|
||||||
delim_copy = vim_strnsave(linep + startpos->col + 1, delim_len);
|
delim_copy = vim_strnsave(linep + startpos->col + 1, delim_len);
|
||||||
if (delim_copy == NULL)
|
bool found = false;
|
||||||
return false;
|
for (lnum = startpos->lnum; lnum <= endpos->lnum; lnum++) {
|
||||||
for (lnum = startpos->lnum; lnum <= endpos->lnum; ++lnum)
|
|
||||||
{
|
|
||||||
char_u *line = ml_get(lnum);
|
char_u *line = ml_get(lnum);
|
||||||
|
|
||||||
for (p = line + (lnum == startpos->lnum
|
for (p = line + (lnum == startpos->lnum ? startpos->col + 1 : 0); *p; p++) {
|
||||||
? startpos->col + 1 : 0); *p; ++p)
|
if (lnum == endpos->lnum && (colnr_T)(p - line) >= endpos->col) {
|
||||||
{
|
|
||||||
if (lnum == endpos->lnum && (colnr_T)(p - line) >= endpos->col)
|
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
if (*p == ')' && p[delim_len + 1] == '"'
|
if (*p == ')' && p[delim_len + 1] == '"'
|
||||||
&& STRNCMP(delim_copy, p + 1, delim_len) == 0)
|
&& STRNCMP(delim_copy, p + 1, delim_len) == 0) {
|
||||||
{
|
|
||||||
found = true;
|
found = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (found)
|
if (found) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
xfree(delim_copy);
|
xfree(delim_copy);
|
||||||
return found;
|
return found;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user