hautils

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit 7fe6f37a3c1e504c1f2c5b14eb7468335ed95397
parent 9d66bb8b11c00654db0abfa08997f71525d941aa
Author: Drew DeVault <sir@cmpwn.com>
Date:   Thu,  8 Jul 2021 15:04:33 -0400

head: don't double-buffer stdin

Diffstat:
Mhead.ha | 7+++----
1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/head.ha b/head.ha @@ -35,15 +35,14 @@ export fn utilmain() (void | main::error) = { file: *io::stream => file, }; defer io::close(file); + static let buf: [os::BUFSIZ]u8 = [0...]; + const file = bufio::buffered(file, buf, []); + defer io::close(file); head(file, n)?; }; }; fn head(in: *io::stream, n: uint) (void | main::error) = { - static let buf: [os::BUFSIZ]u8 = [0...]; - const in = bufio::buffered(in, buf, []); - defer io::close(in); - for (n > 0; n -= 1) { let line = match (bufio::scanline(in)) { err: io::error => return err,