neovim

Neovim text editor
git clone https://git.dasho.dev/neovim.git
Log | Files | Refs | README

commit 334f5382677b3bcf91e74bb8502d38c7d2bd4281
parent ef85238fde4560ae931dc98ac052a2b5564327fd
Author: Lewis Russell <lewis6991@gmail.com>
Date:   Wed, 25 Jan 2023 15:41:55 +0000

refactor(option.c): change nextchar to uint8_t

Diffstat:
Msrc/nvim/option.c | 13++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/src/nvim/option.c b/src/nvim/option.c @@ -1242,7 +1242,7 @@ static void do_set_option(int opt_flags, char **argp, bool *did_show, char *errb len++; } } - char_u nextchar = (uint8_t)arg[len]; // next non-white char after option name + uint8_t nextchar = (uint8_t)arg[len]; // next non-white char after option name if (opt_idx == -1 && key == 0) { // found a mismatch: skip *errmsg = e_unknown_option; @@ -1256,7 +1256,7 @@ static void do_set_option(int opt_flags, char **argp, bool *did_show, char *errb if (options[opt_idx].var == NULL) { // hidden option: skip // Only give an error message when requesting the value of // a hidden option, ignore setting it. - if (vim_strchr("=:!&<", (uint8_t)nextchar) == NULL + if (vim_strchr("=:!&<", nextchar) == NULL && (!(options[opt_idx].flags & P_BOOL) || nextchar == '?')) { *errmsg = e_unsupportedoption; @@ -1310,7 +1310,7 @@ static void do_set_option(int opt_flags, char **argp, bool *did_show, char *errb return; } - if (vim_strchr("?=:!&<", (uint8_t)nextchar) != NULL) { + if (vim_strchr("?=:!&<", nextchar) != NULL) { *argp += len; if (nextchar == '&' && (*argp)[1] == 'v' && (*argp)[2] == 'i') { if ((*argp)[3] == 'm') { // "opt&vim": set to Vim default @@ -1319,7 +1319,7 @@ static void do_set_option(int opt_flags, char **argp, bool *did_show, char *errb *argp += 2; } } - if (vim_strchr("?!&<", (uint8_t)nextchar) != NULL + if (vim_strchr("?!&<", nextchar) != NULL && (*argp)[1] != NUL && !ascii_iswhite((*argp)[1])) { *errmsg = e_trailing; return; @@ -1332,7 +1332,7 @@ static void do_set_option(int opt_flags, char **argp, bool *did_show, char *errb // if (nextchar == '?' || (prefix == 1 - && vim_strchr("=:&<", (uint8_t)nextchar) == NULL + && vim_strchr("=:&<", nextchar) == NULL && !(flags & P_BOOL))) { // print value if (*did_show) { @@ -1365,8 +1365,7 @@ static void do_set_option(int opt_flags, char **argp, bool *did_show, char *errb if (flags & P_BOOL) { // boolean do_set_bool(opt_idx, opt_flags, prefix, nextchar, afterchar, varp, errmsg); } else { // Numeric or string. - if (vim_strchr("=:&<", (uint8_t)nextchar) == NULL - || prefix != 1) { + if (vim_strchr("=:&<", nextchar) == NULL || prefix != 1) { *errmsg = e_invarg; return; }