Fix config validation fail when no new line from end of file

1. i3 config validation failed when the new line is missing from the end of file.
   The error was: "ERROR: Your line continuation is too long, it exceeds 4096 bytes".
   It is wrong to assume that there is always a '\n' at the end of each line in the config file.
   (Not for the last line.)
   Fix it via adding a end-of-file check.

2. See the issue #2051. (https://github.com/i3/i3/issues/2051)
This commit is contained in:
hwangcc23 2015-11-02 22:12:44 +08:00
parent bb7a36e0c7
commit 18b3f09970
1 changed files with 1 additions and 1 deletions

View File

@ -843,7 +843,7 @@ bool parse_file(const char *f, bool use_nagbar) {
break;
die("Could not read configuration file\n");
}
if (buffer[strlen(buffer) - 1] != '\n') {
if (buffer[strlen(buffer) - 1] != '\n' && !feof(fstr)) {
ELOG("Your line continuation is too long, it exceeds %zd bytes\n", sizeof(buffer));
}
continuation = strstr(buffer, "\\\n");