mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-04-04 07:15:29 -04:00
config: add value_to_str()
Takes a pointer to a char*, free:s it, and strdups the current value.
This commit is contained in:
parent
c2127fb2de
commit
3b27a665da
1 changed files with 17 additions and 18 deletions
35
config.c
35
config.c
|
|
@ -524,6 +524,14 @@ value_to_double(struct context *ctx, double *res)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool NOINLINE
|
||||||
|
value_to_str(struct context *ctx, char **res)
|
||||||
|
{
|
||||||
|
free(*res);
|
||||||
|
*res = xstrdup(ctx->value);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
static bool NOINLINE
|
static bool NOINLINE
|
||||||
value_to_wchars(struct context *ctx, wchar_t **res)
|
value_to_wchars(struct context *ctx, wchar_t **res)
|
||||||
{
|
{
|
||||||
|
|
@ -825,32 +833,23 @@ parse_section_main(struct context *ctx)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (strcmp(key, "term") == 0) {
|
else if (strcmp(key, "term") == 0)
|
||||||
free(conf->term);
|
return value_to_str(ctx, &conf->term);
|
||||||
conf->term = xstrdup(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
else if (strcmp(key, "shell") == 0) {
|
else if (strcmp(key, "shell") == 0)
|
||||||
free(conf->shell);
|
return value_to_str(ctx, &conf->shell);
|
||||||
conf->shell = xstrdup(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
else if (strcmp(key, "login-shell") == 0) {
|
else if (strcmp(key, "login-shell") == 0)
|
||||||
return value_to_bool(ctx, &conf->login_shell);
|
return value_to_bool(ctx, &conf->login_shell);
|
||||||
}
|
|
||||||
|
|
||||||
else if (strcmp(key, "title") == 0) {
|
else if (strcmp(key, "title") == 0)
|
||||||
free(conf->title);
|
return value_to_str(ctx, &conf->title);
|
||||||
conf->title = xstrdup(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
else if (strcmp(key, "locked-title") == 0)
|
else if (strcmp(key, "locked-title") == 0)
|
||||||
return value_to_bool(ctx, &conf->locked_title);
|
return value_to_bool(ctx, &conf->locked_title);
|
||||||
|
|
||||||
else if (strcmp(key, "app-id") == 0) {
|
else if (strcmp(key, "app-id") == 0)
|
||||||
free(conf->app_id);
|
return value_to_str(ctx, &conf->app_id);
|
||||||
conf->app_id = xstrdup(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
else if (strcmp(key, "initial-window-size-pixels") == 0) {
|
else if (strcmp(key, "initial-window-size-pixels") == 0) {
|
||||||
unsigned width, height;
|
unsigned width, height;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue