diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/setup.c | 16 | 
1 files changed, 15 insertions, 1 deletions
| diff --git a/src/setup.c b/src/setup.c index cf39f08..131c856 100644 --- a/src/setup.c +++ b/src/setup.c @@ -21,7 +21,12 @@ int setup_interactively(til_settings_t *settings, int (*setup_func)(const til_se  	/* TODO: regex and error handling */ -	while ((r = setup_func(settings, &setting, &desc, res_setup)) > 0) { +	/* until all the setup_funcs guarantee they return the failed setting on -EINVAL w/non-NULL res_setup (finalizing), +	 * this will be done in two steps; this first loop just constructs the settings heirarchy, and if it fails with +	 * -EINVAL we will use the setting for logging.  Then after this loop, one last recurrence of setup_func() w/res_setup +	 * actually set.  Once all setup_funcs behave well even in res_setup we'll go back to just the loop on setup_func(). +	 */ +	while ((r = setup_func(settings, &setting, &desc, NULL)) > 0) {  		assert(desc);  		additions++; @@ -170,5 +175,14 @@ _next:  		til_setting_desc_free(desc);  	} +	if (r < 0) { +		if (r == -EINVAL) +			*res_failed_desc = setting->desc; + +		return r; +	} + +	r = setup_func(settings, &setting, &desc, res_setup); +  	return r < 0 ? r : additions;  } | 
