getline: check if newline at the end to not cut end of line

pull/691/head
Henrixounez 2019-06-27 02:08:36 +02:00 committed by Alexander Medvednikov
parent e57fbeee41
commit d24be8cf6c
1 changed files with 5 additions and 1 deletions

View File

@ -415,8 +415,12 @@ pub fn get_line() string {
if nr_chars == 0 { if nr_chars == 0 {
return '' return ''
} }
if buf[nr_chars - 1] == `\n` /* newline */ {
return tos(buf, nr_chars - 1) 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 { pub fn user_os() string {
$if linux { $if linux {