shithub: puzzles

Download patch

ref: 4c1e47b272274972556d7790384998e593d0ae57
parent: cd338a1a35394a7abfd517569e908b54bf657aaa
author: Ben Hutchings <ben@decadent.org.uk>
date: Sat Aug 17 13:36:51 EDT 2019

Bridges: Fix off-by-one in WITHIN()

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.")

--- a/bridges.c
+++ b/bridges.c
@@ -183,7 +183,7 @@
 
 #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))