# HG changeset patch # User Bram Moolenaar # Date 1548799216 -3600 # Node ID 772e72b046a31bc1106a9db49ead7b0350760841 # Parent b32ade2888eb8f6cdee6c491cbe1167bcfc7f684 patch 8.1.0846: not easy to recognize the system Vim runs on commit https://github.com/vim/vim/commit/39536dd557e847e80572044c2be319db5886abe3 Author: Bram Moolenaar Date: Tue Jan 29 22:58:21 2019 +0100 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 https://github.com/vim/vim/issues/3855) diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -1,4 +1,4 @@ -*eval.txt* For Vim version 8.1. Last change: 2019 Jan 24 +*eval.txt* For Vim version 8.1. Last change: 2019 Jan 29 VIM REFERENCE MANUAL by Bram Moolenaar @@ -696,7 +696,7 @@ similar to -1. > :let otherblob = myblob[:] " make a copy of the Blob If the first index is beyond the last byte of the Blob or the second index is -before the first byte, the result is an empty list. There is no error +before the first index, the result is an empty list. There is no error message. If the second index is equal to or greater than the length of the list the @@ -2511,7 +2511,10 @@ remote_read({serverid} [, {timeout}]) remote_send({server}, {string} [, {idvar}]) String send key sequence remote_startserver({name}) none become server {name} -remove({list}, {idx} [, {end}]) any remove items {idx}-{end} from {list} +remove({list}, {idx} [, {end}]) any/List + remove items {idx}-{end} from {list} +remove({blob}, {idx} [, {end}]) Number/Blob + remove bytes {idx}-{end} from {blob} remove({dict}, {key}) any remove entry {key} from {dict} rename({from}, {to}) Number rename (move) file from {from} to {to} repeat({expr}, {count}) String repeat {expr} {count} times @@ -6056,13 +6059,9 @@ line({expr}) The result is a Number, whi line(".") line number of the cursor line("'t") line number of mark t line("'" . marker) line number of mark marker -< *last-position-jump* - This autocommand jumps to the last known position in a file - just after opening it, if the '" mark is set: > - :au BufReadPost * - \ if line("'\"") > 1 && line("'\"") <= line("$") && &ft !~# 'commit' - \ | exe "normal! g`\"" - \ | endif +< + To jump to the last known position when opening a file see + |last-position-jump|. line2byte({lnum}) *line2byte()* Return the byte count from the start of the buffer for line @@ -6504,8 +6503,10 @@ min({expr}) Return the minimum value of *mkdir()* *E739* mkdir({name} [, {path} [, {prot}]]) Create directory {name}. + If {path} is "p" then intermediate directories are created as necessary. Otherwise it must be "". + If {prot} is given it is used to set the protection bits of the new directory. The default is 0755 (rwxr-xr-x: r/w for the user readable for others). Use 0700 to make it unreadable @@ -6514,9 +6515,17 @@ mkdir({name} [, {path} [, {prot}]]) with 0755. Example: > :call mkdir($HOME . "/tmp/foo/bar", "p", 0700) + < This function is not available in the |sandbox|. + There is no error if the directory already exists and the "p" - flag is passed (since patch 8.0.1708). + flag is passed (since patch 8.0.1708). However, without the + "p" option the call will fail. + + The function result is a Number, which is 1 if the call was + successful or 0 if the directory creation failed or partly + failed. + Not available on all systems. To check use: > :if exists("*mkdir") < @@ -7325,6 +7334,9 @@ remove({list}, {idx} [, {end}]) *remo Example: > :echo "last item: " . remove(mylist, -1) :call remove(mylist, 0, 9) +< + Use |delete()| to remove a file. + remove({blob}, {idx} [, {end}]) Without {end}: Remove the byte at {idx} from |Blob| {blob} and return the byte. @@ -7335,13 +7347,12 @@ remove({blob}, {idx} [, {end}]) Example: > :echo "last byte: " . remove(myblob, -1) :call remove(mylist, 0, 9) + remove({dict}, {key}) Remove the entry from {dict} with key {key}. Example: > :echo "removed " . remove(dict, "one") < If there is no {key} in {dict} this is an error. - Use |delete()| to remove a file. - rename({from}, {to}) *rename()* Rename the file by the name {from} to the name {to}. This should also work to move files across file systems. The @@ -9724,10 +9735,10 @@ type({expr}) The result is a Number repr Dictionary: 4 |v:t_dict| Float: 5 |v:t_float| Boolean: 6 |v:t_bool| (v:false and v:true) - None 7 |v:t_none| (v:null and v:none) - Job 8 |v:t_job| - Channel 9 |v:t_channel| - Blob 10 |v:t_blob| + None: 7 |v:t_none| (v:null and v:none) + Job: 8 |v:t_job| + Channel: 9 |v:t_channel| + Blob: 10 |v:t_blob| For backward compatibility, this method can be used: > :if type(myvar) == type(0) :if type(myvar) == type("") @@ -10150,7 +10161,7 @@ all_builtin_terms Compiled with all buil amiga Amiga version of Vim. arabic Compiled with Arabic support |Arabic|. arp Compiled with ARP support (Amiga). -autocmd Compiled with autocommand support. |autocommand| +autocmd Compiled with autocommand support. (always true) autochdir Compiled with support for 'autochdir' autoservername Automatically enable |clientserver| balloon_eval Compiled with |balloon-eval| support. @@ -10159,6 +10170,7 @@ beos BeOS version of Vim. browse Compiled with |:browse| support, and browse() will work. browsefilter Compiled with support for |browsefilter|. +bsd Compiled on an OS in the BSD family (excluding macOS). builtin_terms Compiled with some builtin terminals. byte_offset Compiled with support for 'o' in 'statusline' cindent Compiled with 'cindent' support. @@ -10171,6 +10183,7 @@ comments Compiled with |'comments'| sup compatible Compiled to be very Vi compatible. cryptv Compiled with encryption support |encryption|. cscope Compiled with |cscope| support. +cursorbind Compiled with |cursorbind| (always true) debug Compiled with "DEBUG" defined. dialog_con Compiled with console dialog support. dialog_gui Compiled with GUI dialog support. @@ -10182,7 +10195,7 @@ ebcdic Compiled on a machine with ebcd emacs_tags Compiled with support for Emacs tags. eval Compiled with expression evaluation support. Always true, of course! -ex_extra |+ex_extra|, always true now +ex_extra |+ex_extra| (always true) extra_search Compiled with support for |'incsearch'| and |'hlsearch'| farsi Compiled with Farsi support |farsi|. @@ -10211,6 +10224,7 @@ gui_running Vim is running in the GUI, gui_win32 Compiled with MS Windows Win32 GUI. gui_win32s idem, and Win32s system being used (Windows 3.1) hangul_input Compiled with Hangul input support. |hangul| +hpux HP-UX version of Vim. iconv Can use iconv() for conversion. insert_expand Compiled with support for CTRL-X expansion commands in Insert mode. @@ -10221,6 +10235,7 @@ langmap Compiled with 'langmap' suppor libcall Compiled with |libcall()| support. linebreak Compiled with 'linebreak', 'breakat', 'showbreak' and 'breakindent' support. +linux Linux version of Vim. lispindent Compiled with support for lisp indenting. listcmds Compiled with commands for the buffer list |:files| and the argument list |arglist|. @@ -10271,7 +10286,7 @@ quickfix Compiled with |quickfix| suppo reltime Compiled with |reltime()| support. rightleft Compiled with 'rightleft' support. ruby Compiled with Ruby interface |ruby|. -scrollbind Compiled with 'scrollbind' support. +scrollbind Compiled with 'scrollbind' support. (always true) showcmd Compiled with 'showcmd' support. signs Compiled with |:sign| support. smartindent Compiled with 'smartindent' support. @@ -10279,6 +10294,7 @@ spell Compiled with spell checking sup startuptime Compiled with |--startuptime| support. statusline Compiled with support for 'statusline', 'rulerformat' and special formats of 'titlestring' and 'iconstring'. +sun SunOS version of Vim. sun_workshop Support for Sun |workshop| has been removed. syntax Compiled with syntax highlighting support |syntax|. syntax_items There are active syntax highlighting items for the @@ -10310,27 +10326,29 @@ user_commands User-defined commands. vcon Win32: Virtual console support is working, can use 'termguicolors'. Also see |+vtp|. vertsplit Compiled with vertically split windows |:vsplit|. + (always true) vim_starting True while initial source'ing takes place. |startup| *vim_starting* viminfo Compiled with viminfo support. -virtualedit Compiled with 'virtualedit' option. +virtualedit Compiled with 'virtualedit' option. (always true) visual Compiled with Visual mode. (always true) visualextra Compiled with extra Visual mode commands. (always true) |blockwise-operators|. vms VMS version of Vim. -vreplace Compiled with |gR| and |gr| commands. +vreplace Compiled with |gR| and |gr| commands. (always true) vtp Compiled for vcon support |+vtp| (check vcon to find out if it works in the current console). wildignore Compiled with 'wildignore' option. wildmenu Compiled with 'wildmenu' option. -win16 old version for MS-Windows 3.1 (always False) +win16 old version for MS-Windows 3.1 (always false) win32 Win32 version of Vim (MS-Windows 95 and later, 32 or 64 bits) win32unix Win32 version of Vim, using Unix files (Cygwin) win64 Win64 version of Vim (MS-Windows 64 bit). -win95 Win32 version for MS-Windows 95/98/ME (always False) +win95 Win32 version for MS-Windows 95/98/ME (always false) winaltkeys Compiled with 'winaltkeys' option. windows Compiled with support for more than one window. + (always true) writebackup Compiled with 'writebackup' default on. xfontset Compiled with X fontset support |xfontset|. xim Compiled with X input method support |xim|. diff --git a/src/evalfunc.c b/src/evalfunc.c --- a/src/evalfunc.c +++ b/src/evalfunc.c @@ -6118,6 +6118,15 @@ f_has(typval_T *argvars, typval_T *rettv #ifdef __BEOS__ "beos", #endif +#if defined(BSD) && !defined(MACOS_X) + "bsd", +#endif +#ifdef hpux + "hpux", +#endif +#ifdef __linux__ + "linux", +#endif #ifdef MACOS_X "mac", /* Mac OS X (and, once, Mac OS Classic) */ "osx", /* Mac OS X */ @@ -6129,6 +6138,11 @@ f_has(typval_T *argvars, typval_T *rettv #ifdef __QNX__ "qnx", #endif +#ifdef SUN_SYSTEM + "sun", +#else + "moon", +#endif #ifdef UNIX "unix", #endif @@ -6158,7 +6172,7 @@ f_has(typval_T *argvars, typval_T *rettv #endif "autocmd", #ifdef FEAT_AUTOCHDIR - "autochdir", + "autochdir", #endif #ifdef FEAT_AUTOSERVERNAME "autoservername", diff --git a/src/testdir/test_channel.vim b/src/testdir/test_channel.vim --- a/src/testdir/test_channel.vim +++ b/src/testdir/test_channel.vim @@ -29,7 +29,7 @@ endfunc func s:get_resources() let pid = getpid() - if has('mac') + if executable('lsof') return systemlist('lsof -p ' . pid . ' | awk ''$4~/^[0-9]*[rwu]$/&&$5=="REG"{print$NF}''') elseif isdirectory('/proc/' . pid . '/fd/') return systemlist('readlink /proc/' . pid . '/fd/* | grep -v ''^/dev/''') diff --git a/src/testdir/test_functions.vim b/src/testdir/test_functions.vim --- a/src/testdir/test_functions.vim +++ b/src/testdir/test_functions.vim @@ -1054,22 +1054,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' + 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. + 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 - let libc = '/usr/lib/libc.so' + " Unfortunately skip this test until a good way is found. + return endif - else - " 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 = '' endif if has('win32') @@ -1208,3 +1217,32 @@ func Test_confirm() call assert_fails('call confirm("Are you sure?", "&Yes\n&No\n", [])', 'E745:') call assert_fails('call confirm("Are you sure?", "&Yes\n&No\n", 0, [])', 'E730:') 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 diff --git a/src/testdir/test_terminal.vim b/src/testdir/test_terminal.vim --- a/src/testdir/test_terminal.vim +++ b/src/testdir/test_terminal.vim @@ -559,7 +559,7 @@ endfunction func Test_terminal_noblock() let buf = term_start(&shell) - if has('mac') + if has('bsd') || has('mac') || has('sun') " The shell or something else has a problem dealing with more than 1000 " characters at the same time. let len = 1000 diff --git a/src/testdir/test_writefile.vim b/src/testdir/test_writefile.vim --- a/src/testdir/test_writefile.vim +++ b/src/testdir/test_writefile.vim @@ -33,7 +33,7 @@ func Test_writefile_fails_gently() endfunc func Test_writefile_fails_conversion() - if !has('iconv') || system('uname -s') =~ 'SunOS' + if !has('iconv') || has('sun') return endif set nobackup nowritebackup diff --git a/src/version.c b/src/version.c --- a/src/version.c +++ b/src/version.c @@ -784,6 +784,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 846, +/**/ 845, /**/ 844,