Karsten Hopp 5889ec
To: vim_dev@googlegroups.com
Karsten Hopp 5889ec
Subject: Patch 7.3.224
Karsten Hopp 5889ec
Fcc: outbox
Karsten Hopp 5889ec
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp 5889ec
Mime-Version: 1.0
Karsten Hopp 5889ec
Content-Type: text/plain; charset=UTF-8
Karsten Hopp 5889ec
Content-Transfer-Encoding: 8bit
Karsten Hopp 5889ec
------------
Karsten Hopp 5889ec
Karsten Hopp 5889ec
Patch 7.3.224
Karsten Hopp 5889ec
Problem:    Can't pass dict to sort function.
Karsten Hopp 5889ec
Solution:   Add the optional {dict} argument to sort(). (ZyX)
Karsten Hopp 5889ec
Files:      runtime/doc/eval.txt, src/eval.c
Karsten Hopp 5889ec
Karsten Hopp 5889ec
Karsten Hopp 5889ec
*** ../mercurial/vim73/runtime/doc/eval.txt	2011-05-19 17:25:36.000000000 +0200
Karsten Hopp 5889ec
--- runtime/doc/eval.txt	2011-06-19 02:42:52.000000000 +0200
Karsten Hopp 5889ec
***************
Karsten Hopp 5889ec
*** 1919,1925 ****
Karsten Hopp 5889ec
  simplify( {filename})		String	simplify filename as much as possible
Karsten Hopp 5889ec
  sin( {expr})			Float	sine of {expr}
Karsten Hopp 5889ec
  sinh( {expr})			Float	hyperbolic sine of {expr}
Karsten Hopp 5889ec
! sort( {list} [, {func}])	List	sort {list}, using {func} to compare
Karsten Hopp 5889ec
  soundfold( {word})		String	sound-fold {word}
Karsten Hopp 5889ec
  spellbadword()			String	badly spelled word at cursor
Karsten Hopp 5889ec
  spellsuggest( {word} [, {max} [, {capital}]])
Karsten Hopp 5889ec
--- 1922,1929 ----
Karsten Hopp 5889ec
  simplify( {filename})		String	simplify filename as much as possible
Karsten Hopp 5889ec
  sin( {expr})			Float	sine of {expr}
Karsten Hopp 5889ec
  sinh( {expr})			Float	hyperbolic sine of {expr}
Karsten Hopp 5889ec
! sort( {list} [, {func} [, {dict}]])
Karsten Hopp 5889ec
! 				List	sort {list}, using {func} to compare
Karsten Hopp 5889ec
  soundfold( {word})		String	sound-fold {word}
Karsten Hopp 5889ec
  spellbadword()			String	badly spelled word at cursor
Karsten Hopp 5889ec
  spellsuggest( {word} [, {max} [, {capital}]])
Karsten Hopp 5889ec
***************
Karsten Hopp 5889ec
*** 5275,5281 ****
Karsten Hopp 5889ec
  		{only available when compiled with the |+float| feature}
Karsten Hopp 5889ec
  
Karsten Hopp 5889ec
  
Karsten Hopp 5889ec
! sort({list} [, {func}])					*sort()* *E702*
Karsten Hopp 5889ec
  		Sort the items in {list} in-place.  Returns {list}.  If you
Karsten Hopp 5889ec
  		want a list to remain unmodified make a copy first: >
Karsten Hopp 5889ec
  			:let sortedlist = sort(copy(mylist))
Karsten Hopp 5889ec
--- 5279,5285 ----
Karsten Hopp 5889ec
  		{only available when compiled with the |+float| feature}
Karsten Hopp 5889ec
  
Karsten Hopp 5889ec
  
Karsten Hopp 5889ec
! sort({list} [, {func} [, {dict}]])			*sort()* *E702*
Karsten Hopp 5889ec
  		Sort the items in {list} in-place.  Returns {list}.  If you
Karsten Hopp 5889ec
  		want a list to remain unmodified make a copy first: >
