summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/setup.c6
-rw-r--r--src/til.c6
-rw-r--r--src/til_settings.c12
-rw-r--r--src/til_settings.h2
4 files changed, 12 insertions, 14 deletions
diff --git a/src/setup.c b/src/setup.c
index dfeb4df..fe5803a 100644
--- a/src/setup.c
+++ b/src/setup.c
@@ -132,7 +132,7 @@ int setup_interactively(til_settings_t *settings, int (*setup_func)(const til_se
if (*buf == '\n') {
/* accept preferred */
- til_settings_add_value(desc->container, desc->spec.key, desc->spec.preferred, NULL);
+ til_settings_add_value(desc->container, desc->spec.key, desc->spec.preferred);
} else {
buf[strlen(buf) - 1] = '\0';
@@ -148,7 +148,7 @@ int setup_interactively(til_settings_t *settings, int (*setup_func)(const til_se
for (found = i = 0; desc->spec.values[i]; i++) {
if (i == j) {
- til_settings_add_value(desc->container, desc->spec.key, desc->spec.values[i], NULL);
+ til_settings_add_value(desc->container, desc->spec.key, desc->spec.values[i]);
found = 1;
break;
}
@@ -163,7 +163,7 @@ int setup_interactively(til_settings_t *settings, int (*setup_func)(const til_se
} else {
/* use typed input as setting, TODO: apply regex */
- til_settings_add_value(desc->container, desc->spec.key, buf, NULL);
+ til_settings_add_value(desc->container, desc->spec.key, buf);
}
}
_next:
diff --git a/src/til.c b/src/til.c
index 66f4870..0abcc17 100644
--- a/src/til.c
+++ b/src/til.c
@@ -395,7 +395,7 @@ int til_module_setup_randomize(const til_module_t *module, unsigned seed, til_se
char *value;
value = desc->spec.random(rand_r(&seed));
- setting = til_settings_add_value(desc->container, desc->spec.key, value, desc);
+ setting = til_settings_add_value(desc->container, desc->spec.key, value);
free(value);
} else if (desc->spec.values) {
int n;
@@ -404,9 +404,9 @@ int til_module_setup_randomize(const til_module_t *module, unsigned seed, til_se
n = rand_r(&seed) % n;
- setting = til_settings_add_value(desc->container, desc->spec.key, desc->spec.values[n], desc);
+ setting = til_settings_add_value(desc->container, desc->spec.key, desc->spec.values[n]);
} else {
- setting = til_settings_add_value(desc->container, desc->spec.key, desc->spec.preferred, desc);
+ setting = til_settings_add_value(desc->container, desc->spec.key, desc->spec.preferred);
}
}
diff --git a/src/til_settings.c b/src/til_settings.c
index 2811b72..cc988c0 100644
--- a/src/til_settings.c
+++ b/src/til_settings.c
@@ -47,7 +47,7 @@ typedef enum til_settings_fsm_state_t {
} til_settings_fsm_state_t;
-static til_setting_t * add_setting(til_settings_t *settings, const char *key, const char *value, const til_setting_desc_t *desc)
+static til_setting_t * add_setting(til_settings_t *settings, const char *key, const char *value)
{
til_setting_t **new_entries;
til_setting_t *s;
@@ -61,7 +61,6 @@ static til_setting_t * add_setting(til_settings_t *settings, const char *key, co
s->parent = settings;
s->key = key;
s->value = value;
- s->desc = desc;
new_entries = realloc(settings->entries, (settings->num + 1) * sizeof(til_setting_t *));
if (!new_entries) {
@@ -119,10 +118,10 @@ til_settings_t * til_settings_new(const til_settings_t *parent, const char *labe
fclose(value_fp);
if (*p == '=') { /* key= */
- (void) add_setting(settings, value_buf, NULL, NULL);
+ (void) add_setting(settings, value_buf, NULL);
state = TIL_SETTINGS_FSM_STATE_EQUAL;
} else { /* bare value */
- (void) add_setting(settings, NULL, value_buf, NULL);
+ (void) add_setting(settings, NULL, value_buf);
state = TIL_SETTINGS_FSM_STATE_COMMA;
}
} else
@@ -297,16 +296,15 @@ int til_settings_get_and_describe_value(const til_settings_t *settings, const ti
/* add key,value as a new setting to settings,
* NULL keys are passed through as-is
* values must not be NULL
- * desc may be NULL, it's simply passed along as a passenger.
*/
/* returns the added setting, or NULL on error (ENOMEM) */
-til_setting_t * til_settings_add_value(til_settings_t *settings, const char *key, const char *value, const til_setting_desc_t *desc)
+til_setting_t * til_settings_add_value(til_settings_t *settings, const char *key, const char *value)
{
assert(settings);
assert(value);
/* XXX: ^^ non-NULL values makes til_settings_get_value_by_idx() NULL-return-for-end-of-settings OK */
- return add_setting(settings, key ? strdup(key) : NULL, strdup(value), desc);
+ return add_setting(settings, key ? strdup(key) : NULL, strdup(value));
}
diff --git a/src/til_settings.h b/src/til_settings.h
index e0b1875..e2653e4 100644
--- a/src/til_settings.h
+++ b/src/til_settings.h
@@ -49,7 +49,7 @@ til_settings_t * til_settings_free(til_settings_t *settings);
unsigned til_settings_get_count(const til_settings_t *settings);
const char * til_settings_get_value_by_key(const til_settings_t *settings, const char *key, til_setting_t **res_setting);
const char * til_settings_get_value_by_idx(const til_settings_t *settings, unsigned idx, til_setting_t **res_setting);
-til_setting_t * til_settings_add_value(til_settings_t *settings, const char *key, const char *value, const til_setting_desc_t *desc);
+til_setting_t * til_settings_add_value(til_settings_t *settings, const char *key, const char *value);
void til_settings_reset_descs(til_settings_t *settings);
int til_settings_get_and_describe_value(const til_settings_t *settings, const til_setting_spec_t *spec, const char **res_value, til_setting_t **res_setting, const til_setting_desc_t **res_desc);
char * til_settings_as_arg(const til_settings_t *settings);
© All Rights Reserved