diff options
author | emersion <contact@emersion.fr> | 2019-01-10 13:29:21 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-01-10 13:29:21 +0100 |
commit | 212baf2f75dca0279759ce6c27cfc68541b1b922 (patch) | |
tree | 7f5697b70e4c3c679b597adec003a90459f02e4a /sway/config.c | |
parent | Merge pull request #3341 from RedSoxFan/mouse-bindings-improved (diff) | |
parent | config.c: fix brace detection at end of file (diff) | |
download | sway-212baf2f75dca0279759ce6c27cfc68541b1b922.tar.gz sway-212baf2f75dca0279759ce6c27cfc68541b1b922.tar.zst sway-212baf2f75dca0279759ce6c27cfc68541b1b922.zip |
Merge pull request #3400 from ianyfan/config-brace
config.c: fix brace detection at end of file
Diffstat (limited to 'sway/config.c')
-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 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) | |||
597 | } | 597 | } |
598 | 598 | ||
599 | static int detect_brace(FILE *file) { | 599 | static int detect_brace(FILE *file) { |
600 | int ret = 0; | ||
600 | int lines = 0; | 601 | int lines = 0; |
601 | long pos = ftell(file); | 602 | long pos = ftell(file); |
602 | char *line = NULL; | 603 | char *line = NULL; |
@@ -605,15 +606,15 @@ static int detect_brace(FILE *file) { | |||
605 | lines++; | 606 | lines++; |
606 | strip_whitespace(line); | 607 | strip_whitespace(line); |
607 | if (*line) { | 608 | if (*line) { |
608 | if (strcmp(line, "{") != 0) { | 609 | if (strcmp(line, "{") == 0) { |
609 | fseek(file, pos, SEEK_SET); | 610 | ret = lines; |
610 | lines = 0; | ||
611 | } | 611 | } |
612 | break; | 612 | break; |
613 | } | 613 | } |
614 | } | 614 | } |
615 | free(line); | 615 | free(line); |
616 | return lines; | 616 | fseek(file, pos, SEEK_SET); |
617 | return ret; | ||
617 | } | 618 | } |
618 | 619 | ||
619 | static char *expand_line(const char *block, const char *line, bool add_brace) { | 620 | static char *expand_line(const char *block, const char *line, bool add_brace) { |