comparison src/if_cscope.c @ 13130:161b5fe12b11 v8.0.1439

patch 8.0.1439: if cscope fails a search Vim may hang commit https://github.com/vim/vim/commit/1274d33493efb6250470a37b9f4432bb31e87d64 Author: Bram Moolenaar <Bram@vim.org> Date: Tue Jan 30 21:47:52 2018 +0100 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)
author Christian Brabandt <cb@256bit.org>
date Tue, 30 Jan 2018 22:00:07 +0100
parents 68d7bc045dbe
children bc735a129ea9
comparison
equal deleted inserted replaced
13129:f2f02cb95fbc 13130:161b5fe12b11
675 static int 675 static int
676 cs_cnt_matches(int idx) 676 cs_cnt_matches(int idx)
677 { 677 {
678 char *stok; 678 char *stok;
679 char *buf; 679 char *buf;
680 int nlines; 680 int nlines = 0;
681 681
682 buf = (char *)alloc(CSREAD_BUFSIZE); 682 buf = (char *)alloc(CSREAD_BUFSIZE);
683 if (buf == NULL) 683 if (buf == NULL)
684 return 0; 684 return 0;
685 for (;;) 685 for (;;)
698 /* 698 /*
699 * If the database is out of date, or there's some other problem, 699 * If the database is out of date, or there's some other problem,
700 * cscope will output error messages before the number-of-lines output. 700 * cscope will output error messages before the number-of-lines output.
701 * Display/discard any output that doesn't match what we want. 701 * Display/discard any output that doesn't match what we want.
702 * Accept "\S*cscope: X lines", also matches "mlcscope". 702 * Accept "\S*cscope: X lines", also matches "mlcscope".
703 * Bail out for the "Unable to search" error.
703 */ 704 */
705 if (strstr((const char *)stok, "Unable to search database") != NULL)
706 break;
704 if ((stok = strtok(buf, (const char *)" ")) == NULL) 707 if ((stok = strtok(buf, (const char *)" ")) == NULL)
705 continue; 708 continue;
706 if (strstr((const char *)stok, "cscope:") == NULL) 709 if (strstr((const char *)stok, "cscope:") == NULL)
707 continue; 710 continue;
708 711