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

IDs but it breaks key sorting. GitHub issue 5646 from Alexandre Fiori.

(cherry picked from commit db3950ed07)
This commit is contained in:
nicm
2026-09-28 10:42:01 +00:00
committed by Nicholas Marriott
parent 35c602bc53
commit 0383107696
3 changed files with 50 additions and 26 deletions

View File

@@ -1,4 +1,4 @@
/* $OpenBSD: window.c,v 1.382 2026/09/28 10:25:43 nicm Exp $ */
/* $OpenBSD: window.c,v 1.383 2026/09/28 10:42:01 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -92,7 +92,11 @@ struct window_pane_prompt {
int
window_cmp(struct window *w1, struct window *w2)
{
return (w1->id - w2->id);
if (w1->id < w2->id)
return (-1);
if (w1->id > w2->id)
return (1);
return (0);
}
static void
@@ -199,7 +203,11 @@ winlink_cmp(struct winlink *wl1, struct winlink *wl2)
int
window_pane_cmp(struct window_pane *wp1, struct window_pane *wp2)
{
return (wp1->id - wp2->id);
if (wp1->id < wp2->id)
return (-1);
if (wp1->id > wp2->id)
return (1);
return (0);
}
struct winlink *