073263
To: vim_dev@googlegroups.com
073263
Subject: Patch 7.4.236
073263
Fcc: outbox
073263
From: Bram Moolenaar <Bram@moolenaar.net>
073263
Mime-Version: 1.0
073263
Content-Type: text/plain; charset=UTF-8
073263
Content-Transfer-Encoding: 8bit
073263
------------
073263
073263
Patch 7.4.236
073263
Problem:    It's not that easy to check the Vim patch version.
073263
Solution:   Make has("patch-7.4.123") work. (partly by Marc Weber)
073263
Files:	    runtime/doc/eval.txt, src/eval.c, src/testdir/test60.in,
073263
	    src/testdir/test60.ok
073263
073263
073263
*** ../vim-7.4.235/runtime/doc/eval.txt	2014-04-01 21:00:45.440733663 +0200
073263
--- runtime/doc/eval.txt	2014-04-01 21:19:52.232717888 +0200
073263
***************
073263
*** 6395,6407 ****
073263
      Example: >
073263
  	:if has("gui_running")
073263
  <							*has-patch*
073263
! 3.  Included patches.  First check |v:version| for the version of Vim.
073263
!     Then the "patch123" feature means that patch 123 has been included for
073263
!     this version.  Example (checking version 6.2.148 or later): >
073263
  	:if v:version > 602 || v:version == 602 && has("patch148")
073263
! <   Note that it's possible for patch 147 to be omitted even though 148 is
073263
      included.
073263
  
073263
  all_builtin_terms	Compiled with all builtin terminals enabled.
073263
  amiga			Amiga version of Vim.
073263
  arabic			Compiled with Arabic support |Arabic|.
073263
--- 6408,6430 ----
073263
      Example: >
073263
  	:if has("gui_running")
073263
  <							*has-patch*
073263
! 3.  Included patches.  The "patch123" feature means that patch 123 has been
073263
!     included.  Note that this form does not check the version of Vim, you need
073263
!     to inspect |v:version| for that:
073263
!     Example (checking version 6.2.148 or later): >
073263
  	:if v:version > 602 || v:version == 602 && has("patch148")
073263
! <    Note that it's possible for patch 147 to be omitted even though 148 is
073263
      included.
073263
  
073263
+ 4.  Beyond a certain patch level.  The "patch-7.4.123" feature means that
073263
+     the Vim version is 7.4 and patch 123 or later was included, or the Vim
073263
+     version is later than 7.4.
073263
+     The example above can be simplified to: >
073263
+ 	:if has("patch-6.2.148")
073263
+ <    Note that this does not check if the patch was actually included, some
073263
+     patches may have been skipped.  That is unusual though.
073263
+ 
073263
+ acl			Compiled with |ACL| support.
073263
  all_builtin_terms	Compiled with all builtin terminals enabled.
073263
  amiga			Amiga version of Vim.
073263
  arabic			Compiled with Arabic support |Arabic|.
073263
*** ../vim-7.4.235/src/eval.c	2014-04-01 21:00:45.428733664 +0200
073263
--- src/eval.c	2014-04-01 21:50:59.084692208 +0200
073263
***************
073263
*** 12638,12644 ****
073263
      if (n == FALSE)
073263
      {
073263
  	if (STRNICMP(name, "patch", 5) == 0)
073263
! 	    n = has_patch(atoi((char *)name + 5));
073263
  	else if (STRICMP(name, "vim_starting") == 0)
073263
  	    n = (starting != 0);
073263
  #ifdef FEAT_MBYTE
073263
--- 12638,12664 ----
073263
      if (n == FALSE)
073263
      {
073263
  	if (STRNICMP(name, "patch", 5) == 0)
073263
! 	{
073263
! 	    if (name[5] == '-'
073263
! 		    && STRLEN(name) > 11
073263
! 		    && vim_isdigit(name[6])
073263
! 		    && vim_isdigit(name[8])
073263
! 		    && vim_isdigit(name[10]))
073263
! 	    {
073263
! 		int major = atoi((char *)name + 6);
073263
! 		int minor = atoi((char *)name + 8);
073263
! 		int patch = atoi((char *)name + 10);
073263
! 
073263
! 		/* Expect "patch-9.9.01234". */
073263
! 		n = (major < VIM_VERSION_MAJOR
073263
! 		     || (major == VIM_VERSION_MAJOR
073263
! 			 && (minor < VIM_VERSION_MINOR
073263
! 			     || (minor == VIM_VERSION_MINOR
073263
! 				 && patch <= highest_patch()))));
073263
! 	    }
073263
! 	    else
073263
! 		n = has_patch(atoi((char *)name + 5));
073263
! 	}
073263
  	else if (STRICMP(name, "vim_starting") == 0)
073263
  	    n = (starting != 0);
073263
  #ifdef FEAT_MBYTE
073263
*** ../vim-7.4.235/src/testdir/test60.in	2014-01-14 15:24:24.000000000 +0100
073263
--- src/testdir/test60.in	2014-04-01 22:01:40.256683388 +0200
073263
***************
073263
*** 1,4 ****
073263
! Tests for the exists() function.  vim: set ft=vim ts=8 :
073263
  
073263
  STARTTEST
073263
  :so small.vim
073263
--- 1,4 ----
073263
! Tests for the exists() and has() functions.  vim: set ft=vim ts=8 sw=2 :
073263
  
073263
  STARTTEST
073263
  :so small.vim
073263
***************
073263
*** 588,593 ****
073263
--- 588,603 ----
073263
      redir END
073263
  endfunction
073263
  :call TestExists()
073263
+ :"
073263
+ :function TestHas()
073263
+   redir >> test.out
073263
+   for pl in ['6.9.999', '7.1.999', '7.4.123', '9.1.0', '9.9.1']
073263
+     echo 'has patch ' . pl . ': ' . has('patch-' . pl)
073263
+   endfor
073263
+   redir END
073263
+ endfunc
073263
+ :call TestHas()
073263
+ :"
073263
  :delfunc TestExists
073263
  :delfunc RunTest
073263
  :delfunc TestFuncArg
073263
*** ../vim-7.4.235/src/testdir/test60.ok	2014-01-14 15:24:24.000000000 +0100
073263
--- src/testdir/test60.ok	2014-04-01 22:01:46.664683300 +0200
073263
***************
073263
*** 204,206 ****
073263
--- 204,211 ----
073263
   g:footest#x = 1
073263
     footest#F() 0
073263
  UndefFun() 0
073263
+ has patch 6.9.999: 1
073263
+ has patch 7.1.999: 1
073263
+ has patch 7.4.123: 1
073263
+ has patch 9.1.0: 0
073263
+ has patch 9.9.1: 0
073263
*** ../vim-7.4.235/src/version.c	2014-04-01 21:00:45.440733663 +0200
073263
--- src/version.c	2014-04-01 21:22:27.964715746 +0200
073263
***************
073263
*** 736,737 ****
073263
--- 736,739 ----
073263
  {   /* Add new patch number below this line */
073263
+ /**/
073263
+     236,
073263
  /**/
073263
073263
-- 
073263
When a fly lands on the ceiling, does it do a half roll or
073263
a half loop?
073263
073263
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
073263
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
073263
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
073263
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///