0
0
mirror of https://github.com/vim/vim.git synced 2025-09-24 03:44:06 -04:00

updated for version 7.0-191

This commit is contained in:
Bram Moolenaar
2007-02-04 01:58:18 +00:00
parent 86ea76404e
commit 48b66fb5a7
3 changed files with 51 additions and 11 deletions

View File

@@ -2897,12 +2897,14 @@ getqflist() *getqflist()*
vcol non-zero: "col" is visual column vcol non-zero: "col" is visual column
zero: "col" is byte index zero: "col" is byte index
nr error number nr error number
pattern search pattern used to locate the error
text description of the error text description of the error
type type of the error, 'E', '1', etc. type type of the error, 'E', '1', etc.
valid non-zero: recognized error message valid non-zero: recognized error message
When there is no error list or it's empty an empty list is When there is no error list or it's empty an empty list is
returned. returned. Quickfix list entries with non-existing buffer
number are returned with "bufnr" set to zero.
Useful application: Find pattern matches in multiple files and Useful application: Find pattern matches in multiple files and
do something with them: > do something with them: >
@@ -4371,7 +4373,10 @@ setqflist({list} [, {action}]) *setqflist()*
Non-dictionary items in {list} are ignored. Each dictionary Non-dictionary items in {list} are ignored. Each dictionary
item can contain the following entries: item can contain the following entries:
filename name of a file bufnr buffer number; must be the number of a valid
buffer
filename name of a file; only used when "bufnr" is not
present or it is invalid.
lnum line number in the file lnum line number in the file
pattern search pattern used to locate the error pattern search pattern used to locate the error
col column number col column number
@@ -4384,11 +4389,13 @@ setqflist({list} [, {action}]) *setqflist()*
The "col", "vcol", "nr", "type" and "text" entries are The "col", "vcol", "nr", "type" and "text" entries are
optional. Either "lnum" or "pattern" entry can be used to optional. Either "lnum" or "pattern" entry can be used to
locate a matching error line. locate a matching error line.
If the "filename" entry is not present or neither the "lnum" If the "filename" and "bufnr" entries are not present or
or "pattern" entries are present, then the item will not be neither the "lnum" or "pattern" entries are present, then the
handled as an error line. item will not be handled as an error line.
If both "pattern" and "lnum" are present then "pattern" will If both "pattern" and "lnum" are present then "pattern" will
be used. be used.
Note that the list is not exactly the same as what
|getqflist()| returns.
If {action} is set to 'a', then the items from {list} are If {action} is set to 'a', then the items from {list} are
added to the existing quickfix list. If there is no existing added to the existing quickfix list. If there is no existing

View File

