From a409d9fd5d861d52dca0e4ed33416a49b00ae2d9 Mon Sep 17 00:00:00 2001 From: Vito Caputo Date: Sun, 7 May 2023 20:05:38 -0700 Subject: setup: constify settings passed to setup_func setup_func isn't formally defined for libtil, but setup_interactively() defacto establishes it and til_module_t.setup() reflects the same signature and calling convention except with til_settings_t constified. This change makes them all consistent in this regard, but there should probably be a formal typedef added for the function. The reason for constifying this is I don't want setup functions directly manipulating the settings instance. In the case of rototiller::setup_interactively() we ensure the stdio-based interactive setup is always the side doing the manipulation of the settings. For a libtil-user like glimmer, it's slightly different beast with GTK+ in the loop, but by preventing the setup_funcs from messing directly with the settings (instead having to describe what they want done iteratively), the front-end always gets its opportunity to maintain its state while doing the described things. Of course, this is mostly a lie, and within libtil the constified til_settings_t gets cast away to modify it in places. But keeping that limited to within libtil is tolerable IMO. We just don't want to see such casts in module code. --- src/setup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/setup.c') diff --git a/src/setup.c b/src/setup.c index 7d413f9..f85ac10 100644 --- a/src/setup.c +++ b/src/setup.c @@ -23,7 +23,7 @@ static int add_value(til_settings_t *settings, const char *key, const char *valu /* returns negative on error, otherwise number of additions made to settings */ -int setup_interactively(til_settings_t *settings, int (*setup_func)(til_settings_t *settings, til_setting_t **res_setting, const til_setting_desc_t **res_desc, til_setup_t **res_setup), int defaults, til_setup_t **res_setup, const til_setting_desc_t **res_failed_desc) +int setup_interactively(til_settings_t *settings, int (*setup_func)(const til_settings_t *settings, til_setting_t **res_setting, const til_setting_desc_t **res_desc, til_setup_t **res_setup), int defaults, til_setup_t **res_setup, const til_setting_desc_t **res_failed_desc) { unsigned additions = 0; char buf[256] = "\n"; -- cgit v1.2.3