diff options
author | oni-link <knil.ino@gmail.com> | 2014-04-18 21:10:49 +0200 |
---|---|---|
committer | Thiago de Arruda <tpadilha84@gmail.com> | 2014-04-19 09:40:18 -0300 |
commit | 971fd3e18e783c134142356cd5ea187a0e1d96b5 (patch) | |
tree | 446e1edea553d10f72c280e99ab4da02ae93afa5 | |
parent | 63cc8b6934e74da2fd13aa5d9f2254c257a45b1c (diff) | |
download | rneovim-971fd3e18e783c134142356cd5ea187a0e1d96b5.tar.gz rneovim-971fd3e18e783c134142356cd5ea187a0e1d96b5.tar.bz2 rneovim-971fd3e18e783c134142356cd5ea187a0e1d96b5.zip |
vim-patch:7.4.236
Problem: It's not that easy to check the Vim patch version.
Solution: Make has("patch-7.4.123") work. (partly by Marc Weber)
https://code.google.com/p/vim/source/detail?r=a44087db72386d080e9da870d751daf498004be8
-rw-r--r-- | src/eval.c | 30 | ||||
-rw-r--r-- | src/testdir/test60.in | 12 | ||||
-rw-r--r-- | src/testdir/test60.ok | 5 | ||||
-rw-r--r-- | src/version.c | 2 |
4 files changed, 41 insertions, 8 deletions
diff --git a/src/eval.c b/src/eval.c index f4ec36fd2e..f3b874c7fe 100644 --- a/src/eval.c +++ b/src/eval.c @@ -10363,18 +10363,36 @@ static void f_has(typval_T *argvars, typval_T *rettv) } if (n == FALSE) { - if (STRNICMP(name, "patch", 5) == 0) - n = has_patch(atoi((char *)name + 5)); - else if (STRICMP(name, "vim_starting") == 0) + if (STRNICMP(name, "patch", 5) == 0) { + if (name[5] == '-' + && STRLEN(name) > 11 + && vim_isdigit(name[6]) + && vim_isdigit(name[8]) + && vim_isdigit(name[10])) { + int major = atoi((char *)name + 6); + int minor = atoi((char *)name + 8); + int patch = atoi((char *)name + 10); + + // Expect "patch-9.9.01234". + n = (major < VIM_VERSION_MAJOR + || (major == VIM_VERSION_MAJOR + && (minor < VIM_VERSION_MINOR + || (minor == VIM_VERSION_MINOR + && patch <= highest_patch())))); + } else { + n = has_patch(atoi((char *)name + 5)); + } + } else if (STRICMP(name, "vim_starting") == 0) { n = (starting != 0); - else if (STRICMP(name, "multi_byte_encoding") == 0) + } else if (STRICMP(name, "multi_byte_encoding") == 0) { n = has_mbyte; #if defined(USE_ICONV) && defined(DYNAMIC_ICONV) - else if (STRICMP(name, "iconv") == 0) + } else if (STRICMP(name, "iconv") == 0) { n = iconv_enabled(FALSE); #endif - else if (STRICMP(name, "syntax_items") == 0) + } else if (STRICMP(name, "syntax_items") == 0) { n = syntax_present(curwin); + } } rettv->vval.v_number = n; diff --git a/src/testdir/test60.in b/src/testdir/test60.in index 0f30142dcf..8835df9e0c 100644 --- a/src/testdir/test60.in +++ b/src/testdir/test60.in @@ -1,4 +1,4 @@ -Tests for the exists() function. vim: set ft=vim ts=8 : +Tests for the exists() and has() functions. vim: set ft=vim ts=8 sw=2 : STARTTEST :so small.vim @@ -588,6 +588,16 @@ endfunction redir END endfunction :call TestExists() +:" +:function TestHas() + redir >> test.out + for pl in ['6.9.999', '7.1.999', '7.4.123', '9.1.0', '9.9.1'] + echo 'has patch ' . pl . ': ' . has('patch-' . pl) + endfor + redir END +endfunc +:call TestHas() +:" :delfunc TestExists :delfunc RunTest :delfunc TestFuncArg diff --git a/src/testdir/test60.ok b/src/testdir/test60.ok index 0c382ad281..dabcd0c05d 100644 --- a/src/testdir/test60.ok +++ b/src/testdir/test60.ok @@ -204,3 +204,8 @@ OK g:footest#x = 1 footest#F() 0 UndefFun() 0 +has patch 6.9.999: 1 +has patch 7.1.999: 1 +has patch 7.4.123: 1 +has patch 9.1.0: 0 +has patch 9.9.1: 0 diff --git a/src/version.c b/src/version.c index e1019be5bc..618caece87 100644 --- a/src/version.c +++ b/src/version.c @@ -224,7 +224,7 @@ static int included_patches[] = { 239, //238, //237, - //236, + 236, //235, 234, 233, |