|
|
d6ba96 |
To: vim_dev@googlegroups.com
|
|
|
d6ba96 |
Subject: Patch 7.4.411
|
|
|
d6ba96 |
Fcc: outbox
|
|
|
d6ba96 |
From: Bram Moolenaar <Bram@moolenaar.net>
|
|
|
d6ba96 |
Mime-Version: 1.0
|
|
|
d6ba96 |
Content-Type: text/plain; charset=UTF-8
|
|
|
d6ba96 |
Content-Transfer-Encoding: 8bit
|
|
|
d6ba96 |
------------
|
|
|
d6ba96 |
|
|
|
d6ba96 |
Patch 7.4.411
|
|
|
d6ba96 |
Problem: "foo bar" sorts before "foo" with sort(). (John Little)
|
|
|
d6ba96 |
Solution: Avoid putting quotes around strings before comparing them.
|
|
|
d6ba96 |
Files: src/eval.c
|
|
|
d6ba96 |
|
|
|
d6ba96 |
|
|
|
d6ba96 |
*** ../vim-7.4.410/src/eval.c 2014-08-06 14:52:05.043236174 +0200
|
|
|
d6ba96 |
--- src/eval.c 2014-08-22 13:08:52.423905619 +0200
|
|
|
d6ba96 |
***************
|
|
|
d6ba96 |
*** 17382,17397 ****
|
|
|
d6ba96 |
const void *s2;
|
|
|
d6ba96 |
{
|
|
|
d6ba96 |
sortItem_T *si1, *si2;
|
|
|
d6ba96 |
char_u *p1, *p2;
|
|
|
d6ba96 |
! char_u *tofree1, *tofree2;
|
|
|
d6ba96 |
int res;
|
|
|
d6ba96 |
char_u numbuf1[NUMBUFLEN];
|
|
|
d6ba96 |
char_u numbuf2[NUMBUFLEN];
|
|
|
d6ba96 |
|
|
|
d6ba96 |
si1 = (sortItem_T *)s1;
|
|
|
d6ba96 |
si2 = (sortItem_T *)s2;
|
|
|
d6ba96 |
! p1 = tv2string(&si1->item->li_tv, &tofree1, numbuf1, 0);
|
|
|
d6ba96 |
! p2 = tv2string(&si2->item->li_tv, &tofree2, numbuf2, 0);
|
|
|
d6ba96 |
if (p1 == NULL)
|
|
|
d6ba96 |
p1 = (char_u *)"";
|
|
|
d6ba96 |
if (p2 == NULL)
|
|
|
d6ba96 |
--- 17382,17419 ----
|
|
|
d6ba96 |
const void *s2;
|
|
|
d6ba96 |
{
|
|
|
d6ba96 |
sortItem_T *si1, *si2;
|
|
|
d6ba96 |
+ typval_T *tv1, *tv2;
|
|
|
d6ba96 |
char_u *p1, *p2;
|
|
|
d6ba96 |
! char_u *tofree1 = NULL, *tofree2 = NULL;
|
|
|
d6ba96 |
int res;
|
|
|
d6ba96 |
char_u numbuf1[NUMBUFLEN];
|
|
|
d6ba96 |
char_u numbuf2[NUMBUFLEN];
|
|
|
d6ba96 |
|
|
|
d6ba96 |
si1 = (sortItem_T *)s1;
|
|
|
d6ba96 |
si2 = (sortItem_T *)s2;
|
|
|
d6ba96 |
! tv1 = &si1->item->li_tv;
|
|
|
d6ba96 |
! tv2 = &si2->item->li_tv;
|
|
|
d6ba96 |
! /* tv2string() puts quotes around a string and allocates memory. Don't do
|
|
|
d6ba96 |
! * that for string variables. Use a single quote when comparing with a
|
|
|
d6ba96 |
! * non-string to do what the docs promise. */
|
|
|
d6ba96 |
! if (tv1->v_type == VAR_STRING)
|
|
|
d6ba96 |
! {
|
|
|
d6ba96 |
! if (tv2->v_type != VAR_STRING || item_compare_numeric)
|
|
|
d6ba96 |
! p1 = (char_u *)"'";
|
|
|
d6ba96 |
! else
|
|
|
d6ba96 |
! p1 = tv1->vval.v_string;
|
|
|
d6ba96 |
! }
|
|
|
d6ba96 |
! else
|
|
|
d6ba96 |
! p1 = tv2string(tv1, &tofree1, numbuf1, 0);
|
|
|
d6ba96 |
! if (tv2->v_type == VAR_STRING)
|
|
|
d6ba96 |
! {
|
|
|
d6ba96 |
! if (tv1->v_type != VAR_STRING || item_compare_numeric)
|
|
|
d6ba96 |
! p2 = (char_u *)"'";
|
|
|
d6ba96 |
! else
|
|
|
d6ba96 |
! p2 = tv2->vval.v_string;
|
|
|
d6ba96 |
! }
|
|
|
d6ba96 |
! else
|
|
|
d6ba96 |
! p2 = tv2string(tv2, &tofree2, numbuf2, 0);
|
|
|
d6ba96 |
if (p1 == NULL)
|
|
|
d6ba96 |
p1 = (char_u *)"";
|
|
|
d6ba96 |
if (p2 == NULL)
|
|
|
d6ba96 |
***************
|
|
|
d6ba96 |
*** 17411,17418 ****
|
|
|
d6ba96 |
res = n1 == n2 ? 0 : n1 > n2 ? 1 : -1;
|
|
|
d6ba96 |
}
|
|
|
d6ba96 |
|
|
|
d6ba96 |
! /* When the result would be zero, compare the pointers themselves. Makes
|
|
|
d6ba96 |
! * the sort stable. */
|
|
|
d6ba96 |
if (res == 0 && !item_compare_keep_zero)
|
|
|
d6ba96 |
res = si1->idx > si2->idx ? 1 : -1;
|
|
|
d6ba96 |
|
|
|
d6ba96 |
--- 17433,17440 ----
|
|
|
d6ba96 |
res = n1 == n2 ? 0 : n1 > n2 ? 1 : -1;
|
|
|
d6ba96 |
}
|
|
|
d6ba96 |
|
|
|
d6ba96 |
! /* When the result would be zero, compare the item indexes. Makes the
|
|
|
d6ba96 |
! * sort stable. */
|
|
|
d6ba96 |
if (res == 0 && !item_compare_keep_zero)
|
|
|
d6ba96 |
res = si1->idx > si2->idx ? 1 : -1;
|
|
|
d6ba96 |
|
|
|
d6ba96 |
*** ../vim-7.4.410/src/version.c 2014-08-17 17:24:03.967017727 +0200
|
|
|
d6ba96 |
--- src/version.c 2014-08-22 12:51:35.011943243 +0200
|
|
|
d6ba96 |
***************
|
|
|
d6ba96 |
*** 743,744 ****
|
|
|
d6ba96 |
--- 743,746 ----
|
|
|
d6ba96 |
{ /* Add new patch number below this line */
|
|
|
d6ba96 |
+ /**/
|
|
|
d6ba96 |
+ 411,
|
|
|
d6ba96 |
/**/
|
|
|
d6ba96 |
|
|
|
d6ba96 |
--
|
|
|
d6ba96 |
I started out with nothing, and I still have most of it.
|
|
|
d6ba96 |
-- Michael Davis -- "Tonight Show"
|
|
|
d6ba96 |
|
|
|
d6ba96 |
/// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
|
|
|
d6ba96 |
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
|
|
|
d6ba96 |
\\\ an exciting new programming language -- http://www.Zimbu.org ///
|
|
|
d6ba96 |
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
|