mirror of
https://github.com/vim/vim.git
synced 2025-09-25 03:54:15 -04:00
patch 9.1.0803: tests: no error check when setting global 'isk'
Problem: tests: no error check when setting global 'isk' Solution: also parse and check global 'isk' value (Milly) closes: #15915 Signed-off-by: Milly <milly.ca@gmail.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
committed by
Christian Brabandt
parent
142cad1f88
commit
5e7a6a4a10
@@ -13,6 +13,7 @@
|
|||||||
# include <wchar.h> // for towupper() and towlower()
|
# include <wchar.h> // for towupper() and towlower()
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static int parse_isopt(char_u *var, buf_T *buf, int only_check);
|
||||||
static int win_nolbr_chartabsize(chartabsize_T *cts, int *headp);
|
static int win_nolbr_chartabsize(chartabsize_T *cts, int *headp);
|
||||||
static unsigned nr2hex(unsigned c);
|
static unsigned nr2hex(unsigned c);
|
||||||
|
|
||||||
@@ -75,11 +76,8 @@ buf_init_chartab(
|
|||||||
int global) // FALSE: only set buf->b_chartab[]
|
int global) // FALSE: only set buf->b_chartab[]
|
||||||
{
|
{
|
||||||
int c;
|
int c;
|
||||||
int c2;
|
|
||||||
char_u *p;
|
char_u *p;
|
||||||
int i;
|
int i;
|
||||||
int tilde;
|
|
||||||
int do_isalpha;
|
|
||||||
|
|
||||||
if (global)
|
if (global)
|
||||||
{
|
{
|
||||||
@@ -135,9 +133,7 @@ buf_init_chartab(
|
|||||||
if (buf->b_p_lisp)
|
if (buf->b_p_lisp)
|
||||||
SET_CHARTAB(buf, '-');
|
SET_CHARTAB(buf, '-');
|
||||||
|
|
||||||
// Walk through the 'isident', 'iskeyword', 'isfname' and 'isprint'
|
// Walk through the 'isident', 'iskeyword', 'isfname' and 'isprint' options.
|
||||||
// options Each option is a list of characters, character numbers or
|
|
||||||
// ranges, separated by commas, e.g.: "200-210,x,#-178,-"
|
|
||||||
for (i = global ? 0 : 3; i <= 3; ++i)
|
for (i = global ? 0 : 3; i <= 3; ++i)
|
||||||
{
|
{
|
||||||
if (i == 0)
|
if (i == 0)
|
||||||
@@ -149,6 +145,41 @@ buf_init_chartab(
|
|||||||
else // i == 3
|
else // i == 3
|
||||||
p = buf->b_p_isk; // fourth round: 'iskeyword'
|
p = buf->b_p_isk; // fourth round: 'iskeyword'
|
||||||
|
|
||||||
|
if (parse_isopt(p, buf, FALSE) == FAIL)
|
||||||
|
return FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
chartab_initialized = TRUE;
|
||||||
|
return OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks the format for the option settings 'iskeyword', 'isident', 'isfname'
|
||||||
|
* or 'isprint'.
|
||||||
|
* Returns FAIL if has an error, OK otherwise.
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
check_isopt(char_u *var)
|
||||||
|
{
|
||||||
|
return parse_isopt(var, NULL, TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
parse_isopt(
|
||||||
|
char_u *var,
|
||||||
|
buf_T *buf,
|
||||||
|
int only_check) // FALSE: refill g_chartab[]
|
||||||
|
{
|
||||||
|
char_u *p = var;
|
||||||
|
int c;
|
||||||
|
int c2;
|
||||||
|
int tilde;
|
||||||
|
int do_isalpha;
|
||||||
|
int trail_comma;
|
||||||
|
|
||||||
|
// Parses the 'isident', 'iskeyword', 'isfname' and 'isprint' options.
|
||||||
|
// Each option is a list of characters, character numbers or ranges,
|
||||||
|
// separated by commas, e.g.: "200-210,x,#-178,-"
|
||||||
while (*p)
|
while (*p)
|
||||||
{
|
{
|
||||||
tilde = FALSE;
|
tilde = FALSE;
|
||||||
@@ -179,6 +210,15 @@ buf_init_chartab(
|
|||||||
|| !(*p == NUL || *p == ','))
|
|| !(*p == NUL || *p == ','))
|
||||||
return FAIL;
|
return FAIL;
|
||||||
|
|
||||||
|
trail_comma = *p == ',';
|
||||||
|
p = skip_to_option_part(p);
|
||||||
|
if (trail_comma && *p == NUL)
|
||||||
|
// Trailing comma is not allowed.
|
||||||
|
return FAIL;
|
||||||
|
|
||||||
|
if (only_check)
|
||||||
|
continue;
|
||||||
|
|
||||||
if (c2 == -1) // not a range
|
if (c2 == -1) // not a range
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
@@ -196,6 +236,7 @@ buf_init_chartab(
|
|||||||
else
|
else
|
||||||
c2 = c;
|
c2 = c;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (c <= c2)
|
while (c <= c2)
|
||||||
{
|
{
|
||||||
// Use the MB_ functions here, because isalpha() doesn't
|
// Use the MB_ functions here, because isalpha() doesn't
|
||||||
@@ -203,14 +244,14 @@ buf_init_chartab(
|
|||||||
// "C".
|
// "C".
|
||||||
if (!do_isalpha || MB_ISLOWER(c) || MB_ISUPPER(c))
|
if (!do_isalpha || MB_ISLOWER(c) || MB_ISUPPER(c))
|
||||||
{
|
{
|
||||||
if (i == 0) // (re)set ID flag
|
if (var == p_isi) // (re)set ID flag
|
||||||
{
|
{
|
||||||
if (tilde)
|
if (tilde)
|
||||||
g_chartab[c] &= ~CT_ID_CHAR;
|
g_chartab[c] &= ~CT_ID_CHAR;
|
||||||
else
|
else
|
||||||
g_chartab[c] |= CT_ID_CHAR;
|
g_chartab[c] |= CT_ID_CHAR;
|
||||||
}
|
}
|
||||||
else if (i == 1) // (re)set printable
|
else if (var == p_isp) // (re)set printable
|
||||||
{
|
{
|
||||||
if ((c < ' ' || c > '~'
|
if ((c < ' ' || c > '~'
|
||||||
// For double-byte we keep the cell width, so
|
// For double-byte we keep the cell width, so
|
||||||
@@ -225,20 +266,20 @@ buf_init_chartab(
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
g_chartab[c] = (g_chartab[c] & ~CT_CELL_MASK)
|
g_chartab[c] = (g_chartab[c] & ~CT_CELL_MASK) + 1;
|
||||||
+ 1;
|
|
||||||
g_chartab[c] |= CT_PRINT_CHAR;
|
g_chartab[c] |= CT_PRINT_CHAR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (i == 2) // (re)set fname flag
|
else if (var == p_isf) // (re)set fname flag
|
||||||
{
|
{
|
||||||
if (tilde)
|
if (tilde)
|
||||||
g_chartab[c] &= ~CT_FNAME_CHAR;
|
g_chartab[c] &= ~CT_FNAME_CHAR;
|
||||||
else
|
else
|
||||||
g_chartab[c] |= CT_FNAME_CHAR;
|
g_chartab[c] |= CT_FNAME_CHAR;
|
||||||
}
|
}
|
||||||
else // i == 3 (re)set keyword flag
|
else // var == p_isk || var == buf->b_p_isk
|
||||||
|
// (re)set keyword flag
|
||||||
{
|
{
|
||||||
if (tilde)
|
if (tilde)
|
||||||
RESET_CHARTAB(buf, c);
|
RESET_CHARTAB(buf, c);
|
||||||
@@ -248,15 +289,8 @@ buf_init_chartab(
|
|||||||
}
|
}
|
||||||
++c;
|
++c;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
c = *p;
|
|
||||||
p = skip_to_option_part(p);
|
|
||||||
if (c == ',' && *p == NUL)
|
|
||||||
// Trailing comma is not allowed.
|
|
||||||
return FAIL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
chartab_initialized = TRUE;
|
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1456,7 +1456,7 @@ static struct vimoption options[] =
|
|||||||
#endif
|
#endif
|
||||||
(char_u *)0L} SCTX_INIT},
|
(char_u *)0L} SCTX_INIT},
|
||||||
{"iskeyword", "isk", P_STRING|P_ALLOCED|P_VIM|P_COMMA|P_NODUP,
|
{"iskeyword", "isk", P_STRING|P_ALLOCED|P_VIM|P_COMMA|P_NODUP,
|
||||||
(char_u *)&p_isk, PV_ISK, did_set_isopt, NULL,
|
(char_u *)&p_isk, PV_ISK, did_set_iskeyword, NULL,
|
||||||
{
|
{
|
||||||
(char_u *)"@,48-57,_",
|
(char_u *)"@,48-57,_",
|
||||||
#if defined(MSWIN)
|
#if defined(MSWIN)
|
||||||
|
@@ -2774,6 +2774,25 @@ did_set_imactivatekey(optset_T *args UNUSED)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The 'iskeyword' option is changed.
|
||||||
|
*/
|
||||||
|
char *
|
||||||
|
did_set_iskeyword(optset_T *args)
|
||||||
|
{
|
||||||
|
char_u **varp = (char_u **)args->os_varp;
|
||||||
|
|
||||||
|
if (varp == &p_isk) // only check for global-value
|
||||||
|
{
|
||||||
|
if (check_isopt(*varp) == FAIL)
|
||||||
|
return e_invalid_argument;
|
||||||
|
}
|
||||||
|
else // fallthrough for local-value
|
||||||
|
return did_set_isopt(args);
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The 'isident' or the 'iskeyword' or the 'isprint' or the 'isfname' option is
|
* The 'isident' or the 'iskeyword' or the 'isprint' or the 'isfname' option is
|
||||||
* changed.
|
* changed.
|
||||||
@@ -2781,7 +2800,7 @@ did_set_imactivatekey(optset_T *args UNUSED)
|
|||||||
char *
|
char *
|
||||||
did_set_isopt(optset_T *args)
|
did_set_isopt(optset_T *args)
|
||||||
{
|
{
|
||||||
// 'isident', 'iskeyword', 'isprint or 'isfname' option: refill g_chartab[]
|
// 'isident', 'iskeyword', 'isprint' or 'isfname' option: refill g_chartab[]
|
||||||
// If the new option is invalid, use old value.
|
// If the new option is invalid, use old value.
|
||||||
// 'lisp' option: refill g_chartab[] for '-' char.
|
// 'lisp' option: refill g_chartab[] for '-' char.
|
||||||
if (init_chartab() == FAIL)
|
if (init_chartab() == FAIL)
|
||||||
|
@@ -1,6 +1,7 @@
|
|||||||
/* charset.c */
|
/* charset.c */
|
||||||
int init_chartab(void);
|
int init_chartab(void);
|
||||||
int buf_init_chartab(buf_T *buf, int global);
|
int buf_init_chartab(buf_T *buf, int global);
|
||||||
|
int check_isopt(char_u *isopt);
|
||||||
void trans_characters(char_u *buf, int bufsize);
|
void trans_characters(char_u *buf, int bufsize);
|
||||||
char_u *transstr(char_u *s);
|
char_u *transstr(char_u *s);
|
||||||
char_u *str_foldcase(char_u *str, int orglen, char_u *buf, int buflen);
|
char_u *str_foldcase(char_u *str, int orglen, char_u *buf, int buflen);
|
||||||
|
@@ -99,6 +99,7 @@ char *did_set_highlight(optset_T *args);
|
|||||||
int expand_set_highlight(optexpand_T *args, int *numMatches, char_u ***matches);
|
int expand_set_highlight(optexpand_T *args, int *numMatches, char_u ***matches);
|
||||||
char *did_set_iconstring(optset_T *args);
|
char *did_set_iconstring(optset_T *args);
|
||||||
char *did_set_imactivatekey(optset_T *args);
|
char *did_set_imactivatekey(optset_T *args);
|
||||||
|
char *did_set_iskeyword(optset_T *args);
|
||||||
char *did_set_isopt(optset_T *args);
|
char *did_set_isopt(optset_T *args);
|
||||||
char *did_set_jumpoptions(optset_T *args);
|
char *did_set_jumpoptions(optset_T *args);
|
||||||
int expand_set_jumpoptions(optexpand_T *args, int *numMatches, char_u ***matches);
|
int expand_set_jumpoptions(optexpand_T *args, int *numMatches, char_u ***matches);
|
||||||
|
@@ -49,7 +49,6 @@ let skip_setglobal_reasons = #{
|
|||||||
\ colorcolumn: 'TODO: fix missing error handling for setglobal',
|
\ colorcolumn: 'TODO: fix missing error handling for setglobal',
|
||||||
\ conceallevel: 'TODO: fix missing error handling for setglobal',
|
\ conceallevel: 'TODO: fix missing error handling for setglobal',
|
||||||
\ foldcolumn: 'TODO: fix missing error handling for setglobal',
|
\ foldcolumn: 'TODO: fix missing error handling for setglobal',
|
||||||
\ iskeyword: 'TODO: fix missing error handling for setglobal',
|
|
||||||
\ numberwidth: 'TODO: fix missing error handling for setglobal',
|
\ numberwidth: 'TODO: fix missing error handling for setglobal',
|
||||||
\ scrolloff: 'TODO: fix missing error handling for setglobal',
|
\ scrolloff: 'TODO: fix missing error handling for setglobal',
|
||||||
\ shiftwidth: 'TODO: fix missing error handling for setglobal',
|
\ shiftwidth: 'TODO: fix missing error handling for setglobal',
|
||||||
|
@@ -704,6 +704,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
803,
|
||||||
/**/
|
/**/
|
||||||
802,
|
802,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user