1
0
forked from aniani/vim

patch 8.2.0111: VAR_SPECIAL is also used for booleans

Problem:    VAR_SPECIAL is also used for booleans.
Solution:   Add VAR_BOOL for better type checking.
This commit is contained in:
Bram Moolenaar
2020-01-11 16:05:23 +01:00
parent e05a89ac63
commit 9b4a15d5db
16 changed files with 87 additions and 54 deletions

View File

@@ -193,11 +193,17 @@ json_encode_item(garray_T *gap, typval_T *val, int copyID, int options)
switch (val->v_type)
{
case VAR_SPECIAL:
case VAR_BOOL:
switch (val->vval.v_number)
{
case VVAL_FALSE: ga_concat(gap, (char_u *)"false"); break;
case VVAL_TRUE: ga_concat(gap, (char_u *)"true"); break;
}
break;
case VAR_SPECIAL:
switch (val->vval.v_number)
{
case VVAL_NONE: if ((options & JSON_JS) != 0
&& (options & JSON_NO_NONE) == 0)
// empty item
@@ -818,7 +824,7 @@ json_decode_item(js_read_T *reader, typval_T *res, int options)
reader->js_used += 5;
if (cur_item != NULL)
{
cur_item->v_type = VAR_SPECIAL;
cur_item->v_type = VAR_BOOL;
cur_item->vval.v_number = VVAL_FALSE;
}
retval = OK;
@@ -829,7 +835,7 @@ json_decode_item(js_read_T *reader, typval_T *res, int options)
reader->js_used += 4;
if (cur_item != NULL)
{
cur_item->v_type = VAR_SPECIAL;
cur_item->v_type = VAR_BOOL;
cur_item->vval.v_number = VVAL_TRUE;
}
retval = OK;