1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
|
From: Ben Hutchings <ben@decadent.org.uk>
Date: Sat, 17 Aug 2019 17:36:51 +0100
Subject: bridges: Fix off-by-one in WITHIN()
Applied-Upstream: https://git.tartarus.org/?p=simon/puzzles.git;a=commitdiff;h=4c1e47b272274972556d7790384998e593d0ae57
WITHIN() used to treat the min and max as inclusive bounds but was
changed to treat the max as exclusive, apparently accidentally.
Fixed: 5f5b284c0bdd ("Use C99 bool within source modules.")
bridges.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/bridges.c b/bridges.c
index d12aa0b..533e04b 100644
@@ -183,7 +183,7 @@ struct game_state {
#define GRIDCOUNT(s,x,y,f) ((GRID(s,x,y) & (f)) ? (INDEX(s,lines,x,y)) : 0)
-#define WITHIN2(x,min,max) ((x) >= (min) && (x) < (max))
+#define WITHIN2(x,min,max) ((x) >= (min) && (x) <= (max))
#define WITHIN(x,min,max) ((min) > (max) ? \
WITHIN2(x,max,min) : WITHIN2(x,min,max))
|