commit 020b868b8abdd437fd1d22405f9165717c36a50a
parent 4517c10f0a3b8d6f38be8c392d8d7ca56bbe721b
Author: Drew DeVault <sir@cmpwn.com>
Date: Sun, 14 Mar 2021 16:13:41 -0400
os: use bufio::buffered for stdin
Diffstat:
1 file changed, 14 insertions(+), 6 deletions(-)
diff --git a/os/+linux/stdfd.ha b/os/+linux/stdfd.ha
@@ -1,11 +1,19 @@
+use bufio;
use io;
-let static_stdin: fd_stream = fd_stream { ... };
-let static_stdout: fd_stream = fd_stream { ... };
-let static_stderr: fd_stream = fd_stream { ... };
+let static_stdin_fd: fd_stream = fd_stream { ... };
+let static_stdout_fd: fd_stream = fd_stream { ... };
+let static_stderr_fd: fd_stream = fd_stream { ... };
+
+let static_stdin_bufio: bufio::bufstream = bufio::bufstream { ... };
+let static_stdout_bufio: bufio::bufstream = bufio::bufstream { ... };
+let static_stderr_bufio: bufio::bufstream = bufio::bufstream { ... };
@init fn init_stdfd() void = {
- stdin = static_fdopen(0, "<stdin>", io::mode::READ, &static_stdin);
- stdout = static_fdopen(1, "<stdout>", io::mode::WRITE, &static_stdout);
- stderr = static_fdopen(2, "<stderr>", io::mode::WRITE, &static_stderr);
+ stdin = static_fdopen(0, "<stdin>", io::mode::READ, &static_stdin_fd);
+ stdout = static_fdopen(1, "<stdout>", io::mode::WRITE, &static_stdout_fd);
+ stderr = static_fdopen(2, "<stderr>", io::mode::WRITE, &static_stderr_fd);
+
+ static let stdinbuf: [4096]u8 = [0...];
+ stdin = bufio::static_buffered(stdin, stdinbuf, [], &static_stdin_bufio);
};