Portability fixes, mostly from James for Palm purposes. Mostly

additions of missing 'static' and explicit 'void' in parameter lists,
plus one or two other things like explicitly casting chars in variadic
argument lists to int and using DBL_MAX if HUGE_VAL isn't available.

[originally from svn r9166]
This commit is contained in:
Simon Tatham
2011-05-04 18:41:21 +00:00
parent e7b2a9dd8d
commit 89bfecaa5a
5 changed files with 69 additions and 54 deletions

31
range.c
View File

@ -49,7 +49,7 @@
#define setmember(obj, field) ( (obj) . field = field )
char *nfmtstr(int n, char *fmt, ...) {
static char *nfmtstr(int n, char *fmt, ...) {
va_list va;
char *ret = snewn(n+1, char);
va_start(va, fmt);
@ -83,7 +83,7 @@ struct game_state {
};
#define DEFAULT_PRESET 0
static struct game_params presets[] = {{9, 6}, {12, 8}, {13, 9}, {16, 11}};
static struct game_params range_presets[] = {{9, 6}, {12, 8}, {13, 9}, {16, 11}};
/* rationale: I want all four combinations of {odd/even, odd/even}, as
* they play out differently with respect to two-way symmetry. I also
* want them to be generated relatively fast yet still be large enough
@ -95,7 +95,7 @@ static struct game_params presets[] = {{9, 6}, {12, 8}, {13, 9}, {16, 11}};
static game_params *default_params(void)
{
game_params *ret = snew(game_params);
*ret = presets[DEFAULT_PRESET]; /* structure copy */
*ret = range_presets[DEFAULT_PRESET]; /* structure copy */
return ret;
}
@ -108,10 +108,15 @@ static game_params *dup_params(game_params *params)
static int game_fetch_preset(int i, char **name, game_params **params)
{
if (i < 0 || i >= lenof(presets)) return FALSE;
game_params *ret;
*name = nfmtstr(40, "%d x %d", presets[i].w, presets[i].h);
*params = dup_params(&presets[i]);
if (i < 0 || i >= lenof(range_presets)) return FALSE;
ret = default_params();
*ret = range_presets[i]; /* struct copy */
*params = ret;
*name = nfmtstr(40, "%d x %d", range_presets[i].w, range_presets[i].h);
return TRUE;
}
@ -333,19 +338,19 @@ static move *solve_internal(game_state *state, move *base, int diff)
return moves;
}
static reasoning *const reasonings[] = {
solver_reasoning_not_too_big,
solver_reasoning_adjacency,
solver_reasoning_connectedness,
solver_reasoning_recursion
};
static move *do_solve(game_state *state,
int nclues,
const square *clues,
move *move_buffer,
int difficulty)
{
reasoning *reasonings[] = {
solver_reasoning_not_too_big,
solver_reasoning_adjacency,
solver_reasoning_connectedness,
solver_reasoning_recursion
};
struct move *buf = move_buffer, *oldbuf;
int i;