mirror of
https://github.com/vim/vim.git
synced 2025-09-25 03:54:15 -04:00
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:
12
src/json.c
12
src/json.c
@@ -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;
|
||||
|
Reference in New Issue
Block a user