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:
parent
bb7a36e0c7
commit
18b3f09970
@ -843,7 +843,7 @@ bool parse_file(const char *f, bool use_nagbar) {
|
|||||||
break;
|
break;
|
||||||
die("Could not read configuration file\n");
|
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));
|
ELOG("Your line continuation is too long, it exceeds %zd bytes\n", sizeof(buffer));
|
||||||
}
|
}
|
||||||
continuation = strstr(buffer, "\\\n");
|
continuation = strstr(buffer, "\\\n");
|
||||||
|
Loading…
Reference in New Issue
Block a user