From 599d0de094dcda705f165144ee107db1334c0ad3 Mon Sep 17 00:00:00 2001 From: Robin Lee Date: Thu, 13 Aug 2020 14:42:52 +0800 Subject: [PATCH] common: document the current semantics of bl::append(std::istream) bl::append(std::istream) comes with a surprise implementation. People may think it would just slurp the indentical binary data from the stream. Document the trap to let people don't mis-use it. Signed-off-by: Robin Lee --- src/include/buffer.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/include/buffer.h b/src/include/buffer.h index 725dd399095f9..4df15cd4aae6a 100644 --- a/src/include/buffer.h +++ b/src/include/buffer.h @@ -1132,6 +1132,11 @@ struct error_code; void append(ptr&& bp); void append(const ptr& bp, unsigned off, unsigned len); void append(const list& bl); + /// append each non-empty line from the stream and add '\n', + /// so a '\n' will be added even the stream does not end with EOL. + /// + /// For example, if the stream contains "ABC\n\nDEF", "ABC\nDEF\n" is + /// actually appended. void append(std::istream& in); contiguous_filler append_hole(unsigned len); void append_zero(unsigned len); -- 2.39.5