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.
This commit is contained in:
Simon Tatham
2018-11-13 21:45:44 +00:00
parent a550ea0a47
commit 5f5b284c0b
61 changed files with 2297 additions and 1973 deletions

19
grid.c
View File

@ -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;
}
}