aboutsummaryrefslogtreecommitdiff
path: root/latin.c
diff options
context:
space:
mode:
authorSimon Tatham <anakin@pobox.com>2018-11-13 21:45:44 +0000
committerSimon Tatham <anakin@pobox.com>2018-11-13 21:48:24 +0000
commit5f5b284c0bddbe67de14b2d2bfb596bc7ba1298a (patch)
treef96b55a27088ae71d74dc83d7cc3731c5d5bf6dc /latin.c
parenta550ea0a47374705a37f36b0f05ffe9e4c8161fb (diff)
downloadpuzzles-5f5b284c0bddbe67de14b2d2bfb596bc7ba1298a.zip
puzzles-5f5b284c0bddbe67de14b2d2bfb596bc7ba1298a.tar.gz
puzzles-5f5b284c0bddbe67de14b2d2bfb596bc7ba1298a.tar.bz2
puzzles-5f5b284c0bddbe67de14b2d2bfb596bc7ba1298a.tar.xz
Use C99 bool within source modules.
This is the main bulk of this boolification work, but although it's making the largest actual change, it should also be the least disruptive to anyone interacting with this code base downstream of me, because it doesn't modify any interface between modules: all the inter-module APIs were updated one by one in the previous commits. This just cleans up the code within each individual source file to use bool in place of int where I think that makes things clearer.
Diffstat (limited to 'latin.c')
-rw-r--r--latin.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/latin.c b/latin.c
index c843671..9d06ccd 100644
--- a/latin.c
+++ b/latin.c
@@ -226,7 +226,7 @@ int latin_solver_set(struct latin_solver *solver,
*/
int rows = 0;
for (i = 0; i < n; i++) {
- int ok = true;
+ bool ok = true;
for (j = 0; j < n; j++)
if (set[j] && grid[i*o+j]) {
ok = false;
@@ -261,7 +261,7 @@ int latin_solver_set(struct latin_solver *solver,
}
if (rows >= n - count) {
- int progress = false;
+ bool progress = false;
/*
* We've got one! Now, for each row which _doesn't_
@@ -275,7 +275,7 @@ int latin_solver_set(struct latin_solver *solver,
* positions in the cube to meddle with.
*/
for (i = 0; i < n; i++) {
- int ok = true;
+ bool ok = true;
for (j = 0; j < n; j++)
if (set[j] && grid[i*o+j]) {
ok = false;
@@ -570,12 +570,12 @@ void latin_solver_alloc(struct latin_solver *solver, digit *grid, int o)
solver->o = o;
solver->cube = snewn(o*o*o, unsigned char);
solver->grid = grid; /* write straight back to the input */
- memset(solver->cube, true, o*o*o);
+ memset(solver->cube, 1, o*o*o);
solver->row = snewn(o*o, unsigned char);
solver->col = snewn(o*o, unsigned char);
- memset(solver->row, false, o*o);
- memset(solver->col, false, o*o);
+ memset(solver->row, 0, o*o);
+ memset(solver->col, 0, o*o);
for (x = 0; x < o; x++)
for (y = 0; y < o; y++)
@@ -908,9 +908,9 @@ static int latin_solver_top(struct latin_solver *solver, int maxdiff,
if (ret == 0 && i == diff_simple)
ret = latin_solver_diff_simple(solver);
if (ret == 0 && i == diff_set_0)
- ret = latin_solver_diff_set(solver, scratch, 0);
+ ret = latin_solver_diff_set(solver, scratch, false);
if (ret == 0 && i == diff_set_1)
- ret = latin_solver_diff_set(solver, scratch, 1);
+ ret = latin_solver_diff_set(solver, scratch, true);
if (ret == 0 && i == diff_forcing)
ret = latin_solver_forcing(solver, scratch);