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(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);
|
||||||
|
|
||||||
|
@ -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 {};
|
||||||
|
Loading…
Reference in New Issue
Block a user