|
Karsten Hopp |
805f60 |
To: vim_dev@googlegroups.com
|
|
Karsten Hopp |
805f60 |
Subject: Patch 7.4.218
|
|
Karsten Hopp |
805f60 |
Fcc: outbox
|
|
Karsten Hopp |
805f60 |
From: Bram Moolenaar <Bram@moolenaar.net>
|
|
Karsten Hopp |
805f60 |
Mime-Version: 1.0
|
|
Karsten Hopp |
805f60 |
Content-Type: text/plain; charset=UTF-8
|
|
Karsten Hopp |
805f60 |
Content-Transfer-Encoding: 8bit
|
|
Karsten Hopp |
805f60 |
------------
|
|
Karsten Hopp |
805f60 |
|
|
Karsten Hopp |
805f60 |
Patch 7.4.218
|
|
Karsten Hopp |
805f60 |
Problem: It's not easy to remove duplicates from a list.
|
|
Karsten Hopp |
805f60 |
Solution: Add the uniq() function. (LCD)
|
|
Karsten Hopp |
805f60 |
Files: runtime/doc/change.txt, runtime/doc/eval.txt,
|
|
Karsten Hopp |
805f60 |
runtime/doc/usr_41.txt, runtime/doc/version7.txt, src/eval.c,
|
|
Karsten Hopp |
805f60 |
src/testdir/test55.in, src/testdir/test55.ok
|
|
Karsten Hopp |
805f60 |
|
|
Karsten Hopp |
805f60 |
|
|
Karsten Hopp |
805f60 |
*** ../vim-7.4.217/runtime/doc/change.txt 2013-09-22 15:23:38.000000000 +0200
|
|
Karsten Hopp |
805f60 |
--- runtime/doc/change.txt 2014-03-25 17:32:29.510040841 +0100
|
|
Karsten Hopp |
805f60 |
***************
|
|
Karsten Hopp |
805f60 |
*** 1645,1651 ****
|
|
Karsten Hopp |
805f60 |
7. Sorting text *sorting*
|
|
Karsten Hopp |
805f60 |
|
|
Karsten Hopp |
805f60 |
Vim has a sorting function and a sorting command. The sorting function can be
|
|
Karsten Hopp |
805f60 |
! found here: |sort()|.
|
|
Karsten Hopp |
805f60 |
|
|
Karsten Hopp |
805f60 |
*:sor* *:sort*
|
|
Karsten Hopp |
805f60 |
:[range]sor[t][!] [i][u][r][n][x][o] [/{pattern}/]
|
|
Karsten Hopp |
805f60 |
--- 1650,1656 ----
|
|
Karsten Hopp |
805f60 |
7. Sorting text *sorting*
|
|
Karsten Hopp |
805f60 |
|
|
Karsten Hopp |
805f60 |
Vim has a sorting function and a sorting command. The sorting function can be
|
|
Karsten Hopp |
805f60 |
! found here: |sort()|, |uniq()|.
|
|
Karsten Hopp |
805f60 |
|
|
Karsten Hopp |
805f60 |
*:sor* *:sort*
|
|
Karsten Hopp |
805f60 |
:[range]sor[t][!] [i][u][r][n][x][o] [/{pattern}/]
|
|
Karsten Hopp |
805f60 |
*** ../vim-7.4.217/runtime/doc/eval.txt 2014-02-23 23:38:58.820760280 +0100
|
|
Karsten Hopp |
805f60 |
--- runtime/doc/eval.txt 2014-03-25 17:47:18.750054467 +0100
|
|
Karsten Hopp |
805f60 |
***************
|
|
Karsten Hopp |
805f60 |
*** 326,331 ****
|
|
Karsten Hopp |
805f60 |
--- 327,333 ----
|
|
Karsten Hopp |
805f60 |
Changing the order of items in a list: >
|
|
Karsten Hopp |
805f60 |
:call sort(list) " sort a list alphabetically
|
|
Karsten Hopp |
805f60 |
:call reverse(list) " reverse the order of items
|
|
Karsten Hopp |
805f60 |
+ :call uniq(sort(list)) " sort and remove duplicates
|
|
Karsten Hopp |
805f60 |
|
|
Karsten Hopp |
805f60 |
|
|
Karsten Hopp |
805f60 |
For loop ~
|
|
Karsten Hopp |
805f60 |
***************
|
|
Karsten Hopp |
805f60 |
*** 1518,1523 ****
|
|
Karsten Hopp |
805f60 |
--- 1520,1526 ----
|
|
Karsten Hopp |
805f60 |
startup. These are the files that Vim remembers marks for.
|
|
Karsten Hopp |
805f60 |
The length of the List is limited by the ' argument of the
|
|
Karsten Hopp |
805f60 |
'viminfo' option (default is 100).
|
|
Karsten Hopp |
805f60 |
+ When the |viminfo| file is not used the List is empty.
|
|
Karsten Hopp |
805f60 |
Also see |:oldfiles| and |c_#<|.
|
|
Karsten Hopp |
805f60 |
The List can be modified, but this has no effect on what is
|
|
Karsten Hopp |
805f60 |
stored in the |viminfo| file later. If you use values other
|
|
Karsten Hopp |
805f60 |
***************
|
|
Karsten Hopp |
805f60 |
*** 2003,2008 ****
|
|
Karsten Hopp |
805f60 |
--- 2006,2013 ----
|
|
Karsten Hopp |
805f60 |
type( {name}) Number type of variable {name}
|
|
Karsten Hopp |
805f60 |
undofile( {name}) String undo file name for {name}
|
|
Karsten Hopp |
805f60 |
undotree() List undo file tree
|
|
Karsten Hopp |
805f60 |
+ uniq( {list} [, {func} [, {dict}]])
|
|
Karsten Hopp |
805f60 |
+ List remove adjacent duplicates from a list
|
|
Karsten Hopp |
805f60 |
values( {dict}) List values in {dict}
|
|
Karsten Hopp |
805f60 |
virtcol( {expr}) Number screen column of cursor or mark
|
|
Karsten Hopp |
805f60 |
visualmode( [expr]) String last visual mode used
|
|
Karsten Hopp |
805f60 |
***************
|
|
Karsten Hopp |
805f60 |
*** 5474,5493 ****
|
|
Karsten Hopp |
805f60 |
|
|
Karsten Hopp |
805f60 |
|
|
Karsten Hopp |
805f60 |
sort({list} [, {func} [, {dict}]]) *sort()* *E702*
|
|
Karsten Hopp |
805f60 |
! Sort the items in {list} in-place. Returns {list}. If you
|
|
Karsten Hopp |
805f60 |
! want a list to remain unmodified make a copy first: >
|
|
Karsten Hopp |
805f60 |
:let sortedlist = sort(copy(mylist))
|
|
Karsten Hopp |
805f60 |
< Uses the string representation of each item to sort on.
|
|
Karsten Hopp |
805f60 |
Numbers sort after Strings, |Lists| after Numbers.
|
|
Karsten Hopp |
805f60 |
For sorting text in the current buffer use |:sort|.
|
|
Karsten Hopp |
805f60 |
When {func} is given and it is one then case is ignored.
|
|
Karsten Hopp |
805f60 |
- {dict} is for functions with the "dict" attribute. It will be
|
|
Karsten Hopp |
805f60 |
- used to set the local variable "self". |Dictionary-function|
|
|
Karsten Hopp |
805f60 |
When {func} is a |Funcref| or a function name, this function
|
|
Karsten Hopp |
805f60 |
is called to compare items. The function is invoked with two
|
|
Karsten Hopp |
805f60 |
items as argument and must return zero if they are equal, 1 or
|
|
Karsten Hopp |
805f60 |
bigger if the first one sorts after the second one, -1 or
|
|
Karsten Hopp |
805f60 |
smaller if the first one sorts before the second one.
|
|
Karsten Hopp |
805f60 |
Example: >
|
|
Karsten Hopp |
805f60 |
func MyCompare(i1, i2)
|
|
Karsten Hopp |
805f60 |
return a:i1 == a:i2 ? 0 : a:i1 > a:i2 ? 1 : -1
|
|
Karsten Hopp |
805f60 |
--- 5491,5516 ----
|
|
Karsten Hopp |
805f60 |
|
|
Karsten Hopp |
805f60 |
|
|
Karsten Hopp |
805f60 |
sort({list} [, {func} [, {dict}]]) *sort()* *E702*
|
|
Karsten Hopp |
805f60 |
! Sort the items in {list} in-place. Returns {list}.
|
|
Karsten Hopp |
805f60 |
!
|
|
Karsten Hopp |
805f60 |
! If you want a list to remain unmodified make a copy first: >
|
|
Karsten Hopp |
805f60 |
:let sortedlist = sort(copy(mylist))
|
|
Karsten Hopp |
805f60 |
< Uses the string representation of each item to sort on.
|
|
Karsten Hopp |
805f60 |
Numbers sort after Strings, |Lists| after Numbers.
|
|
Karsten Hopp |
805f60 |
For sorting text in the current buffer use |:sort|.
|
|
Karsten Hopp |
805f60 |
+
|
|
Karsten Hopp |
805f60 |
When {func} is given and it is one then case is ignored.
|
|
Karsten Hopp |
805f60 |
When {func} is a |Funcref| or a function name, this function
|
|
Karsten Hopp |
805f60 |
is called to compare items. The function is invoked with two
|
|
Karsten Hopp |
805f60 |
items as argument and must return zero if they are equal, 1 or
|
|
Karsten Hopp |
805f60 |
bigger if the first one sorts after the second one, -1 or
|
|
Karsten Hopp |
805f60 |
smaller if the first one sorts before the second one.
|
|
Karsten Hopp |
805f60 |
+
|
|
Karsten Hopp |
805f60 |
+ {dict} is for functions with the "dict" attribute. It will be
|
|
Karsten Hopp |
805f60 |
+ used to set the local variable "self". |Dictionary-function|
|
|
Karsten Hopp |
805f60 |
+
|
|
Karsten Hopp |
805f60 |
+ Also see |uniq()|.
|
|
Karsten Hopp |
805f60 |
+
|
|
Karsten Hopp |
805f60 |
Example: >
|
|
Karsten Hopp |
805f60 |
func MyCompare(i1, i2)
|
|
Karsten Hopp |
805f60 |
return a:i1 == a:i2 ? 0 : a:i1 > a:i2 ? 1 : -1
|
|
Karsten Hopp |
805f60 |
***************
|
|
Karsten Hopp |
805f60 |
*** 6155,6160 ****
|
|
Karsten Hopp |
805f60 |
--- 6178,6191 ----
|
|
Karsten Hopp |
805f60 |
blocks. Each item may again have an "alt"
|
|
Karsten Hopp |
805f60 |
item.
|
|
Karsten Hopp |
805f60 |
|
|
Karsten Hopp |
805f60 |
+ uniq({list} [, {func} [, {dict}]]) *uniq()* *E882*
|
|
Karsten Hopp |
805f60 |
+ Remove second and succeeding copies of repeated adjacent
|
|
Karsten Hopp |
805f60 |
+ {list} items in-place. Returns {list}. If you want a list
|
|
Karsten Hopp |
805f60 |
+ to remain unmodified make a copy first: >
|
|
Karsten Hopp |
805f60 |
+ :let newlist = uniq(copy(mylist))
|
|
Karsten Hopp |
805f60 |
+ < The default compare function uses the string representation of
|
|
Karsten Hopp |
805f60 |
+ each item. For the use of {func} and {dict} see |sort()|.
|
|
Karsten Hopp |
805f60 |
+
|
|
Karsten Hopp |
805f60 |
values({dict}) *values()*
|
|
Karsten Hopp |
805f60 |
Return a |List| with all the values of {dict}. The |List| is
|
|
Karsten Hopp |
805f60 |
in arbitrary order.
|
|
Karsten Hopp |
805f60 |
*** ../vim-7.4.217/runtime/doc/usr_41.txt 2013-08-10 13:25:05.000000000 +0200
|
|
Karsten Hopp |
805f60 |
--- runtime/doc/usr_41.txt 2014-03-25 17:32:29.518040841 +0100
|
|
Karsten Hopp |
805f60 |
***************
|
|
Karsten Hopp |
805f60 |
*** 1,4 ****
|
|
Karsten Hopp |
805f60 |
! *usr_41.txt* For Vim version 7.4. Last change: 2013 Feb 20
|
|
Karsten Hopp |
805f60 |
|
|
Karsten Hopp |
805f60 |
VIM USER MANUAL - by Bram Moolenaar
|
|
Karsten Hopp |
805f60 |
|
|
Karsten Hopp |
805f60 |
--- 1,4 ----
|
|
Karsten Hopp |
805f60 |
! *usr_41.txt* For Vim version 7.4. Last change: 2014 Jan 10
|
|
Karsten Hopp |
805f60 |
|
|
Karsten Hopp |
805f60 |
VIM USER MANUAL - by Bram Moolenaar
|
|
Karsten Hopp |
805f60 |
|
|
Karsten Hopp |
805f60 |
***************
|
|
Karsten Hopp |
805f60 |
*** 595,607 ****
|
|
Karsten Hopp |
805f60 |
matchlist() like matchstr() and also return submatches
|
|
Karsten Hopp |
805f60 |
stridx() first index of a short string in a long string
|
|
Karsten Hopp |
805f60 |
strridx() last index of a short string in a long string
|
|
Karsten Hopp |
805f60 |
! strlen() length of a string
|
|
Karsten Hopp |
805f60 |
substitute() substitute a pattern match with a string
|
|
Karsten Hopp |
805f60 |
submatch() get a specific match in ":s" and substitute()
|
|
Karsten Hopp |
805f60 |
strpart() get part of a string
|
|
Karsten Hopp |
805f60 |
expand() expand special keywords
|
|
Karsten Hopp |
805f60 |
iconv() convert text from one encoding to another
|
|
Karsten Hopp |
805f60 |
byteidx() byte index of a character in a string
|
|
Karsten Hopp |
805f60 |
repeat() repeat a string multiple times
|
|
Karsten Hopp |
805f60 |
eval() evaluate a string expression
|
|
Karsten Hopp |
805f60 |
|
|
Karsten Hopp |
805f60 |
--- 595,611 ----
|
|
Karsten Hopp |
805f60 |
matchlist() like matchstr() and also return submatches
|
|
Karsten Hopp |
805f60 |
stridx() first index of a short string in a long string
|
|
Karsten Hopp |
805f60 |
strridx() last index of a short string in a long string
|
|
Karsten Hopp |
805f60 |
! strlen() length of a string in bytes
|
|
Karsten Hopp |
805f60 |
! strchars() length of a string in characters
|
|
Karsten Hopp |
805f60 |
! strwidth() size of string when displayed
|
|
Karsten Hopp |
805f60 |
! strdisplaywidth() size of string when displayed, deals with tabs
|
|
Karsten Hopp |
805f60 |
substitute() substitute a pattern match with a string
|
|
Karsten Hopp |
805f60 |
submatch() get a specific match in ":s" and substitute()
|
|
Karsten Hopp |
805f60 |
strpart() get part of a string
|
|
Karsten Hopp |
805f60 |
expand() expand special keywords
|
|
Karsten Hopp |
805f60 |
iconv() convert text from one encoding to another
|
|
Karsten Hopp |
805f60 |
byteidx() byte index of a character in a string
|
|
Karsten Hopp |
805f60 |
+ byteidxcomp() like byteidx() but count composing characters
|
|
Karsten Hopp |
805f60 |
repeat() repeat a string multiple times
|
|
Karsten Hopp |
805f60 |
eval() evaluate a string expression
|
|
Karsten Hopp |
805f60 |
|
|
Karsten Hopp |
805f60 |
***************
|
|
Karsten Hopp |
805f60 |
*** 619,624 ****
|
|
Karsten Hopp |
805f60 |
--- 623,629 ----
|
|
Karsten Hopp |
805f60 |
map() change each List item
|
|
Karsten Hopp |
805f60 |
sort() sort a List
|
|
Karsten Hopp |
805f60 |
reverse() reverse the order of a List
|
|
Karsten Hopp |
805f60 |
+ uniq() remove copies of repeated adjacent items
|
|
Karsten Hopp |
805f60 |
split() split a String into a List
|
|
Karsten Hopp |
805f60 |
join() join List items into a String
|
|
Karsten Hopp |
805f60 |
range() return a List with a sequence of numbers
|
|
Karsten Hopp |
805f60 |
***************
|
|
Karsten Hopp |
805f60 |
*** 656,661 ****
|
|
Karsten Hopp |
805f60 |
--- 661,669 ----
|
|
Karsten Hopp |
805f60 |
ceil() round up
|
|
Karsten Hopp |
805f60 |
floor() round down
|
|
Karsten Hopp |
805f60 |
trunc() remove value after decimal point
|
|
Karsten Hopp |
805f60 |
+ fmod() remainder of division
|
|
Karsten Hopp |
805f60 |
+ exp() exponential
|
|
Karsten Hopp |
805f60 |
+ log() natural logarithm (logarithm to base e)
|
|
Karsten Hopp |
805f60 |
log10() logarithm to base 10
|
|
Karsten Hopp |
805f60 |
pow() value of x to the exponent y
|
|
Karsten Hopp |
805f60 |
sqrt() square root
|
|
Karsten Hopp |
805f60 |
***************
|
|
Karsten Hopp |
805f60 |
*** 675,680 ****
|
|
Karsten Hopp |
805f60 |
--- 683,689 ----
|
|
Karsten Hopp |
805f60 |
invert() bitwise invert
|
|
Karsten Hopp |
805f60 |
or() bitwise OR
|
|
Karsten Hopp |
805f60 |
xor() bitwise XOR
|
|
Karsten Hopp |
805f60 |
+ sha256() SHA-256 hash
|
|
Karsten Hopp |
805f60 |
|
|
Karsten Hopp |
805f60 |
Variables: *var-functions*
|
|
Karsten Hopp |
805f60 |
type() type of a variable
|
|
Karsten Hopp |
805f60 |
***************
|
|
Karsten Hopp |
805f60 |
*** 697,707 ****
|
|
Karsten Hopp |
805f60 |
--- 706,720 ----
|
|
Karsten Hopp |
805f60 |
wincol() window column number of the cursor
|
|
Karsten Hopp |
805f60 |
winline() window line number of the cursor
|
|
Karsten Hopp |
805f60 |
cursor() position the cursor at a line/column
|
|
Karsten Hopp |
805f60 |
+ screencol() get screen column of the cursor
|
|
Karsten Hopp |
805f60 |
+ screenrow() get screen row of the cursor
|
|
Karsten Hopp |
805f60 |
getpos() get position of cursor, mark, etc.
|
|
Karsten Hopp |
805f60 |
setpos() set position of cursor, mark, etc.
|
|
Karsten Hopp |
805f60 |
byte2line() get line number at a specific byte count
|
|
Karsten Hopp |
805f60 |
line2byte() byte count at a specific line
|
|
Karsten Hopp |
805f60 |
diff_filler() get the number of filler lines above a line
|
|
Karsten Hopp |
805f60 |
+ screenattr() get attribute at a screen line/row
|
|
Karsten Hopp |
805f60 |
+ screenchar() get character code at a screen line/row
|
|
Karsten Hopp |
805f60 |
|
|
Karsten Hopp |
805f60 |
Working with text in the current buffer: *text-functions*
|
|
Karsten Hopp |
805f60 |
getline() get a line or list of lines from the buffer
|
|
Karsten Hopp |
805f60 |
***************
|
|
Karsten Hopp |
805f60 |
*** 883,896 ****
|
|
Karsten Hopp |
805f60 |
--- 896,917 ----
|
|
Karsten Hopp |
805f60 |
libcall() call a function in an external library
|
|
Karsten Hopp |
805f60 |
libcallnr() idem, returning a number
|
|
Karsten Hopp |
805f60 |
|
|
Karsten Hopp |
805f60 |
+ undofile() get the name of the undo file
|
|
Karsten Hopp |
805f60 |
+ undotree() return the state of the undo tree
|
|
Karsten Hopp |
805f60 |
+
|
|
Karsten Hopp |
805f60 |
getreg() get contents of a register
|
|
Karsten Hopp |
805f60 |
getregtype() get type of a register
|
|
Karsten Hopp |
805f60 |
setreg() set contents and type of a register
|
|
Karsten Hopp |
805f60 |
|
|
Karsten Hopp |
805f60 |
+ shiftwidth() effective value of 'shiftwidth'
|
|
Karsten Hopp |
805f60 |
+
|
|
Karsten Hopp |
805f60 |
taglist() get list of matching tags
|
|
Karsten Hopp |
805f60 |
tagfiles() get a list of tags files
|
|
Karsten Hopp |
805f60 |
|
|
Karsten Hopp |
805f60 |
+ luaeval() evaluate Lua expression
|
|
Karsten Hopp |
805f60 |
mzeval() evaluate |MzScheme| expression
|
|
Karsten Hopp |
805f60 |
+ py3eval() evaluate Python expression (|+python3|)
|
|
Karsten Hopp |
805f60 |
+ pyeval() evaluate Python expression (|+python|)
|
|
Karsten Hopp |
805f60 |
|
|
Karsten Hopp |
805f60 |
==============================================================================
|
|
Karsten Hopp |
805f60 |
*41.7* Defining a function
|
|
Karsten Hopp |
805f60 |
*** ../vim-7.4.217/runtime/doc/version7.txt 2013-08-10 14:23:06.000000000 +0200
|
|
Karsten Hopp |
805f60 |
--- runtime/doc/version7.txt 2014-03-25 17:32:29.518040841 +0100
|
|
Karsten Hopp |
805f60 |
***************
|
|
Karsten Hopp |
805f60 |
*** 942,947 ****
|
|
Karsten Hopp |
805f60 |
--- 942,948 ----
|
|
Karsten Hopp |
805f60 |
|tagfiles()| List with tags file names
|
|
Karsten Hopp |
805f60 |
|taglist()| get list of matching tags (Yegappan Lakshmanan)
|
|
Karsten Hopp |
805f60 |
|tr()| translate characters (Ron Aaron)
|
|
Karsten Hopp |
805f60 |
+ |uniq()| remove copies of repeated adjacent list items
|
|
Karsten Hopp |
805f60 |
|values()| get List of Dictionary values
|
|
Karsten Hopp |
805f60 |
|winnr()| takes an argument: what window to use
|
|
Karsten Hopp |
805f60 |
|winrestview()| restore the view of the current window
|
|
Karsten Hopp |
805f60 |
*** ../vim-7.4.217/src/eval.c 2014-03-23 15:12:29.915264336 +0100
|
|
Karsten Hopp |
805f60 |
--- src/eval.c 2014-03-25 17:52:09.554058923 +0100
|
|
Karsten Hopp |
805f60 |
***************
|
|
Karsten Hopp |
805f60 |
*** 744,749 ****
|
|
Karsten Hopp |
805f60 |
--- 744,750 ----
|
|
Karsten Hopp |
805f60 |
static void f_type __ARGS((typval_T *argvars, typval_T *rettv));
|
|
Karsten Hopp |
805f60 |
static void f_undofile __ARGS((typval_T *argvars, typval_T *rettv));
|
|
Karsten Hopp |
805f60 |
static void f_undotree __ARGS((typval_T *argvars, typval_T *rettv));
|
|
Karsten Hopp |
805f60 |
+ static void f_uniq __ARGS((typval_T *argvars, typval_T *rettv));
|
|
Karsten Hopp |
805f60 |
static void f_values __ARGS((typval_T *argvars, typval_T *rettv));
|
|
Karsten Hopp |
805f60 |
static void f_virtcol __ARGS((typval_T *argvars, typval_T *rettv));
|
|
Karsten Hopp |
805f60 |
static void f_visualmode __ARGS((typval_T *argvars, typval_T *rettv));
|
|
Karsten Hopp |
805f60 |
***************
|
|
Karsten Hopp |
805f60 |
*** 8150,8155 ****
|
|
Karsten Hopp |
805f60 |
--- 8151,8157 ----
|
|
Karsten Hopp |
805f60 |
{"type", 1, 1, f_type},
|
|
Karsten Hopp |
805f60 |
{"undofile", 1, 1, f_undofile},
|
|
Karsten Hopp |
805f60 |
{"undotree", 0, 0, f_undotree},
|
|
Karsten Hopp |
805f60 |
+ {"uniq", 1, 3, f_uniq},
|
|
Karsten Hopp |
805f60 |
{"values", 1, 1, f_values},
|
|
Karsten Hopp |
805f60 |
{"virtcol", 1, 1, f_virtcol},
|
|
Karsten Hopp |
805f60 |
{"visualmode", 0, 1, f_visualmode},
|
|
Karsten Hopp |
805f60 |
***************
|
|
Karsten Hopp |
805f60 |
*** 17023,17032 ****
|
|
Karsten Hopp |
805f60 |
static char_u *item_compare_func;
|
|
Karsten Hopp |
805f60 |
static dict_T *item_compare_selfdict;
|
|
Karsten Hopp |
805f60 |
static int item_compare_func_err;
|
|
Karsten Hopp |
805f60 |
#define ITEM_COMPARE_FAIL 999
|
|
Karsten Hopp |
805f60 |
|
|
Karsten Hopp |
805f60 |
/*
|
|
Karsten Hopp |
805f60 |
! * Compare functions for f_sort() below.
|
|
Karsten Hopp |
805f60 |
*/
|
|
Karsten Hopp |
805f60 |
static int
|
|
Karsten Hopp |
805f60 |
#ifdef __BORLANDC__
|
|
Karsten Hopp |
805f60 |
--- 17025,17035 ----
|
|
Karsten Hopp |
805f60 |
static char_u *item_compare_func;
|
|
Karsten Hopp |
805f60 |
static dict_T *item_compare_selfdict;
|
|
Karsten Hopp |
805f60 |
static int item_compare_func_err;
|
|
Karsten Hopp |
805f60 |
+ static void do_sort_uniq __ARGS((typval_T *argvars, typval_T *rettv, int sort));
|
|
Karsten Hopp |
805f60 |
#define ITEM_COMPARE_FAIL 999
|
|
Karsten Hopp |
805f60 |
|
|
Karsten Hopp |
805f60 |
/*
|
|
Karsten Hopp |
805f60 |
! * Compare functions for f_sort() and f_uniq() below.
|
|
Karsten Hopp |
805f60 |
*/
|
|
Karsten Hopp |
805f60 |
static int
|
|
Karsten Hopp |
805f60 |
#ifdef __BORLANDC__
|
|
Karsten Hopp |
805f60 |
***************
|
|
Karsten Hopp |
805f60 |
*** 17100,17108 ****
|
|
Karsten Hopp |
805f60 |
* "sort({list})" function
|
|
Karsten Hopp |
805f60 |
*/
|
|
Karsten Hopp |
805f60 |
static void
|
|
Karsten Hopp |
805f60 |
! f_sort(argvars, rettv)
|
|
Karsten Hopp |
805f60 |
typval_T *argvars;
|
|
Karsten Hopp |
805f60 |
typval_T *rettv;
|
|
Karsten Hopp |
805f60 |
{
|
|
Karsten Hopp |
805f60 |
list_T *l;
|
|
Karsten Hopp |
805f60 |
listitem_T *li;
|
|
Karsten Hopp |
805f60 |
--- 17103,17112 ----
|
|
Karsten Hopp |
805f60 |
* "sort({list})" function
|
|
Karsten Hopp |
805f60 |
*/
|
|
Karsten Hopp |
805f60 |
static void
|
|
Karsten Hopp |
805f60 |
! do_sort_uniq(argvars, rettv, sort)
|
|
Karsten Hopp |
805f60 |
typval_T *argvars;
|
|
Karsten Hopp |
805f60 |
typval_T *rettv;
|
|
Karsten Hopp |
805f60 |
+ int sort;
|
|
Karsten Hopp |
805f60 |
{
|
|
Karsten Hopp |
805f60 |
list_T *l;
|
|
Karsten Hopp |
805f60 |
listitem_T *li;
|
|
Karsten Hopp |
805f60 |
***************
|
|
Karsten Hopp |
805f60 |
*** 17111,17122 ****
|
|
Karsten Hopp |
805f60 |
long i;
|
|
Karsten Hopp |
805f60 |
|
|
Karsten Hopp |
805f60 |
if (argvars[0].v_type != VAR_LIST)
|
|
Karsten Hopp |
805f60 |
! EMSG2(_(e_listarg), "sort()");
|
|
Karsten Hopp |
805f60 |
else
|
|
Karsten Hopp |
805f60 |
{
|
|
Karsten Hopp |
805f60 |
l = argvars[0].vval.v_list;
|
|
Karsten Hopp |
805f60 |
if (l == NULL || tv_check_lock(l->lv_lock,
|
|
Karsten Hopp |
805f60 |
! (char_u *)_("sort() argument")))
|
|
Karsten Hopp |
805f60 |
return;
|
|
Karsten Hopp |
805f60 |
rettv->vval.v_list = l;
|
|
Karsten Hopp |
805f60 |
rettv->v_type = VAR_LIST;
|
|
Karsten Hopp |
805f60 |
--- 17115,17126 ----
|
|
Karsten Hopp |
805f60 |
long i;
|
|
Karsten Hopp |
805f60 |
|
|
Karsten Hopp |
805f60 |
if (argvars[0].v_type != VAR_LIST)
|
|
Karsten Hopp |
805f60 |
! EMSG2(_(e_listarg), sort ? "sort()" : "uniq()");
|
|
Karsten Hopp |
805f60 |
else
|
|
Karsten Hopp |
805f60 |
{
|
|
Karsten Hopp |
805f60 |
l = argvars[0].vval.v_list;
|
|
Karsten Hopp |
805f60 |
if (l == NULL || tv_check_lock(l->lv_lock,
|
|
Karsten Hopp |
805f60 |
! (char_u *)(sort ? _("sort() argument") : _("uniq() argument"))))
|
|
Karsten Hopp |
805f60 |
return;
|
|
Karsten Hopp |
805f60 |
rettv->vval.v_list = l;
|
|
Karsten Hopp |
805f60 |
rettv->v_type = VAR_LIST;
|
|
Karsten Hopp |
805f60 |
***************
|
|
Karsten Hopp |
805f60 |
*** 17163,17191 ****
|
|
Karsten Hopp |
805f60 |
ptrs = (listitem_T **)alloc((int)(len * sizeof(listitem_T *)));
|
|
Karsten Hopp |
805f60 |
if (ptrs == NULL)
|
|
Karsten Hopp |
805f60 |
return;
|
|
Karsten Hopp |
805f60 |
- i = 0;
|
|
Karsten Hopp |
805f60 |
- for (li = l->lv_first; li != NULL; li = li->li_next)
|
|
Karsten Hopp |
805f60 |
- ptrs[i++] = li;
|
|
Karsten Hopp |
805f60 |
|
|
Karsten Hopp |
805f60 |
! item_compare_func_err = FALSE;
|
|
Karsten Hopp |
805f60 |
! /* test the compare function */
|
|
Karsten Hopp |
805f60 |
! if (item_compare_func != NULL
|
|
Karsten Hopp |
805f60 |
! && item_compare2((void *)&ptrs[0], (void *)&ptrs[1])
|
|
Karsten Hopp |
805f60 |
== ITEM_COMPARE_FAIL)
|
|
Karsten Hopp |
805f60 |
! EMSG(_("E702: Sort compare function failed"));
|
|
Karsten Hopp |
805f60 |
else
|
|
Karsten Hopp |
805f60 |
{
|
|
Karsten Hopp |
805f60 |
! /* Sort the array with item pointers. */
|
|
Karsten Hopp |
805f60 |
! qsort((void *)ptrs, (size_t)len, sizeof(listitem_T *),
|
|
Karsten Hopp |
805f60 |
! item_compare_func == NULL ? item_compare : item_compare2);
|
|
Karsten Hopp |
805f60 |
|
|
Karsten Hopp |
805f60 |
if (!item_compare_func_err)
|
|
Karsten Hopp |
805f60 |
{
|
|
Karsten Hopp |
805f60 |
! /* Clear the List and append the items in the sorted order. */
|
|
Karsten Hopp |
805f60 |
! l->lv_first = l->lv_last = l->lv_idx_item = NULL;
|
|
Karsten Hopp |
805f60 |
! l->lv_len = 0;
|
|
Karsten Hopp |
805f60 |
! for (i = 0; i < len; ++i)
|
|
Karsten Hopp |
805f60 |
! list_append(l, ptrs[i]);
|
|
Karsten Hopp |
805f60 |
}
|
|
Karsten Hopp |
805f60 |
}
|
|
Karsten Hopp |
805f60 |
|
|
Karsten Hopp |
805f60 |
--- 17167,17238 ----
|
|
Karsten Hopp |
805f60 |
ptrs = (listitem_T **)alloc((int)(len * sizeof(listitem_T *)));
|
|
Karsten Hopp |
805f60 |
if (ptrs == NULL)
|
|
Karsten Hopp |
805f60 |
return;
|
|
Karsten Hopp |
805f60 |
|
|
Karsten Hopp |
805f60 |
! i = 0;
|
|
Karsten Hopp |
805f60 |
! if (sort)
|
|
Karsten Hopp |
805f60 |
! {
|
|
Karsten Hopp |
805f60 |
! /* sort(): ptrs will be the list to sort */
|
|
Karsten Hopp |
805f60 |
! for (li = l->lv_first; li != NULL; li = li->li_next)
|
|
Karsten Hopp |
805f60 |
! ptrs[i++] = li;
|
|
Karsten Hopp |
805f60 |
!
|
|
Karsten Hopp |
805f60 |
! item_compare_func_err = FALSE;
|
|
Karsten Hopp |
805f60 |
! /* test the compare function */
|
|
Karsten Hopp |
805f60 |
! if (item_compare_func != NULL
|
|
Karsten Hopp |
805f60 |
! && item_compare2((void *)&ptrs[0], (void *)&ptrs[1])
|
|
Karsten Hopp |
805f60 |
== ITEM_COMPARE_FAIL)
|
|
Karsten Hopp |
805f60 |
! EMSG(_("E702: Sort compare function failed"));
|
|
Karsten Hopp |
805f60 |
! else
|
|
Karsten Hopp |
805f60 |
! {
|
|
Karsten Hopp |
805f60 |
! /* Sort the array with item pointers. */
|
|
Karsten Hopp |
805f60 |
! qsort((void *)ptrs, (size_t)len, sizeof(listitem_T *),
|
|
Karsten Hopp |
805f60 |
! item_compare_func == NULL ? item_compare : item_compare2);
|
|
Karsten Hopp |
805f60 |
!
|
|
Karsten Hopp |
805f60 |
! if (!item_compare_func_err)
|
|
Karsten Hopp |
805f60 |
! {
|
|
Karsten Hopp |
805f60 |
! /* Clear the List and append the items in sorted order. */
|
|
Karsten Hopp |
805f60 |
! l->lv_first = l->lv_last = l->lv_idx_item = NULL;
|
|
Karsten Hopp |
805f60 |
! l->lv_len = 0;
|
|
Karsten Hopp |
805f60 |
! for (i = 0; i < len; ++i)
|
|
Karsten Hopp |
805f60 |
! list_append(l, ptrs[i]);
|
|
Karsten Hopp |
805f60 |
! }
|
|
Karsten Hopp |
805f60 |
! }
|
|
Karsten Hopp |
805f60 |
! }
|
|
Karsten Hopp |
805f60 |
else
|
|
Karsten Hopp |
805f60 |
{
|
|
Karsten Hopp |
805f60 |
! int (*item_compare_func_ptr)__ARGS((const void *, const void *));
|
|
Karsten Hopp |
805f60 |
!
|
|
Karsten Hopp |
805f60 |
! /* f_uniq(): ptrs will be a stack of items to remove */
|
|
Karsten Hopp |
805f60 |
! item_compare_func_err = FALSE;
|
|
Karsten Hopp |
805f60 |
! item_compare_func_ptr = item_compare_func
|
|
Karsten Hopp |
805f60 |
! ? item_compare2 : item_compare;
|
|
Karsten Hopp |
805f60 |
!
|
|
Karsten Hopp |
805f60 |
! for (li = l->lv_first; li != NULL && li->li_next != NULL;
|
|
Karsten Hopp |
805f60 |
! li = li->li_next)
|
|
Karsten Hopp |
805f60 |
! {
|
|
Karsten Hopp |
805f60 |
! if (item_compare_func_ptr((void *)&li, (void *)&li->li_next)
|
|
Karsten Hopp |
805f60 |
! == 0)
|
|
Karsten Hopp |
805f60 |
! ptrs[i++] = li;
|
|
Karsten Hopp |
805f60 |
! if (item_compare_func_err)
|
|
Karsten Hopp |
805f60 |
! {
|
|
Karsten Hopp |
805f60 |
! EMSG(_("E882: Uniq compare function failed"));
|
|
Karsten Hopp |
805f60 |
! break;
|
|
Karsten Hopp |
805f60 |
! }
|
|
Karsten Hopp |
805f60 |
! }
|
|
Karsten Hopp |
805f60 |
|
|
Karsten Hopp |
805f60 |
if (!item_compare_func_err)
|
|
Karsten Hopp |
805f60 |
{
|
|
Karsten Hopp |
805f60 |
! while (--i >= 0)
|
|
Karsten Hopp |
805f60 |
! {
|
|
Karsten Hopp |
805f60 |
! li = ptrs[i]->li_next;
|
|
Karsten Hopp |
805f60 |
! ptrs[i]->li_next = li->li_next;
|
|
Karsten Hopp |
805f60 |
! if (li->li_next != NULL)
|
|
Karsten Hopp |
805f60 |
! li->li_next->li_prev = ptrs[i];
|
|
Karsten Hopp |
805f60 |
! else
|
|
Karsten Hopp |
805f60 |
! l->lv_last = ptrs[i];
|
|
Karsten Hopp |
805f60 |
! list_fix_watch(l, li);
|
|
Karsten Hopp |
805f60 |
! listitem_free(li);
|
|
Karsten Hopp |
805f60 |
! l->lv_len--;
|
|
Karsten Hopp |
805f60 |
! }
|
|
Karsten Hopp |
805f60 |
}
|
|
Karsten Hopp |
805f60 |
}
|
|
Karsten Hopp |
805f60 |
|
|
Karsten Hopp |
805f60 |
***************
|
|
Karsten Hopp |
805f60 |
*** 17194,17199 ****
|
|
Karsten Hopp |
805f60 |
--- 17241,17268 ----
|
|
Karsten Hopp |
805f60 |
}
|
|
Karsten Hopp |
805f60 |
|
|
Karsten Hopp |
805f60 |
/*
|
|
Karsten Hopp |
805f60 |
+ * "sort({list})" function
|
|
Karsten Hopp |
805f60 |
+ */
|
|
Karsten Hopp |
805f60 |
+ static void
|
|
Karsten Hopp |
805f60 |
+ f_sort(argvars, rettv)
|
|
Karsten Hopp |
805f60 |
+ typval_T *argvars;
|
|
Karsten Hopp |
805f60 |
+ typval_T *rettv;
|
|
Karsten Hopp |
805f60 |
+ {
|
|
Karsten Hopp |
805f60 |
+ do_sort_uniq(argvars, rettv, TRUE);
|
|
Karsten Hopp |
805f60 |
+ }
|
|
Karsten Hopp |
805f60 |
+
|
|
Karsten Hopp |
805f60 |
+ /*
|
|
Karsten Hopp |
805f60 |
+ * "uniq({list})" function
|
|
Karsten Hopp |
805f60 |
+ */
|
|
Karsten Hopp |
805f60 |
+ static void
|
|
Karsten Hopp |
805f60 |
+ f_uniq(argvars, rettv)
|
|
Karsten Hopp |
805f60 |
+ typval_T *argvars;
|
|
Karsten Hopp |
805f60 |
+ typval_T *rettv;
|
|
Karsten Hopp |
805f60 |
+ {
|
|
Karsten Hopp |
805f60 |
+ do_sort_uniq(argvars, rettv, FALSE);
|
|
Karsten Hopp |
805f60 |
+ }
|
|
Karsten Hopp |
805f60 |
+
|
|
Karsten Hopp |
805f60 |
+ /*
|
|
Karsten Hopp |
805f60 |
* "soundfold({word})" function
|
|
Karsten Hopp |
805f60 |
*/
|
|
Karsten Hopp |
805f60 |
static void
|
|
Karsten Hopp |
805f60 |
*** ../vim-7.4.217/src/testdir/test55.in 2014-01-14 15:24:24.000000000 +0100
|
|
Karsten Hopp |
805f60 |
--- src/testdir/test55.in 2014-03-25 17:32:29.522040841 +0100
|
|
Karsten Hopp |
805f60 |
***************
|
|
Karsten Hopp |
805f60 |
*** 323,335 ****
|
|
Karsten Hopp |
805f60 |
: $put ='caught ' . v:exception
|
|
Karsten Hopp |
805f60 |
:endtry
|
|
Karsten Hopp |
805f60 |
:"
|
|
Karsten Hopp |
805f60 |
! :" reverse() and sort()
|
|
Karsten Hopp |
805f60 |
! :let l = ['-0', 'A11', 2, 'xaaa', 4, 'foo', 'foo6', [0, 1, 2], 'x8']
|
|
Karsten Hopp |
805f60 |
:$put =string(reverse(l))
|
|
Karsten Hopp |
805f60 |
:$put =string(reverse(reverse(l)))
|
|
Karsten Hopp |
805f60 |
:$put =string(sort(l))
|
|
Karsten Hopp |
805f60 |
:$put =string(reverse(sort(l)))
|
|
Karsten Hopp |
805f60 |
:$put =string(sort(reverse(sort(l))))
|
|
Karsten Hopp |
805f60 |
:"
|
|
Karsten Hopp |
805f60 |
:" splitting a string to a List
|
|
Karsten Hopp |
805f60 |
:$put =string(split(' aa bb '))
|
|
Karsten Hopp |
805f60 |
--- 323,337 ----
|
|
Karsten Hopp |
805f60 |
: $put ='caught ' . v:exception
|
|
Karsten Hopp |
805f60 |
:endtry
|
|
Karsten Hopp |
805f60 |
:"
|
|
Karsten Hopp |
805f60 |
! :" reverse(), sort(), uniq()
|
|
Karsten Hopp |
805f60 |
! :let l = ['-0', 'A11', 2, 2, 'xaaa', 4, 'foo', 'foo6', 'foo', [0, 1, 2], 'x8', [0, 1, 2], 1.5]
|
|
Karsten Hopp |
805f60 |
! :$put =string(uniq(copy(l)))
|
|
Karsten Hopp |
805f60 |
:$put =string(reverse(l))
|
|
Karsten Hopp |
805f60 |
:$put =string(reverse(reverse(l)))
|
|
Karsten Hopp |
805f60 |
:$put =string(sort(l))
|
|
Karsten Hopp |
805f60 |
:$put =string(reverse(sort(l)))
|
|
Karsten Hopp |
805f60 |
:$put =string(sort(reverse(sort(l))))
|
|
Karsten Hopp |
805f60 |
+ :$put =string(uniq(sort(l)))
|
|
Karsten Hopp |
805f60 |
:"
|
|
Karsten Hopp |
805f60 |
:" splitting a string to a List
|
|
Karsten Hopp |
805f60 |
:$put =string(split(' aa bb '))
|
|
Karsten Hopp |
805f60 |
*** ../vim-7.4.217/src/testdir/test55.ok 2014-01-14 15:24:24.000000000 +0100
|
|
Karsten Hopp |
805f60 |
--- src/testdir/test55.ok 2014-03-25 17:32:29.522040841 +0100
|
|
Karsten Hopp |
805f60 |
***************
|
|
Karsten Hopp |
805f60 |
*** 94,104 ****
|
|
Karsten Hopp |
805f60 |
caught a:000[2]
|
|
Karsten Hopp |
805f60 |
caught a:000[3]
|
|
Karsten Hopp |
805f60 |
[1, 2, [3, 9, 5, 6], {'a': 12, '5': 8}]
|
|
Karsten Hopp |
805f60 |
! ['x8', [0, 1, 2], 'foo6', 'foo', 4, 'xaaa', 2, 'A11', '-0']
|
|
Karsten Hopp |
805f60 |
! ['x8', [0, 1, 2], 'foo6', 'foo', 4, 'xaaa', 2, 'A11', '-0']
|
|
Karsten Hopp |
805f60 |
! ['-0', 'A11', 'foo', 'foo6', 'x8', 'xaaa', 2, 4, [0, 1, 2]]
|
|
Karsten Hopp |
805f60 |
! [[0, 1, 2], 4, 2, 'xaaa', 'x8', 'foo6', 'foo', 'A11', '-0']
|
|
Karsten Hopp |
805f60 |
! ['-0', 'A11', 'foo', 'foo6', 'x8', 'xaaa', 2, 4, [0, 1, 2]]
|
|
Karsten Hopp |
805f60 |
['aa', 'bb']
|
|
Karsten Hopp |
805f60 |
['aa', 'bb']
|
|
Karsten Hopp |
805f60 |
['', 'aa', 'bb', '']
|
|
Karsten Hopp |
805f60 |
--- 94,106 ----
|
|
Karsten Hopp |
805f60 |
caught a:000[2]
|
|
Karsten Hopp |
805f60 |
caught a:000[3]
|
|
Karsten Hopp |
805f60 |
[1, 2, [3, 9, 5, 6], {'a': 12, '5': 8}]
|
|
Karsten Hopp |
805f60 |
! ['-0', 'A11', 2, 'xaaa', 4, 'foo', 'foo6', 'foo', [0, 1, 2], 'x8', [0, 1, 2], 1.5]
|
|
Karsten Hopp |
805f60 |
! [1.5, [0, 1, 2], 'x8', [0, 1, 2], 'foo', 'foo6', 'foo', 4, 'xaaa', 2, 2, 'A11', '-0']
|
|
Karsten Hopp |
805f60 |
! [1.5, [0, 1, 2], 'x8', [0, 1, 2], 'foo', 'foo6', 'foo', 4, 'xaaa', 2, 2, 'A11', '-0']
|
|
Karsten Hopp |
805f60 |
! ['-0', 'A11', 'foo', 'foo', 'foo6', 'x8', 'xaaa', 1.5, 2, 2, 4, [0, 1, 2], [0, 1, 2]]
|
|
Karsten Hopp |
805f60 |
! [[0, 1, 2], [0, 1, 2], 4, 2, 2, 1.5, 'xaaa', 'x8', 'foo6', 'foo', 'foo', 'A11', '-0']
|
|
Karsten Hopp |
805f60 |
! ['-0', 'A11', 'foo', 'foo', 'foo6', 'x8', 'xaaa', 1.5, 2, 2, 4, [0, 1, 2], [0, 1, 2]]
|
|
Karsten Hopp |
805f60 |
! ['-0', 'A11', 'foo', 'foo6', 'x8', 'xaaa', 1.5, 2, 4, [0, 1, 2]]
|
|
Karsten Hopp |
805f60 |
['aa', 'bb']
|
|
Karsten Hopp |
805f60 |
['aa', 'bb']
|
|
Karsten Hopp |
805f60 |
['', 'aa', 'bb', '']
|
|
Karsten Hopp |
805f60 |
*** ../vim-7.4.217/src/version.c 2014-03-25 18:05:45.242071421 +0100
|
|
Karsten Hopp |
805f60 |
--- src/version.c 2014-03-25 17:34:51.918043023 +0100
|
|
Karsten Hopp |
805f60 |
***************
|
|
Karsten Hopp |
805f60 |
*** 736,737 ****
|
|
Karsten Hopp |
805f60 |
--- 736,739 ----
|
|
Karsten Hopp |
805f60 |
{ /* Add new patch number below this line */
|
|
Karsten Hopp |
805f60 |
+ /**/
|
|
Karsten Hopp |
805f60 |
+ 218,
|
|
Karsten Hopp |
805f60 |
/**/
|
|
Karsten Hopp |
805f60 |
|
|
Karsten Hopp |
805f60 |
--
|
|
Karsten Hopp |
805f60 |
Never under any circumstances take a sleeping pill
|
|
Karsten Hopp |
805f60 |
and a laxative on the same night.
|
|
Karsten Hopp |
805f60 |
|
|
Karsten Hopp |
805f60 |
/// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
|
|
Karsten Hopp |
805f60 |
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
|
|
Karsten Hopp |
805f60 |
\\\ an exciting new programming language -- http://www.Zimbu.org ///
|
|
Karsten Hopp |
805f60 |
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
|