hare

[hare] The Hare programming language
git clone https://git.torresjrjr.com/hare.git
Log | Files | Refs | README | LICENSE

commit 37a1e42afa0bc3efa01417c99251f495c066087b
parent 4a75403ac7c53e7bb4bde78a30fe122aacf567c2
Author: Armin Preiml <apreiml@strohwolke.at>
Date:   Sat, 19 Aug 2023 20:36:49 +0200

use SZ as suffix for sizes in other modules

Signed-off-by: Armin Preiml <apreiml@strohwolke.at>

Diffstat:
Mbufio/scanner.ha | 8++++----
Mbufio/stream.ha | 4++--
Mcmd/hare/plan.ha | 2+-
Mcmd/harec/main.ha | 2+-
Mencoding/base32/base32.ha | 4++--
Mencoding/base64/base64.ha | 4++--
Mencoding/hex/hex.ha | 6+++---
Mencoding/pem/pem.ha | 2+-
Mformat/tar/reader.ha | 12++++++------
Mformat/tar/types.ha | 4++--
Mhare/lex/lex.ha | 2+-
Mhare/module/manifest.ha | 2+-
Mhare/module/scan.ha | 2+-
Mmime/system.ha | 2+-
Mos/+freebsd/stdfd.ha | 6+++---
Mos/+linux/stdfd.ha | 6+++---
Mstrconv/ftos.ha | 10+++++-----
Mtime/chrono/timezone.ha | 2+-
Mtime/chrono/tzdb.ha | 2+-
19 files changed, 41 insertions(+), 41 deletions(-)

