Skip to content

Commit a8aac48

Browse files
committed
Merge remote-tracking branch 'vim/master'
2 parents abb115b + 2405838 commit a8aac48

132 files changed

Lines changed: 1481 additions & 4481 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

runtime/doc/eval.txt

Lines changed: 72 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
*eval.txt* For Vim version 8.1. Last change: 2019 Jan 17
1+
*eval.txt* For Vim version 8.1. Last change: 2019 Jan 24
22

33

44
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -38,7 +38,7 @@ done, the features in this document are not available. See |+eval| and
3838
1. Variables *variables*
3939

4040
1.1 Variable types ~
41-
*E712*
41+
*E712* *E896* *E897* *E899*
4242
There are nine types of variables:
4343

4444
Number A 32 or 64 bit signed number. |expr-number| *Number*
@@ -633,6 +633,9 @@ Blob creation ~
633633

634634
A Blob can be created with a |blob-literal|: >
635635
:let b = 0zFF00ED015DAF
636+
Dots can be inserted between bytes (pair of hex characters) for readability,
637+
they don't change the value: >
638+
:let b = 0zFF00.ED01.5DAF
636639
637640
A blob can be read from a file with |readfile()| passing the {type} argument
638641
set to "B", for example: >
@@ -659,6 +662,16 @@ is not available it returns -1 or the default value you specify: >
659662
:echo get(myblob, idx, 999)
660663
661664
665+
Blob iteration ~
666+
667+
The |:for| loop executes commands for each byte of a Blob. The loop variable is
668+
set to each byte in the Blob. Example: >
669+
:for byte in 0z112233
670+
: call Doit(byte)
671+
:endfor
672+
This calls Doit() with 0x11, 0x22 and 0x33.
673+
674+
662675
Blob concatenation ~
663676

664677
Two blobs can be concatenated with the "+" operator: >
@@ -790,8 +803,9 @@ Expression syntax summary, from least to most significant:
790803
etc. As above, append ? for ignoring case, # for
791804
matching case
792805

793-
expr5 is expr5 same |List| instance
794-
expr5 isnot expr5 different |List| instance
806+
expr5 is expr5 same |List|, |Dictionary| or |Blob| instance
807+
expr5 isnot expr5 different |List|, |Dictionary| or |Blob|
808+
instance
795809

796810
|expr5| expr6
797811
expr6 + expr6 .. number addition, list or blob concatenation
@@ -959,12 +973,12 @@ Dictionary and arguments, use |get()| to get the function name: >
959973
if get(Part1, 'name') == get(Part2, 'name')
960974
" Part1 and Part2 refer to the same function
961975
962-
When using "is" or "isnot" with a |List| or a |Dictionary| this checks if the
963-
expressions are referring to the same |List| or |Dictionary| instance. A copy
964-
of a |List| is different from the original |List|. When using "is" without
965-
a |List| or a |Dictionary| it is equivalent to using "equal", using "isnot"
966-
equivalent to using "not equal". Except that a different type means the
967-
values are different: >
976+
Using "is" or "isnot" with a |List|, |Dictionary| or |Blob| checks whether
977+
the expressions are referring to the same |List|, |Dictionary| or |Blob|
978+
instance. A copy of a |List| is different from the original |List|. When
979+
using "is" without a |List|, |Dictionary| or |Blob|, it is equivalent to
980+
using "equal", using "isnot" equivalent to using "not equal". Except that
981+
a different type means the values are different: >
968982
echo 4 == '4'
969983
1
970984
echo 4 is '4'
@@ -1009,16 +1023,16 @@ can be matched like an ordinary character. Examples:
10091023

10101024
expr5 and expr6 *expr5* *expr6*
10111025
---------------
1012-
expr6 + expr6 .. Number addition or |List| concatenation *expr-+*
1013-
expr6 - expr6 .. Number subtraction *expr--*
1014-
expr6 . expr6 .. String concatenation *expr-.*
1026+
expr6 + expr6 Number addition, |List| or |Blob| concatenation *expr-+*
1027+
expr6 - expr6 Number subtraction *expr--*
1028+
expr6 . expr6 String concatenation *expr-.*
10151029

10161030
For |Lists| only "+" is possible and then both expr6 must be a list. The
10171031
result is a new list with the two lists Concatenated.
10181032

