diff options
| author | Simon Tatham <anakin@pobox.com> | 2018-11-13 21:45:44 +0000 |
|---|---|---|
| committer | Simon Tatham <anakin@pobox.com> | 2018-11-13 21:48:24 +0000 |
| commit | 5f5b284c0bddbe67de14b2d2bfb596bc7ba1298a (patch) | |
| tree | f96b55a27088ae71d74dc83d7cc3731c5d5bf6dc /grid.c | |
| parent | a550ea0a47374705a37f36b0f05ffe9e4c8161fb (diff) | |
| download | puzzles-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 'grid.c')
| -rw-r--r-- | grid.c | 19 |
1 files changed, 10 insertions, 9 deletions
@@ -386,11 +386,11 @@ static void grid_trim_vigorously(grid *g) */ dots = snewn(g->num_dots, int); for (i = 0; i < g->num_dots; i++) { - dots[i] = true; + dots[i] = 1; for (j = 0; j < g->num_dots; j++) { if ((dotpairs[i*g->num_dots+j] >= 0) ^ (dotpairs[j*g->num_dots+i] >= 0)) - dots[i] = false; /* non-duplicated edge: coastal dot */ + dots[i] = 0; /* non-duplicated edge: coastal dot */ } } @@ -435,14 +435,14 @@ static void grid_trim_vigorously(grid *g) dots[i] = 0; for (i = 0; i < g->num_faces; i++) { grid_face *f = g->faces + i; - int keep = false; + bool keep = false; for (k = 0; k < f->order; k++) if (dsf_canonify(dsf, f->dots[k] - g->dots) == j) keep = true; if (keep) { - faces[i] = true; + faces[i] = 1; for (k = 0; k < f->order; k++) - dots[f->dots[k]-g->dots] = true; + dots[f->dots[k]-g->dots] = 1; } } @@ -862,7 +862,7 @@ static void grid_face_set_dot(grid *g, grid_dot *d, int position) /* * Helper routines for grid_find_incentre. */ -static int solve_2x2_matrix(double mx[4], double vin[2], double vout[2]) +static bool solve_2x2_matrix(double mx[4], double vin[2], double vout[2]) { double inv[4]; double det; @@ -880,7 +880,7 @@ static int solve_2x2_matrix(double mx[4], double vin[2], double vout[2]) return true; } -static int solve_3x3_matrix(double mx[9], double vin[3], double vout[3]) +static bool solve_3x3_matrix(double mx[9], double vin[3], double vout[3]) { double inv[9]; double det; @@ -1239,7 +1239,8 @@ void grid_find_incentre(grid_face *f) * _positive_ epsilon in both the x- and * y-direction.) */ - int e, in = 0; + int e; + bool in = false; for (e = 0; e < f->order; e++) { int xs = f->edges[e]->dot1->x; int xe = f->edges[e]->dot2->x; @@ -1265,7 +1266,7 @@ void grid_find_incentre(grid_face *f) denom = -denom; } if ((x - xs) * denom >= (y - ys) * num) - in ^= 1; + in = !in; } } |