aboutsummaryrefslogtreecommitdiff
path: root/midend.c
diff options
context:
space:
mode:
authorSimon Tatham <anakin@pobox.com>2017-10-01 13:38:35 +0100
committerSimon Tatham <anakin@pobox.com>2017-10-01 16:34:41 +0100
commitde67801b0fd3dfa11777c1ef86cd617baf376b7b (patch)
treef632daee458c8fefcfc90ff809c44672adeedaa4 /midend.c
parenteeb2db283de9115f7256fa4cc49597d63e06b0ab (diff)
downloadpuzzles-de67801b0fd3dfa11777c1ef86cd617baf376b7b.zip
puzzles-de67801b0fd3dfa11777c1ef86cd617baf376b7b.tar.gz
puzzles-de67801b0fd3dfa11777c1ef86cd617baf376b7b.tar.bz2
puzzles-de67801b0fd3dfa11777c1ef86cd617baf376b7b.tar.xz
Use a proper union in struct config_item.
This allows me to use different types for the mutable, dynamically allocated string value in a C_STRING control and the fixed constant list of option names in a C_CHOICES.
Diffstat (limited to 'midend.c')
-rw-r--r--midend.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/midend.c b/midend.c
index 913b322..1f5f077 100644
--- a/midend.c
+++ b/midend.c
@@ -1360,7 +1360,6 @@ config_item *midend_get_config(midend *me, int which, char **wintitle)
ret[0].name = "Game random seed";
else
ret[0].name = "Game ID";
- ret[0].ival = 0;
/*
* For CFG_DESC the text going in here will be a string
* encoding of the restricted parameters, plus a colon,
@@ -1379,13 +1378,12 @@ config_item *midend_get_config(midend *me, int which, char **wintitle)
rest = me->seedstr ? me->seedstr : "";
sep = '#';
}
- ret[0].sval = snewn(strlen(parstr) + strlen(rest) + 2, char);
- sprintf(ret[0].sval, "%s%c%s", parstr, sep, rest);
+ ret[0].u.string.sval = snewn(strlen(parstr) + strlen(rest) + 2, char);
+ sprintf(ret[0].u.string.sval, "%s%c%s", parstr, sep, rest);
sfree(parstr);
ret[1].type = C_END;
- ret[1].name = ret[1].sval = NULL;
- ret[1].ival = 0;
+ ret[1].name = NULL;
return ret;
}
@@ -1620,7 +1618,7 @@ char *midend_set_config(midend *me, int which, config_item *cfg)
case CFG_SEED:
case CFG_DESC:
- error = midend_game_id_int(me, cfg[0].sval,
+ error = midend_game_id_int(me, cfg[0].u.string.sval,
(which == CFG_SEED ? DEF_SEED : DEF_DESC));
if (error)
return error;