Karsten Hopp 5889ec
  			:let sortedlist = sort(copy(mylist))
Karsten Hopp 5889ec
***************
Karsten Hopp 5889ec
*** 5283,5288 ****
Karsten Hopp 5889ec
--- 5287,5294 ----
Karsten Hopp 5889ec
  		Numbers sort after Strings, |Lists| after Numbers.
Karsten Hopp 5889ec
  		For sorting text in the current buffer use |:sort|.
Karsten Hopp 5889ec
  		When {func} is given and it is one then case is ignored.
Karsten Hopp 5889ec
+ 		{dict} is for functions with the "dict" attribute.  It will be
Karsten Hopp 5889ec
+ 		used to set the local variable "self". |Dictionary-function|
Karsten Hopp 5889ec
  		When {func} is a |Funcref| or a function name, this function
Karsten Hopp 5889ec
  		is called to compare items.  The function is invoked with two
Karsten Hopp 5889ec
  		items as argument and must return zero if they are equal, 1 or
Karsten Hopp 5889ec
*** ../mercurial/vim73/src/eval.c	2011-05-19 18:26:34.000000000 +0200
Karsten Hopp 5889ec
--- src/eval.c	2011-06-19 02:51:13.000000000 +0200
Karsten Hopp 5889ec
***************
Karsten Hopp 5889ec
*** 7930,7936 ****
Karsten Hopp 5889ec
      {"sin",		1, 1, f_sin},
Karsten Hopp 5889ec
      {"sinh",		1, 1, f_sinh},
Karsten Hopp 5889ec
  #endif
Karsten Hopp 5889ec
!     {"sort",		1, 2, f_sort},
Karsten Hopp 5889ec
      {"soundfold",	1, 1, f_soundfold},
Karsten Hopp 5889ec
      {"spellbadword",	0, 1, f_spellbadword},
Karsten Hopp 5889ec
      {"spellsuggest",	1, 3, f_spellsuggest},
Karsten Hopp 5889ec
--- 7930,7936 ----
Karsten Hopp 5889ec
      {"sin",		1, 1, f_sin},
Karsten Hopp 5889ec
      {"sinh",		1, 1, f_sinh},
Karsten Hopp 5889ec
  #endif
Karsten Hopp 5889ec
!     {"sort",		1, 3, f_sort},
Karsten Hopp 5889ec
      {"soundfold",	1, 1, f_soundfold},
Karsten Hopp 5889ec
      {"spellbadword",	0, 1, f_spellbadword},
Karsten Hopp 5889ec
      {"spellsuggest",	1, 3, f_spellsuggest},
Karsten Hopp 5889ec
***************
Karsten Hopp 5889ec
*** 16366,16371 ****
Karsten Hopp 5889ec
--- 16366,16372 ----
Karsten Hopp 5889ec
  
Karsten Hopp 5889ec
  static int	item_compare_ic;
Karsten Hopp 5889ec
  static char_u	*item_compare_func;
Karsten Hopp 5889ec
+ static dict_T	*item_compare_selfdict;
Karsten Hopp 5889ec
  static int	item_compare_func_err;
Karsten Hopp 5889ec
  #define ITEM_COMPARE_FAIL 999
Karsten Hopp 5889ec
  
Karsten Hopp 5889ec
***************
Karsten Hopp 5889ec
*** 16425,16431 ****
Karsten Hopp 5889ec
  
Karsten Hopp 5889ec
      rettv.v_type = VAR_UNKNOWN;		/* clear_tv() uses this */
Karsten Hopp 5889ec
      res = call_func(item_compare_func, (int)STRLEN(item_compare_func),
Karsten Hopp 5889ec
! 				 &rettv, 2, argv, 0L, 0L, &dummy, TRUE, NULL);
Karsten Hopp 5889ec
      clear_tv(&argv[0]);
Karsten Hopp 5889ec
      clear_tv(&argv[1]);
Karsten Hopp 5889ec
  
Karsten Hopp 5889ec
--- 16426,16433 ----
Karsten Hopp 5889ec
  
