diff options
-rw-r--r-- | src/setup.c | 14 | ||||
-rw-r--r-- | src/til_settings.h | 1 |
2 files changed, 12 insertions, 3 deletions
diff --git a/src/setup.c b/src/setup.c index 6b8677f..7d413f9 100644 --- a/src/setup.c +++ b/src/setup.c @@ -46,14 +46,22 @@ int setup_interactively(til_settings_t *settings, int (*setup_func)(til_settings /* XXX FIXME: this key as value exception is janky, make a helper to access the value or stop doing that. */ r = til_setting_desc_check(desc, setting->value ? : setting->key); if (r < 0) { - /* TODO: send back desc to caller, caller must free. */ *res_failed_desc = desc; return r; } - /* XXX FIXME everything's constified necessitating this fuckery, revisit and cleanup later, prolly another til_settings helper */ - ((til_setting_t *)setting)->desc = desc; + if (desc->as_nested_settings && !setting->settings) { + setting->settings = til_settings_new(setting->key, setting->value); + if (!setting->settings) { + *res_failed_desc = desc; + + /* FIXME: til_settings_new() seems like it should return an errno, since it can encounter parse errors too? */ + return -ENOMEM; + }; + } + + setting->desc = desc; continue; } diff --git a/src/til_settings.h b/src/til_settings.h index d4822be..8911e6c 100644 --- a/src/til_settings.h +++ b/src/til_settings.h @@ -16,6 +16,7 @@ typedef struct til_setting_desc_t { const char **values; /* if a set of values is provided, listed here */ const char **annotations; /* if a set of values is provided, annotations for those values may be listed here */ char * (*random)(unsigned seed);/* if set, returns a valid random value for this setting */ + unsigned as_nested_settings:1; /* if set, this setting expects a settings string for its value and wants a nested til_setting_t.settings instance created for it */ } til_setting_desc_t; /* For conveniently representing setting description generators */ |