mirror of
https://github.com/vim/vim.git
synced 2025-09-24 03:44:06 -04:00
patch 8.2.1475: Vim9: can't use v:true for option flags
Problem: Vim9: can't use v:true for option flags. Solution: Add tv_get_bool_chk(). (closes #6725)
This commit is contained in:
@@ -4922,7 +4922,7 @@ get_job_options(typval_T *tv, jobopt_T *opt, int supported, int supported2)
|
|||||||
{
|
{
|
||||||
if (!(supported & JO_MODE))
|
if (!(supported & JO_MODE))
|
||||||
break;
|
break;
|
||||||
opt->jo_noblock = tv_get_number(item);
|
opt->jo_noblock = tv_get_bool(item);
|
||||||
}
|
}
|
||||||
else if (STRCMP(hi->hi_key, "in_io") == 0
|
else if (STRCMP(hi->hi_key, "in_io") == 0
|
||||||
|| STRCMP(hi->hi_key, "out_io") == 0
|
|| STRCMP(hi->hi_key, "out_io") == 0
|
||||||
@@ -4949,7 +4949,7 @@ get_job_options(typval_T *tv, jobopt_T *opt, int supported, int supported2)
|
|||||||
{
|
{
|
||||||
if (!(supported & JO_MODE))
|
if (!(supported & JO_MODE))
|
||||||
break;
|
break;
|
||||||
opt->jo_pty = tv_get_number(item);
|
opt->jo_pty = tv_get_bool(item);
|
||||||
}
|
}
|
||||||
else if (STRCMP(hi->hi_key, "in_buf") == 0
|
else if (STRCMP(hi->hi_key, "in_buf") == 0
|
||||||
|| STRCMP(hi->hi_key, "out_buf") == 0
|
|| STRCMP(hi->hi_key, "out_buf") == 0
|
||||||
@@ -4980,7 +4980,7 @@ get_job_options(typval_T *tv, jobopt_T *opt, int supported, int supported2)
|
|||||||
if (!(supported & JO_OUT_IO))
|
if (!(supported & JO_OUT_IO))
|
||||||
break;
|
break;
|
||||||
opt->jo_set |= JO_OUT_MODIFIABLE << (part - PART_OUT);
|
opt->jo_set |= JO_OUT_MODIFIABLE << (part - PART_OUT);
|
||||||
opt->jo_modifiable[part] = tv_get_number(item);
|
opt->jo_modifiable[part] = tv_get_bool(item);
|
||||||
}
|
}
|
||||||
else if (STRCMP(hi->hi_key, "out_msg") == 0
|
else if (STRCMP(hi->hi_key, "out_msg") == 0
|
||||||
|| STRCMP(hi->hi_key, "err_msg") == 0)
|
|| STRCMP(hi->hi_key, "err_msg") == 0)
|
||||||
@@ -4990,7 +4990,7 @@ get_job_options(typval_T *tv, jobopt_T *opt, int supported, int supported2)
|
|||||||
if (!(supported & JO_OUT_IO))
|
if (!(supported & JO_OUT_IO))
|
||||||
break;
|
break;
|
||||||
opt->jo_set2 |= JO2_OUT_MSG << (part - PART_OUT);
|
opt->jo_set2 |= JO2_OUT_MSG << (part - PART_OUT);
|
||||||
opt->jo_message[part] = tv_get_number(item);
|
opt->jo_message[part] = tv_get_bool(item);
|
||||||
}
|
}
|
||||||
else if (STRCMP(hi->hi_key, "in_top") == 0
|
else if (STRCMP(hi->hi_key, "in_top") == 0
|
||||||
|| STRCMP(hi->hi_key, "in_bot") == 0)
|
|| STRCMP(hi->hi_key, "in_bot") == 0)
|
||||||
@@ -5184,7 +5184,7 @@ get_job_options(typval_T *tv, jobopt_T *opt, int supported, int supported2)
|
|||||||
if (!(supported2 & JO2_VERTICAL))
|
if (!(supported2 & JO2_VERTICAL))
|
||||||
break;
|
break;
|
||||||
opt->jo_set2 |= JO2_VERTICAL;
|
opt->jo_set2 |= JO2_VERTICAL;
|
||||||
opt->jo_vertical = tv_get_number(item);
|
opt->jo_vertical = tv_get_bool(item);
|
||||||
}
|
}
|
||||||
else if (STRCMP(hi->hi_key, "curwin") == 0)
|
else if (STRCMP(hi->hi_key, "curwin") == 0)
|
||||||
{
|
{
|
||||||
@@ -5224,14 +5224,14 @@ get_job_options(typval_T *tv, jobopt_T *opt, int supported, int supported2)
|
|||||||
if (!(supported2 & JO2_HIDDEN))
|
if (!(supported2 & JO2_HIDDEN))
|
||||||
break;
|
break;
|
||||||
opt->jo_set2 |= JO2_HIDDEN;
|
opt->jo_set2 |= JO2_HIDDEN;
|
||||||
opt->jo_hidden = tv_get_number(item);
|
opt->jo_hidden = tv_get_bool(item);
|
||||||
}
|
}
|
||||||
else if (STRCMP(hi->hi_key, "norestore") == 0)
|
else if (STRCMP(hi->hi_key, "norestore") == 0)
|
||||||
{
|
{
|
||||||
if (!(supported2 & JO2_NORESTORE))
|
if (!(supported2 & JO2_NORESTORE))
|
||||||
break;
|
break;
|
||||||
opt->jo_set2 |= JO2_NORESTORE;
|
opt->jo_set2 |= JO2_NORESTORE;
|
||||||
opt->jo_term_norestore = tv_get_number(item);
|
opt->jo_term_norestore = tv_get_bool(item);
|
||||||
}
|
}
|
||||||
else if (STRCMP(hi->hi_key, "term_kill") == 0)
|
else if (STRCMP(hi->hi_key, "term_kill") == 0)
|
||||||
{
|
{
|
||||||
|
@@ -6,6 +6,7 @@ void clear_tv(typval_T *varp);
|
|||||||
void init_tv(typval_T *varp);
|
void init_tv(typval_T *varp);
|
||||||
varnumber_T tv_get_number(typval_T *varp);
|
varnumber_T tv_get_number(typval_T *varp);
|
||||||
varnumber_T tv_get_number_chk(typval_T *varp, int *denote);
|
varnumber_T tv_get_number_chk(typval_T *varp, int *denote);
|
||||||
|
varnumber_T tv_get_bool(typval_T *varp);
|
||||||
float_T tv_get_float(typval_T *varp);
|
float_T tv_get_float(typval_T *varp);
|
||||||
char_u *tv_get_string(typval_T *varp);
|
char_u *tv_get_string(typval_T *varp);
|
||||||
char_u *tv_get_string_buf(typval_T *varp, char_u *buf);
|
char_u *tv_get_string_buf(typval_T *varp, char_u *buf);
|
||||||
|
55
src/typval.c
55
src/typval.c
@@ -169,24 +169,8 @@ init_tv(typval_T *varp)
|
|||||||
CLEAR_POINTER(varp);
|
CLEAR_POINTER(varp);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
static varnumber_T
|
||||||
* Get the number value of a variable.
|
tv_get_bool_or_number_chk(typval_T *varp, int *denote, int want_bool)
|
||||||
* If it is a String variable, uses vim_str2nr().
|
|
||||||
* For incompatible types, return 0.
|
|
||||||
* tv_get_number_chk() is similar to tv_get_number(), but informs the
|
|
||||||
* caller of incompatible types: it sets *denote to TRUE if "denote"
|
|
||||||
* is not NULL or returns -1 otherwise.
|
|
||||||
*/
|
|
||||||
varnumber_T
|
|
||||||
tv_get_number(typval_T *varp)
|
|
||||||
{
|
|
||||||
int error = FALSE;
|
|
||||||
|
|
||||||
return tv_get_number_chk(varp, &error); // return 0L on error
|
|
||||||
}
|
|
||||||
|
|
||||||
varnumber_T
|
|
||||||
tv_get_number_chk(typval_T *varp, int *denote)
|
|
||||||
{
|
{
|
||||||
varnumber_T n = 0L;
|
varnumber_T n = 0L;
|
||||||
|
|
||||||
@@ -221,7 +205,7 @@ tv_get_number_chk(typval_T *varp, int *denote)
|
|||||||
break;
|
break;
|
||||||
case VAR_BOOL:
|
case VAR_BOOL:
|
||||||
case VAR_SPECIAL:
|
case VAR_SPECIAL:
|
||||||
if (in_vim9script())
|
if (!want_bool && in_vim9script())
|
||||||
{
|
{
|
||||||
emsg(_("E611: Using a Special as a Number"));
|
emsg(_("E611: Using a Special as a Number"));
|
||||||
break;
|
break;
|
||||||
@@ -253,6 +237,39 @@ tv_get_number_chk(typval_T *varp, int *denote)
|
|||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Get the number value of a variable.
|
||||||
|
* If it is a String variable, uses vim_str2nr().
|
||||||
|
* For incompatible types, return 0.
|
||||||
|
* tv_get_number_chk() is similar to tv_get_number(), but informs the
|
||||||
|
* caller of incompatible types: it sets *denote to TRUE if "denote"
|
||||||
|
* is not NULL or returns -1 otherwise.
|
||||||
|
*/
|
||||||
|
varnumber_T
|
||||||
|
tv_get_number(typval_T *varp)
|
||||||
|
{
|
||||||
|
int error = FALSE;
|
||||||
|
|
||||||
|
return tv_get_number_chk(varp, &error); // return 0L on error
|
||||||
|
}
|
||||||
|
|
||||||
|
varnumber_T
|
||||||
|
tv_get_number_chk(typval_T *varp, int *denote)
|
||||||
|
{
|
||||||
|
return tv_get_bool_or_number_chk(varp, denote, FALSE);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Get the boolean value of "varp". This is like tv_get_number_chk(),
|
||||||
|
* but in Vim9 script accepts Number and Bool.
|
||||||
|
*/
|
||||||
|
varnumber_T
|
||||||
|
tv_get_bool(typval_T *varp)
|
||||||
|
{
|
||||||
|
return tv_get_bool_or_number_chk(varp, NULL, TRUE);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef FEAT_FLOAT
|
#ifdef FEAT_FLOAT
|
||||||
float_T
|
float_T
|
||||||
tv_get_float(typval_T *varp)
|
tv_get_float(typval_T *varp)
|
||||||
|
@@ -754,6 +754,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 */
|
||||||
|
/**/
|
||||||
|
1475,
|
||||||
/**/
|
/**/
|
||||||
1474,
|
1474,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user