To: vim_dev@googlegroups.com Subject: Patch 8.2.3449 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ 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 -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// \\\ \\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///