vim-patch:8.0.1439: if cscope fails a search Vim may hang

Problem:    If cscope fails a search Vim may hang.
Solution:   Bail out when a search error is encountered. (Safouane Baroudi,
            closes vim/vim#2598)

1274d33493
This commit is contained in:
Marco Hinz 2018-02-26 14:24:45 +01:00
parent f588113191
commit 81a520e60e
No known key found for this signature in database
GPG Key ID: 1C980A1B657B4A4F

View File

@ -549,7 +549,7 @@ static void cs_reading_emsg(
static int cs_cnt_matches(size_t idx)
{
char *stok;
int nlines;
int nlines = 0;
char *buf = xmalloc(CSREAD_BUFSIZE);
for (;; ) {
@ -569,16 +569,20 @@ static int cs_cnt_matches(size_t idx)
return CSCOPE_FAILURE;
}
/*
* If the database is out of date, or there's some other problem,
* cscope will output error messages before the number-of-lines output.
* Display/discard any output that doesn't match what we want.
* Accept "\S*cscope: X lines", also matches "mlcscope".
*/
if ((stok = strtok(buf, (const char *)" ")) == NULL)
// If the database is out of date, or there's some other problem,
// cscope will output error messages before the number-of-lines output.
// Display/discard any output that doesn't match what we want.
// Accept "\S*cscope: X lines", also matches "mlcscope".
// Bail out for the "Unable to search" error.
if (strstr((const char *)stok, "Unable to search database") != NULL) {
break;
}
if ((stok = strtok(buf, (const char *)" ")) == NULL) {
continue;
if (strstr((const char *)stok, "cscope:") == NULL)
}
if (strstr((const char *)stok, "cscope:") == NULL) {
continue;
}
if ((stok = strtok(NULL, (const char *)" ")) == NULL)
continue;