diff options
author | Yasuhiro Matsumoto <mattn.jp@gmail.com> | 2021-09-19 17:01:39 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2021-09-19 17:01:39 +0200 |
commit | c04f62346bfd6b92151908239a3c5ab1a7d18f2a (patch) | |
tree | bf51ef760f6ae2a6fd3283b78ae2ec06a1914565 /src/list.c | |
parent | 1d34189ecb99fa76363c06e1aa815c1075675a1c (diff) | |
download | vim-git-c04f62346bfd6b92151908239a3c5ab1a7d18f2a.tar.gz |
patch 8.2.3449: sort fails if the sort compare function returns 999v8.2.3449
Problem: Sort fails if the sort compare function returns 999.
Solution: Adjust value to -1 / 0 / 1. (Yasuhiro Matsumoto, closes #8884)
Diffstat (limited to 'src/list.c')
-rw-r--r-- | src/list.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/list.c b/src/list.c index 8e67a61db..16e59837e 100644 --- a/src/list.c +++ b/src/list.c @@ -1945,7 +1945,13 @@ item_compare2(const void *s1, const void *s2) 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); |