diff options
author | Jan Edmund Lazo <janedmundlazo@hotmail.com> | 2018-07-26 20:26:20 -0400 |
---|---|---|
committer | Jan Edmund Lazo <janedmundlazo@hotmail.com> | 2018-07-29 07:51:51 -0400 |
commit | db4bddb770ea9244ad40eb7f09e2bce145a7981c (patch) | |
tree | bcb5ea6cecbc3b5716515f2470f134958b8b0c83 /src | |
parent | 2a7047b77cc5814fcd2d3107e4cfe2a56ad1b7c8 (diff) | |
download | rneovim-db4bddb770ea9244ad40eb7f09e2bce145a7981c.tar.gz rneovim-db4bddb770ea9244ad40eb7f09e2bce145a7981c.tar.bz2 rneovim-db4bddb770ea9244ad40eb7f09e2bce145a7981c.zip |
syntax: use const on check_keyword_id() variables
Declare and initialize variables as close as possible.
Use const pointers without changing semantics if possible.
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/syntax.c | 46 |
1 files changed, 21 insertions, 25 deletions
diff --git a/src/nvim/syntax.c b/src/nvim/syntax.c index 9f36f1ce92..22dcb35373 100644 --- a/src/nvim/syntax.c +++ b/src/nvim/syntax.c @@ -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. * Return its ID if found, 0 otherwise. */ -static int -check_keyword_id( - char_u *line, - int startcol, /* position in line to check for keyword */ - int *endcolp, /* return: character after found keyword */ - long *flagsp, /* return: flags of matching keyword */ - short **next_listp, /* return: next_list of matching keyword */ - stateitem_T *cur_si, /* item at the top of the stack */ - int *ccharp /* conceal substitution char */ +static int check_keyword_id( + char_u *const line, + const int startcol, // position in line to check for keyword + int *const endcolp, // return: character after found keyword + long *const flagsp, // return: flags of matching keyword + int16_t **const next_listp, // return: next_list of matching keyword + stateitem_T *const cur_si, // item at the top of the stack + int *const ccharp // conceal substitution char ) { - char_u *kwp; - int kwlen; - char_u keyword[MAXKEYWLEN + 1]; /* assume max. keyword len is 80 */ - - /* Find first character after the keyword. First character was already - * checked. */ - kwp = line + startcol; - kwlen = 0; + // Find first character after the keyword. First character was already + // checked. + char_u *const kwp = line + startcol; + int kwlen = 0; do { - if (has_mbyte) + if (has_mbyte) { kwlen += (*mb_ptr2len)(kwp + kwlen); - else - ++kwlen; + } else { + kwlen++; + } } while (vim_iswordp_buf(kwp + kwlen, syn_buf)); - if (kwlen > MAXKEYWLEN) + if (kwlen > MAXKEYWLEN) { return 0; + } - /* - * Must make a copy of the keyword, so we can add a NUL and make it - * lowercase. - */ + // Must make a copy of the keyword, so we can add a NUL and make it + // lowercase. + char_u keyword[MAXKEYWLEN + 1]; // assume max. keyword len is 80 STRLCPY(keyword, kwp, kwlen + 1); keyentry_T *kp = NULL; |