aboutsummaryrefslogtreecommitdiff
path: root/runtime/autoload
diff options
context:
space:
mode:
authorbfredl <bjorn.linse@gmail.com>2024-06-27 18:45:18 +0200
committerGitHub <noreply@github.com>2024-06-27 18:45:18 +0200
commit46187117c9464dd6c09eae8e47bb279d72a01038 (patch)
treecffb3d6a5b9875893ae4de6457a656542856dc93 /runtime/autoload
parent724d1110b1e4699a34f489e9cdb2d25098746499 (diff)
parentbda63d5b97dfb333de6f4bd757dbb978906062a2 (diff)
downloadrneovim-46187117c9464dd6c09eae8e47bb279d72a01038.tar.gz
rneovim-46187117c9464dd6c09eae8e47bb279d72a01038.tar.bz2
rneovim-46187117c9464dd6c09eae8e47bb279d72a01038.zip
Merge pull request #29483 from bfredl/nonbinary
refactor(typval)!: remove binary distinction of binary and nonbinary strings
Diffstat (limited to 'runtime/autoload')
-rw-r--r--runtime/autoload/msgpack.vim50
-rw-r--r--runtime/autoload/shada.vim4
2 files changed, 26 insertions, 28 deletions
diff --git a/runtime/autoload/msgpack.vim b/runtime/autoload/msgpack.vim
index 18dcd1e6a6..fb438def4f 100644
--- a/runtime/autoload/msgpack.vim
+++ b/runtime/autoload/msgpack.vim
@@ -361,7 +361,7 @@ endfunction
let s:MSGPACK_STANDARD_TYPES = {
\type(0): 'integer',
\type(0.0): 'float',
- \type(''): 'binary',
+ \type(''): 'string',
\type([]): 'array',
\type({}): 'map',
\type(v:true): 'boolean',
@@ -412,9 +412,15 @@ endfunction
""
" Dump |msgpack-special-dict| that represents a string. If any additional
" parameter is given then it dumps binary string.
-function s:msgpack_dump_string(v, ...) abort
- let ret = [a:0 ? '"' : '="']
- for v in a:v._VAL
+function s:msgpack_dump_string(v) abort
+ if type(a:v) == type({})
+ let val = a:v
+ else
+ let val = {'_VAL': split(a:v, "\n", 1)}
+ end
+
+ let ret = ['"']
+ for v in val._VAL
call add(
\ret,
\substitute(
@@ -427,16 +433,6 @@ function s:msgpack_dump_string(v, ...) abort
endfunction
""
-" Dump binary string.
-function s:msgpack_dump_binary(v) abort
- if type(a:v) == type({})
- return s:msgpack_dump_string(a:v, 1)
- else
- return s:msgpack_dump_string({'_VAL': split(a:v, "\n", 1)}, 1)
- endif
-endfunction
-
-""
" Dump array value.
function s:msgpack_dump_array(v) abort
let val = type(a:v) == type({}) ? a:v._VAL : a:v
@@ -449,7 +445,7 @@ function s:msgpack_dump_map(v) abort
let ret = ['{']
if msgpack#special_type(a:v) is 0
for [k, v] in items(a:v)
- let ret += [s:msgpack_dump_string({'_VAL': split(k, "\n", 1)}),
+ let ret += [s:msgpack_dump_string({'_VAL': split(k, "\n")}),
\': ',
\msgpack#string(v),
\', ']
@@ -479,7 +475,7 @@ endfunction
" Dump extension value.
function s:msgpack_dump_ext(v) abort
return printf('+(%i)%s', a:v._VAL[0],
- \s:msgpack_dump_string({'_VAL': a:v._VAL[1]}, 1))
+ \s:msgpack_dump_string({'_VAL': a:v._VAL[1]}))
endfunction
""
@@ -619,9 +615,7 @@ function msgpack#eval(s, special_objs) abort
throw '"-invalid:Invalid string: ' . s
endif
call add(expr, '{''_TYPE'': v:msgpack_types.')
- if empty(match[1])
- call add(expr, 'binary')
- elseif match[1] is# '='
+ if empty(match[1]) || match[1] is# '='
call add(expr, 'string')
else
call add(expr, 'ext')
@@ -772,7 +766,7 @@ function msgpack#equal(a, b)
let a = aspecial is 0 ? a:a : a:a._VAL
let b = bspecial is 0 ? a:b : a:b._VAL
return msgpack#equal(a, b)
- elseif atype is# 'binary'
+ elseif atype is# 'string'
let a = (aspecial is 0 ? split(a:a, "\n", 1) : a:a._VAL)
let b = (bspecial is 0 ? split(a:b, "\n", 1) : a:b._VAL)
return a ==# b
@@ -787,13 +781,17 @@ function msgpack#equal(a, b)
" Non-special mapping cannot have non-string keys
return 0
endif
- if (empty(k._VAL)
- \|| k._VAL ==# [""]
- \|| !empty(filter(copy(k._VAL), 'stridx(v:val, "\n") != -1')))
- " Non-special mapping cannot have zero byte in key or an empty key
- return 0
+ if type(k) == type({})
+ if (empty(k._VAL)
+ \|| k._VAL ==# [""]
+ \|| !empty(filter(copy(k._VAL), 'stridx(v:val, "\n") != -1')))
+ " Non-special mapping cannot have zero byte in key or an empty key
+ return 0
+ endif
+ let kstr = join(k._VAL, "\n")
+ else
+ let kstr = k
endif
- let kstr = join(k._VAL, "\n")
if !has_key(akeys, kstr)
" Protects from both missing and duplicate keys
return 0
diff --git a/runtime/autoload/shada.vim b/runtime/autoload/shada.vim
index ae718ad2e7..4753973196 100644
--- a/runtime/autoload/shada.vim
+++ b/runtime/autoload/shada.vim
@@ -230,7 +230,7 @@ function s:shada_check_type(type, val) abort
return 0
elseif a:type is# 'bin'
" Binary string without zero bytes
- if type isnot# 'binary'
+ if type isnot# 'string'
return 'Expected binary string'
elseif (type(a:val) == type({})
\&& !empty(filter(copy(a:val._VAL), 'stridx(v:val, "\n") != -1')))
@@ -247,7 +247,7 @@ function s:shada_check_type(type, val) abort
if type isnot# 'array'
return 'Expected array value'
elseif !empty(filter(copy(type(a:val) == type({}) ? a:val._VAL : a:val),
- \'msgpack#type(v:val) isnot# "binary"'))
+ \'msgpack#type(v:val) isnot# "string"'))
return 'Expected array of binary strings'
else
for element in (type(a:val) == type({}) ? a:val._VAL : a:val)