Skip to content

Commit 39536dd

Browse files
committed
patch 8.1.0846: not easy to recognize the system Vim runs on
Problem: Not easy to recognize the system Vim runs on. Solution: Add more items to the features list. (Ozaki Kiichi, closes #3855)
1 parent 2a4857a commit 39536dd

File tree

7 files changed

+114
-42
lines changed

7 files changed

+114
-42
lines changed

runtime/doc/eval.txt

Lines changed: 42 additions & 24 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 24
1+
*eval.txt* For Vim version 8.1. Last change: 2019 Jan 29
22

33

44
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -696,7 +696,7 @@ similar to -1. >
696696
:let otherblob = myblob[:] " make a copy of the Blob
697697
698698
If the first index is beyond the last byte of the Blob or the second index is
699-
before the first byte, the result is an empty list. There is no error
699+
before the first index, the result is an empty list. There is no error
700700
message.
701701

702702
If the second index is equal to or greater than the length of the list the
@@ -2511,7 +2511,10 @@ remote_read({serverid} [, {timeout}])
25112511
remote_send({server}, {string} [, {idvar}])
25122512
String send key sequence
25132513
remote_startserver({name}) none become server {name}
2514-
remove({list}, {idx} [, {end}]) any remove items {idx}-{end} from {list}
2514+
remove({list}, {idx} [, {end}]) any/List
2515+
remove items {idx}-{end} from {list}
2516+
remove({blob}, {idx} [, {end}]) Number/Blob
2517+
remove bytes {idx}-{end} from {blob}
25152518
remove({dict}, {key}) any remove entry {key} from {dict}
25162519
rename({from}, {to}) Number rename (move) file from {from} to {to}
25172520
repeat({expr}, {count}) String repeat {expr} {count} times
@@ -6056,13 +6059,9 @@ line({expr}) The result is a Number, which is the line number of the file
60566059
line(".") line number of the cursor
60576060
line("'t") line number of mark t
60586061
line("'" . marker) line number of mark marker
6059-
< *last-position-jump*
6060-
This autocommand jumps to the last known position in a file
6061-
just after opening it, if the '" mark is set: >
6062-
:au BufReadPost *
6063-
\ if line("'\"") > 1 && line("'\"") <= line("$") && &ft !~# 'commit'
6064-
\ | exe "normal! g`\""
6065-
\ | endif
6062+
<
6063+
To jump to the last known position when opening a file see
6064+
|last-position-jump|.
60666065

60676066
line2byte({lnum}) *line2byte()*
60686067
Return the byte count from the start of the buffer for line
@@ -6504,8 +6503,10 @@ min({expr}) Return the minimum value of all items in {expr}.
65046503
*mkdir()* *E739*
65056504
mkdir({name} [, {path} [, {prot}]])
65066505
Create directory {name}.
6506+
65076507
If {path} is "p" then intermediate directories are created as
65086508
necessary. Otherwise it must be "".
6509+
65096510
If {prot} is given it is used to set the protection bits of
65106511
the new directory. The default is 0755 (rwxr-xr-x: r/w for
65116512
the user readable for others). Use 0700 to make it unreadable
@@ -6514,9 +6515,17 @@ mkdir({name} [, {path} [, {prot}]])
65146515
with 0755.
65156516
Example: >
65166517
:call mkdir($HOME . "/tmp/foo/bar", "p", 0700)
6518+
65176519
< This function is not available in the |sandbox|.
6520+
65186521
There is no error if the directory already exists and the "p"
6519-
flag is passed (since patch 8.0.1708).
6522+
flag is passed (since patch 8.0.1708). However, without the
6523+
"p" option the call will fail.
6524+
6525+
The function result is a Number, which is 1 if the call was
6526+
successful or 0 if the directory creation failed or partly
6527+
failed.
6528+
65206529
Not available on all systems. To check use: >
65216530
:if exists("*mkdir")
65226531
<
@@ -7325,6 +7334,9 @@ remove({list}, {idx} [, {end}]) *remove()*
73257334
Example: >
73267335
:echo "last item: " . remove(mylist, -1)
73277336
:call remove(mylist, 0, 9)
7337+
<
7338+
Use |delete()| to remove a file.
7339+
73287340
remove({blob}, {idx} [, {end}])
73297341
Without {end}: Remove the byte at {idx} from |Blob| {blob} and
73307342
return the byte.
@@ -7335,13 +7347,12 @@ remove({blob}, {idx} [, {end}])
73357347
Example: >
73367348
:echo "last byte: " . remove(myblob, -1)
73377349
:call remove(mylist, 0, 9)
7350+
73387351
remove({dict}, {key})
73397352
Remove the entry from {dict} with key {key}. Example: >
73407353
:echo "removed " . remove(dict, "one")
73417354
< If there is no {key} in {dict} this is an error.
73427355

7343-
Use |delete()| to remove a file.
7344-
73457356
rename({from}, {to}) *rename()*
73467357
Rename the file by the name {from} to the name {to}. This
73477358
should also work to move files across file systems. The
@@ -9724,10 +9735,10 @@ type({expr}) The result is a Number representing the type of {expr}.
97249735
Dictionary: 4 |v:t_dict|
97259736
Float: 5 |v:t_float|
97269737
Boolean: 6 |v:t_bool| (v:false and v:true)
9727-
None 7 |v:t_none| (v:null and v:none)
9728-
Job 8 |v:t_job|
9729-
Channel 9 |v:t_channel|
9730-
Blob 10 |v:t_blob|
9738+
None: 7 |v:t_none| (v:null and v:none)
9739+
Job: 8 |v:t_job|
9740+
Channel: 9 |v:t_channel|
9741+
Blob: 10 |v:t_blob|
97319742
For backward compatibility, this method can be used: >
97329743
:if type(myvar) == type(0)
97339744
:if type(myvar) == type("")
@@ -10150,7 +10161,7 @@ all_builtin_terms Compiled with all builtin terminals enabled.
1015010161
amiga Amiga version of Vim.
1015110162
arabic Compiled with Arabic support |Arabic|.
1015210163
arp Compiled with ARP support (Amiga).
10153-
autocmd Compiled with autocommand support. |autocommand|
10164+
autocmd Compiled with autocommand support. (always true)
1015410165
autochdir Compiled with support for 'autochdir'
1015510166
autoservername Automatically enable |clientserver|
1015610167
balloon_eval Compiled with |balloon-eval| support.
@@ -10159,6 +10170,7 @@ beos BeOS version of Vim.
1015910170
browse Compiled with |:browse| support, and browse() will
1016010171
work.
1016110172
browsefilter Compiled with support for |browsefilter|.
10173+
bsd Compiled on an OS in the BSD family (excluding macOS).
1016210174
builtin_terms Compiled with some builtin terminals.
1016310175
byte_offset Compiled with support for 'o' in 'statusline'
1016410176
cindent Compiled with 'cindent' support.
@@ -10171,6 +10183,7 @@ comments Compiled with |'comments'| support.
1017110183
compatible Compiled to be very Vi compatible.
1017210184
cryptv Compiled with encryption support |encryption|.
1017310185
cscope Compiled with |cscope| support.
10186+
cursorbind Compiled with |cursorbind| (always true)
1017410187
debug Compiled with "DEBUG" defined.
1017510188
dialog_con Compiled with console dialog support.
1017610189
dialog_gui Compiled with GUI dialog support.
@@ -10182,7 +10195,7 @@ ebcdic Compiled on a machine with ebcdic character set.
1018210195
emacs_tags Compiled with support for Emacs tags.
1018310196
eval Compiled with expression evaluation support. Always
1018410197
true, of course!
10185-
ex_extra |+ex_extra|, always true now
10198+
ex_extra |+ex_extra| (always true)
1018610199
extra_search Compiled with support for |'incsearch'| and
1018710200
|'hlsearch'|
1018810201
farsi Compiled with Farsi support |farsi|.
@@ -10211,6 +10224,7 @@ gui_running Vim is running in the GUI, or it will start soon.
1021110224
gui_win32 Compiled with MS Windows Win32 GUI.
1021210225
gui_win32s idem, and Win32s system being used (Windows 3.1)
1021310226
hangul_input Compiled with Hangul input support. |hangul|
10227+
hpux HP-UX version of Vim.
1021410228
iconv Can use iconv() for conversion.
1021510229
insert_expand Compiled with support for CTRL-X expansion commands in
1021610230
Insert mode.
@@ -10221,6 +10235,7 @@ langmap Compiled with 'langmap' support.
1022110235
libcall Compiled with |libcall()| support.
1022210236
linebreak Compiled with 'linebreak', 'breakat', 'showbreak' and
1022310237
'breakindent' support.
10238+
linux Linux version of Vim.
1022410239
lispindent Compiled with support for lisp indenting.
1022510240
listcmds Compiled with commands for the buffer list |:files|
1022610241
and the argument list |arglist|.
@@ -10271,14 +10286,15 @@ quickfix Compiled with |quickfix| support.
1027110286
reltime Compiled with |reltime()| support.
1027210287
rightleft Compiled with 'rightleft' support.
1027310288
ruby Compiled with Ruby interface |ruby|.
10274-
scrollbind Compiled with 'scrollbind' support.
10289+
scrollbind Compiled with 'scrollbind' support. (always true)
1027510290
showcmd Compiled with 'showcmd' support.
1027610291
signs Compiled with |:sign| support.
1027710292
smartindent Compiled with 'smartindent' support.
1027810293
spell Compiled with spell checking support |spell|.
1027910294
startuptime Compiled with |--startuptime| support.
1028010295
statusline Compiled with support for 'statusline', 'rulerformat'
1028110296
and special formats of 'titlestring' and 'iconstring'.
10297+
sun SunOS version of Vim.
1028210298
sun_workshop Support for Sun |workshop| has been removed.
1028310299
syntax Compiled with syntax highlighting support |syntax|.
1028410300
syntax_items There are active syntax highlighting items for the
@@ -10310,27 +10326,29 @@ user_commands User-defined commands.
1031010326
vcon Win32: Virtual console support is working, can use
1031110327
'termguicolors'. Also see |+vtp|.
1031210328
vertsplit Compiled with vertically split windows |:vsplit|.
10329+
(always true)
1031310330
vim_starting True while initial source'ing takes place. |startup|
1031410331
*vim_starting*
1031510332
viminfo Compiled with viminfo support.
10316-
virtualedit Compiled with 'virtualedit' option.
10333+
virtualedit Compiled with 'virtualedit' option. (always true)
1031710334
visual Compiled with Visual mode. (always true)
1031810335
visualextra Compiled with extra Visual mode commands. (always
1031910336
true) |blockwise-operators|.
1032010337
vms VMS version of Vim.
10321-
vreplace Compiled with |gR| and |gr| commands.
10338+
vreplace Compiled with |gR| and |gr| commands. (always true)
1032210339
vtp Compiled for vcon support |+vtp| (check vcon to find
1032310340
out if it works in the current console).
1032410341
wildignore Compiled with 'wildignore' option.
1032510342
wildmenu Compiled with 'wildmenu' option.
10326-
win16 old version for MS-Windows 3.1 (always False)
10343+
win16 old version for MS-Windows 3.1 (always false)
1032710344
win32 Win32 version of Vim (MS-Windows 95 and later, 32 or
1032810345
64 bits)
1032910346
win32unix Win32 version of Vim, using Unix files (Cygwin)
1033010347
win64 Win64 version of Vim (MS-Windows 64 bit).
10331-
win95 Win32 version for MS-Windows 95/98/ME (always False)
10348+
win95 Win32 version for MS-Windows 95/98/ME (always false)
1033210349
winaltkeys Compiled with 'winaltkeys' option.
1033310350
windows Compiled with support for more than one window.
10351+
(always true)
1033410352
writebackup Compiled with 'writebackup' default on.
1033510353
xfontset Compiled with X fontset support |xfontset|.
1033610354
xim Compiled with X input method support |xim|.

src/evalfunc.c

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6118,6 +6118,15 @@ f_has(typval_T *argvars, typval_T *rettv)
61186118
#ifdef __BEOS__
61196119
"beos",
61206120
#endif
6121+
#if defined(BSD) && !defined(MACOS_X)
6122+
"bsd",
6123+
#endif
6124+
#ifdef hpux
6125+
"hpux",
6126+
#endif
6127+
#ifdef __linux__
6128+
"linux",
6129+
#endif
61216130
#ifdef MACOS_X
61226131
"mac", /* Mac OS X (and, once, Mac OS Classic) */
61236132
"osx", /* Mac OS X */
@@ -6129,6 +6138,11 @@ f_has(typval_T *argvars, typval_T *rettv)
61296138
#ifdef __QNX__
61306139
"qnx",
61316140
#endif
6141+
#ifdef SUN_SYSTEM
6142+
"sun",
6143+
#else
6144+
"moon",
6145+
#endif
61326146
#ifdef UNIX
61336147
"unix",
61346148
#endif
@@ -6158,7 +6172,7 @@ f_has(typval_T *argvars, typval_T *rettv)
61586172
#endif
61596173
"autocmd",
61606174
#ifdef FEAT_AUTOCHDIR
6161-
"autochdir",
6175+
"autochdir",
61626176
#endif
61636177
#ifdef FEAT_AUTOSERVERNAME
61646178
"autoservername",

src/testdir/test_channel.vim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ endfunc
2929
func s:get_resources()
3030
let pid = getpid()
3131

32-
if has('mac')
32+
if executable('lsof')
3333
return systemlist('lsof -p ' . pid . ' | awk ''$4~/^[0-9]*[rwu]$/&&$5=="REG"{print$NF}''')
3434
elseif isdirectory('/proc/' . pid . '/fd/')
3535
return systemlist('readlink /proc/' . pid . '/fd/* | grep -v ''^/dev/''')

src/testdir/test_functions.vim

Lines changed: 52 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1054,22 +1054,31 @@ func Test_libcall_libcallnr()
10541054
let libc = 'msvcrt.dll'
10551055
elseif has('mac')
10561056
let libc = 'libSystem.B.dylib'
1057-
elseif system('uname -s') =~ 'SunOS'
1058-
" Set the path to libc.so according to the architecture.
1059-
let test_bits = system('file ' . GetVimProg())
1060-
let test_arch = system('uname -p')
1061-
if test_bits =~ '64-bit' && test_arch =~ 'sparc'
1062-
let libc = '/usr/lib/sparcv9/libc.so'
1063-
elseif test_bits =~ '64-bit' && test_arch =~ 'i386'
1064-
let libc = '/usr/lib/amd64/libc.so'
1057+
elseif executable('ldd')
1058+
let libc = matchstr(split(system('ldd ' . GetVimProg())), '/libc\.so\>')
1059+
endif
1060+
if get(l:, 'libc', '') ==# ''
1061+
" On Unix, libc.so can be in various places.
1062+
if has('linux')
1063+
" There is not documented but regarding the 1st argument of glibc's
1064+
" dlopen an empty string and nullptr are equivalent, so using an empty
1065+
" string for the 1st argument of libcall allows to call functions.
1066+
let libc = ''
1067+
elseif has('sun')
1068+
" Set the path to libc.so according to the architecture.
1069+
let test_bits = system('file ' . GetVimProg())
1070+
let test_arch = system('uname -p')
1071+
if test_bits =~ '64-bit' && test_arch =~ 'sparc'
1072+
let libc = '/usr/lib/sparcv9/libc.so'
1073+
elseif test_bits =~ '64-bit' && test_arch =~ 'i386'
1074+
let libc = '/usr/lib/amd64/libc.so'
1075+
else
1076+
let libc = '/usr/lib/libc.so'
1077+
endif
10651078
else
1066-
let libc = '/usr/lib/libc.so'
1079+
" Unfortunately skip this test until a good way is found.
1080+
return
10671081
endif
1068-
else
1069-
" On Unix, libc.so can be in various places.
1070-
" Interestingly, using an empty string for the 1st argument of libcall
1071-
" allows to call functions from libc which is not documented.
1072-
let libc = ''
10731082
endif
10741083

10751084
if has('win32')
@@ -1208,3 +1217,32 @@ func Test_confirm()
12081217
call assert_fails('call confirm("Are you sure?", "&Yes\n&No\n", [])', 'E745:')
12091218
call assert_fails('call confirm("Are you sure?", "&Yes\n&No\n", 0, [])', 'E730:')
12101219
endfunc
1220+
1221+
func Test_platform_name()
1222+
" The system matches at most only one name.
1223+
let names = ['amiga', 'beos', 'bsd', 'hpux', 'linux', 'mac', 'qnx', 'sun', 'vms', 'win32', 'win32unix']
1224+
call assert_inrange(0, 1, len(filter(copy(names), 'has(v:val)')))
1225+
1226+
" Is Unix?
1227+
call assert_equal(has('beos'), has('beos') && has('unix'))
1228+
call assert_equal(has('bsd'), has('bsd') && has('unix'))
1229+
call assert_equal(has('hpux'), has('hpux') && has('unix'))
1230+
call assert_equal(has('linux'), has('linux') && has('unix'))
1231+
call assert_equal(has('mac'), has('mac') && has('unix'))
1232+
call assert_equal(has('qnx'), has('qnx') && has('unix'))
1233+
call assert_equal(has('sun'), has('sun') && has('unix'))
1234+
call assert_equal(has('win32'), has('win32') && !has('unix'))
1235+
call assert_equal(has('win32unix'), has('win32unix') && has('unix'))
1236+
1237+
if has('unix') && executable('uname')
1238+
let uname = system('uname')
1239+
call assert_equal(uname =~? 'BeOS', has('beos'))
1240+
call assert_equal(uname =~? 'BSD\|DragonFly', has('bsd'))
1241+
call assert_equal(uname =~? 'HP-UX', has('hpux'))
1242+
call assert_equal(uname =~? 'Linux', has('linux'))
1243+
call assert_equal(uname =~? 'Darwin', has('mac'))
1244+
call assert_equal(uname =~? 'QNX', has('qnx'))
1245+
call assert_equal(uname =~? 'SunOS', has('sun'))
1246+
call assert_equal(uname =~? 'CYGWIN\|MSYS', has('win32unix'))
1247+
endif
1248+
endfunc

src/testdir/test_terminal.vim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,7 @@ endfunction
559559

560560
func Test_terminal_noblock()
561561
let buf = term_start(&shell)
562-
if has('mac')
562+
if has('bsd') || has('mac') || has('sun')
563563
" The shell or something else has a problem dealing with more than 1000
564564
" characters at the same time.
565565
let len = 1000

src/testdir/test_writefile.vim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ func Test_writefile_fails_gently()
3333
endfunc
3434

3535
func Test_writefile_fails_conversion()
36-
if !has('iconv') || system('uname -s') =~ 'SunOS'
36+
if !has('iconv') || has('sun')
3737
return
3838
endif
3939
set nobackup nowritebackup

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -783,6 +783,8 @@ static char *(features[]) =
783783

784784
static int included_patches[] =
785785
{ /* Add new patch number below this line */
786+
/**/
787+
846,
786788
/**/
787789
845,
788790
/**/

0 commit comments

Comments
 (0)