File tree Expand file tree Collapse file tree 1 file changed +14
-1
lines changed
Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -615,8 +615,21 @@ pub fn get_raw_line() string {
615615 } $else {
616616 max := usize (0 )
617617 buf := & u8 (unsafe { nil })
618+
619+ mut str := ''
618620 nr_chars := unsafe { C.getline (voidptr (& buf), & max, C.stdin) }
619- str := unsafe { tos (buf, if nr_chars < 0 { 0 } else { nr_chars }) }
621+ // On OpenBSD, buf=0 for EOF => panic when calling tos function
622+ $if openbsd {
623+ if nr_chars != - 1 {
624+ str = unsafe { tos (buf, nr_chars) }
625+ } else {
626+ if int (C.feof (C.stdin)) == 0 && int (C.ferror (C.stdin)) != 0 {
627+ panic ('get_raw_line(): error to read string' )
628+ }
629+ }
630+ } $else {
631+ str = unsafe { tos (buf, if nr_chars < 0 { 0 } else { nr_chars }) }
632+ }
620633 ret := str.clone ()
621634 $if ! autofree {
622635 unsafe {
You can’t perform that action at this time.
0 commit comments