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