]> git.pld-linux.org Git - packages/vim.git/blob - 7.3.224
- rel 3; no more tinfo
[packages/vim.git] / 7.3.224
1 To: vim_dev@googlegroups.com
2 Subject: Patch 7.3.224
3 Fcc: outbox
4 From: Bram Moolenaar <Bram@moolenaar.net>
5 Mime-Version: 1.0
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
8 ------------
9
10 Patch 7.3.224
11 Problem:    Can't pass dict to sort function.
12 Solution:   Add the optional {dict} argument to sort(). (ZyX)
13 Files:      runtime/doc/eval.txt, src/eval.c
14
15
16 *** ../mercurial/vim73/runtime/doc/eval.txt     2011-05-19 17:25:36.000000000 +0200
17 --- runtime/doc/eval.txt        2011-06-19 02:42:52.000000000 +0200
18 ***************
19 *** 1919,1925 ****
20   simplify( {filename})         String  simplify filename as much as possible
21   sin( {expr})                  Float   sine of {expr}
22   sinh( {expr})                 Float   hyperbolic sine of {expr}
23 ! sort( {list} [, {func}])      List    sort {list}, using {func} to compare
24   soundfold( {word})            String  sound-fold {word}
25   spellbadword()                        String  badly spelled word at cursor
26   spellsuggest( {word} [, {max} [, {capital}]])
27 --- 1922,1929 ----
28   simplify( {filename})         String  simplify filename as much as possible
29   sin( {expr})                  Float   sine of {expr}
30   sinh( {expr})                 Float   hyperbolic sine of {expr}
31 ! sort( {list} [, {func} [, {dict}]])
32 !                               List    sort {list}, using {func} to compare
33   soundfold( {word})            String  sound-fold {word}
34   spellbadword()                        String  badly spelled word at cursor
35   spellsuggest( {word} [, {max} [, {capital}]])
36 ***************
37 *** 5275,5281 ****
38                 {only available when compiled with the |+float| feature}
39   
40   
41 ! sort({list} [, {func}])                                       *sort()* *E702*
42                 Sort the items in {list} in-place.  Returns {list}.  If you
43                 want a list to remain unmodified make a copy first: >
44                         :let sortedlist = sort(copy(mylist))
45 --- 5279,5285 ----
46                 {only available when compiled with the |+float| feature}
47   
48   
49 ! sort({list} [, {func} [, {dict}]])                    *sort()* *E702*
50                 Sort the items in {list} in-place.  Returns {list}.  If you
51                 want a list to remain unmodified make a copy first: >
52                         :let sortedlist = sort(copy(mylist))
53 ***************
54 *** 5283,5288 ****
55 --- 5287,5294 ----
56                 Numbers sort after Strings, |Lists| after Numbers.
57                 For sorting text in the current buffer use |:sort|.
58                 When {func} is given and it is one then case is ignored.
59 +               {dict} is for functions with the "dict" attribute.  It will be
60 +               used to set the local variable "self". |Dictionary-function|
61                 When {func} is a |Funcref| or a function name, this function
62                 is called to compare items.  The function is invoked with two
63                 items as argument and must return zero if they are equal, 1 or
64 *** ../mercurial/vim73/src/eval.c       2011-05-19 18:26:34.000000000 +0200
65 --- src/eval.c  2011-06-19 02:51:13.000000000 +0200
66 ***************
67 *** 7930,7936 ****
68       {"sin",           1, 1, f_sin},
69       {"sinh",          1, 1, f_sinh},
70   #endif
71 !     {"sort",          1, 2, f_sort},
72       {"soundfold",     1, 1, f_soundfold},
73       {"spellbadword",  0, 1, f_spellbadword},
74       {"spellsuggest",  1, 3, f_spellsuggest},
75 --- 7930,7936 ----
76       {"sin",           1, 1, f_sin},
77       {"sinh",          1, 1, f_sinh},
78   #endif
79 !     {"sort",          1, 3, f_sort},
80       {"soundfold",     1, 1, f_soundfold},
81       {"spellbadword",  0, 1, f_spellbadword},
82       {"spellsuggest",  1, 3, f_spellsuggest},
83 ***************
84 *** 16366,16371 ****
85 --- 16366,16372 ----
86   
87   static int    item_compare_ic;
88   static char_u *item_compare_func;
89 + static dict_T *item_compare_selfdict;
90   static int    item_compare_func_err;
91   #define ITEM_COMPARE_FAIL 999
92   
93 ***************
94 *** 16425,16431 ****
95   
96       rettv.v_type = VAR_UNKNOWN;               /* clear_tv() uses this */
97       res = call_func(item_compare_func, (int)STRLEN(item_compare_func),
98 !                                &rettv, 2, argv, 0L, 0L, &dummy, TRUE, NULL);
99       clear_tv(&argv[0]);
100       clear_tv(&argv[1]);
101   
102 --- 16426,16433 ----
103   
104       rettv.v_type = VAR_UNKNOWN;               /* clear_tv() uses this */
105       res = call_func(item_compare_func, (int)STRLEN(item_compare_func),
106 !                                &rettv, 2, argv, 0L, 0L, &dummy, TRUE,
107 !                                item_compare_selfdict);
108       clear_tv(&argv[0]);
109       clear_tv(&argv[1]);
110   
111 ***************
112 *** 16471,16478 ****
113 --- 16473,16482 ----
114   
115         item_compare_ic = FALSE;
116         item_compare_func = NULL;
117 +       item_compare_selfdict = NULL;
118         if (argvars[1].v_type != VAR_UNKNOWN)
119         {
120 +           /* optional second argument: {func} */
121             if (argvars[1].v_type == VAR_FUNC)
122                 item_compare_func = argvars[1].vval.v_string;
123             else
124 ***************
125 *** 16487,16492 ****
126 --- 16491,16507 ----
127                 else
128                     item_compare_func = get_tv_string(&argvars[1]);
129             }
130
131 +           if (argvars[2].v_type != VAR_UNKNOWN)
132 +           {
133 +               /* optional third argument: {dict} */
134 +               if (argvars[2].v_type != VAR_DICT)
135 +               {
136 +                   EMSG(_(e_dictreq));
137 +                   return;
138 +               }
139 +               item_compare_selfdict = argvars[2].vval.v_dict;
140 +           }
141         }
142   
143         /* Make an array with each entry pointing to an item in the List. */
144 *** ../vim-7.3.223/src/version.c        2011-06-19 01:30:01.000000000 +0200
145 --- src/version.c       2011-06-19 02:52:46.000000000 +0200
146 ***************
147 *** 711,712 ****
148 --- 711,714 ----
149   {   /* Add new patch number below this line */
150 + /**/
151 +     224,
152   /**/
153
154 -- 
155 hundred-and-one symptoms of being an internet addict:
156 193. You ask your girlfriend to drive home so you can sit back with
157      your PDA and download the information to your laptop
158
159  /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
160 ///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
161 \\\  an exciting new programming language -- http://www.Zimbu.org        ///
162  \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///
This page took 0.03055 seconds and 3 git commands to generate.