diff options
Diffstat (limited to 'runtime')
-rw-r--r-- | runtime/autoload/msgpack.vim | 8 | ||||
-rw-r--r-- | runtime/autoload/shada.vim | 13 | ||||
-rw-r--r-- | runtime/doc/pi_msgpack.txt | 5 |
3 files changed, 19 insertions, 7 deletions
diff --git a/runtime/autoload/msgpack.vim b/runtime/autoload/msgpack.vim index 2e2697c57f..a10ac32469 100644 --- a/runtime/autoload/msgpack.vim +++ b/runtime/autoload/msgpack.vim @@ -665,11 +665,15 @@ function msgpack#eval(s, special_objs) abort call add(expr, ']}') let s = s[1:] elseif s[0] is# '''' - let char = matchstr(s, '\m\C^''\zs.\ze''') + let char = matchstr(s, '\v\C^\''\zs%(\\\d+|.)\ze\''') if empty(char) throw 'char-invalid:Invalid integer character literal format: ' . s endif - call add(expr, char2nr(char)) + if char[0] is# '\' + call add(expr, +char[1:]) + else + call add(expr, char2nr(char)) + endif let s = s[len(char) + 2:] else throw 'unknown:Invalid non-space character: ' . s diff --git a/runtime/autoload/shada.vim b/runtime/autoload/shada.vim index 9be85b6f2e..cf27ee608a 100644 --- a/runtime/autoload/shada.vim +++ b/runtime/autoload/shada.vim @@ -241,8 +241,6 @@ function s:shada_check_type(type, val) abort if msg isnot# 0 return msg endif - if a:val > 0 || a:val < 1 - endif return 0 elseif a:type is# 'binarray' if type isnot# 'array' @@ -359,9 +357,14 @@ function s:shada_string(type, v) abort if (has_key(s:SHADA_ENUMS, a:type) && type(a:v) == type(0) \&& has_key(s:SHADA_REV_ENUMS[a:type], a:v)) return s:SHADA_REV_ENUMS[a:type][a:v] - elseif (a:type is# 'intchar' && type(a:v) == type(0) - \&& strtrans(nr2char(a:v)) is# nr2char(a:v)) - return "'" . nr2char(a:v) . "'" + " Restricting a:v to be <= 127 is not necessary, but intchar constants are + " normally expected to be either ASCII printable characters or NUL. + elseif a:type is# 'intchar' && type(a:v) == type(0) && a:v >= 0 && a:v <= 127 + if a:v > 0 && strtrans(nr2char(a:v)) is# nr2char(a:v) + return "'" . nr2char(a:v) . "'" + else + return "'\\" . a:v . "'" + endif else return msgpack#string(a:v) endif diff --git a/runtime/doc/pi_msgpack.txt b/runtime/doc/pi_msgpack.txt index 95d6ff7467..d695ac42cb 100644 --- a/runtime/doc/pi_msgpack.txt +++ b/runtime/doc/pi_msgpack.txt @@ -128,6 +128,11 @@ msgpack#eval({string}, {dict}) *msgpack#eval()* always evaluated to |msgpack-special-dict| values, as well as hexadecimal digits. When evaluating maps order of keys is preserved. + Note that in addition to regular integer representations that may be + obtained using |msgpack#string()| msgpack#eval() also supports C-style + “character” integer constants like `'/'` (equivalent to + `char2nr('/')`: `47`). This also allows `'\0'` (number is decimal). + *msgpack#equal* msgpack#equal({msgpack-value}, {msgpack-value}) *msgpack#equal()* Returns 1 if given values are equal, 0 otherwise. When comparing |