Karsten Hopp 0bdd14
To: vim_dev@googlegroups.com
Karsten Hopp 0bdd14
Subject: Patch 7.4.668
Karsten Hopp 0bdd14
Fcc: outbox
Karsten Hopp 0bdd14
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp 0bdd14
Mime-Version: 1.0
Karsten Hopp 0bdd14
Content-Type: text/plain; charset=UTF-8
Karsten Hopp 0bdd14
Content-Transfer-Encoding: 8bit
Karsten Hopp 0bdd14
------------
Karsten Hopp 0bdd14
Karsten Hopp 0bdd14
Patch 7.4.668
Karsten Hopp 0bdd14
Problem:    Can't use a glob pattern as a regexp pattern.
Karsten Hopp 0bdd14
Solution:   Add glob2regpat(). (Christian Brabandt)
Karsten Hopp 0bdd14
Files:      src/eval.c, runtime/doc/eval.txt
Karsten Hopp 0bdd14
Karsten Hopp 0bdd14
Karsten Hopp 0bdd14
*** ../vim-7.4.667/src/eval.c	2015-03-05 19:35:20.690114997 +0100
Karsten Hopp 0bdd14
--- src/eval.c	2015-03-20 17:28:18.912588318 +0100
Karsten Hopp 0bdd14
***************
Karsten Hopp 0bdd14
*** 575,580 ****
Karsten Hopp 0bdd14
--- 575,581 ----
Karsten Hopp 0bdd14
  static void f_getwinvar __ARGS((typval_T *argvars, typval_T *rettv));
Karsten Hopp 0bdd14
  static void f_glob __ARGS((typval_T *argvars, typval_T *rettv));
Karsten Hopp 0bdd14
  static void f_globpath __ARGS((typval_T *argvars, typval_T *rettv));
Karsten Hopp 0bdd14
+ static void f_glob2regpat  __ARGS((typval_T *argvars, typval_T *rettv));
Karsten Hopp 0bdd14
  static void f_has __ARGS((typval_T *argvars, typval_T *rettv));
Karsten Hopp 0bdd14
  static void f_has_key __ARGS((typval_T *argvars, typval_T *rettv));
Karsten Hopp 0bdd14
  static void f_haslocaldir __ARGS((typval_T *argvars, typval_T *rettv));
Karsten Hopp 0bdd14
***************
Karsten Hopp 0bdd14
*** 8142,8147 ****
Karsten Hopp 0bdd14
--- 8143,8149 ----
Karsten Hopp 0bdd14
      {"getwinposy",	0, 0, f_getwinposy},
Karsten Hopp 0bdd14
      {"getwinvar",	2, 3, f_getwinvar},
Karsten Hopp 0bdd14
      {"glob",		1, 4, f_glob},
Karsten Hopp 0bdd14
+     {"glob2regpat",	1, 1, f_glob2regpat},
Karsten Hopp 0bdd14
      {"globpath",	2, 5, f_globpath},
Karsten Hopp 0bdd14
      {"has",		1, 1, f_has},
Karsten Hopp 0bdd14
      {"has_key",		2, 2, f_has_key},
Karsten Hopp 0bdd14
***************
Karsten Hopp 0bdd14
*** 12500,12505 ****
Karsten Hopp 0bdd14
--- 12502,12521 ----
Karsten Hopp 0bdd14
  }
Karsten Hopp 0bdd14
  
Karsten Hopp 0bdd14
  /*
Karsten Hopp 0bdd14
+  * "glob2regpat()" function
Karsten Hopp 0bdd14
+  */
Karsten Hopp 0bdd14
+     static void
Karsten Hopp 0bdd14
+ f_glob2regpat(argvars, rettv)
Karsten Hopp 0bdd14
+     typval_T	*argvars;
Karsten Hopp 0bdd14
+     typval_T	*rettv;
Karsten Hopp 0bdd14
+ {
Karsten Hopp 0bdd14
+     char_u	*pat = get_tv_string_chk(&argvars[0]);
Karsten Hopp 0bdd14
+ 
Karsten Hopp 0bdd14
+     rettv->v_type = VAR_STRING;
Karsten Hopp 0bdd14
+     rettv->vval.v_string = file_pat_to_reg_pat(pat, NULL, NULL, FALSE);
Karsten Hopp 0bdd14
+ }
Karsten Hopp 0bdd14
+ 
Karsten Hopp 0bdd14
+ /*
Karsten Hopp 0bdd14
   * "has()" function
Karsten Hopp 0bdd14
   */
Karsten Hopp 0bdd14
      static void
Karsten Hopp 0bdd14
*** ../vim-7.4.667/runtime/doc/eval.txt	2015-01-27 15:18:55.152333309 +0100
Karsten Hopp 0bdd14
--- runtime/doc/eval.txt	2015-03-20 17:32:43.597601391 +0100
Karsten Hopp 0bdd14
***************
Karsten Hopp 0bdd14
*** 1833,1841 ****
Karsten Hopp 0bdd14
  getwinposy()			Number	Y coord in pixels of GUI Vim window
