summaryrefslogtreecommitdiff
path: root/src/til_settings.c
diff options
context:
space:
mode:
authorVito Caputo <vcaputo@pengaru.com>2023-08-03 17:02:57 -0700
committerVito Caputo <vcaputo@pengaru.com>2023-08-03 17:02:57 -0700
commitf2ad42777ddf96038e08a29cce81acc1b426ae1e (patch)
tree16ccbad5878899644449f93ed39b137b4d948485 /src/til_settings.c
parent595d5e8b54dde06d7f624d4e64458a2648477669 (diff)
til_settings: honor til_setting_t.nocheck in spec_check
Trivial refactor s/til_setting_spec_check/til_setting_check_spec/ so it operates on a til_setting_t as opposed to the bare value. With the containing til_setting_t onhand it can be responsible for bypassing the check when til_setting_t.nocheck is set. Adjusted callers in setup_interactively() and rkt_scener_update() accordingly.
Diffstat (limited to 'src/til_settings.c')
-rw-r--r--src/til_settings.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/til_settings.c b/src/til_settings.c
index eca937b..228a430 100644
--- a/src/til_settings.c
+++ b/src/til_settings.c
@@ -574,16 +574,24 @@ int til_setting_desc_fprint_path(const til_setting_desc_t *desc, FILE *out)
/* TODO: spec checking in general needs refinement and to be less intolerant of
* creative experimentation.
*/
-int til_setting_spec_check(const til_setting_spec_t *spec, const char *value)
+/* Check's setting's value against the provided spec.
+ * If setting->nocheck is set the check is skipped.
+ * If spec->as_nested_settings is set, no check is performed, as it's not really applicable until leaf settings
+ */
+int til_setting_check_spec(const til_setting_t *setting, const til_setting_spec_t *spec)
{
assert(spec);
- assert(value);
+ assert(setting);
+ assert(setting->value);
+
+ if (setting->nocheck)
+ return 0;
/* XXX: this check can't really be performed on anything but "leaf" settings. */
if (spec->values && !spec->as_nested_settings) {
for (int i = 0; spec->values[i]; i++) {
- if (!strcasecmp(spec->values[i], value))
+ if (!strcasecmp(spec->values[i], setting->value))
return 0;
}
© All Rights Reserved