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 | Merge pull request #3386 from RedSoxFan/seat-reload-wait (diff) | |
download | sway-00f8d0209f814bb7c4c235383e4f00e32d964e31.tar.gz sway-00f8d0209f814bb7c4c235383e4f00e32d964e31.tar.zst sway-00f8d0209f814bb7c4c235383e4f00e32d964e31.zip |
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) | |||
601 | } | 601 | } |
602 | 602 | ||
603 | static int detect_brace(FILE *file) { | 603 | static int detect_brace(FILE *file) { |
604 | int ret = 0; | ||
604 | int lines = 0; | 605 | int lines = 0; |
605 | long pos = ftell(file); | 606 | long pos = ftell(file); |
606 | char *line = NULL; | 607 | char *line = NULL; |
@@ -609,15 +610,15 @@ static int detect_brace(FILE *file) { | |||
609 | lines++; | 610 | lines++; |
610 | strip_whitespace(line); | 611 | strip_whitespace(line); |
611 | if (*line) { | 612 | if (*line) { |
612 | if (strcmp(line, "{") != 0) { | 613 | if (strcmp(line, "{") == 0) { |
613 | fseek(file, pos, SEEK_SET); | 614 | ret = lines; |
614 | lines = 0; | ||
615 | } | 615 | } |
616 | break; | 616 | break; |
617 | } | 617 | } |
618 | } | 618 | } |
619 | free(line); | 619 | free(line); |
620 | return lines; | 620 | fseek(file, pos, SEEK_SET); |
621 | return ret; | ||
621 | } | 622 | } |
622 | 623 | ||
623 | static char *expand_line(const char *block, const char *line, bool add_brace) { | 624 | static char *expand_line(const char *block, const char *line, bool add_brace) { |