aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2023-01-26 09:12:33 +0800
committerGitHub <noreply@github.com>2023-01-26 09:12:33 +0800
commit116766f243b4ac647f040181334c8001e01aab75 (patch)
treea80653aa58e14a74ad6b809737a27aba4a9e298f /src
parent88e906d165b5dd57fb13b190ec9cb2d67bc6b223 (diff)
downloadrneovim-116766f243b4ac647f040181334c8001e01aab75.tar.gz
rneovim-116766f243b4ac647f040181334c8001e01aab75.tar.bz2
rneovim-116766f243b4ac647f040181334c8001e01aab75.zip
refactor(options): don't pass negative number to illegal_char() (#21999)
This only changes the error messages for an unexpected Unicode char in an option to show its first byte instead of some special keycode. The second argument of vim_strchr() usually doesn't matter, but it may be better to consistently cast to uint8_t.
Diffstat (limited to 'src')
-rw-r--r--src/nvim/optionstr.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/nvim/optionstr.c b/src/nvim/optionstr.c
index 162d8b691a..5ebff9ed77 100644
--- a/src/nvim/optionstr.c
+++ b/src/nvim/optionstr.c
@@ -615,7 +615,7 @@ char *check_stl_option(char *s)
continue;
}
if (vim_strchr(STL_ALL, (uint8_t)(*s)) == NULL) {
- return illegal_char(errbuf, sizeof(errbuf), *s);
+ return illegal_char(errbuf, sizeof(errbuf), (uint8_t)(*s));
}
if (*s == '{') {
bool reevaluate = (*++s == '%');
@@ -957,7 +957,7 @@ static void did_set_comments(char **varp, char *errbuf, size_t errbuflen, char *
while (*s && *s != ':') {
if (vim_strchr(COM_ALL, (uint8_t)(*s)) == NULL
&& !ascii_isdigit(*s) && *s != '-') {
- *errmsg = illegal_char(errbuf, errbuflen, *s);
+ *errmsg = illegal_char(errbuf, errbuflen, (uint8_t)(*s));
break;
}
s++;
@@ -1029,7 +1029,7 @@ static void did_set_shada(vimoption_T **opt, int *opt_idx, bool *free_oldval, ch
for (char *s = p_shada; *s;) {
// Check it's a valid character
if (vim_strchr("!\"%'/:<@cfhnrs", (uint8_t)(*s)) == NULL) {
- *errmsg = illegal_char(errbuf, errbuflen, *s);
+ *errmsg = illegal_char(errbuf, errbuflen, (uint8_t)(*s));
break;
}
if (*s == 'n') { // name is always last one
@@ -1236,7 +1236,7 @@ static void did_set_complete(char **varp, char *errbuf, size_t errbuflen, char *
break;
}
if (vim_strchr(".wbuksid]tU", (uint8_t)(*s)) == NULL) {
- *errmsg = illegal_char(errbuf, errbuflen, *s);
+ *errmsg = illegal_char(errbuf, errbuflen, (uint8_t)(*s));
break;
}
if (*++s != NUL && *s != ',' && *s != ' ') {
@@ -1511,8 +1511,8 @@ static void did_set_option_listflag(char **varp, char *flags, char *errbuf, size
char **errmsg)
{
for (char *s = *varp; *s; s++) {
- if (vim_strchr(flags, *s) == NULL) {
- *errmsg = illegal_char(errbuf, errbuflen, *s);
+ if (vim_strchr(flags, (uint8_t)(*s)) == NULL) {
+ *errmsg = illegal_char(errbuf, errbuflen, (uint8_t)(*s));
break;
}
}