Do not use subtraction for comparators, this doesn't really matter for

IDs but it breaks key sorting. GitHub issue 5646 from Alexandre Fiori.
This commit is contained in:
nicm
2026-09-28 10:42:01 +00:00
committed by tmux update bot
parent a16e62849d
commit db3950ed07
3 changed files with 50 additions and 26 deletions

View File

@@ -1,4 +1,4 @@
/* $OpenBSD: hyperlinks.c,v 1.5 2026/06/29 16:44:06 nicm Exp $ */
/* $OpenBSD: hyperlinks.c,v 1.6 2026/09/28 10:42:01 nicm Exp $ */
/*
* Copyright (c) 2021 Will <author@will.party>
@@ -88,7 +88,11 @@ hyperlinks_by_uri_cmp(struct hyperlinks_uri *left, struct hyperlinks_uri *right)
return (-1);
if (*right->internal_id != '\0')
return (1);
return (left->inner - right->inner);
if (left->inner < right->inner)
return (-1);
if (left->inner > right->inner)
return (1);
return (0);
}
r = strcmp(left->internal_id, right->internal_id);
@@ -105,7 +109,11 @@ static int
hyperlinks_by_inner_cmp(struct hyperlinks_uri *left,
struct hyperlinks_uri *right)
{
return (left->inner - right->inner);
if (left->inner < right->inner)
return (-1);
if (left->inner > right->inner)
return (1);
return (0);
}
RB_PROTOTYPE_STATIC(hyperlinks_by_inner_tree, hyperlinks_uri, by_inner_entry,
hyperlinks_by_inner_cmp);