aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFurkan Sahin <furkan-dev@proton.me>2019-01-10 13:29:21 +0100
committerFurkan Sahin <furkan-dev@proton.me>2019-01-10 13:29:21 +0100
commit21edd31a3475c6fbcc19c96f0290b7c4fe39afd5 (patch)
tree7f5697b70e4c3c679b597adec003a90459f02e4a
parent4b3f95eee407e0b85b241dff645392c812a83396 (diff)
parent310faea5b36674bc9f078b183fb4120775dcec2a (diff)
Merge pull request #3400 from ianyfan/config-brace
config.c: fix brace detection at end of file
-rw-r--r--sway/config.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/sway/config.c b/sway/config.c
index f99f043c..ea9f23dd 100644
--- 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) {