1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

io: deprecate io.make_reader (not needed anymore)

This commit is contained in:
Delyan Angelov
2021-05-13 10:26:10 +03:00
parent 49deeac71e
commit 143c3d4bb4
11 changed files with 28 additions and 26 deletions

View File

@ -9,13 +9,13 @@ const (
// read_line is a *simple*, *non customizable*, blocking line reader.
// It will *always* return a line, ending with CRLF, or just '', on EOF.
// NB: if you want more control over the buffer, please use a buffered IO
// reader instead: `io.new_buffered_reader({reader: io.make_reader(con)})`
// reader instead: `io.new_buffered_reader(reader: con)`
pub fn (mut con TcpConn) read_line() string {
mut buf := [max_read]byte{} // where C.recv will store the network data
mut buf := [net.max_read]byte{} // where C.recv will store the network data
mut res := '' // The final result, including the ending \n.
for {
mut line := '' // The current line. Can be a partial without \n in it.
n := C.recv(con.sock.handle, &buf[0], max_read - 1, msg_peek | msg_nosignal)
n := C.recv(con.sock.handle, &buf[0], net.max_read - 1, net.msg_peek | msg_nosignal)
if n == -1 {
return res
}
@ -48,7 +48,7 @@ pub fn (mut con TcpConn) read_line() string {
// recv returned a buffer without \n in it .
C.recv(con.sock.handle, &buf[0], n, msg_nosignal)
res += line
res += crlf
res += net.crlf
break
}
return res