aboutsummaryrefslogtreecommitdiff
path: root/runtime
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2016-02-28 11:48:54 -0500
committerJustin M. Keyes <justinkz@gmail.com>2016-02-28 11:48:54 -0500
commit0c2ba7554fe6b1b821ad662872ab6b13dd0487d3 (patch)
tree854f68f6a1648cf44c267b03dc6090c295728548 /runtime
parent8ade191b7ab6dec93b09259ac4a370ed5b29df3a (diff)
parent92d4dfdca5f83906f4a9fa7409c7c8f5e603e4d5 (diff)
downloadrneovim-0c2ba7554fe6b1b821ad662872ab6b13dd0487d3.tar.gz
rneovim-0c2ba7554fe6b1b821ad662872ab6b13dd0487d3.tar.bz2
rneovim-0c2ba7554fe6b1b821ad662872ab6b13dd0487d3.zip
Merge pull request #3900 from ZyX-I/inf-nan-string
Make it possible to eval() all floating-point values dumped by string()
Diffstat (limited to 'runtime')
-rw-r--r--runtime/autoload/msgpack.vim3
-rw-r--r--runtime/doc/eval.txt14
-rw-r--r--runtime/doc/vim_diff.txt2
3 files changed, 16 insertions, 3 deletions
diff --git a/runtime/autoload/msgpack.vim b/runtime/autoload/msgpack.vim
index e6022922fe..2bb7ec5b02 100644
--- a/runtime/autoload/msgpack.vim
+++ b/runtime/autoload/msgpack.vim
@@ -395,7 +395,8 @@ endfunction
""
" Dump floating-point value.
function s:msgpack_dump_float(v) abort
- return string(type(a:v) == type({}) ? a:v._VAL : a:v)
+ return substitute(string(type(a:v) == type({}) ? a:v._VAL : a:v),
+ \'\V\^\(-\)\?str2float(''\(inf\|nan\)'')\$', '\1\2', '')
endfunction
""
diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt
index 5dbef81748..ad736e9c81 100644
--- a/runtime/doc/eval.txt
+++ b/runtime/doc/eval.txt
@@ -6238,12 +6238,22 @@ string({expr}) Return {expr} converted to a String. If {expr} is a Number,
{expr} type result ~
String 'string'
Number 123
- Float 123.123456 or 1.123456e8
- Funcref function('name')
+ Float 123.123456 or 1.123456e8 or
+ `str2float('inf')`
+ Funcref `function('name')`
List [item, item]
Dictionary {key: value, key: value}
Note that in String values the ' character is doubled.
Also see |strtrans()|.
+ Note 2: Output format is mostly compatible with YAML, except
+ for infinite and NaN floating-point values representations
+ which use |str2float()|. Strings are also dumped literally,
+ only single quote is escaped, which does not allow using YAML
+ for parsing back binary strings (including text when
+ 'encoding' is not UTF-8). |eval()| should always work for
+ strings and floats though and this is the only official
+ method, use |msgpackdump()| or |json_encode()| if you need to
+ share data with other application.
*strlen()*
strlen({expr}) The result is a Number, which is the length of the String
diff --git a/runtime/doc/vim_diff.txt b/runtime/doc/vim_diff.txt
index d3768409f5..8722fced26 100644
--- a/runtime/doc/vim_diff.txt
+++ b/runtime/doc/vim_diff.txt
@@ -99,6 +99,8 @@ are always available and may be used simultaneously in separate plugins. The
Same thing applies to |string()| (though it uses construct like
"{E724@level}"), but this is not reliable because |string()| continues to
error out.
+4. Stringifyed infinite and NaN values now use |str2float()| and can be evaled
+ back.
Viminfo text files were replaced with binary (messagepack) ShaDa files.
Additional differences: