diff options
Diffstat (limited to 'sway/config.c')
-rw-r--r-- | sway/config.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/sway/config.c b/sway/config.c index 12a02163..0aae1696 100644 --- a/sway/config.c +++ b/sway/config.c | |||
@@ -302,6 +302,11 @@ static char *get_config_path(void) { | |||
302 | const char *current_config_path; | 302 | const char *current_config_path; |
303 | 303 | ||
304 | static bool load_config(const char *path, struct sway_config *config) { | 304 | static bool load_config(const char *path, struct sway_config *config) { |
305 | if (path == NULL) { | ||
306 | wlr_log(L_ERROR, "Unable to find a config file!"); | ||
307 | return false; | ||
308 | } | ||
309 | |||
305 | wlr_log(L_INFO, "Loading config from %s", path); | 310 | wlr_log(L_INFO, "Loading config from %s", path); |
306 | current_config_path = path; | 311 | current_config_path = path; |
307 | 312 | ||
@@ -310,11 +315,6 @@ static bool load_config(const char *path, struct sway_config *config) { | |||
310 | return false; | 315 | return false; |
311 | } | 316 | } |
312 | 317 | ||
313 | if (path == NULL) { | ||
314 | wlr_log(L_ERROR, "Unable to find a config file!"); | ||
315 | return false; | ||
316 | } | ||
317 | |||
318 | FILE *f = fopen(path, "r"); | 318 | FILE *f = fopen(path, "r"); |
319 | if (!f) { | 319 | if (!f) { |
320 | wlr_log(L_ERROR, "Unable to open %s for reading", path); | 320 | wlr_log(L_ERROR, "Unable to open %s for reading", path); |
@@ -425,7 +425,7 @@ static bool load_include_config(const char *path, const char *parent_dir, | |||
425 | // save parent config | 425 | // save parent config |
426 | const char *parent_config = config->current_config; | 426 | const char *parent_config = config->current_config; |
427 | 427 | ||
428 | char *full_path = strdup(path); | 428 | char *full_path; |
429 | int len = strlen(path); | 429 | int len = strlen(path); |
430 | if (len >= 1 && path[0] != '/') { | 430 | if (len >= 1 && path[0] != '/') { |
431 | len = len + strlen(parent_dir) + 2; | 431 | len = len + strlen(parent_dir) + 2; |
@@ -436,6 +436,8 @@ static bool load_include_config(const char *path, const char *parent_dir, | |||
436 | return false; | 436 | return false; |
437 | } | 437 | } |
438 | snprintf(full_path, len, "%s/%s", parent_dir, path); | 438 | snprintf(full_path, len, "%s/%s", parent_dir, path); |
439 | } else { | ||
440 | full_path = strdup(path); | ||
439 | } | 441 | } |
440 | 442 | ||
441 | char *real_path = realpath(full_path, NULL); | 443 | char *real_path = realpath(full_path, NULL); |
@@ -583,6 +585,8 @@ bool read_config(FILE *file, struct sway_config *config) { | |||
583 | } | 585 | } |
584 | char *expanded = expand_line(block, line, brace_detected > 0); | 586 | char *expanded = expand_line(block, line, brace_detected > 0); |
585 | if (!expanded) { | 587 | if (!expanded) { |
588 | list_foreach(stack, free); | ||
589 | list_free(stack); | ||
586 | return false; | 590 | return false; |
587 | } | 591 | } |
588 | wlr_log(L_DEBUG, "Expanded line: %s", expanded); | 592 | wlr_log(L_DEBUG, "Expanded line: %s", expanded); |