Revert "libos: Make File::read_line optionally strip the ending newline"
All checks were successful
continuous-integration/drone/push Build is passing
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:
parent
c075aa77b9
commit
e378d8ee2f
@ -33,7 +33,7 @@ namespace os
|
||||
Result<void> write(StringView str);
|
||||
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);
|
||||
|
||||
|
@ -108,7 +108,7 @@ namespace os
|
||||
return {};
|
||||
}
|
||||
|
||||
Result<String> File::read_line(bool keep_newline)
|
||||
Result<String> File::read_line()
|
||||
{
|
||||
Vector<char> data;
|
||||
|
||||
@ -121,11 +121,7 @@ namespace os
|
||||
|
||||
TRY(data.try_append((char)current));
|
||||
|
||||
if (current == '\n')
|
||||
{
|
||||
if (!keep_newline) data.try_pop();
|
||||
break;
|
||||
}
|
||||
if (current == '\n') break;
|
||||
}
|
||||
|
||||
if (!data.size()) return String {};
|
||||
|
Loading…
Reference in New Issue
Block a user