To: vim-dev@vim.org Subject: Patch 6.1.384 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit ------------ Patch 6.1.384 Problem: It is not possible to find if a certain patch has been included. (Lubomir Host) Solution: Support using has() to check if a patch was included. Files: runtime/doc/eval.txt, src/eval.c, src/proto/version.pro, src/version.c *** ../vim61.383/runtime/doc/eval.txt Tue Jan 28 22:17:41 2003 --- runtime/doc/eval.txt Sun Mar 9 22:21:25 2003 *************** *** 1,4 **** ! *eval.txt* For Vim version 6.1. Last change: 2003 Jan 28 VIM REFERENCE MANUAL by Bram Moolenaar --- 1,4 ---- ! *eval.txt* For Vim version 6.1. Last change: 2003 Mar 09 VIM REFERENCE MANUAL by Bram Moolenaar *************** *** 730,735 **** --- 734,744 ---- minor version number. Version 5.0 is 500. Version 5.1 (5.01) is 501. Read-only. "version" also works, for backwards compatibility. + Use |has()| to check if a certain patch was included, e.g.: > + if has("patch123") + < Note that patch numbers are specific to the version, thus both + version 5.0 and 5.1 may have a patch 123, but these are + completely different. *v:warningmsg* *warningmsg-variable* v:warningmsg Last given warning message. It's allowed to set this variable. *************** *** 2451,2463 **** < *feature-list* ! There are two types of features: 1. Features that are only supported when they have been enabled when Vim was compiled |+feature-list|. Example: > :if has("cindent") 2. Features that are only supported when certain conditions have been met. Example: > :if has("gui_running") all_builtin_terms Compiled with all builtin terminals enabled. amiga Amiga version of Vim. --- 2493,2508 ---- < *feature-list* ! There are three types of features: 1. Features that are only supported when they have been enabled when Vim was compiled |+feature-list|. Example: > :if has("cindent") 2. Features that are only supported when certain conditions have been met. Example: > :if has("gui_running") + 3. Included patches. First check |v:version| for the version of Vim. + Then the "patch123" feature means that patch 123 has been included for + this version. all_builtin_terms Compiled with all builtin terminals enabled. amiga Amiga version of Vim. *** ../vim61.383/src/eval.c Mon Feb 24 11:29:14 2003 --- src/eval.c Sun Mar 9 22:15:22 2003 *************** *** 4572,4578 **** if (n == FALSE) { ! if (STRICMP(name, "vim_starting") == 0) n = (starting != 0); #ifdef DYNAMIC_TCL else if (STRICMP(name, "tcl") == 0) --- 4576,4584 ---- if (n == FALSE) { ! if (STRNICMP(name, "patch", 5) == 0) ! n = has_patch(atoi(name + 5)); ! else if (STRICMP(name, "vim_starting") == 0) n = (starting != 0); #ifdef DYNAMIC_TCL else if (STRICMP(name, "tcl") == 0) *** ../vim61.383/src/proto/version.pro Fri Mar 22 21:41:24 2002 --- src/proto/version.pro Sun Mar 9 22:14:42 2003 *************** *** 1,6 **** --- 1,7 ---- /* version.c */ void make_version __ARGS((void)); int highest_patch __ARGS((void)); + int has_patch __ARGS((int n)); void ex_version __ARGS((exarg_T *eap)); void list_version __ARGS((void)); void intro_message __ARGS((int colon)); *** ../vim61.383/src/version.c Sun Mar 9 17:49:38 2003 --- src/version.c Sun Mar 9 22:22:27 2003 *************** *** 613,614 **** --- 613,616 ---- { /* Add new patch number below this line */ + /**/ + 384, /**/ *************** *** 1391,1396 **** --- 1393,1413 ---- if (included_patches[i] > h) h = included_patches[i]; return h; + } + + /* + * Return TRUE if patch "n" has been included. + */ + int + has_patch(n) + int n; + { + int i; + + for (i = 0; included_patches[i] != 0; ++i) + if (included_patches[i] == n) + return TRUE; + return FALSE; } void -- hundred-and-one symptoms of being an internet addict: 11. You find yourself typing "com" after every period when using a word processor.com /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// Creator of Vim - Vi IMproved -- http://www.Vim.org \\\ \\\ Project leader for A-A-P -- http://www.A-A-P.org /// \\\ Help AIDS victims, buy at Amazon -- http://ICCF.nl/click1.html ///