From 9a20f40bb5e7106f3fa59affbbb81f30337ada6b Mon Sep 17 00:00:00 2001 From: David Oberhollenzer Date: Sun, 4 Jun 2023 21:41:32 +0200 Subject: libio: istream_get_line: fix trailing CR sanitation The istream_get_line function is supposed to remove the line break, inclduing CR+LF if used. The previous implementation simply checked the buffer when the LF was found, missing the case where the CR was alraedy added and the LF is at the beginning of the newly loaded data. This commit modifies the check to inspect the line itself when it was found, and remove the CR after the fact. Signed-off-by: David Oberhollenzer --- lib/io/test/get_line.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/io/test/get_line.c') diff --git a/lib/io/test/get_line.c b/lib/io/test/get_line.c index bb06b3e..0ce67ac 100644 --- a/lib/io/test/get_line.c +++ b/lib/io/test/get_line.c @@ -20,7 +20,7 @@ static void run_test_case(const char *raw, const line_t *lines, size_t count, char *line; int ret; - fp = istream_memory_create("lines.txt", 512, raw, strlen(raw)); + fp = istream_memory_create("lines.txt", 2, raw, strlen(raw)); TEST_NOT_NULL(fp); line_num = 1; -- cgit v1.2.3