From e378d8ee2f5948475f26a48e80d0365d689262d3 Mon Sep 17 00:00:00 2001 From: apio Date: Sat, 22 Apr 2023 15:21:04 +0200 Subject: [PATCH] Revert "libos: Make File::read_line optionally strip the ending newline" 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. --- libos/include/os/File.h | 2 +- libos/src/File.cpp | 8 ++------ 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/libos/include/os/File.h b/libos/include/os/File.h index 476fab1b..d26050da 100644 --- a/libos/include/os/File.h +++ b/libos/include/os/File.h @@ -33,7 +33,7 @@ namespace os Result write(StringView str); Result write(const Buffer& buf); - Result read_line(bool keep_newline = true); + Result read_line(); Result read(Buffer& buf, usize size); diff --git a/libos/src/File.cpp b/libos/src/File.cpp index 6387821d..9eb8b872 100644 --- a/libos/src/File.cpp +++ b/libos/src/File.cpp @@ -108,7 +108,7 @@ namespace os return {}; } - Result File::read_line(bool keep_newline) + Result File::read_line() { Vector 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 {};