|
|
@ -518,21 +518,20 @@ static int detect_brace_on_following_line(FILE *file, char *line,
|
|
|
|
int lines = 0;
|
|
|
|
int lines = 0;
|
|
|
|
if (line[strlen(line) - 1] != '{' && line[strlen(line) - 1] != '}') {
|
|
|
|
if (line[strlen(line) - 1] != '{' && line[strlen(line) - 1] != '}') {
|
|
|
|
char *peeked = NULL;
|
|
|
|
char *peeked = NULL;
|
|
|
|
|
|
|
|
long position = 0;
|
|
|
|
do {
|
|
|
|
do {
|
|
|
|
wlr_log(L_DEBUG, "Peeking line %d", line_number + lines + 1);
|
|
|
|
wlr_log(L_DEBUG, "Peeking line %d", line_number + lines + 1);
|
|
|
|
free(peeked);
|
|
|
|
free(peeked);
|
|
|
|
peeked = peek_line(file, lines);
|
|
|
|
peeked = peek_line(file, lines, &position);
|
|
|
|
if (peeked) {
|
|
|
|
if (peeked) {
|
|
|
|
peeked = strip_whitespace(peeked);
|
|
|
|
peeked = strip_whitespace(peeked);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
wlr_log(L_DEBUG, "Peeked line: `%s`", peeked);
|
|
|
|
lines++;
|
|
|
|
lines++;
|
|
|
|
} while (peeked && strlen(peeked) == 0);
|
|
|
|
} while (peeked && strlen(peeked) == 0);
|
|
|
|
|
|
|
|
|
|
|
|
if (peeked && strlen(peeked) == 1 && peeked[0] == '{') {
|
|
|
|
if (peeked && strlen(peeked) == 1 && peeked[0] == '{') {
|
|
|
|
for (int i = 0; i < lines; i++) {
|
|
|
|
fseek(file, position, SEEK_SET);
|
|
|
|
free(peeked);
|
|
|
|
|
|
|
|
peeked = read_line(file);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
lines = 0;
|
|
|
|
lines = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -541,7 +540,7 @@ static int detect_brace_on_following_line(FILE *file, char *line,
|
|
|
|
return lines;
|
|
|
|
return lines;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static char *expand_line(char *block, char *line, bool add_brace) {
|
|
|
|
static char *expand_line(const char *block, const char *line, bool add_brace) {
|
|
|
|
int size = (block ? strlen(block) + 1 : 0) + strlen(line)
|
|
|
|
int size = (block ? strlen(block) + 1 : 0) + strlen(line)
|
|
|
|
+ (add_brace ? 2 : 0) + 1;
|
|
|
|
+ (add_brace ? 2 : 0) + 1;
|
|
|
|
char *expanded = calloc(1, size);
|
|
|
|
char *expanded = calloc(1, size);
|
|
|
@ -549,10 +548,8 @@ static char *expand_line(char *block, char *line, bool add_brace) {
|
|
|
|
wlr_log(L_ERROR, "Cannot allocate expanded line buffer");
|
|
|
|
wlr_log(L_ERROR, "Cannot allocate expanded line buffer");
|
|
|
|
return NULL;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
strcat(expanded, block ? block : "");
|
|
|
|
snprintf(expanded, size, "%s%s%s%s", block ? block : "",
|
|
|
|
strcat(expanded, block ? " " : "");
|
|
|
|
block ? " " : "", line, add_brace ? " {" : "");
|
|
|
|
strcat(expanded, line);
|
|
|
|
|
|
|
|
strcat(expanded, add_brace ? " {" : "");
|
|
|
|
|
|
|
|
return expanded;
|
|
|
|
return expanded;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -594,9 +591,7 @@ bool read_config(FILE *file, struct sway_config *config) {
|
|
|
|
// Special case
|
|
|
|
// Special case
|
|
|
|
res = config_commands_command(expanded);
|
|
|
|
res = config_commands_command(expanded);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
wlr_log(L_DEBUG, "Entering c_c");
|
|
|
|
|
|
|
|
res = config_command(expanded);
|
|
|
|
res = config_command(expanded);
|
|
|
|
wlr_log(L_DEBUG, "Exiting c_c");
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
free(expanded);
|
|
|
|
free(expanded);
|
|
|
|
switch(res->status) {
|
|
|
|
switch(res->status) {
|
|
|
|