From fc7ac25a98aa1c4f0ac73d2e494d68ce9078acd1 Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Thu, 27 Jun 2019 02:12:50 +0200 Subject: [PATCH] Revert "Revert "getline: check if newline at the end to not cut end of line"" This reverts commit bda50e96f047ea9ff447ea57df0b0126734827b1. --- os/os.v | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/os/os.v b/os/os.v index 64dcfda16b..61ab53e0a9 100644 --- a/os/os.v +++ b/os/os.v @@ -415,7 +415,11 @@ pub fn get_line() string { if nr_chars == 0 { return '' } - return tos(buf, nr_chars - 1) + if buf[nr_chars - 1] == `\n` /* newline */ { + return tos(buf, nr_chars - 1) + } + /* To prevent cutting end of line if no newline */ + return tos(buf, nr_chars) } pub fn user_os() string {