223
int multiline = FALSE;
224
int multiignore = FALSE;
225
int multiscan = FALSE;
226
int retval = -1; /* default: return error flag */
227
char_u *directory = NULL;
228
char_u *currfile = NULL;
230
char_u *p_str = NULL;
231
listitem_T *p_li = NULL;
232
struct dir_stack_T *file_stack = NULL;
222
bool multiline = false;
223
bool multiignore = false;
224
bool multiscan = false;
225
int retval = -1; // default: return error flag
226
char_u *directory = NULL;
227
char_u *currfile = NULL;
229
char_u *p_str = NULL;
230
listitem_T *p_li = NULL;
231
struct dir_stack_T *file_stack = NULL;
233
232
regmatch_T regmatch;
234
233
static struct fmtpattern {
279
278
* Get some space to modify the format string into.
281
i = 3 * FMT_PATTERNS + 4 * (int)STRLEN(efm);
282
for (round = FMT_PATTERNS; round > 0; )
283
i += (int)STRLEN(fmt_pat[--round].pattern);
280
size_t fmtstr_size = 3 * FMT_PATTERNS + 4 * STRLEN(efm);
281
for (round = FMT_PATTERNS; round > 0; ) {
282
fmtstr_size += STRLEN(fmt_pat[--round].pattern);
284
284
#ifdef COLON_IN_FILENAME
285
i += 12; /* "%f" can become twelve chars longer */
285
fmtstr_size += 12; // "%f" can become twelve chars longer
287
i += 2; /* "%f" can become two chars longer */
287
fmtstr_size += 2; // "%f" can become two chars longer
289
fmtstr = xmalloc(fmtstr_size);
291
291
while (efm[0] != NUL) {
555
553
int r = vim_regexec(®match, IObuff, (colnr_T)0);
556
554
fmt_ptr->prog = regmatch.regprog;
558
if ((idx == 'C' || idx == 'Z') && !multiline)
556
if ((idx == 'C' || idx == 'Z') && !multiline) {
560
if (vim_strchr((char_u *)"EWI", idx) != NULL)
559
if (vim_strchr((char_u *)"EWI", idx) != NULL) {
565
* Extract error message data from matched line.
566
* We check for an actual submatch, because "\[" and "\]" in
567
* the 'errorformat' may cause the wrong submatch to be used.
569
if ((i = (int)fmt_ptr->addr[0]) > 0) { /* %f */
572
if (regmatch.startp[i] == NULL || regmatch.endp[i] == NULL)
564
// Extract error message data from matched line.
565
// We check for an actual submatch, because "\[" and "\]" in
566
// the 'errorformat' may cause the wrong submatch to be used.
567
if ((i = (int)fmt_ptr->addr[0]) > 0) { // %f
568
if (regmatch.startp[i] == NULL || regmatch.endp[i] == NULL) {
575
/* Expand ~/file and $HOME/file to full path. */
576
c = *regmatch.endp[i];
571
// Expand ~/file and $HOME/file to full path.
572
char_u c = *regmatch.endp[i];
577
573
*regmatch.endp[i] = NUL;
578
574
expand_env(regmatch.startp[i], namebuf, CMDBUFFSIZE);
579
575
*regmatch.endp[i] = c;
635
631
if ((i = (int)fmt_ptr->addr[8]) > 0) { /* %v */
636
632
if (regmatch.startp[i] == NULL)
638
634
col = (int)atol((char *)regmatch.startp[i]);
641
637
if ((i = (int)fmt_ptr->addr[9]) > 0) { /* %s */
642
638
if (regmatch.startp[i] == NULL || regmatch.endp[i] == NULL)
667
663
} else if (idx == 'X') /* leave directory */
668
664
directory = qf_pop_dir(&dir_stack);
670
namebuf[0] = NUL; /* no match found, remove file name */
671
lnum = 0; /* don't jump to this line */
673
STRCPY(errmsg, IObuff); /* copy whole line to error message */
675
multiline = multiignore = FALSE;
666
namebuf[0] = NUL; // no match found, remove file name
667
lnum = 0; // don't jump to this line
669
STRCPY(errmsg, IObuff); // copy whole line to error message
670
if (fmt_ptr == NULL) {
671
multiline = multiignore = false;
676
673
} else if (fmt_ptr != NULL) {
677
674
/* honor %> item */
678
675
if (fmt_ptr->conthere)
679
676
fmt_start = fmt_ptr;
681
678
if (vim_strchr((char_u *)"AEWI", idx) != NULL) {
682
multiline = TRUE; /* start of a multi-line message */
683
multiignore = FALSE; /* reset continuation */
679
multiline = true; // start of a multi-line message
680
multiignore = false; // reset continuation
684
681
} else if (vim_strchr((char_u *)"CZ", idx)
685
682
!= NULL) { /* continuation of multi-line msg */
686
683
if (qfprev == NULL)
702
699
qfprev->qf_viscol = use_viscol;
703
700
if (!qfprev->qf_fnum)
704
701
qfprev->qf_fnum = qf_get_fnum(directory,
705
*namebuf || directory ? namebuf
706
: currfile && valid ? currfile : 0);
708
multiline = multiignore = FALSE;
703
|| directory ? namebuf : currfile
704
&& valid ? currfile : 0);
706
multiline = multiignore = false;
709
708
line_breakcheck();
711
710
} else if (vim_strchr((char_u *)"OPQ", idx) != NULL) {
712
/* global file names */
714
713
if (*namebuf == NUL || os_file_exists(namebuf)) {
715
714
if (*namebuf && idx == 'P')
716
715
currfile = qf_push_dir(namebuf, &file_stack);
720
719
if (tail && *tail) {
721
720
STRMOVE(IObuff, skipwhite(tail));
727
if (fmt_ptr->flags == '-') { /* generally exclude this line */
729
multiignore = TRUE; /* also exclude continuation lines */
726
if (fmt_ptr->flags == '-') { // generally exclude this line
728
multiignore = true; // also exclude continuation lines
871
* Add an entry to the end of the list of errors.
872
* Returns OK or FAIL.
876
qf_info_T *qi, /* quickfix list */
877
qfline_T **prevp, /* nonnull pointer (to previously added entry or NULL) */
878
char_u *dir, /* optional directory name */
879
char_u *fname, /* file name or NULL */
880
int bufnum, /* buffer number or zero */
881
char_u *mesg, /* message */
882
long lnum, /* line number */
883
int col, /* column */
884
int vis_col, /* using visual column */
885
char_u *pattern, /* search pattern */
886
int nr, /* error number */
887
int type, /* type character */
888
int valid /* valid entry */
870
/// Add an entry to the end of the list of errors.
872
/// @param qi quickfix list
873
/// @param prevp nonnull pointer (to previously added entry or NULL)
874
/// @param dir optional directory name
875
/// @param fname file name or NULL
876
/// @param bufnum buffer number or zero
877
/// @param mesg message
878
/// @param lnum line number
879
/// @param col column
880
/// @param vis_col using visual column
881
/// @param pattern search pattern
882
/// @param nr error number
883
/// @param type type character
884
/// @param valid valid entry
886
/// @returns OK or FAIL.
887
static int qf_add_entry(qf_info_T *qi, qfline_T **prevp, char_u *dir,
888
char_u *fname, int bufnum, char_u *mesg, long lnum,
889
int col, char_u vis_col, char_u *pattern, int nr,
890
char_u type, char_u valid)
891
892
qfline_T *qfp = xmalloc(sizeof(qfline_T));
1657
1658
* flag is present in 'shortmess'; But when not jumping, print the
1658
1659
* whole message. */
1659
1660
i = msg_scroll;
1660
if (curbuf == old_curbuf && curwin->w_cursor.lnum == old_lnum)
1662
else if (!msg_scrolled && shortmess(SHM_OVERALL))
1664
msg_attr_keep(IObuff, 0, TRUE);
1661
if (curbuf == old_curbuf && curwin->w_cursor.lnum == old_lnum) {
1663
} else if (!msg_scrolled && shortmess(SHM_OVERALL)) {
1666
msg_attr_keep(IObuff, 0, true);
1667
msg_scroll = (int)i;
1668
1670
if (opened_window)
1830
if (eap->addr_count != 0)
1832
if (eap->addr_count != 0) {
1833
assert(eap->line2 <= INT_MAX);
1834
count = (int)eap->line2;
1834
1838
while (count--) {
1835
1839
if (eap->cmdidx == CMD_colder || eap->cmdidx == CMD_lolder) {
1836
1840
if (qi->qf_curlist == 0) {
1882
1886
--qi->qf_lists[idx].qf_count;
1884
1888
xfree(qi->qf_lists[idx].qf_title);
1889
qi->qf_lists[idx].qf_start = NULL;
1890
qi->qf_lists[idx].qf_ptr = NULL;
1885
1891
qi->qf_lists[idx].qf_title = NULL;
1886
1892
qi->qf_lists[idx].qf_index = 0;
2039
if (eap->addr_count != 0)
2040
height = eap->line2;
2045
if (eap->addr_count != 0) {
2046
assert(eap->line2 <= INT_MAX);
2047
height = (int)eap->line2;
2042
2049
height = QF_WINHEIGHT;
2044
reset_VIsual_and_resel(); /* stop Visual mode */
2051
reset_VIsual_and_resel(); // stop Visual mode
2047
2054
* Find existing quickfix window, or open a new one.
2299
2306
if (qfp->qf_fnum != 0
2300
2307
&& (errbuf = buflist_findnr(qfp->qf_fnum)) != NULL
2301
2308
&& errbuf->b_fname != NULL) {
2302
if (qfp->qf_type == 1) /* :helpgrep */
2303
STRCPY(IObuff, path_tail(errbuf->b_fname));
2305
STRCPY(IObuff, errbuf->b_fname);
2309
if (qfp->qf_type == 1) { // :helpgrep
2310
STRLCPY(IObuff, path_tail(errbuf->b_fname), sizeof(IObuff));
2312
STRLCPY(IObuff, errbuf->b_fname, sizeof(IObuff));
2306
2314
len = (int)STRLEN(IObuff);
2309
2318
IObuff[len++] = '|';
2311
2320
if (qfp->qf_lnum > 0) {
2474
2483
* If 'shellpipe' empty: don't redirect to 'errorfile'.
2476
len = (unsigned)STRLEN(p_shq) * 2 + (unsigned)STRLEN(eap->arg) + 1;
2478
len += (unsigned)STRLEN(p_sp) + (unsigned)STRLEN(fname) + 3;
2485
len = STRLEN(p_shq) * 2 + STRLEN(eap->arg) + 1;
2487
len += STRLEN(p_sp) + STRLEN(fname) + 3;
2479
2489
cmd = xmalloc(len);
2480
2490
sprintf((char *)cmd, "%s%s%s", (char *)p_shq, (char *)eap->arg,
2481
2491
(char *)p_shq);
2547
2557
/* Keep trying until the name doesn't exist yet. */
2550
start = os_get_pid();
2560
start = (int)os_get_pid();
2554
2564
name = xmalloc(STRLEN(p_mef) + 30);
2555
2565
STRCPY(name, p_mef);
2556
2566
sprintf((char *)name + (p - p_mef), "%d%d", start, off);
3455
3465
int set_errorlist(win_T *wp, list_T *list, int action, char_u *title)
3459
char_u *filename, *pattern, *text, *type;
3464
qfline_T *prevp = NULL;
3469
qfline_T *prevp = NULL;
3466
3470
int retval = OK;
3467
qf_info_T *qi = &ql_info;
3468
int did_bufnr_emsg = FALSE;
3471
qf_info_T *qi = &ql_info;
3472
bool did_bufnr_emsg = false;
3470
3474
if (wp != NULL) {
3471
3475
qi = ll_get_or_alloc_list(wp);
3495
filename = get_dict_string(d, (char_u *)"filename", TRUE);
3496
bufnum = get_dict_number(d, (char_u *)"bufnr");
3497
lnum = get_dict_number(d, (char_u *)"lnum");
3498
col = get_dict_number(d, (char_u *)"col");
3499
vcol = get_dict_number(d, (char_u *)"vcol");
3500
nr = get_dict_number(d, (char_u *)"nr");
3501
type = get_dict_string(d, (char_u *)"type", TRUE);
3502
pattern = get_dict_string(d, (char_u *)"pattern", TRUE);
3503
text = get_dict_string(d, (char_u *)"text", TRUE);
3499
char_u *filename = get_dict_string(d, (char_u *)"filename", true);
3500
int bufnum = (int)get_dict_number(d, (char_u *)"bufnr");
3501
long lnum = get_dict_number(d, (char_u *)"lnum");
3502
int col = (int)get_dict_number(d, (char_u *)"col");
3503
char_u vcol = (char_u)get_dict_number(d, (char_u *)"vcol");
3504
int nr = (int)get_dict_number(d, (char_u *)"nr");
3505
char_u *type = get_dict_string(d, (char_u *)"type", true);
3506
char_u *pattern = get_dict_string(d, (char_u *)"pattern", true);
3507
char_u *text = get_dict_string(d, (char_u *)"text", true);
3505
3509
text = vim_strsave((char_u *)"");
3508
if ((filename == NULL && bufnum == 0) || (lnum == 0 && pattern == NULL))
3512
if ((filename == NULL && bufnum == 0) || (lnum == 0 && pattern == NULL)) {
3511
3516
/* Mark entries with non-existing buffer number as not valid. Give the
3512
3517
* error message only once. */
3515
3520
did_bufnr_emsg = TRUE;
3516
3521
EMSGN(_("E92: Buffer %" PRId64 " not found"), bufnum);
3522
status = qf_add_entry(qi, &prevp,
3530
pattern, /* search pattern */
3532
type == NULL ? NUL : *type,
3527
int status = qf_add_entry(qi,
3536
pattern, // search pattern
3538
(char_u)(type == NULL ? NUL : *type),
3535
3541
xfree(filename);
3536
3542
xfree(pattern);