diff options
author | Ian Fan <ianfan0@gmail.com> | 2019-01-10 10:59:07 +0000 |
---|---|---|
committer | Ian Fan <ianfan0@gmail.com> | 2019-01-10 10:59:07 +0000 |
commit | 00f8d0209f814bb7c4c235383e4f00e32d964e31 (patch) | |
tree | 3f4254c29184b3cef9b27f422b7b3d18e4b06bb9 | |
parent | d06782c5e71fb1a6229c1add16bae0dbf919c5c1 (diff) |
config.c: fix brace detection at end of file
-rw-r--r-- | sway/config.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/sway/config.c b/sway/config.c index dfbe4cb9..b2742327 100644 --- a/sway/config.c +++ b/sway/config.c @@ -601,6 +601,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; @@ -609,15 +610,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) { |