vim-patch:8.2.3449: sort fails if the sort compare function returns 999 (#17909)

Problem:    Sort fails if the sort compare function returns 999.
Solution:   Adjust value to -1 / 0 / 1. (Yasuhiro Matsumoto, closes vim/vim#8884)
c04f62346b
This commit is contained in:
dundargoc
2022-03-29 22:14:37 +02:00
committed by GitHub
parent 7a6978ba29
commit 29aa08a09d
2 changed files with 6 additions and 0 deletions

View File

@@ -9466,6 +9466,11 @@ static int item_compare2(const void *s1, const void *s2, bool keep_zero)
res = ITEM_COMPARE_FAIL;
} else {
res = 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