summaryrefslogtreecommitdiff
path: root/src/viminfo.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2020-01-11 16:05:23 +0100
committerBram Moolenaar <Bram@vim.org>2020-01-11 16:05:23 +0100
commit9b4a15d5dba354d2e1e02871470bad103f34769a (patch)
treee5e49ad3182e07e641cdea0e04c4a8078186c58c /src/viminfo.c
parente05a89ac6399a8c7d164c99fdab6841d999a9128 (diff)
downloadvim-git-9b4a15d5dba354d2e1e02871470bad103f34769a.tar.gz
patch 8.2.0111: VAR_SPECIAL is also used for booleansv8.2.0111
Problem: VAR_SPECIAL is also used for booleans. Solution: Add VAR_BOOL for better type checking.
Diffstat (limited to 'src/viminfo.c')
-rw-r--r--src/viminfo.c22
1 files changed, 15 insertions, 7 deletions
diff --git a/src/viminfo.c b/src/viminfo.c
index 308a9a609..24cd4f713 100644
--- a/src/viminfo.c
+++ b/src/viminfo.c
@@ -1233,7 +1233,12 @@ read_viminfo_varlist(vir_T *virp, int writing)
(void)string2float(tab + 1, &tv.vval.v_float);
#endif
else
+ {
tv.vval.v_number = atol((char *)tab + 1);
+ if (type == VAR_SPECIAL && (tv.vval.v_number == VVAL_FALSE
+ || tv.vval.v_number == VVAL_TRUE))
+ tv.v_type = VAR_BOOL;
+ }
if (type == VAR_DICT || type == VAR_LIST)
{
typval_T *etv = eval_expr(tv.vval.v_string, NULL);
@@ -1312,12 +1317,13 @@ write_viminfo_varlist(FILE *fp)
{
switch (this_var->di_tv.v_type)
{
- case VAR_STRING: s = "STR"; break;
- case VAR_NUMBER: s = "NUM"; break;
- case VAR_FLOAT: s = "FLO"; break;
- case VAR_DICT: s = "DIC"; break;
- case VAR_LIST: s = "LIS"; break;
- case VAR_BLOB: s = "BLO"; break;
+ case VAR_STRING: s = "STR"; break;
+ case VAR_NUMBER: s = "NUM"; break;
+ case VAR_FLOAT: s = "FLO"; break;
+ case VAR_DICT: s = "DIC"; break;
+ case VAR_LIST: s = "LIS"; break;
+ case VAR_BLOB: s = "BLO"; break;
+ case VAR_BOOL: s = "XPL"; break; // backwards compat.
case VAR_SPECIAL: s = "XPL"; break;
case VAR_UNKNOWN:
@@ -1328,8 +1334,10 @@ write_viminfo_varlist(FILE *fp)
continue;
}
fprintf(fp, "!%s\t%s\t", this_var->di_key, s);
- if (this_var->di_tv.v_type == VAR_SPECIAL)
+ if (this_var->di_tv.v_type == VAR_BOOL
+ || this_var->di_tv.v_type == VAR_SPECIAL)
{
+ // do not use "v:true" but "1"
sprintf((char *)numbuf, "%ld",
(long)this_var->di_tv.vval.v_number);
p = numbuf;