syntax: use const on check_keyword_id() variables

Declare and initialize variables as close as possible.
Use const pointers without changing semantics if possible.
This commit is contained in:
Jan Edmund Lazo 2018-07-26 20:26:20 -04:00
parent 2a7047b77c
commit db4bddb770

View File

@ -2932,39 +2932,35 @@ static int syn_regexec(regmmatch_T *rmp, linenr_T lnum, colnr_T col, syn_time_T
* The caller must check if a keyword can start at startcol. * The caller must check if a keyword can start at startcol.
* Return its ID if found, 0 otherwise. * Return its ID if found, 0 otherwise.
*/ */
static int static int check_keyword_id(
check_keyword_id( char_u *const line,
char_u *line, const int startcol, // position in line to check for keyword
int startcol, /* position in line to check for keyword */ int *const endcolp, // return: character after found keyword
int *endcolp, /* return: character after found keyword */ long *const flagsp, // return: flags of matching keyword
long *flagsp, /* return: flags of matching keyword */ int16_t **const next_listp, // return: next_list of matching keyword
short **next_listp, /* return: next_list of matching keyword */ stateitem_T *const cur_si, // item at the top of the stack
stateitem_T *cur_si, /* item at the top of the stack */ int *const ccharp // conceal substitution char
int *ccharp /* conceal substitution char */
) )
{ {
char_u *kwp; // Find first character after the keyword. First character was already
int kwlen; // checked.
char_u keyword[MAXKEYWLEN + 1]; /* assume max. keyword len is 80 */ char_u *const kwp = line + startcol;
int kwlen = 0;
/* Find first character after the keyword. First character was already
* checked. */
kwp = line + startcol;
kwlen = 0;
do { do {
if (has_mbyte) if (has_mbyte) {
kwlen += (*mb_ptr2len)(kwp + kwlen); kwlen += (*mb_ptr2len)(kwp + kwlen);
else } else {
++kwlen; kwlen++;
}
} while (vim_iswordp_buf(kwp + kwlen, syn_buf)); } while (vim_iswordp_buf(kwp + kwlen, syn_buf));
if (kwlen > MAXKEYWLEN) if (kwlen > MAXKEYWLEN) {
return 0; return 0;
}
/* // Must make a copy of the keyword, so we can add a NUL and make it
* Must make a copy of the keyword, so we can add a NUL and make it // lowercase.
* lowercase. char_u keyword[MAXKEYWLEN + 1]; // assume max. keyword len is 80
*/
STRLCPY(keyword, kwp, kwlen + 1); STRLCPY(keyword, kwp, kwlen + 1);
keyentry_T *kp = NULL; keyentry_T *kp = NULL;