Patch 8.2.3449
Problem: Sort fails if the sort compare function returns 999.
Solution: Adjust value to -1 / 0 / 1. (Yasuhiro Matsumoto, closes #8884)
Files: src/list.c, src/testdir/test_sort.vim
*** ../vim-8.2.3448/src/list.c 2021-09-11 20:20:34.007127618 +0200
--- src/list.c 2021-09-19 16:57:26.146938404 +0200
***************
*** 1945,1951 ****
--- 1945,1957 ----
if (res == FAIL)
res = ITEM_COMPARE_FAIL;
else
+ {
res = (int)tv_get_number_chk(&rettv, &sortinfo->item_compare_func_err);
+ if (res > 0)
+ res = 1;
+ else if (res < 0)
+ res = -1;
+ }
if (sortinfo->item_compare_func_err)
res = ITEM_COMPARE_FAIL; // return value has wrong type
clear_tv(&rettv);
*** ../vim-8.2.3448/src/testdir/test_sort.vim 2021-01-03 17:39:24.434674818
+0100
--- src/testdir/test_sort.vim 2021-09-19 16:57:26.146938404 +0200
***************
*** 58,63 ****
--- 58,64 ----
func Test_sort_numbers()
call assert_equal([3, 13, 28], sort([13, 28, 3], 'N'))
call assert_equal(['3', '13', '28'], sort(['13', '28', '3'], 'N'))
+ call assert_equal([3997, 4996], sort([4996, 3997], 'Compare1'))
endfunc
func Test_sort_float()
*** ../vim-8.2.3448/src/version.c 2021-09-18 15:25:49.276973756 +0200
--- src/version.c 2021-09-19 17:00:16.498634987 +0200
***************
*** 759,760 ****
--- 759,762 ----
{ /* Add new patch number below this line */
+ /**/
+ 3449,
/**/
--
On the other hand, you have different fingers.
-- Steven Wright
/// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/vim_dev/202109191502.18JF2BGW2731435%40masaka.moolenaar.net.