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 #2598)
diff --git a/src/if_cscope.c b/src/if_cscope.c
index 168b3e4..9466c34 100644
--- a/src/if_cscope.c
+++ b/src/if_cscope.c
@@ -677,7 +677,7 @@
{
char *stok;
char *buf;
- int nlines;
+ int nlines = 0;
buf = (char *)alloc(CSREAD_BUFSIZE);
if (buf == NULL)
@@ -700,7 +700,10 @@
* 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)