Skip line continuation when it is a comment

Currently commented lines ending in the backslash character will be
concatenated with the following line.

```
 # with this comment \
exec swaynag -m 'will not run'
```

This change modifies `getline_with_cont` to stop reading when the
initial character is a '#'.
This commit is contained in:
Robert Günzler 2019-10-31 20:09:33 +01:00 committed by Simon Ser
parent 1a253ca7ab
commit 354e705a7b
1 changed files with 1 additions and 1 deletions

View File

@ -677,7 +677,7 @@ static ssize_t getline_with_cont(char **lineptr, size_t *line_size, FILE *file,
size_t next_line_size = 0;
ssize_t nread = getline(lineptr, line_size, file);
*nlines = nread == -1 ? 0 : 1;
while (nread >= 2 && strcmp(&(*lineptr)[nread - 2], "\\\n") == 0) {
while (nread >= 2 && strcmp(&(*lineptr)[nread - 2], "\\\n") == 0 && (*lineptr)[0] != '#') {
ssize_t next_nread = getline(&next_line, &next_line_size, file);
if (next_nread == -1) {
break;