@@ -106,7 +106,7 @@ struct efm_S
static int qf_init_ext __ARGS((qf_info_T *qi, char_u *efile, buf_T *buf, typval_T *tv, char_u *errorformat, int newlist, linenr_T lnumfirst, linenr_T lnumlast)); static int qf_init_ext __ARGS((qf_info_T *qi, char_u *efile, buf_T *buf, typval_T *tv, char_u *errorformat, int newlist, linenr_T lnumfirst, linenr_T lnumlast));
static void qf_new_list __ARGS((qf_info_T *qi)); static void qf_new_list __ARGS((qf_info_T *qi));
static int qf_add_entry __ARGS((qf_info_T *qi, qfline_T **prevp, char_u *dir, char_u *fname, char_u *mesg, long lnum, int col, int vis_col, char_u *pattern, int nr, int type, int valid)); static int qf_add_entry __ARGS((qf_info_T *qi, qfline_T **prevp, char_u *dir, char_u *fname, int bufnum, char_u *mesg, long lnum, int col, int vis_col, char_u *pattern, int nr, int type, int valid));
static void qf_msg __ARGS((qf_info_T *qi)); static void qf_msg __ARGS((qf_info_T *qi));
static void qf_free __ARGS((qf_info_T *qi, int idx)); static void qf_free __ARGS((qf_info_T *qi, int idx));
static char_u *qf_types __ARGS((int, int)); static char_u *qf_types __ARGS((int, int));
@@ -791,6 +791,7 @@ restofline:
(*namebuf || directory) (*namebuf || directory)
? namebuf ? namebuf
: ((currfile && valid) ? currfile : (char_u *)NULL), : ((currfile && valid) ? currfile : (char_u *)NULL),
0,
errmsg, errmsg,
lnum, lnum,
col, col,
@@ -936,12 +937,13 @@ qf_free_all(wp)
* Returns OK or FAIL. * Returns OK or FAIL.
*/ */
static int static int
qf_add_entry(qi, prevp, dir, fname, mesg, lnum, col, vis_col, pattern, nr, type, qf_add_entry(qi, prevp, dir, fname, bufnum, mesg, lnum, col, vis_col, pattern,
valid) nr, type, valid)
qf_info_T *qi; /* quickfix list */ qf_info_T *qi; /* quickfix list */
qfline_T **prevp; /* pointer to previously added entry or NULL */ qfline_T **prevp; /* pointer to previously added entry or NULL */
char_u *dir; /* optional directory name */ char_u *dir; /* optional directory name */
char_u *fname; /* file name or NULL */ char_u *fname; /* file name or NULL */
int bufnum; /* buffer number or zero */
char_u *mesg; /* message */ char_u *mesg; /* message */
long lnum; /* line number */ long lnum; /* line number */
int col; /* column */ int col; /* column */
@@ -955,7 +957,10 @@ qf_add_entry(qi, prevp, dir, fname, mesg, lnum, col, vis_col, pattern, nr, type,
if ((qfp = (qfline_T *)alloc((unsigned)sizeof(qfline_T))) == NULL) if ((qfp = (qfline_T *)alloc((unsigned)sizeof(qfline_T))) == NULL)
return FAIL; return FAIL;
qfp->qf_fnum = qf_get_fnum(dir, fname); if (bufnum != 0)
qfp->qf_fnum = bufnum;
else
qfp->qf_fnum = qf_get_fnum(dir, fname);
if ((qfp->qf_text = vim_strsave(mesg)) == NULL) if ((qfp->qf_text = vim_strsave(mesg)) == NULL)
{ {
vim_free(qfp); vim_free(qfp);
@@ -1106,6 +1111,7 @@ copy_loclist(from, to)
if (qf_add_entry(to->w_llist, &prevp, if (qf_add_entry(to->w_llist, &prevp,
NULL, NULL,
NULL, NULL,
0,
from_qfp->qf_text, from_qfp->qf_text,
from_qfp->qf_lnum, from_qfp->qf_lnum,
from_qfp->qf_col, from_qfp->qf_col,
@@ -3134,6 +3140,7 @@ ex_vimgrep(eap)
if (qf_add_entry(qi, &prevp, if (qf_add_entry(qi, &prevp,
NULL, /* dir */ NULL, /* dir */
fnames[fi], fnames[fi],
0,
ml_get_buf(buf, ml_get_buf(buf,
regmatch.startpos[0].lnum + lnum, FALSE), regmatch.startpos[0].lnum + lnum, FALSE),
regmatch.startpos[0].lnum + lnum, regmatch.startpos[0].lnum + lnum,
@@ -3419,6 +3426,7 @@ get_errorlist(wp, list)
char_u buf[2]; char_u buf[2];
qfline_T *qfp; qfline_T *qfp;
int i; int i;
int bufnum;
if (wp != NULL) if (wp != NULL)
{ {
@@ -3434,6 +3442,11 @@ get_errorlist(wp, list)
qfp = qi->qf_lists[qi->qf_curlist].qf_start; qfp = qi->qf_lists[qi->qf_curlist].qf_start;
for (i = 1; !got_int && i <= qi->qf_lists[qi->qf_curlist].qf_count; ++i) for (i = 1; !got_int && i <= qi->qf_lists[qi->qf_curlist].qf_count; ++i)
{ {
/* Handle entries with a non-existing buffer number. */
bufnum = qfp->qf_fnum;
if (bufnum != 0 && (buflist_findnr(bufnum) == NULL))
bufnum = 0;
if ((dict = dict_alloc()) == NULL) if ((dict = dict_alloc()) == NULL)
return FAIL; return FAIL;
if (list_append_dict(list, dict) == FAIL) if (list_append_dict(list, dict) == FAIL)
@@ -3441,7 +3454,7 @@ get_errorlist(wp, list)
buf[0] = qfp->qf_type; buf[0] = qfp->qf_type;
buf[1] = NUL; buf[1] = NUL;
if ( dict_add_nr_str(dict, "bufnr", (long)qfp->qf_fnum, NULL) == FAIL if ( dict_add_nr_str(dict, "bufnr", (long)bufnum, NULL) == FAIL
|| dict_add_nr_str(dict, "lnum", (long)qfp->qf_lnum, NULL) == FAIL || dict_add_nr_str(dict, "lnum", (long)qfp->qf_lnum, NULL) == FAIL
|| dict_add_nr_str(dict, "col", (long)qfp->qf_col, NULL) == FAIL || dict_add_nr_str(dict, "col", (long)qfp->qf_col, NULL) == FAIL
|| dict_add_nr_str(dict, "vcol", (long)qfp->qf_viscol, NULL) == FAIL || dict_add_nr_str(dict, "vcol", (long)qfp->qf_viscol, NULL) == FAIL
@@ -3472,6 +3485,7 @@ set_errorlist(wp, list, action)
listitem_T *li; listitem_T *li;
dict_T *d; dict_T *d;
char_u *filename, *pattern, *text, *type; char_u *filename, *pattern, *text, *type;
int bufnum;
long lnum; long lnum;
int col, nr; int col, nr;
int vcol; int vcol;
@@ -3479,6 +3493,7 @@ set_errorlist(wp, list, action)
int valid, status; int valid, status;
int retval = OK; int retval = OK;
qf_info_T *qi = &ql_info; qf_info_T *qi = &ql_info;
int did_bufnr_emsg = FALSE;
if (wp != NULL) if (wp != NULL)
{ {
@@ -3508,6 +3523,7 @@ set_errorlist(wp, list, action)
continue; continue;
filename = get_dict_string(d, (char_u *)"filename", TRUE); filename = get_dict_string(d, (char_u *)"filename", TRUE);
bufnum = get_dict_number(d, (char_u *)"bufnr");
lnum = get_dict_number(d, (char_u *)"lnum"); lnum = get_dict_number(d, (char_u *)"lnum");
col = get_dict_number(d, (char_u *)"col"); col = get_dict_number(d, (char_u *)"col");
vcol = get_dict_number(d, (char_u *)"vcol"); vcol = get_dict_number(d, (char_u *)"vcol");
@@ -3519,12 +3535,26 @@ set_errorlist(wp, list, action)
text = vim_strsave((char_u *)""); text = vim_strsave((char_u *)"");
valid = TRUE; valid = TRUE;
if (filename == NULL || (lnum == 0 && pattern == NULL)) if ((filename == NULL && bufnum == 0) || (lnum == 0 && pattern == NULL))
valid = FALSE; valid = FALSE;
/* Mark entries with non-existing buffer number as not valid. Give the
* error message only once. */
if (bufnum != 0 && (buflist_findnr(bufnum) == NULL))
{
if (!did_bufnr_emsg)
{
did_bufnr_emsg = TRUE;
EMSGN(_("E92: Buffer %ld not found"), bufnum);
}
valid = FALSE;
bufnum = 0;
}
status = qf_add_entry(qi, &prevp, status = qf_add_entry(qi, &prevp,
NULL, /* dir */ NULL, /* dir */
filename, filename,
bufnum,
text, text,
lnum, lnum,
col, col,
@@ -3757,6 +3787,7 @@ ex_helpgrep(eap)
if (qf_add_entry(qi, &prevp, if (qf_add_entry(qi, &prevp,
NULL, /* dir */ NULL, /* dir */
fnames[fi], fnames[fi],
0,
IObuff, IObuff,
lnum, lnum,
(int)(regmatch.startp[0] - IObuff) (int)(regmatch.startp[0] - IObuff)

View File

@@ -666,6 +666,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
191,
/**/ /**/
190, 190,
/**/ /**/