Revert "libos: Make File::read_line optionally strip the ending newline"
All checks were successful
continuous-integration/drone/push Build is passing

This should be done by the caller, as making libos do it will not return a different value if the line was empty or was EOF.

Fortunately, we now have String::trim.
This commit is contained in:
apio 2023-04-22 15:21:04 +02:00
parent c075aa77b9
commit e378d8ee2f
Signed by: apio
GPG Key ID: B8A7D06E42258954
2 changed files with 3 additions and 7 deletions

View File

@ -33,7 +33,7 @@ namespace os
Result<void> write(StringView str); Result<void> write(StringView str);
Result<void> write(const Buffer& buf); Result<void> write(const Buffer& buf);
Result<String> read_line(bool keep_newline = true); Result<String> read_line();
Result<void> read(Buffer& buf, usize size); Result<void> read(Buffer& buf, usize size);

View File

@ -108,7 +108,7 @@ namespace os
return {}; return {};
} }
Result<String> File::read_line(bool keep_newline) Result<String> File::read_line()
{ {
Vector<char> data; Vector<char> data;
@ -121,11 +121,7 @@ namespace os
TRY(data.try_append((char)current)); TRY(data.try_append((char)current));
if (current == '\n') if (current == '\n') break;
{
if (!keep_newline) data.try_pop();
break;
}
} }
if (!data.size()) return String {}; if (!data.size()) return String {};