Replace TRUE/FALSE with C99 true/false throughout.

This commit removes the old #defines of TRUE and FALSE from puzzles.h,
and does a mechanical search-and-replace throughout the code to
replace them with the C99 standard lowercase spellings.
This commit is contained in:
Simon Tatham
2018-11-13 21:44:02 +00:00
parent 064da87682
commit a550ea0a47
64 changed files with 2111 additions and 2118 deletions

View File

@ -112,19 +112,19 @@ static game_params *default_params(void)
ret->w = 6;
ret->diff = DIFF_NORMAL;
ret->id = TRUE;
ret->id = true;
return ret;
}
const static struct game_params group_presets[] = {
{ 6, DIFF_NORMAL, TRUE },
{ 6, DIFF_NORMAL, FALSE },
{ 8, DIFF_NORMAL, TRUE },
{ 8, DIFF_NORMAL, FALSE },
{ 8, DIFF_HARD, TRUE },
{ 8, DIFF_HARD, FALSE },
{ 12, DIFF_NORMAL, TRUE },
{ 6, DIFF_NORMAL, true },
{ 6, DIFF_NORMAL, false },
{ 8, DIFF_NORMAL, true },
{ 8, DIFF_NORMAL, false },
{ 8, DIFF_HARD, true },
{ 8, DIFF_HARD, false },
{ 12, DIFF_NORMAL, true },
};
static bool game_fetch_preset(int i, char **name, game_params **params)
@ -133,7 +133,7 @@ static bool game_fetch_preset(int i, char **name, game_params **params)
char buf[80];
if (i < 0 || i >= lenof(group_presets))
return FALSE;
return false;
ret = snew(game_params);
*ret = group_presets[i]; /* structure copy */
@ -143,7 +143,7 @@ static bool game_fetch_preset(int i, char **name, game_params **params)
*name = dupstr(buf);
*params = ret;
return TRUE;
return true;
}
static void free_params(game_params *params)
@ -165,7 +165,7 @@ static void decode_params(game_params *params, char const *string)
params->w = atoi(p);
while (*p && isdigit((unsigned char)*p)) p++;
params->diff = DIFF_NORMAL;
params->id = TRUE;
params->id = true;
while (*p) {
if (*p == 'd') {
@ -180,7 +180,7 @@ static void decode_params(game_params *params, char const *string)
p++;
}
} else if (*p == 'i') {
params->id = FALSE;
params->id = false;
p++;
} else {
/* unrecognised character */
@ -866,9 +866,9 @@ static game_state *new_game(midend *me, const game_params *params,
desc = spec_to_grid(desc, state->grid, a);
for (i = 0; i < a; i++)
if (state->grid[i] != 0)
state->immutable[i] = TRUE;
state->immutable[i] = true;
state->completed = state->cheated = FALSE;
state->completed = state->cheated = false;
return state;
}
@ -942,7 +942,7 @@ static char *solve_game(const game_state *state, const game_state *currstate,
static bool game_can_format_as_text_now(const game_params *params)
{
return TRUE;
return true;
}
static char *game_text_format(const game_state *state)
@ -1142,7 +1142,7 @@ static int check_errors(const game_state *state, long *errors)
{
int w = state->par.w, a = w*w;
digit *grid = state->grid;
int i, j, k, x, y, errs = FALSE;
int i, j, k, x, y, errs = false;
/*
* To verify that we have a valid group table, it suffices to
@ -1185,7 +1185,7 @@ static int check_errors(const game_state *state, long *errors)
}
if (mask != (1 << (w+1)) - (1 << 1)) {
errs = TRUE;
errs = true;
errmask &= ~1UL;
if (errors) {
for (x = 0; x < w; x++)
@ -1204,7 +1204,7 @@ static int check_errors(const game_state *state, long *errors)
}
if (mask != (1 << (w+1)) - (1 << 1)) {
errs = TRUE;
errs = true;
errmask &= ~1UL;
if (errors) {
for (y = 0; y < w; y++)
@ -1240,7 +1240,7 @@ static int check_errors(const game_state *state, long *errors)
errors[right] |= err << EF_RIGHT_SHIFT;
}
}
errs = TRUE;
errs = true;
}
return errs;
@ -1452,7 +1452,7 @@ static game_state *execute_move(const game_state *from, const char *move)
if (move[0] == 'S') {
ret = dup_game(from);
ret->completed = ret->cheated = TRUE;
ret->completed = ret->cheated = true;
for (i = 0; i < a; i++) {
if (!ISCHAR(move[i+1]) || FROMCHAR(move[i+1], from->par.id) > w) {
@ -1502,7 +1502,7 @@ static game_state *execute_move(const game_state *from, const char *move)
}
if (!ret->completed && !check_errors(ret, NULL))
ret->completed = TRUE;
ret->completed = true;
return ret;
} else if (move[0] == 'M') {
@ -1621,7 +1621,7 @@ static game_drawstate *game_new_drawstate(drawing *dr, const game_state *state)
ds->w = w;
ds->par = state->par; /* structure copy */
ds->tilesize = 0;
ds->started = FALSE;
ds->started = false;
ds->tiles = snewn(a, long);
ds->legend = snewn(w, long);
ds->pencil = snewn(a, long);
@ -1845,7 +1845,7 @@ static void game_redraw(drawing *dr, game_drawstate *ds,
draw_update(dr, 0, 0, SIZE(w), SIZE(w));
ds->started = TRUE;
ds->started = true;
}
check_errors(state, ds->errtmp);
@ -1976,8 +1976,8 @@ static int game_status(const game_state *state)
static bool game_timing_state(const game_state *state, game_ui *ui)
{
if (state->completed)
return FALSE;
return TRUE;
return false;
return true;
}
static void game_print_size(const game_params *params, float *x, float *y)
@ -2068,15 +2068,15 @@ const struct game thegame = {
encode_params,
free_params,
dup_params,
TRUE, game_configure, custom_params,
true, game_configure, custom_params,
validate_params,
new_game_desc,
validate_desc,
new_game,
dup_game,
free_game,
TRUE, solve_game,
TRUE, game_can_format_as_text_now, game_text_format,
true, solve_game,
true, game_can_format_as_text_now, game_text_format,
new_ui,
free_ui,
encode_ui,
@ -2093,9 +2093,9 @@ const struct game thegame = {
game_anim_length,
game_flash_length,
game_status,
TRUE, FALSE, game_print_size, game_print,
FALSE, /* wants_statusbar */
FALSE, game_timing_state,
true, false, game_print_size, game_print,
false, /* wants_statusbar */
false, game_timing_state,
REQUIRE_RBUTTON | REQUIRE_NUMPAD, /* flags */
};
@ -2110,15 +2110,15 @@ int main(int argc, char **argv)
char *id = NULL, *desc;
const char *err;
digit *grid;
int grade = FALSE;
int ret, diff, really_show_working = FALSE;
int grade = false;
int ret, diff, really_show_working = false;
while (--argc > 0) {
char *p = *++argv;
if (!strcmp(p, "-v")) {
really_show_working = TRUE;
really_show_working = true;
} else if (!strcmp(p, "-g")) {
grade = TRUE;
grade = true;
} else if (*p == '-') {
fprintf(stderr, "%s: unrecognised option `%s'\n", argv[0], p);
return 1;
@ -2156,7 +2156,7 @@ int main(int argc, char **argv)
* the puzzle internally before doing anything else.
*/
ret = -1; /* placate optimiser */
solver_show_working = FALSE;
solver_show_working = false;
for (diff = 0; diff < DIFFCOUNT; diff++) {
memcpy(grid, s->grid, p->w * p->w);
ret = solver(&s->par, grid, diff);

View File

@ -182,8 +182,8 @@ struct operation {
int commutes;
/*
* Function which implements the operator. Returns TRUE on
* success, FALSE on failure. Takes two rationals and writes
* Function which implements the operator. Returns true on
* success, false on failure. Takes two rationals and writes
* out a third.
*/
int (*perform)(int *a, int *b, int *output);
@ -196,21 +196,21 @@ struct rules {
#define MUL(r, a, b) do { \
(r) = (a) * (b); \
if ((b) && (a) && (r) / (b) != (a)) return FALSE; \
if ((b) && (a) && (r) / (b) != (a)) return false; \
} while (0)
#define ADD(r, a, b) do { \
(r) = (a) + (b); \
if ((a) > 0 && (b) > 0 && (r) < 0) return FALSE; \
if ((a) < 0 && (b) < 0 && (r) > 0) return FALSE; \
if ((a) > 0 && (b) > 0 && (r) < 0) return false; \
if ((a) < 0 && (b) < 0 && (r) > 0) return false; \
} while (0)
#define OUT(output, n, d) do { \
int g = gcd((n),(d)); \
if (g < 0) g = -g; \
if ((d) < 0) g = -g; \
if (g == -1 && (n) < -INT_MAX) return FALSE; \
if (g == -1 && (d) < -INT_MAX) return FALSE; \
if (g == -1 && (n) < -INT_MAX) return false; \
if (g == -1 && (d) < -INT_MAX) return false; \
(output)[0] = (n)/g; \
(output)[1] = (d)/g; \
assert((output)[1] > 0); \
@ -238,7 +238,7 @@ static int perform_add(int *a, int *b, int *output)
ADD(tn, at, bt);
MUL(bn, a[1], b[1]);
OUT(output, tn, bn);
return TRUE;
return true;
}
static int perform_sub(int *a, int *b, int *output)
@ -252,7 +252,7 @@ static int perform_sub(int *a, int *b, int *output)
ADD(tn, at, -bt);
MUL(bn, a[1], b[1]);
OUT(output, tn, bn);
return TRUE;
return true;
}
static int perform_mul(int *a, int *b, int *output)
@ -264,7 +264,7 @@ static int perform_mul(int *a, int *b, int *output)
MUL(tn, a[0], b[0]);
MUL(bn, a[1], b[1]);
OUT(output, tn, bn);
return TRUE;
return true;
}
static int perform_div(int *a, int *b, int *output)
@ -275,7 +275,7 @@ static int perform_div(int *a, int *b, int *output)
* Division by zero is outlawed.
*/
if (b[0] == 0)
return FALSE;
return false;
/*
* a0/a1 / b0/b1 = (a0*b1) / (a1*b0)
@ -283,7 +283,7 @@ static int perform_div(int *a, int *b, int *output)
MUL(tn, a[0], b[1]);
MUL(bn, a[1], b[0]);
OUT(output, tn, bn);
return TRUE;
return true;
}
static int perform_exact_div(int *a, int *b, int *output)
@ -294,7 +294,7 @@ static int perform_exact_div(int *a, int *b, int *output)
* Division by zero is outlawed.
*/
if (b[0] == 0)
return FALSE;
return false;
/*
* a0/a1 / b0/b1 = (a0*b1) / (a1*b0)
@ -324,9 +324,9 @@ static int max_p10(int n, int *p10_r)
while (p10 <= (INT_MAX/10) && p10 <= n)
p10 *= 10;
if (p10 > INT_MAX/10)
return FALSE; /* integer overflow */
return false; /* integer overflow */
*p10_r = p10;
return TRUE;
return true;
}
static int perform_concat(int *a, int *b, int *output)
@ -338,7 +338,7 @@ static int perform_concat(int *a, int *b, int *output)
* integer.
*/
if (a[1] != 1 || b[1] != 1 || a[0] < 0 || b[0] < 0)
return FALSE;
return false;
/*
* For concatenation, we can safely assume leading zeroes
@ -357,14 +357,14 @@ static int perform_concat(int *a, int *b, int *output)
* _end_ of the 1 first.
*/
if (a[0] == 0)
return FALSE;
return false;
if (!max_p10(b[0], &p10)) return FALSE;
if (!max_p10(b[0], &p10)) return false;
MUL(t1, p10, a[0]);
ADD(t2, t1, b[0]);
OUT(output, t2, 1);
return TRUE;
return true;
}
#define IPOW(ret, x, y) do { \
@ -400,7 +400,7 @@ static int perform_exp(int *a, int *b, int *output)
IPOW(xn, an, b[1]);
IPOW(xd, ad, b[1]);
if (xn != a[0] || xd != a[1])
return FALSE;
return false;
} else {
an = a[0];
ad = a[1];
@ -413,10 +413,10 @@ static int perform_exp(int *a, int *b, int *output)
IPOW(xn, ad, -b[0]);
}
if (xd == 0)
return FALSE;
return false;
OUT(output, xn, xd);
return TRUE;
return true;
}
static int perform_factorial(int *a, int *b, int *output)
@ -427,14 +427,14 @@ static int perform_factorial(int *a, int *b, int *output)
* Factorials of non-negative integers are permitted.
*/
if (a[1] != 1 || a[0] < 0)
return FALSE;
return false;
/*
* However, a special case: we don't take a factorial of
* anything which would thereby remain the same.
*/
if (a[0] == 1 || a[0] == 2)
return FALSE;
return false;
ret = 1;
for (i = 1; i <= a[0]; i++) {
@ -443,7 +443,7 @@ static int perform_factorial(int *a, int *b, int *output)
}
OUT(output, ret, 1);
return TRUE;
return true;
}
static int perform_decimal(int *a, int *b, int *output)
@ -458,12 +458,12 @@ static int perform_decimal(int *a, int *b, int *output)
* x --> x / (smallest power of 10 > than x)
*
*/
if (a[1] != 1) return FALSE;
if (a[1] != 1) return false;
if (!max_p10(a[0], &p10)) return FALSE;
if (!max_p10(a[0], &p10)) return false;
OUT(output, a[0], p10);
return TRUE;
return true;
}
static int perform_recur(int *a, int *b, int *output)
@ -478,20 +478,20 @@ static int perform_recur(int *a, int *b, int *output)
* returning if no such power of 10 exists. Then multiply the numerator
* up accordingly, and the new denominator becomes that power of 10 - 1.
*/
if (abs(a[0]) >= abs(a[1])) return FALSE; /* -1 < a < 1 */
if (abs(a[0]) >= abs(a[1])) return false; /* -1 < a < 1 */
p10 = 10;
while (p10 <= (INT_MAX/10)) {
if ((a[1] <= p10) && (p10 % a[1]) == 0) goto found;
p10 *= 10;
}
return FALSE;
return false;
found:
tn = a[0] * (p10 / a[1]);
bn = p10 - 1;
OUT(output, tn, bn);
return TRUE;
return true;
}
static int perform_root(int *a, int *b, int *output)
@ -504,7 +504,7 @@ static int perform_root(int *a, int *b, int *output)
if (a[0] == 0) {
OUT(output, 1, 1);
return TRUE;
return true;
}
OUT(ainv, a[1], a[0]);
@ -514,11 +514,11 @@ static int perform_root(int *a, int *b, int *output)
static int perform_perc(int *a, int *b, int *output)
{
if (a[0] == 0) return FALSE; /* 0% = 0, uninteresting. */
if (a[1] > (INT_MAX/100)) return FALSE;
if (a[0] == 0) return false; /* 0% = 0, uninteresting. */
if (a[1] > (INT_MAX/100)) return false;
OUT(output, a[0], a[1]*100);
return TRUE;
return true;
}
static int perform_gamma(int *a, int *b, int *output)
@ -531,7 +531,7 @@ static int perform_gamma(int *a, int *b, int *output)
* special case not caught by perform_fact: gamma(1) is 1 so
* don't bother.
*/
if (a[0] == 1 && a[1] == 1) return FALSE;
if (a[0] == 1 && a[1] == 1) return false;
OUT(asub1, a[0]-a[1], a[1]);
return perform_factorial(asub1, b, output);
@ -544,53 +544,53 @@ static int perform_sqrt(int *a, int *b, int *output)
/*
* sqrt(0) == 0, sqrt(1) == 1: don't perform unary noops.
*/
if (a[0] == 0 || (a[0] == 1 && a[1] == 1)) return FALSE;
if (a[0] == 0 || (a[0] == 1 && a[1] == 1)) return false;
return perform_exp(a, half, output);
}
const static struct operation op_add = {
TRUE, "+", "+", 0, 10, 0, TRUE, perform_add
true, "+", "+", 0, 10, 0, true, perform_add
};
const static struct operation op_sub = {
TRUE, "-", "-", 0, 10, 2, FALSE, perform_sub
true, "-", "-", 0, 10, 2, false, perform_sub
};
const static struct operation op_mul = {
TRUE, "*", "*", 0, 20, 0, TRUE, perform_mul
true, "*", "*", 0, 20, 0, true, perform_mul
};
const static struct operation op_div = {
TRUE, "/", "/", 0, 20, 2, FALSE, perform_div
true, "/", "/", 0, 20, 2, false, perform_div
};
const static struct operation op_xdiv = {
TRUE, "/", "/", 0, 20, 2, FALSE, perform_exact_div
true, "/", "/", 0, 20, 2, false, perform_exact_div
};
const static struct operation op_concat = {
FALSE, "", "concat", OPFLAG_NEEDS_CONCAT | OPFLAG_KEEPS_CONCAT,
1000, 0, FALSE, perform_concat
false, "", "concat", OPFLAG_NEEDS_CONCAT | OPFLAG_KEEPS_CONCAT,
1000, 0, false, perform_concat
};
const static struct operation op_exp = {
TRUE, "^", "^", 0, 30, 1, FALSE, perform_exp
true, "^", "^", 0, 30, 1, false, perform_exp
};
const static struct operation op_factorial = {
TRUE, "!", "!", OPFLAG_UNARY, 40, 0, FALSE, perform_factorial
true, "!", "!", OPFLAG_UNARY, 40, 0, false, perform_factorial
};
const static struct operation op_decimal = {
TRUE, ".", ".", OPFLAG_UNARY | OPFLAG_UNARYPREFIX | OPFLAG_NEEDS_CONCAT | OPFLAG_KEEPS_CONCAT, 50, 0, FALSE, perform_decimal
true, ".", ".", OPFLAG_UNARY | OPFLAG_UNARYPREFIX | OPFLAG_NEEDS_CONCAT | OPFLAG_KEEPS_CONCAT, 50, 0, false, perform_decimal
};
const static struct operation op_recur = {
TRUE, "...", "recur", OPFLAG_UNARY | OPFLAG_NEEDS_CONCAT, 45, 2, FALSE, perform_recur
true, "...", "recur", OPFLAG_UNARY | OPFLAG_NEEDS_CONCAT, 45, 2, false, perform_recur
};
const static struct operation op_root = {
TRUE, "v~", "root", 0, 30, 1, FALSE, perform_root
true, "v~", "root", 0, 30, 1, false, perform_root
};
const static struct operation op_perc = {
TRUE, "%", "%", OPFLAG_UNARY | OPFLAG_NEEDS_CONCAT, 45, 1, FALSE, perform_perc
true, "%", "%", OPFLAG_UNARY | OPFLAG_NEEDS_CONCAT, 45, 1, false, perform_perc
};
const static struct operation op_gamma = {
TRUE, "gamma", "gamma", OPFLAG_UNARY | OPFLAG_UNARYPREFIX | OPFLAG_FN, 1, 3, FALSE, perform_gamma
true, "gamma", "gamma", OPFLAG_UNARY | OPFLAG_UNARYPREFIX | OPFLAG_FN, 1, 3, false, perform_gamma
};
const static struct operation op_sqrt = {
TRUE, "v~", "sqrt", OPFLAG_UNARY | OPFLAG_UNARYPREFIX, 30, 1, FALSE, perform_sqrt
true, "v~", "sqrt", OPFLAG_UNARY | OPFLAG_UNARYPREFIX, 30, 1, false, perform_sqrt
};
/*
@ -601,7 +601,7 @@ const static struct operation *const ops_countdown[] = {
&op_add, &op_mul, &op_sub, &op_xdiv, NULL
};
const static struct rules rules_countdown = {
ops_countdown, FALSE
ops_countdown, false
};
/*
@ -613,7 +613,7 @@ const static struct operation *const ops_3388[] = {
&op_add, &op_mul, &op_sub, &op_div, NULL
};
const static struct rules rules_3388 = {
ops_3388, TRUE
ops_3388, true
};
/*
@ -624,7 +624,7 @@ const static struct operation *const ops_four4s[] = {
&op_add, &op_mul, &op_sub, &op_div, &op_concat, NULL
};
const static struct rules rules_four4s = {
ops_four4s, TRUE
ops_four4s, true
};
/*
@ -636,7 +636,7 @@ const static struct operation *const ops_anythinggoes[] = {
&op_decimal, &op_recur, &op_root, &op_perc, &op_gamma, &op_sqrt, NULL
};
const static struct rules rules_anythinggoes = {
ops_anythinggoes, TRUE
ops_anythinggoes, true
};
#define ratcmp(a,op,b) ( (long long)(a)[0] * (b)[1] op \
@ -805,7 +805,7 @@ static int addoutput(struct sets *s, struct set *ss, int index, int *n)
* Target numbers are always integers.
*/
if (ss->numbers[2*index+1] != 1)
return FALSE;
return false;
ensure(s->outputlists, s->outputlistsize, s->noutputs/OUTPUTLISTLEN+1,
struct output *);
@ -826,7 +826,7 @@ static int addoutput(struct sets *s, struct set *ss, int index, int *n)
s->noutputs++;
}
*n = o->number;
return TRUE;
return true;
}
static struct sets *do_search(int ninputs, int *inputs,
@ -1095,16 +1095,16 @@ void print(int pathindex, struct sets *s, struct output *o)
*/
int main(int argc, char **argv)
{
int doing_opts = TRUE;
int doing_opts = true;
const struct rules *rules = NULL;
char *pname = argv[0];
int got_target = FALSE, target = 0;
int got_target = false, target = 0;
int numbers[10], nnumbers = 0;
int verbose = FALSE;
int pathcounts = FALSE;
int multiple = FALSE;
int debug_bfs = FALSE;
int got_range = FALSE, rangemin = 0, rangemax = 0;
int verbose = false;
int pathcounts = false;
int multiple = false;
int debug_bfs = false;
int got_range = false, rangemin = 0, rangemax = 0;
struct output *o;
struct sets *s;
@ -1118,12 +1118,12 @@ int main(int argc, char **argv)
p++;
if (!strcmp(p, "-")) {
doing_opts = FALSE;
doing_opts = false;
continue;
} else if (*p == '-') {
p++;
if (!strcmp(p, "debug-bfs")) {
debug_bfs = TRUE;
debug_bfs = true;
} else {
fprintf(stderr, "%s: option '--%s' not recognised\n",
pname, p);
@ -1142,13 +1142,13 @@ int main(int argc, char **argv)
rules = &rules_anythinggoes;
break;
case 'v':
verbose = TRUE;
verbose = true;
break;
case 'p':
pathcounts = TRUE;
pathcounts = true;
break;
case 'm':
multiple = TRUE;
multiple = true;
break;
case 't':
case 'r':
@ -1166,13 +1166,13 @@ int main(int argc, char **argv)
}
switch (c) {
case 't':
got_target = TRUE;
got_target = true;
target = atoi(v);
break;
case 'r':
{
char *sep = strchr(v, '-');
got_range = TRUE;
got_range = true;
if (sep) {
rangemin = atoi(v);
rangemax = atoi(sep+1);

View File

@ -201,17 +201,17 @@ static int is_endpoint(struct genctx *ctx, int x, int y)
c = ctx->grid[y*w+x];
if (c < 0)
return FALSE; /* empty square is not an endpoint! */
return false; /* empty square is not an endpoint! */
assert(c >= 0 && c < ctx->npaths);
if (ctx->pathends[c*2] == y*w+x || ctx->pathends[c*2+1] == y*w+x)
return TRUE;
return FALSE;
return true;
return false;
}
/*
* Tries to extend a path by one square in the given direction,
* pushing other paths around if necessary. Returns TRUE on success
* or FALSE on failure.
* pushing other paths around if necessary. Returns true on success
* or false on failure.
*/
static int extend_path(struct genctx *ctx, int path, int end, int direction)
{
@ -233,7 +233,7 @@ static int extend_path(struct genctx *ctx, int path, int end, int direction)
xe = x + DX(direction);
ye = y + DY(direction);
if (xe < 0 || xe >= w || ye < 0 || ye >= h)
return FALSE; /* could not extend in this direction */
return false; /* could not extend in this direction */
/*
* We don't extend paths _directly_ into endpoints of other
@ -242,13 +242,13 @@ static int extend_path(struct genctx *ctx, int path, int end, int direction)
* path's endpoint.
*/
if (is_endpoint(ctx, xe, ye))
return FALSE;
return false;
/*
* We can't extend a path back the way it came.
*/
if (ctx->grid[ye*w+xe] == path)
return FALSE;
return false;
/*
* Paths may not double back on themselves. Check if the new
@ -262,7 +262,7 @@ static int extend_path(struct genctx *ctx, int path, int end, int direction)
if (xf >= 0 && xf < w && yf >= 0 && yf < h &&
(xf != x || yf != y) && ctx->grid[yf*w+xf] == path)
return FALSE;
return false;
}
/*
@ -331,7 +331,7 @@ static int extend_path(struct genctx *ctx, int path, int end, int direction)
ctx->dist, ctx->list);
first = last = -1;
if (ctx->sparegrid3[ctx->pathends[i*2]] != i ||
ctx->sparegrid3[ctx->pathends[i*2+1]] != i) return FALSE;/* FIXME */
ctx->sparegrid3[ctx->pathends[i*2+1]] != i) return false;/* FIXME */
for (j = 0; j < n; j++) {
jp = ctx->list[j];
assert(ctx->dist[jp] == j);
@ -375,7 +375,7 @@ if (ctx->sparegrid3[ctx->pathends[i*2]] != i ||
}
if (first < 0 || last < 0)
return FALSE; /* path is completely wiped out! */
return false; /* path is completely wiped out! */
/*
* Now we've covered sparegrid3 in possible squares for
@ -393,7 +393,7 @@ if (ctx->sparegrid3[ctx->pathends[i*2]] != i ||
* any more. This means the entire push operation
* has failed.
*/
return FALSE;
return false;
}
/*
@ -407,7 +407,7 @@ if (ctx->sparegrid3[ctx->pathends[i*2]] != i ||
if (ctx->sparegrid[jp] >= 0) {
if (ctx->pathspare[ctx->sparegrid[jp]] == 2)
return FALSE; /* somehow we've hit a fixed path */
return false; /* somehow we've hit a fixed path */
ctx->pathspare[ctx->sparegrid[jp]] = 1; /* broken */
}
ctx->sparegrid[jp] = i;
@ -443,7 +443,7 @@ if (ctx->sparegrid3[ctx->pathends[i*2]] != i ||
*/
memcpy(ctx->grid, ctx->sparegrid, w*h*sizeof(int));
memcpy(ctx->pathends, ctx->sparepathends, ctx->npaths*2*sizeof(int));
return TRUE;
return true;
}
/*
@ -556,10 +556,10 @@ static int add_path(struct genctx *ctx, random_state *rs)
ctx->grid[j] = c;
}
return TRUE;
return true;
}
return FALSE;
return false;
}
/*

View File

@ -122,7 +122,7 @@ static game_params *default_params(void)
static bool game_fetch_preset(int i, char **name, game_params **params)
{
return FALSE;
return false;
}
static void free_params(game_params *params)
@ -337,7 +337,7 @@ int solver_attempt(struct solver_scratch *sc, const unsigned char *grid,
int w = sc->w, h = sc->h, k = sc->k;
int wh = w*h;
int i, x, y;
int done_something_overall = FALSE;
int done_something_overall = false;
/*
* Set up the contents array from the grid.
@ -348,7 +348,7 @@ int solver_attempt(struct solver_scratch *sc, const unsigned char *grid,
sc->contents[dsf_canonify(sc->dsf, i)*k+grid[i]] = i;
while (1) {
int done_something = FALSE;
int done_something = false;
/*
* Go over the grid looking for reasons to add to the
@ -393,7 +393,7 @@ int solver_attempt(struct solver_scratch *sc, const unsigned char *grid,
printf("Disconnecting %d and %d (%c)\n", yx, yx2, 'A'+i);
#endif
solver_disconnect(sc, yx, yx2);
done_something = done_something_overall = TRUE;
done_something = done_something_overall = true;
/*
* We have just made a deduction which hinges
@ -467,7 +467,7 @@ int solver_attempt(struct solver_scratch *sc, const unsigned char *grid,
printf("Connecting %d and %d\n", i, sc->tmp[i]);
#endif
solver_connect(sc, i, sc->tmp[i]);
done_something = done_something_overall = TRUE;
done_something = done_something_overall = true;
break;
}
}
@ -683,7 +683,7 @@ static char *solve_game(const game_state *state, const game_state *currstate,
static bool game_can_format_as_text_now(const game_params *params)
{
return TRUE;
return true;
}
static char *game_text_format(const game_state *state)
@ -805,7 +805,7 @@ static int game_status(const game_state *state)
static bool game_timing_state(const game_state *state, game_ui *ui)
{
return TRUE;
return true;
}
static void game_print_size(const game_params *params, float *x, float *y)
@ -828,15 +828,15 @@ const struct game thegame = {
encode_params,
free_params,
dup_params,
FALSE, game_configure, custom_params,
false, game_configure, custom_params,
validate_params,
new_game_desc,
validate_desc,
new_game,
dup_game,
free_game,
FALSE, solve_game,
FALSE, game_can_format_as_text_now, game_text_format,
false, solve_game,
false, game_can_format_as_text_now, game_text_format,
new_ui,
free_ui,
encode_ui,
@ -853,8 +853,8 @@ const struct game thegame = {
game_anim_length,
game_flash_length,
game_status,
FALSE, FALSE, game_print_size, game_print,
FALSE, /* wants_statusbar */
FALSE, game_timing_state,
false, false, game_print_size, game_print,
false, /* wants_statusbar */
false, game_timing_state,
0, /* flags */
};

View File

@ -174,7 +174,7 @@ static bool game_fetch_preset(int i, char **name, game_params **params)
char str[80];
if (i < 0 || i >= lenof(slide_presets))
return FALSE;
return false;
ret = snew(game_params);
*ret = slide_presets[i];
@ -187,7 +187,7 @@ static bool game_fetch_preset(int i, char **name, game_params **params)
*name = dupstr(str);
*params = ret;
return TRUE;
return true;
}
static void free_params(game_params *params)
@ -481,10 +481,10 @@ static int solve_board(int w, int h, unsigned char *board,
*/
for (i = 0; i < wh; i++) {
next[i] = -1;
anchors[i] = FALSE;
anchors[i] = false;
which[i] = -1;
if (ISANCHOR(b->data[i])) {
anchors[i] = TRUE;
anchors[i] = true;
which[i] = i;
} else if (ISDIST(b->data[i])) {
j = i - b->data[i];
@ -503,7 +503,7 @@ static int solve_board(int w, int h, unsigned char *board,
mqhead = mqtail = 0;
for (j = 0; j < wh; j++)
movereached[j] = FALSE;
movereached[j] = false;
movequeue[mqtail++] = i;
while (mqhead < mqtail) {
int pos = movequeue[mqhead++];
@ -542,7 +542,7 @@ static int solve_board(int w, int h, unsigned char *board,
*/
if (movereached[newpos])
continue;
movereached[newpos] = TRUE;
movereached[newpos] = true;
movequeue[mqtail++] = newpos;
/*
@ -656,7 +656,7 @@ static void generate_board(int w, int h, int *rtx, int *rty, int *minmoves,
forcefield = snewn(wh, unsigned char);
board2 = snewn(wh, unsigned char);
memset(board, ANCHOR, wh);
memset(forcefield, FALSE, wh);
memset(forcefield, false, wh);
for (i = 0; i < w; i++)
board[i] = board[i+w*(h-1)] = WALL;
for (i = 0; i < h; i++)
@ -680,7 +680,7 @@ static void generate_board(int w, int h, int *rtx, int *rty, int *minmoves,
*/
tx = w-2;
ty = h-3;
forcefield[ty*w+tx+1] = forcefield[(ty+1)*w+tx+1] = TRUE;
forcefield[ty*w+tx+1] = forcefield[(ty+1)*w+tx+1] = true;
board[ty*w+tx+1] = board[(ty+1)*w+tx+1] = EMPTY;
/*
@ -799,7 +799,7 @@ static void generate_board(int w, int h, int *rtx, int *rty, int *minmoves,
* Didn't work. Revert the merge.
*/
memcpy(board, board2, wh);
tried_merge[c1 * wh + c2] = tried_merge[c2 * wh + c1] = TRUE;
tried_merge[c1 * wh + c2] = tried_merge[c2 * wh + c1] = true;
} else {
int c;
@ -904,7 +904,7 @@ static const char *validate_desc(const game_params *params, const char *desc)
goto done;
}
link[i] = -1;
active[i] = FALSE;
active[i] = false;
if (*desc == 'f' || *desc == 'F') {
desc++;
if (!*desc) {
@ -937,8 +937,8 @@ static const char *validate_desc(const game_params *params, const char *desc)
link[i] = i - dist;
active[i] = TRUE;
active[link[i]] = FALSE;
active[i] = true;
active[link[i]] = false;
i++;
} else {
int c = *desc++;
@ -1016,12 +1016,12 @@ static game_state *new_game(midend *me, const game_params *params,
i = 0;
while (*desc && *desc != ',') {
int f = FALSE;
int f = false;
assert(i < wh);
if (*desc == 'f') {
f = TRUE;
f = true;
desc++;
assert(*desc);
}
@ -1072,7 +1072,7 @@ static game_state *new_game(midend *me, const game_params *params,
else
state->completed = -1;
state->cheated = FALSE;
state->cheated = false;
state->soln = NULL;
state->soln_index = -1;
@ -1166,7 +1166,7 @@ static char *solve_game(const game_state *state, const game_state *currstate,
static bool game_can_format_as_text_now(const game_params *params)
{
return TRUE;
return true;
}
static char *game_text_format(const game_state *state)
@ -1189,7 +1189,7 @@ static game_ui *new_ui(const game_state *state)
int w = state->w, h = state->h, wh = w*h;
game_ui *ui = snew(game_ui);
ui->dragging = FALSE;
ui->dragging = false;
ui->drag_anchor = ui->drag_currpos = -1;
ui->drag_offset_x = ui->drag_offset_y = -1;
ui->reachable = snewn(wh, unsigned char);
@ -1263,7 +1263,7 @@ static char *interpret_move(const game_state *state, game_ui *ui,
i -= state->board[i];
assert(i >= 0 && i < wh);
ui->dragging = TRUE;
ui->dragging = true;
ui->drag_anchor = i;
ui->drag_offset_x = tx - (i % w);
ui->drag_offset_y = ty - (i / w);
@ -1274,9 +1274,9 @@ static char *interpret_move(const game_state *state, game_ui *ui,
* the anchor, to find all the places to which this block
* can be dragged.
*/
memset(ui->reachable, FALSE, wh);
memset(ui->reachable, false, wh);
qhead = qtail = 0;
ui->reachable[i] = TRUE;
ui->reachable[i] = true;
ui->bfs_queue[qtail++] = i;
for (j = i; j < wh; j++)
if (state->board[j] == DIST(j - i))
@ -1334,7 +1334,7 @@ static char *interpret_move(const game_state *state, game_ui *ui,
* disqualifying this position, mark it as
* reachable for this drag.
*/
ui->reachable[newpos] = TRUE;
ui->reachable[newpos] = true;
ui->bfs_queue[qtail++] = newpos;
}
}
@ -1390,7 +1390,7 @@ static char *interpret_move(const game_state *state, game_ui *ui,
} else
str = ""; /* null move; just update the UI */
ui->dragging = FALSE;
ui->dragging = false;
ui->drag_anchor = ui->drag_currpos = -1;
ui->drag_offset_x = ui->drag_offset_y = -1;
memset(ui->reachable, 0, wh);
@ -1422,7 +1422,7 @@ static int move_piece(int w, int h, const unsigned char *src,
int i, j;
if (!ISANCHOR(dst[from]))
return FALSE;
return false;
/*
* Scan to the far end of the piece's linked list.
@ -1444,15 +1444,15 @@ static int move_piece(int w, int h, const unsigned char *src,
for (j = i; j >= 0; j = (ISDIST(src[j]) ? j - src[j] : -1)) {
int jn = j + to - from;
if (jn < 0 || jn >= wh)
return FALSE;
return false;
if (dst[jn] == EMPTY && (!ff[jn] || src[from] == MAINANCHOR)) {
dst[jn] = src[j];
} else {
return FALSE;
return false;
}
}
return TRUE;
return true;
}
static game_state *execute_move(const game_state *state, const char *move)
@ -1478,7 +1478,7 @@ static game_state *execute_move(const game_state *state, const char *move)
ret->soln->moves = NULL;
ret->soln->refcount = 1;
ret->soln_index = 0;
ret->cheated = TRUE;
ret->cheated = true;
movesize = 0;
move++;
@ -1673,7 +1673,7 @@ static game_drawstate *game_new_drawstate(drawing *dr, const game_state *state)
ds->tilesize = 0;
ds->w = w;
ds->h = h;
ds->started = FALSE;
ds->started = false;
ds->grid = snewn(wh, unsigned long);
for (i = 0; i < wh; i++)
ds->grid[i] = ~(unsigned long)0;
@ -2130,7 +2130,7 @@ static void game_redraw(drawing *dr, game_drawstate *ds,
* background-colour rectangle covering the whole window.
*/
draw_rect(dr, 0, 0, 10*ds->tilesize, 10*ds->tilesize, COL_BACKGROUND);
ds->started = TRUE;
ds->started = true;
}
/*
@ -2297,7 +2297,7 @@ static int game_status(const game_state *state)
static bool game_timing_state(const game_state *state, game_ui *ui)
{
return TRUE;
return true;
}
static void game_print_size(const game_params *params, float *x, float *y)
@ -2320,15 +2320,15 @@ const struct game thegame = {
encode_params,
free_params,
dup_params,
TRUE, game_configure, custom_params,
true, game_configure, custom_params,
validate_params,
new_game_desc,
validate_desc,
new_game,
dup_game,
free_game,
TRUE, solve_game,
TRUE, game_can_format_as_text_now, game_text_format,
true, solve_game,
true, game_can_format_as_text_now, game_text_format,
new_ui,
free_ui,
encode_ui,
@ -2345,9 +2345,9 @@ const struct game thegame = {
game_anim_length,
game_flash_length,
game_status,
FALSE, FALSE, game_print_size, game_print,
TRUE, /* wants_statusbar */
FALSE, game_timing_state,
false, false, game_print_size, game_print,
true, /* wants_statusbar */
false, game_timing_state,
0, /* flags */
};
@ -2360,7 +2360,7 @@ int main(int argc, char **argv)
game_params *p;
game_state *s;
char *id = NULL, *desc, *err;
int count = FALSE;
int count = false;
int ret;
int *moves;
@ -2368,11 +2368,11 @@ int main(int argc, char **argv)
char *p = *++argv;
/*
if (!strcmp(p, "-v")) {
verbose = TRUE;
verbose = true;
} else
*/
if (!strcmp(p, "-c")) {
count = TRUE;
count = true;
} else if (*p == '-') {
fprintf(stderr, "%s: unrecognised option `%s'\n", argv[0], p);
return 1;

View File

@ -169,7 +169,7 @@ static bool game_fetch_preset(int i, char **name, game_params **params)
char namebuf[80];
if (i < 0 || i >= lenof(sokoban_presets))
return FALSE;
return false;
p = sokoban_presets[i];
ret = dup_params(&p);
@ -178,7 +178,7 @@ static bool game_fetch_preset(int i, char **name, game_params **params)
*params = ret;
*name = retname;
return TRUE;
return true;
}
static void decode_params(game_params *params, char const *string)
@ -741,7 +741,7 @@ static char *new_game_desc(const game_params *params, random_state *rs,
* many moves to try?
*/
grid = snewn(w*h, unsigned char);
sokoban_generate(w, h, grid, w*h, FALSE, rs);
sokoban_generate(w, h, grid, w*h, false, rs);
desclen = descpos = descsize = 0;
desc = NULL;
@ -849,7 +849,7 @@ static game_state *new_game(midend *me, const game_params *params,
state->p = *params; /* structure copy */
state->grid = snewn(w*h, unsigned char);
state->px = state->py = -1;
state->completed = FALSE;
state->completed = false;
i = 0;
@ -906,7 +906,7 @@ static char *solve_game(const game_state *state, const game_state *currstate,
static bool game_can_format_as_text_now(const game_params *params)
{
return TRUE;
return true;
}
static char *game_text_format(const game_state *state)
@ -1158,20 +1158,20 @@ static game_state *execute_move(const game_state *state, const char *move)
* no free target squares, and no deep pits at all.
*/
if (!ret->completed) {
freebarrels = FALSE;
freetargets = FALSE;
freebarrels = false;
freetargets = false;
for (i = 0; i < w*h; i++) {
int v = ret->grid[i];
if (IS_BARREL(v) && !IS_ON_TARGET(v))
freebarrels = TRUE;
freebarrels = true;
if (v == DEEP_PIT || v == PIT ||
(!IS_BARREL(v) && IS_ON_TARGET(v)))
freetargets = TRUE;
freetargets = true;
}
if (!freebarrels || !freetargets)
ret->completed = TRUE;
ret->completed = true;
}
return ret;
@ -1261,7 +1261,7 @@ static game_drawstate *game_new_drawstate(drawing *dr, const game_state *state)
ds->grid = snewn(w*h, unsigned short);
for (i = 0; i < w*h; i++)
ds->grid[i] = INVALID;
ds->started = FALSE;
ds->started = false;
return ds;
}
@ -1371,7 +1371,7 @@ static void game_redraw(drawing *dr, game_drawstate *ds,
draw_line(dr, COORD(x), COORD(0), COORD(x), COORD(h),
COL_LOWLIGHT);
ds->started = TRUE;
ds->started = true;
}
/*
@ -1421,7 +1421,7 @@ static int game_status(const game_state *state)
static bool game_timing_state(const game_state *state, game_ui *ui)
{
return TRUE;
return true;
}
static void game_print_size(const game_params *params, float *x, float *y)
@ -1444,15 +1444,15 @@ const struct game thegame = {
encode_params,
free_params,
dup_params,
TRUE, game_configure, custom_params,
true, game_configure, custom_params,
validate_params,
new_game_desc,
validate_desc,
new_game,
dup_game,
free_game,
FALSE, solve_game,
FALSE, game_can_format_as_text_now, game_text_format,
false, solve_game,
false, game_can_format_as_text_now, game_text_format,
new_ui,
free_ui,
encode_ui,
@ -1469,8 +1469,8 @@ const struct game thegame = {
game_anim_length,
game_flash_length,
game_status,
FALSE, FALSE, game_print_size, game_print,
FALSE, /* wants_statusbar */
FALSE, game_timing_state,
false, false, game_print_size, game_print,
false, /* wants_statusbar */
false, game_timing_state,
0, /* flags */
};