mirror of
https://github.com/neovim/neovim.git
synced 2025-09-06 03:18:16 +00:00
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.
This commit is contained in:
@@ -615,7 +615,7 @@ char *check_stl_option(char *s)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (vim_strchr(STL_ALL, (uint8_t)(*s)) == NULL) {
|
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 == '{') {
|
if (*s == '{') {
|
||||||
bool reevaluate = (*++s == '%');
|
bool reevaluate = (*++s == '%');
|
||||||
@@ -957,7 +957,7 @@ static void did_set_comments(char **varp, char *errbuf, size_t errbuflen, char *
|
|||||||
while (*s && *s != ':') {
|
while (*s && *s != ':') {
|
||||||
if (vim_strchr(COM_ALL, (uint8_t)(*s)) == NULL
|
if (vim_strchr(COM_ALL, (uint8_t)(*s)) == NULL
|
||||||
&& !ascii_isdigit(*s) && *s != '-') {
|
&& !ascii_isdigit(*s) && *s != '-') {
|
||||||
*errmsg = illegal_char(errbuf, errbuflen, *s);
|
*errmsg = illegal_char(errbuf, errbuflen, (uint8_t)(*s));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
s++;
|
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;) {
|
for (char *s = p_shada; *s;) {
|
||||||
// Check it's a valid character
|
// Check it's a valid character
|
||||||
if (vim_strchr("!\"%'/:<@cfhnrs", (uint8_t)(*s)) == NULL) {
|
if (vim_strchr("!\"%'/:<@cfhnrs", (uint8_t)(*s)) == NULL) {
|
||||||
*errmsg = illegal_char(errbuf, errbuflen, *s);
|
*errmsg = illegal_char(errbuf, errbuflen, (uint8_t)(*s));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (*s == 'n') { // name is always last one
|
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;
|
break;
|
||||||
}
|
}
|
||||||
if (vim_strchr(".wbuksid]tU", (uint8_t)(*s)) == NULL) {
|
if (vim_strchr(".wbuksid]tU", (uint8_t)(*s)) == NULL) {
|
||||||
*errmsg = illegal_char(errbuf, errbuflen, *s);
|
*errmsg = illegal_char(errbuf, errbuflen, (uint8_t)(*s));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (*++s != NUL && *s != ',' && *s != ' ') {
|
if (*++s != NUL && *s != ',' && *s != ' ') {
|
||||||
@@ -1511,8 +1511,8 @@ static void did_set_option_listflag(char **varp, char *flags, char *errbuf, size
|
|||||||
char **errmsg)
|
char **errmsg)
|
||||||
{
|
{
|
||||||
for (char *s = *varp; *s; s++) {
|
for (char *s = *varp; *s; s++) {
|
||||||
if (vim_strchr(flags, *s) == NULL) {
|
if (vim_strchr(flags, (uint8_t)(*s)) == NULL) {
|
||||||
*errmsg = illegal_char(errbuf, errbuflen, *s);
|
*errmsg = illegal_char(errbuf, errbuflen, (uint8_t)(*s));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user