commit 804e873b494a0b109fb6403a5d50c37afa6f4602
parent c3a8a49446041de85bc88b82b9b044ef78e1c0d6
Author: Andreas Gruhler <agruhl@gmx.ch>
Date: Fri, 8 Jan 2021 00:06:09 +0100
expand diary_dir from config
Diffstat:
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/diary.c b/diary.c
@@ -316,9 +316,13 @@ bool read_config(const char* file_path)
if (sscanf(line, "%s = %s", key_buf, value_buf) == 2) {
if (strcmp("diary_dir", key_buf) == 0) {
- // set diary directory from config file
- CONFIG.diary_dir = (char *) calloc(strlen(value_buf) + 1, sizeof(char));
- strcpy(CONFIG.diary_dir, value_buf);
+ wordexp_t diary_dir_wordexp;
+ if ( wordexp( value_buf, &diary_dir_wordexp, 0 ) == 0) {
+ // set expanded diary directory path from config file
+ CONFIG.diary_dir = (char *) calloc(strlen(diary_dir_wordexp.we_wordv[0]) + 1, sizeof(char));
+ strcpy(CONFIG.diary_dir, diary_dir_wordexp.we_wordv[0]);
+ }
+ wordfree(&diary_dir_wordexp);
} else if (strcmp("year_range", key_buf) == 0) {
CONFIG.year_range = atoi(value_buf);
} else if (strcmp("first_weekday", key_buf) == 0) {