mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-04-02 07:15:31 -04:00
commit
35041cd431
3 changed files with 28 additions and 9 deletions
|
|
@ -35,6 +35,8 @@
|
||||||
* Window title in the CSDs
|
* Window title in the CSDs
|
||||||
(https://codeberg.org/dnkl/foot/issues/638).
|
(https://codeberg.org/dnkl/foot/issues/638).
|
||||||
* `-Ddocs=disabled|enabled|auto` meson command line option.
|
* `-Ddocs=disabled|enabled|auto` meson command line option.
|
||||||
|
* Support for `~`-expansion in the `include` directive
|
||||||
|
(https://codeberg.org/dnkl/foot/issues/659).
|
||||||
|
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
|
||||||
25
config.c
25
config.c
|
|
@ -644,12 +644,29 @@ parse_section_main(const char *key, const char *value, struct config *conf,
|
||||||
const char *path, unsigned lineno, bool errors_are_fatal)
|
const char *path, unsigned lineno, bool errors_are_fatal)
|
||||||
{
|
{
|
||||||
if (strcmp(key, "include") == 0) {
|
if (strcmp(key, "include") == 0) {
|
||||||
const char *include_path = value;
|
char *_include_path = NULL;
|
||||||
|
const char *include_path = NULL;
|
||||||
|
|
||||||
|
if (value[0] == '~' && value[1] == '/') {
|
||||||
|
const char *home_dir = get_user_home_dir();
|
||||||
|
|
||||||
|
if (home_dir == NULL) {
|
||||||
|
LOG_AND_NOTIFY_ERRNO(
|
||||||
|
"%s:%d: [default]: include: %s: failed to expand '~'",
|
||||||
|
path, lineno, value);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
_include_path = xasprintf("%s/%s", home_dir, value + 2);
|
||||||
|
include_path = _include_path;
|
||||||
|
} else
|
||||||
|
include_path = value;
|
||||||
|
|
||||||
if (include_path[0] != '/') {
|
if (include_path[0] != '/') {
|
||||||
LOG_AND_NOTIFY_ERR(
|
LOG_AND_NOTIFY_ERR(
|
||||||
"%s:%d: [default]: %s: not an absolute path",
|
"%s:%d: [default]: include: %s: not an absolute path",
|
||||||
path, lineno, include_path);
|
path, lineno, include_path);
|
||||||
|
free(_include_path);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -657,8 +674,9 @@ parse_section_main(const char *key, const char *value, struct config *conf,
|
||||||
|
|
||||||
if (include == NULL) {
|
if (include == NULL) {
|
||||||
LOG_AND_NOTIFY_ERRNO(
|
LOG_AND_NOTIFY_ERRNO(
|
||||||
"%s:%d: [default]: %s: failed to open",
|
"%s:%d: [default]: include: %s: failed to open",
|
||||||
path, lineno, include_path);
|
path, lineno, include_path);
|
||||||
|
free(_include_path);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -667,6 +685,7 @@ parse_section_main(const char *key, const char *value, struct config *conf,
|
||||||
fclose(include);
|
fclose(include);
|
||||||
|
|
||||||
LOG_INFO("imported sub-configuration from %s", include_path);
|
LOG_INFO("imported sub-configuration from %s", include_path);
|
||||||
|
free(_include_path);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -70,13 +70,11 @@ in this order:
|
||||||
The import file has its own section scope. I.e. the including
|
The import file has its own section scope. I.e. the including
|
||||||
configuration is still in the default section after the include,
|
configuration is still in the default section after the include,
|
||||||
regardless of which section the included file ends in.
|
regardless of which section the included file ends in.
|
||||||
|
|
||||||
The path must be an absolute path.
|
|
||||||
|
|
||||||
Multiple include directives are allowed, but only one path per
|
- The path must be an absolute path, or start with *~/*.
|
||||||
directive.
|
- Multiple include directives are allowed, but only one path per
|
||||||
|
directive.
|
||||||
Nested imports are allowed.
|
- Nested imports are allowed.
|
||||||
|
|
||||||
Default: _not set_.
|
Default: _not set_.
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue