summaryrefslogtreecommitdiffstats
path: root/sway/config.c
diff options
context:
space:
mode:
Diffstat (limited to 'sway/config.c')
-rw-r--r--sway/config.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/sway/config.c b/sway/config.c
index ea9f23dd..5ca4806c 100644
--- a/sway/config.c
+++ b/sway/config.c
@@ -387,6 +387,8 @@ bool load_main_config(const char *file, bool is_active, bool validating) {
387 memcpy(&config->swaynag_config_errors, 387 memcpy(&config->swaynag_config_errors,
388 &old_config->swaynag_config_errors, 388 &old_config->swaynag_config_errors,
389 sizeof(struct swaynag_instance)); 389 sizeof(struct swaynag_instance));
390
391 input_manager_reset_all_inputs();
390 } 392 }
391 393
392 config->current_config_path = path; 394 config->current_config_path = path;
@@ -571,15 +573,18 @@ bool load_include_configs(const char *path, struct sway_config *config,
571} 573}
572 574
573// get line, with backslash continuation 575// get line, with backslash continuation
574static ssize_t getline_with_cont(char **lineptr, size_t *line_size, FILE *file) { 576static ssize_t getline_with_cont(char **lineptr, size_t *line_size, FILE *file,
577 int *nlines) {
575 char *next_line = NULL; 578 char *next_line = NULL;
576 size_t next_line_size = 0; 579 size_t next_line_size = 0;
577 ssize_t nread = getline(lineptr, line_size, file); 580 ssize_t nread = getline(lineptr, line_size, file);
581 *nlines = nread == -1 ? 0 : 1;
578 while (nread >= 2 && strcmp(&(*lineptr)[nread - 2], "\\\n") == 0) { 582 while (nread >= 2 && strcmp(&(*lineptr)[nread - 2], "\\\n") == 0) {
579 ssize_t next_nread = getline(&next_line, &next_line_size, file); 583 ssize_t next_nread = getline(&next_line, &next_line_size, file);
580 if (next_nread == -1) { 584 if (next_nread == -1) {
581 break; 585 break;
582 } 586 }
587 (*nlines)++;
583 588
584 nread += next_nread - 2; 589 nread += next_nread - 2;
585 if ((ssize_t) *line_size < nread + 1) { 590 if ((ssize_t) *line_size < nread + 1) {
@@ -613,7 +618,9 @@ static int detect_brace(FILE *file) {
613 } 618 }
614 } 619 }
615 free(line); 620 free(line);
616 fseek(file, pos, SEEK_SET); 621 if (ret == 0) {
622 fseek(file, pos, SEEK_SET);
623 }
617 return ret; 624 return ret;
618} 625}
619 626
@@ -661,7 +668,8 @@ bool read_config(FILE *file, struct sway_config *config,
661 ssize_t nread; 668 ssize_t nread;
662 list_t *stack = create_list(); 669 list_t *stack = create_list();
663 size_t read = 0; 670 size_t read = 0;
664 while ((nread = getline_with_cont(&line, &line_size, file)) != -1) { 671 int nlines = 0;
672 while ((nread = getline_with_cont(&line, &line_size, file, &nlines)) != -1) {
665 if (reading_main_config) { 673 if (reading_main_config) {
666 if (read + nread > config_size) { 674 if (read + nread > config_size) {
667 wlr_log(WLR_ERROR, "Config file changed during reading"); 675 wlr_log(WLR_ERROR, "Config file changed during reading");
@@ -677,7 +685,7 @@ bool read_config(FILE *file, struct sway_config *config,
677 line[nread - 1] = '\0'; 685 line[nread - 1] = '\0';
678 } 686 }
679 687
680 line_number++; 688 line_number += nlines;
681 wlr_log(WLR_DEBUG, "Read line %d: %s", line_number, line); 689 wlr_log(WLR_DEBUG, "Read line %d: %s", line_number, line);
682 690
683 strip_whitespace(line); 691 strip_whitespace(line);