1019-
expr7 * expr7 .. Number multiplication *expr-star*
1020-
expr7 / expr7 .. Number division *expr-/*
1021-
expr7 % expr7 .. Number modulo *expr-%*
1033+
expr7 * expr7 Number multiplication *expr-star*
1034+
expr7 / expr7 Number division *expr-/*
1035+
expr7 % expr7 Number modulo *expr-%*
10221036

10231037
For all, except ".", Strings are converted to Numbers.
10241038
For bitwise operators see |and()|, |or()| and |xor()|.
@@ -3805,8 +3819,8 @@ escape({string}, {chars}) *escape()*
38053819
*eval()*
38063820
eval({string}) Evaluate {string} and return the result. Especially useful to
38073821
turn the result of |string()| back into the original value.
3808-
This works for Numbers, Floats, Strings and composites of
3809-
them. Also works for |Funcref|s that refer to existing
3822+
This works for Numbers, Floats, Strings, Blobs and composites
3823+
of them. Also works for |Funcref|s that refer to existing
38103824
functions.
38113825

38123826
eventhandler() *eventhandler()*
@@ -4118,6 +4132,9 @@ feedkeys({string} [, {mode}]) *feedkeys()*
41184132
't' Handle keys as if typed; otherwise they are handled as
41194133
if coming from a mapping. This matters for undo,
41204134
opening folds, etc.
4135+
'L' Lowlevel input. Only works for Unix or when using the
4136+
GUI. Keys are used as if they were coming from the
4137+
terminal. Other flags are not used. *E980*
41214138
'i' Insert the string instead of appending (see above).
41224139
'x' Execute commands until typeahead is empty. This is
41234140
similar to using ":normal!". You can call feedkeys()
@@ -5700,7 +5717,11 @@ items({dict}) *items()*
57005717
Return a |List| with all the key-value pairs of {dict}. Each
57015718
|List| item is a list with two items: the key of a {dict}
57025719
entry and the value of this entry. The |List| is in arbitrary
5703-
order.
5720+
order. Also see |keys()| and |values()|.
5721+
Example: >
5722+
for [key, value] in items(mydict)
5723+
echo key . ': ' . value
5724+
endfor
57045725
57055726
job_getchannel({job}) *job_getchannel()*
57065727
Get the channel handle that {job} is using.
@@ -5733,6 +5754,10 @@ job_start({command} [, {options}]) *job_start()*
57335754
|:!cmd| this does not wait for the job to finish.
57345755
To start a job in a terminal window see |term_start()|.
57355756

5757+
If the job fails to start then |job_status()| on the returned
5758+
Job object results in "fail" and none of the callbacks will be
5759+
invoked.
5760+
57365761
{command} can be a String. This works best on MS-Windows. On
57375762
Unix it is split up in white-separated parts to be passed to
57385763
execvp(). Arguments in double quotes can contain white space.
@@ -5885,7 +5910,7 @@ json_decode({string}) *json_decode()*
58855910
- A trailing comma in an array and object is ignored, e.g.
58865911
"[1, 2, ]" is the same as "[1, 2]".
58875912
- Integer keys are accepted in objects, e.g. {1:2} is the
5888-
same as {'1':2}.
5913+
same as {"1":2}.
58895914
- More floating point numbers are recognized, e.g. "1." for
58905915
"1.0", or "001.2" for "1.2". Special floating point values
58915916
"Infinity", "-Infinity" and "NaN" (capitalization ignored)
@@ -5897,6 +5922,8 @@ json_decode({string}) *json_decode()*
58975922
- Control characters U+0000 through U+001F which are not
58985923
escaped in strings are accepted, e.g. " " (tab
58995924
character in string) for "\t".
5925+
- An empty JSON expression or made of only spaces is accepted
5926+
and results in v:none.
59005927
- Backslash in an invalid 2-character sequence escape is
59015928
ignored, e.g. "\a" is decoded as "a".
59025929
- A correct surrogate pair in JSON strings should normally be
@@ -5936,7 +5963,7 @@ json_encode({expr}) *json_encode()*
59365963

59375964
keys({dict}) *keys()*
59385965
Return a |List| with all the keys of {dict}. The |List| is in
5939-
arbitrary order.
5966+
arbitrary order. Also see |items()| and |values()|.
59405967

59415968
*len()* *E701*
59425969
len({expr}) The result is a Number, which is the length of the argument.
@@ -8617,13 +8644,14 @@ stridx({haystack}, {needle} [, {start}]) *stridx()*
86178644

86188645
*string()*
86198646
string({expr}) Return {expr} converted to a String. If {expr} is a Number,
8620-
Float, String or a composition of them, then the result can be
8621-
parsed back with |eval()|.
8647+
Float, String, Blob or a composition of them, then the result
8648+
can be parsed back with |eval()|.
86228649
{expr} type result ~
86238650
String 'string' (single quotes are doubled)
86248651
Number 123
86258652
Float 123.123456 or 1.123456e8
86268653
Funcref function('name')
8654+
Blob 0z00112233.44556677.8899
86278655
List [item, item]
86288656
Dictionary {key: value, key: value}
86298657

@@ -9778,7 +9806,7 @@ uniq({list} [, {func} [, {dict}]]) *uniq()* *E882*
97789806

97799807
values({dict}) *values()*
97809808
Return a |List| with all the values of {dict}. The |List| is
9781-
in arbitrary order.
9809+
in arbitrary order. Also see |items()| and |keys()|.
97829810

97839811

97849812
virtcol({expr}) *virtcol()*
@@ -11039,28 +11067,34 @@ This does NOT work: >
1103911067
NOTE: The ":append" and ":insert" commands don't work
1104011068
properly inside a ":while" and ":for" loop.
1104111069

11042-
:for {var} in {list} *:for* *E690* *E732*
11070+
:for {var} in {object} *:for* *E690* *E732*
1104311071
:endfo[r] *:endfo* *:endfor*
1104411072
Repeat the commands between ":for" and ":endfor" for
11045-
each item in {list}. Variable {var} is set to the
11046-
value of each item.
11047-
When an error is detected for a command inside the
11048-
loop, execution continues after the "endfor".
11049-
Changing {list} inside the loop affects what items are
11050-
used. Make a copy if this is unwanted: >
11073+
each item in {object}. {object} can be a |List| or
11074+
a |Blob|. Variable {var} is set to the value of each
11075+
item. When an error is detected for a command inside
11076+
the loop, execution continues after the "endfor".
11077+
Changing {object} inside the loop affects what items
11078+
are used. Make a copy if this is unwanted: >
1105111079
:for item in copy(mylist)
11052-
< When not making a copy, Vim stores a reference to the
11053-
next item in the list, before executing the commands
11054-
with the current item. Thus the current item can be
11055-
removed without effect. Removing any later item means
11056-
it will not be found. Thus the following example
11057-
works (an inefficient way to make a list empty): >
11080+
<
11081+
When {object} is a |List| and not making a copy, Vim
11082+
stores a reference to the next item in the |List|
11083+
before executing the commands with the current item.
11084+
Thus the current item can be removed without effect.
11085+
Removing any later item means it will not be found.
11086+
Thus the following example works (an inefficient way
11087+
to make a |List| empty): >
1105811088
for item in mylist
1105911089
call remove(mylist, 0)
1106011090
endfor
11061-
< Note that reordering the list (e.g., with sort() or
11091+
< Note that reordering the |List| (e.g., with sort() or
1106211092
reverse()) may have unexpected effects.
1106311093

11094+
When {object} is a |Blob|, Vim always makes a copy to
11095+
iterate over. Unlike with |List|, modifying the
11096+
|Blob| does not affect the iteration.
11097+
1106411098
:for [{var1}, {var2}, ...] in {listlist}
1106511099
:endfo[r]
1106611100
Like ":for" above, but each item in {listlist} must be

src/appveyor.bat

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ cd %APPVEYOR_BUILD_FOLDER%
77
cd src
88
echo "Building MinGW 32bit console version"
99
set PATH=c:\msys64\mingw32\bin;%PATH%
10-
mingw32-make.exe -f Make_ming.mak GUI=no OPTIMIZE=speed IME=yes MBYTE=yes ICONV=yes DEBUG=no FEATURES=%FEATURE% || exit 1
10+
mingw32-make.exe -f Make_ming.mak GUI=no OPTIMIZE=speed IME=yes ICONV=yes DEBUG=no FEATURES=%FEATURE% || exit 1
1111
:: Save vim.exe before Make clean, moved back below.
1212
copy vim.exe testdir
1313
mingw32-make.exe -f Make_ming.mak clean
@@ -16,24 +16,24 @@ mingw32-make.exe -f Make_ming.mak clean
1616
:: with specified features without python.
1717
echo "Building MinGW 32bit GUI version"
1818
if "%FEATURE%" == "HUGE" (
19-
mingw32-make.exe -f Make_ming.mak OPTIMIZE=speed CHANNEL=yes GUI=yes IME=yes MBYTE=yes ICONV=yes DEBUG=no PYTHON_VER=27 DYNAMIC_PYTHON=yes PYTHON=C:\Python27 PYTHON3_VER=35 DYNAMIC_PYTHON3=yes PYTHON3=C:\Python35 FEATURES=%FEATURE% || exit 1
19+
mingw32-make.exe -f Make_ming.mak OPTIMIZE=speed CHANNEL=yes GUI=yes IME=yes ICONV=yes DEBUG=no PYTHON_VER=27 DYNAMIC_PYTHON=yes PYTHON=C:\Python27 PYTHON3_VER=35 DYNAMIC_PYTHON3=yes PYTHON3=C:\Python35 FEATURES=%FEATURE% || exit 1
2020
) ELSE (
21-
mingw32-make.exe -f Make_ming.mak OPTIMIZE=speed GUI=yes IME=yes MBYTE=yes ICONV=yes DEBUG=no FEATURES=%FEATURE% || exit 1
21+
mingw32-make.exe -f Make_ming.mak OPTIMIZE=speed GUI=yes IME=yes ICONV=yes DEBUG=no FEATURES=%FEATURE% || exit 1
2222
)
2323
.\gvim -u NONE -c "redir @a | ver |0put a | wq" ver_ming.txt
2424

2525
echo "Building MSVC 64bit console Version"
2626
sed -e "s/\$(LINKARGS2)/\$(LINKARGS2) | sed -e 's#.*\\\\r.*##'/" Make_mvc.mak > Make_mvc2.mak
27-
nmake -f Make_mvc2.mak CPU=AMD64 OLE=no GUI=no IME=yes MBYTE=yes ICONV=yes DEBUG=no FEATURES=%FEATURE% || exit 1
27+
nmake -f Make_mvc2.mak CPU=AMD64 OLE=no GUI=no IME=yes ICONV=yes DEBUG=no FEATURES=%FEATURE% || exit 1
2828
nmake -f Make_mvc2.mak clean
2929

3030
:: build MSVC huge version with python and channel support
3131
:: GUI needs to be last, so that testing works
3232
echo "Building MSVC 64bit GUI Version"
3333
if "%FEATURE%" == "HUGE" (
34-
nmake -f Make_mvc2.mak DIRECTX=yes CPU=AMD64 CHANNEL=yes OLE=no GUI=yes IME=yes MBYTE=yes ICONV=yes DEBUG=no PYTHON_VER=27 DYNAMIC_PYTHON=yes PYTHON=C:\Python27-x64 PYTHON3_VER=35 DYNAMIC_PYTHON3=yes PYTHON3=C:\Python35-x64 FEATURES=%FEATURE% || exit 1
34+
nmake -f Make_mvc2.mak DIRECTX=yes CPU=AMD64 CHANNEL=yes OLE=no GUI=yes IME=yes ICONV=yes DEBUG=no PYTHON_VER=27 DYNAMIC_PYTHON=yes PYTHON=C:\Python27-x64 PYTHON3_VER=35 DYNAMIC_PYTHON3=yes PYTHON3=C:\Python35-x64 FEATURES=%FEATURE% || exit 1
3535
) ELSE (
36-
nmake -f Make_mvc2.mak CPU=AMD64 OLE=no GUI=yes IME=yes MBYTE=yes ICONV=yes DEBUG=no FEATURES=%FEATURE% || exit 1
36+
nmake -f Make_mvc2.mak CPU=AMD64 OLE=no GUI=yes IME=yes ICONV=yes DEBUG=no FEATURES=%FEATURE% || exit 1
3737
)
3838
.\gvim -u NONE -c "redir @a | ver |0put a | wq" ver_msvc.txt
3939

src/auto/configure

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8021,10 +8021,7 @@ fi
80218021

80228022
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_multibyte" >&5
80238023
$as_echo "$enable_multibyte" >&6; }
8024-
if test "$enable_multibyte" = "yes"; then
8025-
$as_echo "#define FEAT_MBYTE 1" >>confdefs.h
8026-
8027-
else
8024+
if test "$enable_multibyte" != "yes"; then
80288025
as_fn_error $? "The multi-byte feature can no longer be disabled. If you have
80298026
a problem with this, discuss on the Vim mailing list." "$LINENO" 5
80308027
fi

src/blob.c

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,32 @@ rettv_blob_set(typval_T *rettv, blob_T *b)
5757
++b->bv_refcount;
5858
}
5959

60+
int
61+
blob_copy(typval_T *from, typval_T *to)
62+
{
63+
int ret = OK;
64+
65+
to->v_type = VAR_BLOB;
66+
if (from->vval.v_blob == NULL)
67+
to->vval.v_blob = NULL;
68+
else if (rettv_blob_alloc(to) == FAIL)
69+
ret = FAIL;
70+
else
71+
{
72+
int len = from->vval.v_blob->bv_ga.ga_len;
73+
74+
if (len > 0)
75+
{
76+
to->vval.v_blob->bv_ga.ga_data =
77+
vim_memsave(from->vval.v_blob->bv_ga.ga_data, len);
78+
if (to->vval.v_blob->bv_ga.ga_data == NULL)
79+
len = 0;
80+
}
81+
to->vval.v_blob->bv_ga.ga_len = len;
82+
}
83+
return ret;
84+
}
85+
6086
void
6187
blob_free(blob_T *b)
6288
{
@@ -90,7 +116,7 @@ blob_len(blob_T *b)
90116
* Get byte "idx" in blob "b".
91117
* Caller must check that "idx" is valid.
92118
*/
93-
char_u
119+
int
94120
blob_get(blob_T *b, int idx)
95121
{
96122
return ((char_u*)b->bv_ga.ga_data)[idx];

0 commit comments

Comments
 (0)