diff options
author | zeertzjq <zeertzjq@outlook.com> | 2023-02-28 19:04:32 +0800 |
---|---|---|
committer | zeertzjq <zeertzjq@outlook.com> | 2023-02-28 19:52:45 +0800 |
commit | bfa0bc7df0ca527fcec49dbd2055f1bac438663e (patch) | |
tree | 9b654edacf1b0f91bbf79b70b3fceec8d4e911b5 /runtime | |
parent | 3b927762264c27aaeb31b83ba2e4924d5312ddcc (diff) | |
download | rneovim-bfa0bc7df0ca527fcec49dbd2055f1bac438663e.tar.gz rneovim-bfa0bc7df0ca527fcec49dbd2055f1bac438663e.tar.bz2 rneovim-bfa0bc7df0ca527fcec49dbd2055f1bac438663e.zip |
vim-patch:9.0.0795: readblob() always reads the whole file
Problem: readblob() always reads the whole file.
Solution: Add arguments to read part of the file. (Ken Takata,
closes vim/vim#11402)
https://github.com/vim/vim/commit/11df3aeee548b959ccd4b9a4d3c44651eab6b3ce
Remove trailing whitespace in test as done in patch 9.0.1257.
Move the help for rand() before range().
Co-authored-by: K.Takata <kentkt@csc.jp>
Diffstat (limited to 'runtime')
-rw-r--r-- | runtime/doc/builtin.txt | 53 |
1 files changed, 33 insertions, 20 deletions
diff --git a/runtime/doc/builtin.txt b/runtime/doc/builtin.txt index ed8c78ef2f..113703680f 100644 --- a/runtime/doc/builtin.txt +++ b/runtime/doc/builtin.txt @@ -359,7 +359,8 @@ pyxeval({expr}) any evaluate |python_x| expression rand([{expr}]) Number get pseudo-random number range({expr} [, {max} [, {stride}]]) List items from {expr} to {max} -readblob({fname}) Blob read a |Blob| from {fname} +readblob({fname} [, {offset} [, {size}]]) + Blob read a |Blob| from {fname} readdir({dir} [, {expr}]) List file names in {dir} selected by {expr} readfile({fname} [, {type} [, {max}]]) List get list of lines from file {fname} @@ -6110,6 +6111,25 @@ pyxeval({expr}) *pyxeval()* Can also be used as a |method|: > GetExpr()->pyxeval() < +rand([{expr}]) *rand()* + Return a pseudo-random Number generated with an xoshiro128** + algorithm using seed {expr}. The returned number is 32 bits, + also on 64 bits systems, for consistency. + {expr} can be initialized by |srand()| and will be updated by + rand(). If {expr} is omitted, an internal seed value is used + and updated. + Returns -1 if {expr} is invalid. + + Examples: > + :echo rand() + :let seed = srand() + :echo rand(seed) + :echo rand(seed) % 16 " random number 0 - 15 +< + Can also be used as a |method|: > + seed->rand() +< + *E726* *E727* range({expr} [, {max} [, {stride}]]) *range()* Returns a |List| with Numbers: @@ -6132,29 +6152,22 @@ range({expr} [, {max} [, {stride}]]) *range()* Can also be used as a |method|: > GetExpr()->range() < -rand([{expr}]) *rand()* - Return a pseudo-random Number generated with an xoshiro128** - algorithm using seed {expr}. The returned number is 32 bits, - also on 64 bits systems, for consistency. - {expr} can be initialized by |srand()| and will be updated by - rand(). If {expr} is omitted, an internal seed value is used - and updated. - Returns -1 if {expr} is invalid. - - Examples: > - :echo rand() - :let seed = srand() - :echo rand(seed) - :echo rand(seed) % 16 " random number 0 - 15 -< - Can also be used as a |method|: > - seed->rand() -< -readblob({fname}) *readblob()* +readblob({fname} [, {offset} [, {size}]]) *readblob()* Read file {fname} in binary mode and return a |Blob|. + If {offset} is specified, read the file from the specified + offset. If it is a negative value, it is used as an offset + from the end of the file. E.g., to read the last 12 bytes: > + readblob('file.bin', -12) +< If {size} is specified, only the specified size will be read. + E.g. to read the first 100 bytes of a file: > + readblob('file.bin', 0, 100) +< If {size} is -1 or omitted, the whole data starting from + {offset} will be read. When the file can't be opened an error message is given and the result is an empty |Blob|. + When trying to read bytes beyond the end of the file the + result is an empty blob. Also see |readfile()| and |writefile()|. |