vim-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 vim/vim#3855)
39536dd557

Some doc changes have already been applied. Some others are N/A.
"moon" was removed in patch 8.2.0427 so I did not add it.
This commit is contained in:
zeertzjq
2022-02-04 09:23:54 +08:00
parent f5c4c1d768
commit f25ab39faa
5 changed files with 70 additions and 22 deletions

View File

@@ -1377,6 +1377,35 @@ func Test_func_exists_on_reload()
delfunc ExistingFunction
endfunc
func Test_platform_name()
" The system matches at most only one name.
let names = ['amiga', 'beos', 'bsd', 'hpux', 'linux', 'mac', 'qnx', 'sun', 'vms', 'win32', 'win32unix']
call assert_inrange(0, 1, len(filter(copy(names), 'has(v:val)')))
" Is Unix?
call assert_equal(has('beos'), has('beos') && has('unix'))
call assert_equal(has('bsd'), has('bsd') && has('unix'))
call assert_equal(has('hpux'), has('hpux') && has('unix'))
call assert_equal(has('linux'), has('linux') && has('unix'))
call assert_equal(has('mac'), has('mac') && has('unix'))
call assert_equal(has('qnx'), has('qnx') && has('unix'))
call assert_equal(has('sun'), has('sun') && has('unix'))
call assert_equal(has('win32'), has('win32') && !has('unix'))
call assert_equal(has('win32unix'), has('win32unix') && has('unix'))
if has('unix') && executable('uname')
let uname = system('uname')
call assert_equal(uname =~? 'BeOS', has('beos'))
call assert_equal(uname =~? 'BSD\|DragonFly', has('bsd'))
call assert_equal(uname =~? 'HP-UX', has('hpux'))
call assert_equal(uname =~? 'Linux', has('linux'))
call assert_equal(uname =~? 'Darwin', has('mac'))
call assert_equal(uname =~? 'QNX', has('qnx'))
call assert_equal(uname =~? 'SunOS', has('sun'))
call assert_equal(uname =~? 'CYGWIN\|MSYS', has('win32unix'))
endif
endfunc
sandbox function Fsandbox()
normal ix
endfunc
@@ -1519,24 +1548,31 @@ func Test_libcall_libcallnr()
let libc = 'msvcrt.dll'
elseif has('mac')
let libc = 'libSystem.B.dylib'
elseif system('uname -s') =~ 'SunOS'
" Set the path to libc.so according to the architecture.
let test_bits = system('file ' . GetVimProg())
let test_arch = system('uname -p')
if test_bits =~ '64-bit' && test_arch =~ 'sparc'
let libc = '/usr/lib/sparcv9/libc.so'
elseif test_bits =~ '64-bit' && test_arch =~ 'i386'
let libc = '/usr/lib/amd64/libc.so'
else
let libc = '/usr/lib/libc.so'
endif
elseif system('uname -s') =~ 'OpenBSD'
let libc = 'libc.so'
else
elseif executable('ldd')
let libc = matchstr(split(system('ldd ' . GetVimProg())), '/libc\.so\>')
endif
if get(l:, 'libc', '') ==# ''
" On Unix, libc.so can be in various places.
" Interestingly, using an empty string for the 1st argument of libcall
" allows to call functions from libc which is not documented.
let libc = ''
if has('linux')
" There is not documented but regarding the 1st argument of glibc's
" dlopen an empty string and nullptr are equivalent, so using an empty
" string for the 1st argument of libcall allows to call functions.
let libc = ''
elseif has('sun')
" Set the path to libc.so according to the architecture.
let test_bits = system('file ' . GetVimProg())
let test_arch = system('uname -p')
if test_bits =~ '64-bit' && test_arch =~ 'sparc'
let libc = '/usr/lib/sparcv9/libc.so'
elseif test_bits =~ '64-bit' && test_arch =~ 'i386'
let libc = '/usr/lib/amd64/libc.so'
else
let libc = '/usr/lib/libc.so'
endif
else
" Unfortunately skip this test until a good way is found.
return
endif
endif
if has('win32')