Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix includes with relative paths #8147

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 4 additions & 20 deletions sway/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -549,28 +549,12 @@ bool load_main_config(const char *file, bool is_active, bool validating) {
return success;
}

static bool load_include_config(const char *path, const char *parent_dir,
struct sway_config *config, struct swaynag_instance *swaynag) {
static bool load_include_config(const char *path, struct sway_config *config,
struct swaynag_instance *swaynag) {
// save parent config
const char *parent_config = config->current_config_path;

char *full_path;
int len = strlen(path);
if (len >= 1 && path[0] != '/') {
len = len + strlen(parent_dir) + 2;
full_path = malloc(len * sizeof(char));
if (!full_path) {
sway_log(SWAY_ERROR,
"Unable to allocate full path to included config");
return false;
}
snprintf(full_path, len, "%s/%s", parent_dir, path);
} else {
full_path = strdup(path);
}

char *real_path = realpath(full_path, NULL);
free(full_path);
char *real_path = realpath(path, NULL);

if (real_path == NULL) {
sway_log(SWAY_DEBUG, "%s not found.", path);
Expand Down Expand Up @@ -622,7 +606,7 @@ void load_include_configs(const char *path, struct sway_config *config,
char **w = p.we_wordv;
size_t i;
for (i = 0; i < p.we_wordc; ++i) {
load_include_config(w[i], parent_dir, config, swaynag);
load_include_config(w[i], config, swaynag);
}
wordfree(&p);
}
Expand Down