diff --git a/bufio/scanner.ha b/bufio/scanner.ha @@ -9,7 +9,7 @@ use io; use strings; use types; -def BUFSIZ: size = 4096; +def BUFSZ: size = 4096; export type scanner = struct { src: io::handle, @@ -32,7 +32,7 @@ export type scanner = struct { export fn newscanner(src: io::handle, maxread: size) scanner = { return scanner { src = src, - buffer = alloc([0...], BUFSIZ), + buffer = alloc([0...], BUFSZ), maxread = maxread, pending = 0, readout = 0, @@ -60,13 +60,13 @@ export fn finish(scan: *scanner) void = { }; // Fills up the scanner buffer with data from the underlying I/O handle. If no -// space remains in the read buffer, it is expanded by BUFSIZ (up to maxread). +// space remains in the read buffer, it is expanded by BUFSZ (up to maxread). // Then, one read from the underlying I/O handle is performed and scan.pending // is updated accordingly. Returns the number of bytes which had been available // prior to the call. fn scan_readahead(scan: *scanner) (size | io::EOF | io::error) = { if (scan.pending >= len(scan.buffer)) { - let readahead = scan.pending + BUFSIZ; + let readahead = scan.pending + BUFSZ; if (readahead > scan.maxread) { readahead = scan.maxread; }; diff --git a/bufio/stream.ha b/bufio/stream.ha @@ -51,8 +51,8 @@ export type stream = struct { // The caller is responsible for closing the underlying stream, and freeing the // provided buffers if necessary, after the buffered stream is closed. // -// let rbuf: [os::BUFSIZ]u8 = [0...]; -// let wbuf: [os::BUFSIZ]u8 = [0...]; +// let rbuf: [os::BUFSZ]u8 = [0...]; +// let wbuf: [os::BUFSZ]u8 = [0...]; // let buffered = bufio::init(source, rbuf, wbuf); export fn init( src: io::handle, diff --git a/cmd/hare/plan.ha b/cmd/hare/plan.ha @@ -301,7 +301,7 @@ fn execute( let cleared = false; if (pipe.0 != 0) { for (true) { - let buf: [os::BUFSIZ]u8 = [0...]; + let buf: [os::BUFSZ]u8 = [0...]; match (io::read(pipe.0, buf)?) { case let n: size => if (!cleared) { diff --git a/cmd/harec/main.ha b/cmd/harec/main.ha @@ -69,7 +69,7 @@ export fn main() void = { cmd.args[i], fs::strerror(err)); }; defer io::close(input)!; - static let buf: [os::BUFSIZ]u8 = [0...]; + static let buf: [os::BUFSZ]u8 = [0...]; let bufin = bufio::init(input, buf, []); defer io::close(&bufin)!; diff --git a/encoding/base32/base32.ha b/encoding/base32/base32.ha @@ -277,8 +277,8 @@ fn decode_reader( return n; }; }; - static let buf: [os::BUFSIZ]u8 = [0...]; - static let obuf: [os::BUFSIZ / 8 * 5]u8 = [0...]; + static let buf: [os::BUFSZ]u8 = [0...]; + static let obuf: [os::BUFSZ / 8 * 5]u8 = [0...]; const nn = ((l - n) / 5 + 1) * 8; // 8 extra bytes may be read. let nr = 0z; for (nr < nn) { diff --git a/encoding/base64/base64.ha b/encoding/base64/base64.ha @@ -334,8 +334,8 @@ fn decode_reader( return n; }; }; - static let buf: [os::BUFSIZ]u8 = [0...]; - static let obuf: [os::BUFSIZ / 4 * 3]u8 = [0...]; + static let buf: [os::BUFSZ]u8 = [0...]; + static let obuf: [os::BUFSZ / 4 * 3]u8 = [0...]; const nn = ((l - n) / 3 + 1) * 4; // 4 extra bytes may be read. let nr = 0z; for (nr < nn) { diff --git a/encoding/hex/hex.ha b/encoding/hex/hex.ha @@ -130,10 +130,10 @@ fn decode_reader(s: *io::stream, out: []u8) (size | io::EOF | io::error) = { case void => yield; }; - static let buf: [os::BUFSIZ]u8 = [0...]; + static let buf: [os::BUFSZ]u8 = [0...]; let n = len(out) * 2; - if (n > os::BUFSIZ) { - n = os::BUFSIZ; + if (n > os::BUFSZ) { + n = os::BUFSZ; }; let nr = 0z; for (nr < n) { diff --git a/encoding/pem/pem.ha b/encoding/pem/pem.ha @@ -48,7 +48,7 @@ const b64stream_r_vt: io::vtable = io::vtable { // Creates a new PEM decoder. The caller must either read it until it returns // [[io::EOF]], or call [[finish]] to free state associated with the parser. export fn newdecoder(in: io::handle) decoder = { - let buf: []u8 = alloc([0...], os::BUFSIZ); + let buf: []u8 = alloc([0...], os::BUFSZ); return decoder { in = bufio::init(in, buf, []), buf = buf, diff --git a/format/tar/reader.ha b/format/tar/reader.ha @@ -31,7 +31,7 @@ export fn read(src: io::handle) reader = { // // Note that reading from the header will modify the file size. export fn next(rd: *reader) (entry | error | io::EOF) = { - static let buf: [BLOCKSIZE]u8 = [0...]; + static let buf: [BLOCKSZ]u8 = [0...]; match (io::read(rd.src, buf)?) { case let z: size => if (z != len(buf)) { @@ -107,8 +107,8 @@ export fn next(rd: *reader) (entry | error | io::EOF) = { // Seeks the underlying tar file to the entry following this one. export fn skip(ent: *entry) (void | io::error) = { let amt = ent.remain; - if (amt % BLOCKSIZE != 0) { - amt += BLOCKSIZE - (amt % BLOCKSIZE); + if (amt % BLOCKSZ != 0) { + amt += BLOCKSZ - (amt % BLOCKSZ); }; match (io::seek(ent.src, amt: io::off, io::whence::CUR)) { case io::off => @@ -148,9 +148,9 @@ fn file_read(s: *io::stream, buf: []u8) (size | io::EOF | io::error) = { ent.remain -= z; // Read until we reach the block size - static let buf: [BLOCKSIZE]u8 = [0...]; - if (ent.remain == 0 && ent.orig % BLOCKSIZE != 0) { - let remain = BLOCKSIZE - (ent.orig % BLOCKSIZE); + static let buf: [BLOCKSZ]u8 = [0...]; + if (ent.remain == 0 && ent.orig % BLOCKSZ != 0) { + let remain = BLOCKSZ - (ent.orig % BLOCKSZ); for (remain > 0) { match (io::read(ent.src, buf[..remain])?) { case let z: size => diff --git a/format/tar/types.ha b/format/tar/types.ha @@ -3,7 +3,7 @@ use io; // The size of each block in a tar file. -export def BLOCKSIZE: size = 512; +export def BLOCKSZ: size = 512; // A file or directory in a tar file. export type entry = struct { @@ -43,7 +43,7 @@ export type entry_type = enum u8 { FIFO, }; -// Returned if the source file size is not aligned on [[BLOCKSIZE]]. +// Returned if the source file size is not aligned on [[BLOCKSZ]]. export type truncated = !void; // Returned if the source file does not contain a valid ustar archive. diff --git a/hare/lex/lex.ha b/hare/lex/lex.ha @@ -63,7 +63,7 @@ export fn init(in: io::handle, path: str, flags: flag...) lexer = { for (let i = 0z; i < len(flags); i += 1) { f |= flags[i]; }; - let scanner = bufio::newscanner(in, os::BUFSIZ); + let scanner = bufio::newscanner(in, os::BUFSZ); const loc = location { path = path, line = 1, col = 1 }; return lexer { in = scanner, diff --git a/hare/module/manifest.ha b/hare/module/manifest.ha @@ -323,7 +323,7 @@ export fn manifest_write(ctx: *context, man: *manifest) (void | error) = { let mpath = path::string(&mpath); let (truefile, name) = temp::named(ctx.fs, cachedir, io::mode::WRITE, 0o644)?; - let wbuf: [os::BUFSIZ]u8 = [0...]; + let wbuf: [os::BUFSZ]u8 = [0...]; let file = &bufio::init(truefile, [], wbuf); defer { bufio::flush(file)!; diff --git a/hare/module/scan.ha b/hare/module/scan.ha @@ -357,7 +357,7 @@ fn scan_file( ) ([]u8 | error) = { let truef = fs::open(ctx.fs, path)?; defer io::close(truef)!; - let rbuf: [os::BUFSIZ]u8 = [0...]; + let rbuf: [os::BUFSZ]u8 = [0...]; let f = &bufio::init(truef, rbuf, []); let sha = sha256::sha256(); hash::write(&sha, strings::toutf8(path)); diff --git a/mime/system.ha b/mime/system.ha @@ -19,7 +19,7 @@ export def SYSTEM_DB: str = "/etc/mime.types"; fn load_systemdb() (void | fs::error | io::error) = { const file = os::open(SYSTEM_DB)?; - let buf: [os::BUFSIZ]u8 = [0...]; + let buf: [os::BUFSZ]u8 = [0...]; const strm = bufio::init(file, buf, []); for (true) { diff --git a/os/+freebsd/stdfd.ha b/os/+freebsd/stdfd.ha @@ -38,14 +38,14 @@ export let stderr: io::handle = rt::STDERR_FILENO; export let stderr_file: io::file = rt::STDERR_FILENO; // The recommended buffer size for reading from disk. -export def BUFSIZ: size = 4096; // 4 KiB +export def BUFSZ: size = 4096; // 4 KiB @init fn init_stdfd() void = { - static let stdinbuf: [BUFSIZ]u8 = [0...]; + static let stdinbuf: [BUFSZ]u8 = [0...]; stdin_bufio = bufio::init(stdin_file, stdinbuf, []); stdin = &stdin_bufio; - static let stdoutbuf: [BUFSIZ]u8 = [0...]; + static let stdoutbuf: [BUFSZ]u8 = [0...]; stdout_bufio = bufio::init(stdout_file, [], stdoutbuf); stdout = &stdout_bufio; }; diff --git a/os/+linux/stdfd.ha b/os/+linux/stdfd.ha @@ -38,14 +38,14 @@ export let stderr: io::handle = rt::STDERR_FILENO; export let stderr_file: io::file = rt::STDERR_FILENO; // The recommended buffer size for reading from disk. -export def BUFSIZ: size = 4096; // 4 KiB +export def BUFSZ: size = 4096; // 4 KiB @init fn init_stdfd() void = { - static let stdinbuf: [BUFSIZ]u8 = [0...]; + static let stdinbuf: [BUFSZ]u8 = [0...]; stdin_bufio = bufio::init(stdin_file, stdinbuf, []); stdin = &stdin_bufio; - static let stdoutbuf: [BUFSIZ]u8 = [0...]; + static let stdoutbuf: [BUFSZ]u8 = [0...]; stdout_bufio = bufio::init(stdout_file, [], stdoutbuf); stdout = &stdout_bufio; }; diff --git a/strconv/ftos.ha b/strconv/ftos.ha @@ -210,9 +210,9 @@ const POW5_OFFSETS: [21]u32 = [ 0x55559155, 0x51405555, 0x00000105 ]; -def POW5_TABLE_SIZE: u8 = 26; +def POW5_TABLE_SZ: u8 = 26; -const POW5_TABLE: [POW5_TABLE_SIZE]u64 = [ +const POW5_TABLE: [POW5_TABLE_SZ]u64 = [ 1u64, 5u64, 25u64, 125u64, 625u64, 3125u64, 15625u64, 78125u64, 390625u64, 1953125u64, 9765625u64, 48828125u64, 244140625u64, 1220703125u64, 6103515625u64, 30517578125u64, 152587890625u64, @@ -222,8 +222,8 @@ const POW5_TABLE: [POW5_TABLE_SIZE]u64 = [ ]; fn f64computeinvpow5(i: u32) (u64, u64) = { - const base = ((i + POW5_TABLE_SIZE - 1) / POW5_TABLE_SIZE): u32; - const base2 = base * POW5_TABLE_SIZE; + const base = ((i + POW5_TABLE_SZ - 1) / POW5_TABLE_SZ): u32; + const base2 = base * POW5_TABLE_SZ; const mul = F64_POW5_INV_SPLIT2[base]; const off = base2 - i; if (off == 0) { @@ -244,7 +244,7 @@ fn f64computeinvpow5(i: u32) (u64, u64) = { }; fn f64computepow5(i: u32) (u64, u64) = { - const base = i / POW5_TABLE_SIZE, base2 = base * POW5_TABLE_SIZE; + const base = i / POW5_TABLE_SZ, base2 = base * POW5_TABLE_SZ; const mul = F64_POW5_SPLIT2[base]; const off = i - base2; if (off == 0) { diff --git a/time/chrono/timezone.ha b/time/chrono/timezone.ha @@ -239,7 +239,7 @@ let TZ_LOCAL: timezone = timezone { ); }; - static let buf: [os::BUFSIZ]u8 = [0...]; + static let buf: [os::BUFSZ]u8 = [0...]; const file = bufio::init(file, buf, []); load_tzif(&file, &TZ_LOCAL): void; }; diff --git a/time/chrono/tzdb.ha b/time/chrono/tzdb.ha @@ -29,7 +29,7 @@ export fn tz(name: str) (locality | tzdberror) = { const fpath = path::string(&filepath); const file = os::open(fpath)?; - static let buf: [os::BUFSIZ]u8 = [0...]; + static let buf: [os::BUFSZ]u8 = [0...]; const bufstrm = bufio::init(file, buf, []); let loc = alloc(timezone {