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