Trim out \r from string

Fix #3490
This commit is contained in:
topjohnwu 2020-11-15 06:30:29 -08:00
parent 1469b82aa2
commit 0064b01ae0

View File

@ -340,7 +340,7 @@ void file_readline(bool trim, const char *file, const function<bool(string_view)
while ((read = getline(&buf, &len, fp)) >= 0) {
start = buf;
if (trim) {
while (read && (buf[read - 1] == '\n' || buf[read - 1] == ' '))
while (read && "\n\r "sv.find(buf[read - 1]) != string::npos)
--read;
buf[read] = '\0';
while (*start == ' ')