Commit 04b9ef8b authored by Abdelhakeem's avatar Abdelhakeem Committed by James McCoy

fixup: use vim_snprintf, ASCII_ISALNUM

ASCII_ISALNUM is part of vim-patch:8.1.0540

(cherry picked from commit 0ec8da43)
Signed-off-by: James McCoy's avatarJames McCoy <jamessan@debian.org>
parent 47b1c246
......@@ -1803,7 +1803,9 @@ do_set (
// or 'filetype' autocommands may be triggered that can
// cause havoc.
errmsg = did_set_string_option(opt_idx, (char_u **)varp,
new_value_alloced, oldval, errbuf, opt_flags, &value_checked);
new_value_alloced, oldval,
errbuf, sizeof(errbuf),
opt_flags, &value_checked);
if (did_inc_secure) {
--secure;
......@@ -1912,19 +1914,21 @@ did_set_option (
* flag. */
uint32_t *p = insecure_flag(opt_idx, opt_flags);
if (!value_checked && (secure
|| sandbox != 0
|| (opt_flags & OPT_MODELINE)))
|| sandbox != 0
|| (opt_flags & OPT_MODELINE))) {
*p = *p | P_INSECURE;
else if (new_value)
} else if (new_value) {
*p = *p & ~P_INSECURE;
}
}
static char_u *illegal_char(char_u *errbuf, int c)
static char_u *illegal_char(char_u *errbuf, size_t errbuflen, int c)
{
if (errbuf == NULL)
if (errbuf == NULL) {
return (char_u *)"";
sprintf((char *)errbuf, _("E539: Illegal character <%s>"),
(char *)transchar(c));
}
vim_snprintf((char *)errbuf, errbuflen, _("E539: Illegal character <%s>"),
(char *)transchar(c));
return errbuf;
}
......@@ -2416,7 +2420,7 @@ static char *set_string_option(const int opt_idx, const char *const value,
int value_checked = false;
char *const r = (char *)did_set_string_option(
opt_idx, (char_u **)varp, (int)true, (char_u *)oldval,
NULL, opt_flags, &value_checked);
NULL, 0, opt_flags, &value_checked);
if (r == NULL) {
did_set_option(opt_idx, opt_flags, true, value_checked);
}
......@@ -2459,15 +2463,16 @@ static bool valid_filetype(char_u *val)
* Returns NULL for success, or an error message for an error.
*/
static char_u *
did_set_string_option (
int opt_idx, /* index in options[] table */
char_u **varp, /* pointer to the option variable */
int new_value_alloced, /* new value was allocated */
char_u *oldval, /* previous value of the option */
char_u *errbuf, /* buffer for errors, or NULL */
int opt_flags, /* OPT_LOCAL and/or OPT_GLOBAL */
int *value_checked /* value was checked to be safe, no
need to set P_INSECURE */
did_set_string_option(
int opt_idx, // index in options[] table
char_u **varp, // pointer to the option variable
int new_value_alloced, // new value was allocated
char_u *oldval, // previous value of the option
char_u *errbuf, // buffer for errors, or NULL
size_t errbuflen, // length of errors buffer
int opt_flags, // OPT_LOCAL and/or OPT_GLOBAL
int *value_checked // value was checked to be safe, no
// need to set P_INSECURE
)
{
char_u *errmsg = NULL;
......@@ -2784,7 +2789,7 @@ did_set_string_option (
while (*s && *s != ':') {
if (vim_strchr((char_u *)COM_ALL, *s) == NULL
&& !ascii_isdigit(*s) && *s != '-') {
errmsg = illegal_char(errbuf, *s);
errmsg = illegal_char(errbuf, errbuflen, *s);
break;
}
++s;
......@@ -2836,7 +2841,7 @@ did_set_string_option (
for (s = p_shada; *s; ) {
/* Check it's a valid character */
if (vim_strchr((char_u *)"!\"%'/:<@cfhnrs", *s) == NULL) {
errmsg = illegal_char(errbuf, *s);
errmsg = illegal_char(errbuf, errbuflen, *s);
break;
}
if (*s == 'n') { /* name is always last one */
......@@ -2856,9 +2861,9 @@ did_set_string_option (
if (!ascii_isdigit(*(s - 1))) {
if (errbuf != NULL) {
sprintf((char *)errbuf,
_("E526: Missing number after <%s>"),
transchar_byte(*(s - 1)));
vim_snprintf((char *)errbuf, errbuflen,
_("E526: Missing number after <%s>"),
transchar_byte(*(s - 1)));
errmsg = errbuf;
} else
errmsg = (char_u *)"";
......@@ -3036,7 +3041,7 @@ did_set_string_option (
if (!*s)
break;
if (vim_strchr((char_u *)".wbuksid]tU", *s) == NULL) {
errmsg = illegal_char(errbuf, *s);
errmsg = illegal_char(errbuf, errbuflen, *s);
break;
}
if (*++s != NUL && *s != ',' && *s != ' ') {
......@@ -3050,9 +3055,9 @@ did_set_string_option (
}
} else {
if (errbuf != NULL) {
sprintf((char *)errbuf,
_("E535: Illegal character after <%c>"),
*--s);
vim_snprintf((char *)errbuf, errbuflen,
_("E535: Illegal character after <%c>"),
*--s);
errmsg = errbuf;
} else
errmsg = (char_u *)"";
......@@ -3248,7 +3253,7 @@ did_set_string_option (
if (p != NULL) {
for (s = *varp; *s; ++s)
if (vim_strchr(p, *s) == NULL) {
errmsg = illegal_char(errbuf, *s);
errmsg = illegal_char(errbuf, errbuflen, *s);
break;
}
}
......@@ -3347,7 +3352,7 @@ did_set_string_option (
* '.encoding'.
*/
for (p = q; *p != NUL; ++p)
if (!ASCII_ISALPHA(*p) && *p != '-')
if (!ASCII_ISALNUM(*p) && *p != '-')
break;
if (p > q) {
vim_snprintf((char *)fname, sizeof(fname), "spell/%.*s.vim",
......@@ -3615,7 +3620,7 @@ char_u *check_stl_option(char_u *s)
continue;
}
if (vim_strchr(STL_ALL, *s) == NULL) {
return illegal_char(errbuf, *s);
return illegal_char(errbuf, sizeof(errbuf), *s);
}
if (*s == '{') {
s++;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment