aboutsummaryrefslogtreecommitdiffstats
path: root/sway/config.c
diff options
context:
space:
mode:
authorLibravatar Ian Fan <ianfan0@gmail.com>2019-01-10 10:59:07 +0000
committerLibravatar Ian Fan <ianfan0@gmail.com>2019-01-10 10:59:07 +0000
commit00f8d0209f814bb7c4c235383e4f00e32d964e31 (patch)
tree3f4254c29184b3cef9b27f422b7b3d18e4b06bb9 /sway/config.c
parentMerge pull request #3386 from RedSoxFan/seat-reload-wait (diff)
downloadsway-00f8d0209f814bb7c4c235383e4f00e32d964e31.tar.gz
sway-00f8d0209f814bb7c4c235383e4f00e32d964e31.tar.zst
sway-00f8d0209f814bb7c4c235383e4f00e32d964e31.zip
config.c: fix brace detection at end of file
Diffstat (limited to 'sway/config.c')
-rw-r--r--sway/config.c9
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
603static int detect_brace(FILE *file) { 603static 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
623static char *expand_line(const char *block, const char *line, bool add_brace) { 624static char *expand_line(const char *block, const char *line, bool add_brace) {