Karsten Hopp 0bdd14
  getwinvar( {nr}, {varname} [, {def}])
Karsten Hopp 0bdd14
  				any	variable {varname} in window {nr}
Karsten Hopp 0bdd14
! glob( {expr} [, {nosuf} [, {list}]])
Karsten Hopp 0bdd14
  				any	expand file wildcards in {expr}
Karsten Hopp 0bdd14
! globpath( {path}, {expr} [, {nosuf} [, {list}]])
Karsten Hopp 0bdd14
  				String	do glob({expr}) for all dirs in {path}
Karsten Hopp 0bdd14
  has( {feature})			Number	TRUE if feature {feature} supported
Karsten Hopp 0bdd14
  has_key( {dict}, {key})		Number	TRUE if {dict} has entry {key}
Karsten Hopp 0bdd14
--- 1834,1843 ----
Karsten Hopp 0bdd14
  getwinposy()			Number	Y coord in pixels of GUI Vim window
Karsten Hopp 0bdd14
  getwinvar( {nr}, {varname} [, {def}])
Karsten Hopp 0bdd14
  				any	variable {varname} in window {nr}
Karsten Hopp 0bdd14
! glob( {expr} [, {nosuf} [, {list} [, {alllinks}]]])
Karsten Hopp 0bdd14
  				any	expand file wildcards in {expr}
Karsten Hopp 0bdd14
! glob2regpat( {expr})		String  convert a glob pat into a search pat
Karsten Hopp 0bdd14
! globpath( {path}, {expr} [, {nosuf} [, {list} [, {alllinks}]]])
Karsten Hopp 0bdd14
  				String	do glob({expr}) for all dirs in {path}
Karsten Hopp 0bdd14
  has( {feature})			Number	TRUE if feature {feature} supported
Karsten Hopp 0bdd14
  has_key( {dict}, {key})		Number	TRUE if {dict} has entry {key}
Karsten Hopp 0bdd14
***************
Karsten Hopp 0bdd14
*** 3611,3617 ****
Karsten Hopp 0bdd14
  		See |expand()| for expanding special Vim variables.  See
Karsten Hopp 0bdd14
  		|system()| for getting the raw output of an external command.
Karsten Hopp 0bdd14
  
Karsten Hopp 0bdd14
! globpath({path}, {expr} [, {nosuf} [, {list}]])			*globpath()*
Karsten Hopp 0bdd14
  		Perform glob() on all directories in {path} and concatenate
Karsten Hopp 0bdd14
  		the results.  Example: >
Karsten Hopp 0bdd14
  			:echo globpath(&rtp, "syntax/c.vim")
Karsten Hopp 0bdd14
--- 3672,3687 ----
Karsten Hopp 0bdd14
  		See |expand()| for expanding special Vim variables.  See
Karsten Hopp 0bdd14
  		|system()| for getting the raw output of an external command.
Karsten Hopp 0bdd14
  
Karsten Hopp 0bdd14
! glob2regpat({expr})					 *glob2regpat()*
Karsten Hopp 0bdd14
! 		Convert a file patter, as used by glob(), into a search
Karsten Hopp 0bdd14
! 		pattern.  The result can be used to match with a string that
Karsten Hopp 0bdd14
! 		is a file name.  E.g. >
Karsten Hopp 0bdd14
! 			if filename =~ glob2regpat('Make*.mak')
Karsten Hopp 0bdd14
! <		This is equivalent to: >
Karsten Hopp 0bdd14
! 			if filename =~ '^Make.*\.mak$'
Karsten Hopp 0bdd14
! <
Karsten Hopp 0bdd14
! 								*globpath()*
Karsten Hopp 0bdd14
! globpath({path}, {expr} [, {nosuf} [, {list} [, {allinks}]]])
Karsten Hopp 0bdd14
  		Perform glob() on all directories in {path} and concatenate
Karsten Hopp 0bdd14
  		the results.  Example: >
Karsten Hopp 0bdd14
  			:echo globpath(&rtp, "syntax/c.vim")
Karsten Hopp 0bdd14
*** ../vim-7.4.667/src/version.c	2015-03-20 17:16:23.656659419 +0100
Karsten Hopp 0bdd14
--- src/version.c	2015-03-20 17:19:45.610380844 +0100
Karsten Hopp 0bdd14
***************
Karsten Hopp 0bdd14
*** 743,744 ****
Karsten Hopp 0bdd14
--- 743,746 ----
Karsten Hopp 0bdd14
  {   /* Add new patch number below this line */
Karsten Hopp 0bdd14
+ /**/
Karsten Hopp 0bdd14
+     668,
Karsten Hopp 0bdd14
  /**/
Karsten Hopp 0bdd14
Karsten Hopp 0bdd14
-- 
Karsten Hopp 0bdd14
Seen on the back of a biker's vest: If you can read this, my wife fell off.
Karsten Hopp 0bdd14
Karsten Hopp 0bdd14
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp 0bdd14
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp 0bdd14
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
Karsten Hopp 0bdd14
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///