]> git.pld-linux.org Git - packages/vim.git/blame - 7.3.377
- new
[packages/vim.git] / 7.3.377
CommitLineData
d034a75d
AG
1To: vim_dev@googlegroups.com
2Subject: Patch 7.3.377
3Fcc: outbox
4From: Bram Moolenaar <Bram@moolenaar.net>
5Mime-Version: 1.0
6Content-Type: text/plain; charset=UTF-8
7Content-Transfer-Encoding: 8bit
8------------
9
10Patch 7.3.377
11Problem: No support for bitwise AND, OR, XOR and invert.
12Solution: Add and(), or(), invert() and xor() functions.
13Files: src/eval.c, src/testdir/test49.in, src/testdir/test65.in,
14 src/testdir/test65.ok, runtime/doc/eval.txt
15
16
17*** ../vim-7.3.376/src/eval.c 2011-11-30 15:19:25.000000000 +0100
18--- src/eval.c 2011-12-11 13:49:31.000000000 +0100
19***************
20*** 474,479 ****
21--- 474,480 ----
22 static void f_acos __ARGS((typval_T *argvars, typval_T *rettv));
23 #endif
24 static void f_add __ARGS((typval_T *argvars, typval_T *rettv));
25+ static void f_and __ARGS((typval_T *argvars, typval_T *rettv));
26 static void f_append __ARGS((typval_T *argvars, typval_T *rettv));
27 static void f_argc __ARGS((typval_T *argvars, typval_T *rettv));
28 static void f_argidx __ARGS((typval_T *argvars, typval_T *rettv));
29***************
30*** 602,607 ****
31--- 603,609 ----
32 static void f_inputsave __ARGS((typval_T *argvars, typval_T *rettv));
33 static void f_inputsecret __ARGS((typval_T *argvars, typval_T *rettv));
34 static void f_insert __ARGS((typval_T *argvars, typval_T *rettv));
35+ static void f_invert __ARGS((typval_T *argvars, typval_T *rettv));
36 static void f_isdirectory __ARGS((typval_T *argvars, typval_T *rettv));
37 static void f_islocked __ARGS((typval_T *argvars, typval_T *rettv));
38 static void f_items __ARGS((typval_T *argvars, typval_T *rettv));
39***************
40*** 640,645 ****
41--- 642,648 ----
42 #endif
43 static void f_nextnonblank __ARGS((typval_T *argvars, typval_T *rettv));
44 static void f_nr2char __ARGS((typval_T *argvars, typval_T *rettv));
45+ static void f_or __ARGS((typval_T *argvars, typval_T *rettv));
46 static void f_pathshorten __ARGS((typval_T *argvars, typval_T *rettv));
47 #ifdef FEAT_FLOAT
48 static void f_pow __ARGS((typval_T *argvars, typval_T *rettv));
49***************
50*** 751,756 ****
51--- 754,760 ----
52 static void f_winsaveview __ARGS((typval_T *argvars, typval_T *rettv));
53 static void f_winwidth __ARGS((typval_T *argvars, typval_T *rettv));
54 static void f_writefile __ARGS((typval_T *argvars, typval_T *rettv));
55+ static void f_xor __ARGS((typval_T *argvars, typval_T *rettv));
56
57 static int list2fpos __ARGS((typval_T *arg, pos_T *posp, int *fnump));
58 static pos_T *var2fpos __ARGS((typval_T *varp, int dollar_lnum, int *fnum));
59***************
60*** 7715,7720 ****
61--- 7719,7725 ----
62 {"acos", 1, 1, f_acos}, /* WJMc */
63 #endif
64 {"add", 2, 2, f_add},
65+ {"and", 2, 2, f_and},
66 {"append", 2, 2, f_append},
67 {"argc", 0, 0, f_argc},
68 {"argidx", 0, 0, f_argidx},
69***************
70*** 7850,7855 ****
71--- 7855,7861 ----
72 {"inputsave", 0, 0, f_inputsave},
73 {"inputsecret", 1, 2, f_inputsecret},
74 {"insert", 2, 3, f_insert},
75+ {"invert", 1, 1, f_invert},
76 {"isdirectory", 1, 1, f_isdirectory},
77 {"islocked", 1, 1, f_islocked},
78 {"items", 1, 1, f_items},
79***************
80*** 7888,7893 ****
81--- 7894,7900 ----
82 #endif
83 {"nextnonblank", 1, 1, f_nextnonblank},
84 {"nr2char", 1, 1, f_nr2char},
85+ {"or", 2, 2, f_or},
86 {"pathshorten", 1, 1, f_pathshorten},
87 #ifdef FEAT_FLOAT
88 {"pow", 2, 2, f_pow},
89***************
90*** 7999,8004 ****
91--- 8006,8012 ----
92 {"winsaveview", 0, 0, f_winsaveview},
93 {"winwidth", 1, 1, f_winwidth},
94 {"writefile", 2, 3, f_writefile},
95+ {"xor", 2, 2, f_xor},
96 };
97
98 #if defined(FEAT_CMDL_COMPL) || defined(PROTO)
99***************
100*** 8572,8577 ****
101--- 8580,8597 ----
102 }
103
104 /*
105+ * "and(expr, expr)" function
106+ */
107+ static void
108+ f_and(argvars, rettv)
109+ typval_T *argvars;
110+ typval_T *rettv;
111+ {
112+ rettv->vval.v_number = get_tv_number_chk(&argvars[0], NULL)
113+ & get_tv_number_chk(&argvars[1], NULL);
114+ }
115+
116+ /*
117 * "append(lnum, string/list)" function
118 */
119 static void
120***************
121*** 12958,12963 ****
122--- 12978,12994 ----
123 }
124
125 /*
126+ * "invert(expr)" function
127+ */
128+ static void
129+ f_invert(argvars, rettv)
130+ typval_T *argvars;
131+ typval_T *rettv;
132+ {
133+ rettv->vval.v_number = ~get_tv_number_chk(&argvars[0], NULL);
134+ }
135+
136+ /*
137 * "isdirectory()" function
138 */
139 static void
140***************
141*** 14108,14113 ****
142--- 14139,14156 ----
143 }
144
145 /*
146+ * "or(expr, expr)" function
147+ */
148+ static void
149+ f_or(argvars, rettv)
150+ typval_T *argvars;
151+ typval_T *rettv;
152+ {
153+ rettv->vval.v_number = get_tv_number_chk(&argvars[0], NULL)
154+ | get_tv_number_chk(&argvars[1], NULL);
155+ }
156+
157+ /*
158 * "pathshorten()" function
159 */
160 static void
161***************
162*** 18394,18399 ****
163--- 18437,18455 ----
164 }
165
166 /*
167+ * "xor(expr, expr)" function
168+ */
169+ static void
170+ f_xor(argvars, rettv)
171+ typval_T *argvars;
172+ typval_T *rettv;
173+ {
174+ rettv->vval.v_number = get_tv_number_chk(&argvars[0], NULL)
175+ ^ get_tv_number_chk(&argvars[1], NULL);
176+ }
177+
178+
179+ /*
180 * Translate a String variable into a position.
181 * Returns NULL when there is an error.
182 */
183*** ../vim-7.3.376/src/testdir/test65.in 2010-08-15 21:57:29.000000000 +0200
184--- src/testdir/test65.in 2011-12-11 13:55:06.000000000 +0100
185***************
186*** 1,4 ****
187! Test for floating point.
188
189 STARTTEST
190 :so small.vim
191--- 1,4 ----
192! Test for floating point and logical operators.
193
194 STARTTEST
195 :so small.vim
196***************
197*** 72,77 ****
198--- 72,94 ----
199 :$put ='float2nr'
200 :$put =float2nr(123.456)
201 :$put =float2nr(-123.456)
202+ :$put ='AND'
203+ :$put =and(127, 127)
204+ :$put =and(127, 16)
205+ :$put =and(127, 128)
206+ :$put ='OR'
207+ :$put =or(16, 7)
208+ :$put =or(8, 7)
209+ :$put =or(0, 123)
210+ :$put ='XOR'
211+ :$put =xor(127, 127)
212+ :$put =xor(127, 16)
213+ :$put =xor(127, 128)
214+ :$put ='invert'
215+ :$put =and(invert(127), 65535)
216+ :$put =and(invert(16), 65535)
217+ :$put =and(invert(128), 65535)
218+ :$put =invert(1.0)
219 :/^Results/,$wq! test.out
220 ENDTEST
221
222*** ../vim-7.3.376/src/testdir/test65.ok 2010-08-15 21:57:29.000000000 +0200
223--- src/testdir/test65.ok 2011-12-11 13:55:30.000000000 +0100
224***************
225*** 54,56 ****
226--- 54,73 ----
227 float2nr
228 123
229 -123
230+ AND
231+ 127
232+ 16
233+ 0
234+ OR
235+ 23
236+ 15
237+ 123
238+ XOR
239+ 0
240+ 111
241+ 255
242+ invert
243+ 65408
244+ 65519
245+ 65407
246+ 0
247*** ../vim-7.3.376/runtime/doc/eval.txt 2011-06-19 02:55:32.000000000 +0200
248--- runtime/doc/eval.txt 2011-12-14 15:28:23.000000000 +0100
249***************
250*** 798,808 ****
251 For |Lists| only "+" is possible and then both expr6 must be a list. The
252 result is a new list with the two lists Concatenated.
253
254! expr7 * expr7 .. number multiplication *expr-star*
255! expr7 / expr7 .. number division *expr-/*
256! expr7 % expr7 .. number modulo *expr-%*
257
258 For all, except ".", Strings are converted to Numbers.
259
260 Note the difference between "+" and ".":
261 "123" + "456" = 579
262--- 800,811 ----
263 For |Lists| only "+" is possible and then both expr6 must be a list. The
264 result is a new list with the two lists Concatenated.
265
266! expr7 * expr7 .. Number multiplication *expr-star*
267! expr7 / expr7 .. Number division *expr-/*
268! expr7 % expr7 .. Number modulo *expr-%*
269
270 For all, except ".", Strings are converted to Numbers.
271+ For bitwise operators see |and()|, |or()| and |xor()|.
272
273 Note the difference between "+" and ".":
274 "123" + "456" = 579
275***************
276*** 1679,1684 ****
277--- 1688,1694 ----
278 abs( {expr}) Float or Number absolute value of {expr}
279 acos( {expr}) Float arc cosine of {expr}
280 add( {list}, {item}) List append {item} to |List| {list}
281+ and( {expr}, {expr}) Number bitwise AND
282 append( {lnum}, {string}) Number append {string} below line {lnum}
283 append( {lnum}, {list}) Number append lines {list} below line {lnum}
284 argc() Number number of files in the argument list
285***************
286*** 1817,1822 ****
287--- 1827,1833 ----
288 inputsave() Number save and clear typeahead
289 inputsecret( {prompt} [, {text}]) String like input() but hiding the text
290 insert( {list}, {item} [, {idx}]) List insert {item} in {list} [before {idx}]
291+ invert( {expr}) Number bitwise invert
292 isdirectory( {directory}) Number TRUE if {directory} is a directory
293 islocked( {expr}) Number TRUE if {expr} is locked
294 items( {dict}) List key-value pairs in {dict}
295***************
296*** 1856,1861 ****
297--- 1868,1874 ----
298 mzeval( {expr}) any evaluate |MzScheme| expression
299 nextnonblank( {lnum}) Number line nr of non-blank line >= {lnum}
300 nr2char( {expr}) String single char with ASCII value {expr}
301+ or( {expr}, {expr}) Number bitwise OR
302 pathshorten( {expr}) String shorten directory names in a path
303 pow( {x}, {y}) Float {x} to the power of {y}
304 prevnonblank( {lnum}) Number line nr of non-blank line <= {lnum}
305***************
306*** 1978,1983 ****
307--- 1992,1998 ----
308 winwidth( {nr}) Number width of window {nr}
309 writefile( {list}, {fname} [, {binary}])
310 Number write list of lines to file {fname}
311+ xor( {expr}, {expr}) Number bitwise XOR
312
313 abs({expr}) *abs()*
314 Return the absolute value of {expr}. When {expr} evaluates to
315***************
316*** 2017,2022 ****
317--- 2032,2044 ----
318 Use |insert()| to add an item at another position.
319
320
321+ and({expr}, {expr}) *and()*
322+ Bitwise AND on the two arguments. The arguments are converted
323+ to a number. A List, Dict or Float argument causes an error.
324+ Example: >
325+ :let flag = and(bits, 0x80)
326+
327+
328 append({lnum}, {expr}) *append()*
329 When {expr} is a |List|: Append each item of the |List| as a
330 text line below line {lnum} in the current buffer.
331***************
332*** 3770,3775 ****
333--- 3798,3808 ----
334 Note that when {item} is a |List| it is inserted as a single
335 item. Use |extend()| to concatenate |Lists|.
336
337+ invert({expr}) *invert()*
338+ Bitwise invert. The argument is converted to a number. A
339+ List, Dict or Float argument causes an error. Example: >
340+ :let bits = invert(bits)
341+
342 isdirectory({directory}) *isdirectory()*
343 The result is a Number, which is non-zero when a directory
344 with the name {directory} exists. If {directory} doesn't
345***************
346*** 4334,4339 ****
347--- 4368,4380 ----
348 call setpos('.', save_cursor)
349 < Also see |setpos()|.
350
351+ or({expr}, {expr}) *or()*
352+ Bitwise OR on the two arguments. The arguments are converted
353+ to a number. A List, Dict or Float argument causes an error.
354+ Example: >
355+ :let bits = or(bits, 0x80)
356+
357+
358 pathshorten({expr}) *pathshorten()*
359 Shorten directory names in the path {expr} and return the
360 result. The tail, the file name, is kept as-is. The other
361***************
362*** 6097,6103 ****
363 To copy a file byte for byte: >
364 :let fl = readfile("foo", "b")
365 :call writefile(fl, "foocopy", "b")
366! <
367
368 *feature-list*
369 There are three types of features:
370--- 6149,6163 ----
371 To copy a file byte for byte: >
372 :let fl = readfile("foo", "b")
373 :call writefile(fl, "foocopy", "b")
374!
375!
376! xor({expr}, {expr}) *xor()*
377! Bitwise XOR on the two arguments. The arguments are converted
378! to a number. A List, Dict or Float argument causes an error.
379! Example: >
380! :let bits = xor(bits, 0x80)
381!
382!
383
384 *feature-list*
385 There are three types of features:
386*** ../vim-7.3.376/src/version.c 2011-12-14 15:23:53.000000000 +0100
387--- src/version.c 2011-12-14 15:28:39.000000000 +0100
388***************
389*** 716,717 ****
390--- 716,719 ----
391 { /* Add new patch number below this line */
392+ /**/
393+ 377,
394 /**/
395
396--
397DINGO: Wicked wicked Zoot ... she is a bad person and she must pay the
398 penalty. And here in Castle Anthrax, we have but one punishment
399 ... you must tie her down on a bed ... and spank her. Come!
400GIRLS: A spanking! A spanking!
401 "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD
402
403 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
404/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
405\\\ an exciting new programming language -- http://www.Zimbu.org ///
406 \\\ help me help AIDS victims -- http://ICCF-Holland.org ///
This page took 1.193198 seconds and 4 git commands to generate.