shithub: puzzles

Download patch

ref: 795ef3c137a0ead6ab058ab60d6f90bd4029ab43
parent: 3dc6adba5ef474f5e145b22184639b7b86b329f3
author: Simon Tatham <anakin@pobox.com>
date: Sun Jun 27 07:17:27 EDT 2010

Some minor fixes to the unfinished Pearl solver:
 - move critical correctness checks out of diagnostic ifdefs (ahem)
 - move declarations to before conditionally compiled code (we don't
   build in C99 mode round here)
 - tidy up an unsightly blank line while I'm here.

[originally from svn r8969]

--- a/unfinished/pearl.c
+++ b/unfinished/pearl.c
@@ -217,6 +217,7 @@
      * Now repeatedly try to find something we can do.
      */
     while (1) {
+	int done_something = FALSE;
 
 #ifdef SOLVER_DIAGNOSTICS
 	for (y = 0; y < H; y++) {
@@ -226,8 +227,6 @@
 	}
 #endif
 
-	int done_something = FALSE;
-
 	/*
 	 * Go through the square state words, and discard any
 	 * square state which is inconsistent with known facts
@@ -267,9 +266,9 @@
 		if (!workspace[(2*y+1)*W+(2*x+1)]) {
 #ifdef SOLVER_DIAGNOSTICS
 		    printf("edge check at (%d,%d): inconsistency\n", x, y);
+#endif
 		    ret = 0;
 		    goto cleanup;
-#endif
 		}
 	    }
 
@@ -298,9 +297,9 @@
 		if (edgeand & ~edgeor) {
 #ifdef SOLVER_DIAGNOSTICS
 		    printf("square check at (%d,%d): inconsistency\n", x, y);
+#endif
 		    ret = 0;
 		    goto cleanup;
-#endif
 		}
 
 		for (d = 1; d <= 8; d += d) {
@@ -384,7 +383,6 @@
 			    }
 			}
 		    }
-
 
 		    break;
 		  case STRAIGHT: