summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--config.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/config.c b/config.c
index 537bb76..17dbf73 100644
--- a/config.c
+++ b/config.c
@@ -297,6 +297,7 @@ static void option_string_set(Settings *settings, const OptionString *opt, const
static void parse_section_header(ConfigReader *cfg, char *line, ConfigPart *part) {
#define SECTION_HEADER_HELP "Section headers should look like this: [(path//)(language.)section-name]"
+ Ted *ted = cfg->ted;
char *closing = strchr(line, ']');
if (!closing) {
config_err(cfg, "Unmatched [. " SECTION_HEADER_HELP);
@@ -310,8 +311,17 @@ static void parse_section_header(ConfigReader *cfg, char *line, ConfigPart *part
char *path_end = strstr(section, "//");
if (path_end) {
size_t path_len = (size_t)(path_end - section);
- // @TODO: expand ~
- part->context.path = strn_dup(section, path_len);
+ char path[TED_PATH_MAX];
+ path[0] = '\0';
+
+ // expand ~
+ if (section[0] == '~') {
+ str_cpy(path, sizeof path, ted->home);
+ ++section;
+ --path_len;
+ }
+ strn_cat(path, sizeof path, section, path_len);
+ part->context.path = str_dup(path);
section = path_end + 2;
}