Karsten Hopp 5889ec
      rettv.v_type = VAR_UNKNOWN;		/* clear_tv() uses this */
Karsten Hopp 5889ec
      res = call_func(item_compare_func, (int)STRLEN(item_compare_func),
Karsten Hopp 5889ec
! 				 &rettv, 2, argv, 0L, 0L, &dummy, TRUE,
Karsten Hopp 5889ec
! 				 item_compare_selfdict);
Karsten Hopp 5889ec
      clear_tv(&argv[0]);
Karsten Hopp 5889ec
      clear_tv(&argv[1]);
Karsten Hopp 5889ec
  
Karsten Hopp 5889ec
***************
Karsten Hopp 5889ec
*** 16471,16478 ****
Karsten Hopp 5889ec
--- 16473,16482 ----
Karsten Hopp 5889ec
  
Karsten Hopp 5889ec
  	item_compare_ic = FALSE;
Karsten Hopp 5889ec
  	item_compare_func = NULL;
Karsten Hopp 5889ec
+ 	item_compare_selfdict = NULL;
Karsten Hopp 5889ec
  	if (argvars[1].v_type != VAR_UNKNOWN)
Karsten Hopp 5889ec
  	{
Karsten Hopp 5889ec
+ 	    /* optional second argument: {func} */
Karsten Hopp 5889ec
  	    if (argvars[1].v_type == VAR_FUNC)
Karsten Hopp 5889ec
  		item_compare_func = argvars[1].vval.v_string;
Karsten Hopp 5889ec
  	    else
Karsten Hopp 5889ec
***************
Karsten Hopp 5889ec
*** 16487,16492 ****
Karsten Hopp 5889ec
--- 16491,16507 ----
Karsten Hopp 5889ec
  		else
Karsten Hopp 5889ec
  		    item_compare_func = get_tv_string(&argvars[1]);
Karsten Hopp 5889ec
  	    }
Karsten Hopp 5889ec
+ 
Karsten Hopp 5889ec
+ 	    if (argvars[2].v_type != VAR_UNKNOWN)
Karsten Hopp 5889ec
+ 	    {
Karsten Hopp 5889ec
+ 		/* optional third argument: {dict} */
Karsten Hopp 5889ec
+ 		if (argvars[2].v_type != VAR_DICT)
Karsten Hopp 5889ec
+ 		{
Karsten Hopp 5889ec
+ 		    EMSG(_(e_dictreq));
Karsten Hopp 5889ec
+ 		    return;
Karsten Hopp 5889ec
+ 		}
Karsten Hopp 5889ec
+ 		item_compare_selfdict = argvars[2].vval.v_dict;
Karsten Hopp 5889ec
+ 	    }
Karsten Hopp 5889ec
  	}
Karsten Hopp 5889ec
  
Karsten Hopp 5889ec
  	/* Make an array with each entry pointing to an item in the List. */
Karsten Hopp 5889ec
*** ../vim-7.3.223/src/version.c	2011-06-19 01:30:01.000000000 +0200
Karsten Hopp 5889ec
--- src/version.c	2011-06-19 02:52:46.000000000 +0200
Karsten Hopp 5889ec
***************
Karsten Hopp 5889ec
*** 711,712 ****
Karsten Hopp 5889ec
--- 711,714 ----
Karsten Hopp 5889ec
  {   /* Add new patch number below this line */
Karsten Hopp 5889ec
+ /**/
Karsten Hopp 5889ec
+     224,
Karsten Hopp 5889ec
  /**/
Karsten Hopp 5889ec
Karsten Hopp 5889ec
-- 
Karsten Hopp 5889ec
hundred-and-one symptoms of being an internet addict:
Karsten Hopp 5889ec
193. You ask your girlfriend to drive home so you can sit back with
Karsten Hopp 5889ec
     your PDA and download the information to your laptop
Karsten Hopp 5889ec
Karsten Hopp 5889ec
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp 5889ec
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp 5889ec
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
Karsten Hopp 5889ec
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///