/* vi:set ts=8 sts=4 sw=4 noet:
*
* VIM - Vi IMproved by Bram Moolenaar
*
* Do ":help uganda" in Vim to read copying and usage conditions.
* Do ":help credits" in Vim to see a list of people who contributed.
* See README.txt for an overview of the Vim source code.
*/
/*
* match.c: functions for highlighting matches
*/
#include "vim.h"
#if defined(FEAT_SEARCH_EXTRA) || defined(PROTO)
# define SEARCH_HL_PRIORITY 0
/*
* Add match to the match list of window 'wp'. The pattern 'pat' will be
* highlighted with the group 'grp' with priority 'prio'.
* Optionally, a desired ID 'id' can be specified (greater than or equal to 1).
* If no particular ID is desired, -1 must be specified for 'id'.
* Return ID of added match, -1 on failure.
*/
static int
match_add(
win_T *wp,
char_u *grp,
char_u *pat,
int prio,
int id,
list_T *pos_list,
char_u *conceal_char UNUSED) // pointer to conceal replacement char
{
matchitem_T *cur;
matchitem_T *prev;
matchitem_T *m;
int hlg_id;
regprog_T *regprog = NULL;
int rtype = SOME_VALID;
if (*grp == NUL || (pat != NULL && *pat == NUL))
return -1;
if (id < -1 || id == 0)
{
semsg(_("E799: Invalid ID: %d (must be greater than or equal to 1)"),
id);
return -1;
}
if (id != -1)
{
cur = wp->w_match_head;
while (cur != NULL)
{
if (cur->id == id)
{
semsg(_("E801: ID already taken: %d"), id);
return -1;
}
cur = cur->next;
}
}
if ((hlg_id = syn_namen2id(grp, (int)STRLEN(grp))) == 0)
{
semsg(_(e_nogroup), grp);
return -1;
}
if (pat != NULL &&