We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent ed95028 commit 8bc4ab8Copy full SHA for 8bc4ab8
1 file changed
vlib/os/os.c.v
@@ -615,8 +615,21 @@ pub fn get_raw_line() string {
615
} $else {
616
max := usize(0)
617
buf := &u8(unsafe { nil })
618
+
619
+ mut str := ''
620
nr_chars := unsafe { C.getline(voidptr(&buf), &max, C.stdin) }
- 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
633
ret := str.clone()
634
$if !autofree {
635
unsafe {
0 commit comments