commit 212baf2f75dca0279759ce6c27cfc68541b1b922
parent 15ac580b28a2906d799fd709e83cb75e0efc3f45
Author: emersion <contact@emersion.fr>
Date: Thu, 10 Jan 2019 13:29:21 +0100
Merge pull request #3400 from ianyfan/config-brace
config.c: fix brace detection at end of file
Diffstat:
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/sway/config.c b/sway/config.c
@@ -597,6 +597,7 @@ static ssize_t getline_with_cont(char **lineptr, size_t *line_size, FILE *file)
}
static int detect_brace(FILE *file) {
+ int ret = 0;
int lines = 0;
long pos = ftell(file);
char *line = NULL;
@@ -605,15 +606,15 @@ static int detect_brace(FILE *file) {
lines++;
strip_whitespace(line);
if (*line) {
- if (strcmp(line, "{") != 0) {
- fseek(file, pos, SEEK_SET);
- lines = 0;
+ if (strcmp(line, "{") == 0) {
+ ret = lines;
}
break;
}
}
free(line);
- return lines;
+ fseek(file, pos, SEEK_SET);
+ return ret;
}
static char *expand_line(const char *block, const char *line, bool add_brace) {