hare

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

commit e7313818ecb35ace0428dfa097b2de82b6bce357
parent 5cc7fa8154af2d909c3a4bcbd5260822e162e35b
Author: Sebastian <sebastian@sebsite.pw>
Date:   Thu, 24 Aug 2023 00:24:28 -0400

all: take advantage of loosened rune castability rules

Signed-off-by: Sebastian <sebastian@sebsite.pw>

Diffstat:
Mascii/string.ha | 2+-
Mbufio/scanner.ha | 2+-
Mcrypto/bcrypt/bcrypt.ha | 4++--
Mencoding/base32/base32.ha | 2+-
Mencoding/base64/base64.ha | 2+-
Mencoding/hex/hex.ha | 2+-
Mencoding/pem/pem.ha | 2+-
Mfs/util.ha | 20++++++++++----------
Mhare/lex/lex.ha | 2+-
Mstrconv/stof.ha | 12++++++------
Mstrconv/utos.ha | 2+-
Mstrings/index.ha | 4++--
12 files changed, 28 insertions(+), 28 deletions(-)

diff --git a/ascii/string.ha b/ascii/string.ha @@ -46,7 +46,7 @@ export fn strcasecmp(a: str, b: str) int = { // because i *really* love to cast... // sometimes i sit and cast all day... ha ha, but // sometimes i get carried away! - let cmp = tolower(abs[i]: u32: rune): u32: int - tolower(bbs[i]: u32: rune): u32: int; + let cmp = tolower(abs[i]: rune): u32: int - tolower(bbs[i]: rune): u32: int; if (cmp != 0) return cmp; }; return len(abs): int - len(bbs): int; diff --git a/bufio/scanner.ha b/bufio/scanner.ha @@ -304,7 +304,7 @@ export fn scanrune( }; if (sz == 1) { - return b[0]: u32: rune; + return b[0]: rune; }; match (io::readall(file, b[1..sz])) { diff --git a/crypto/bcrypt/bcrypt.ha b/crypto/bcrypt/bcrypt.ha @@ -79,9 +79,9 @@ export fn compare(hash: []u8, password: []u8) (bool | errors::invalid) = { fn mkhash(h: *hash) []u8 = { let buf = memio::dynamic(); - fmt::fprintf(&buf, "${}$", h.major: u32: rune)!; + fmt::fprintf(&buf, "${}$", h.major: rune)!; if (h.minor != 0) { - fmt::fprintf(&buf, "{}", h.minor: u32: rune)!; + fmt::fprintf(&buf, "{}", h.minor: rune)!; }; fmt::fprintf(&buf, "${:02}$", h.cost)!; io::write(&buf, h.salt)!; diff --git a/encoding/base32/base32.ha b/encoding/base32/base32.ha @@ -29,7 +29,7 @@ export fn encoding_init(enc: *encoding, alphabet: str) void = { assert(len(alphabet) == 32); for (let i: u8 = 0; i < 32; i += 1) { const ch = alphabet[i]; - assert(ascii::valid(ch: u32: rune)); + assert(ascii::valid(ch: rune)); enc.encmap[i] = ch; enc.decmap[ch] = i; enc.valid[ch] = true; diff --git a/encoding/base64/base64.ha b/encoding/base64/base64.ha @@ -35,7 +35,7 @@ export fn encoding_init(enc: *encoding, alphabet: str) void = { assert(len(alphabet) == 64); for (let i: u8 = 0; i < 64; i += 1) { const ch = alphabet[i]; - assert(ascii::valid(ch: u32: rune) && enc.decmap[ch] == -1); + assert(ascii::valid(ch: rune) && enc.decmap[ch] == -1); enc.encmap[i] = ch; enc.decmap[ch] = i; }; diff --git a/encoding/hex/hex.ha b/encoding/hex/hex.ha @@ -218,7 +218,7 @@ export fn dump(out: io::handle, data: []u8) (void | io::error) = { fmt::fprint(out, "|")?; for (let i = 0z; i < 16 && off + i < datalen; i += 1) { - let r = data[off + i]: u32: rune; + let r = data[off + i]: rune; fmt::fprint(out, if (ascii::isprint(r)) r else '.')?; }; diff --git a/encoding/pem/pem.ha b/encoding/pem/pem.ha @@ -187,7 +187,7 @@ fn b64_read(st: *io::stream, buf: []u8) (size | io::EOF | io::error) = { sub = sub[..i]; break; }; - if (ascii::isspace(sub[i]: u32: rune)) { + if (ascii::isspace(sub[i]: rune)) { static delete(sub[i]); i -= 1; continue; diff --git a/fs/util.ha b/fs/util.ha @@ -19,22 +19,22 @@ export fn mode_str(m: mode) const str = { else if (m & mode::BLK == mode::BLK) 'b' else if (m & mode::LINK == mode::LINK) 'l' else if (m & mode::CHR == mode::CHR) 'c' - else '-'): u32: u8, - (if (m & mode::USER_R == mode::USER_R) 'r' else '-'): u32: u8, - (if (m & mode::USER_W == mode::USER_W) 'w' else '-'): u32: u8, + else '-'): u8, + (if (m & mode::USER_R == mode::USER_R) 'r' else '-'): u8, + (if (m & mode::USER_W == mode::USER_W) 'w' else '-'): u8, (if (m & mode::SETUID == mode::SETUID) 's' else if (m & mode::USER_X == mode::USER_X) 'x' - else '-'): u32: u8, - (if (m & mode::GROUP_R == mode::GROUP_R) 'r' else '-'): u32: u8, - (if (m & mode::GROUP_W == mode::GROUP_W) 'w' else '-'): u32: u8, + else '-'): u8, + (if (m & mode::GROUP_R == mode::GROUP_R) 'r' else '-'): u8, + (if (m & mode::GROUP_W == mode::GROUP_W) 'w' else '-'): u8, (if (m & mode::SETGID == mode::SETGID) 's' else if (m & mode::GROUP_X == mode::GROUP_X) 'x' - else '-'): u32: u8, - (if (m & mode::OTHER_R == mode::OTHER_R) 'r' else '-'): u32: u8, - (if (m & mode::OTHER_W == mode::OTHER_W) 'w' else '-'): u32: u8, + else '-'): u8, + (if (m & mode::OTHER_R == mode::OTHER_R) 'r' else '-'): u8, + (if (m & mode::OTHER_W == mode::OTHER_W) 'w' else '-'): u8, (if (m & mode::STICKY == mode::STICKY) 't' else if (m & mode::OTHER_X == mode::OTHER_X) 'x' - else '-'): u32: u8, + else '-'): u8, ]; return strings::fromutf8(buf)!; }; diff --git a/hare/lex/lex.ha b/hare/lex/lex.ha @@ -174,7 +174,7 @@ fn lex_unicode(lex: *lexer, loc: location, n: size) (rune | error) = { return syntaxerr(loc, "unexpected rune scanning for escape"); }; - buf[i] = r: u32: u8; + buf[i] = r: u8; }; let s = strings::fromutf8_unsafe(buf[..n]); return strconv::stou32b(s, strconv::base::HEX) as u32: rune; diff --git a/strconv/stof.ha b/strconv/stof.ha @@ -224,7 +224,7 @@ fn fast_parse(s: str) (fast_parsed_float | void | invalid) = { if (sawdot) return i: invalid; sawdot = true; dp = nd; - } else if (ascii::isdigit(buf[i]: u32: rune)) { + } else if (ascii::isdigit(buf[i]: rune)) { sawdigits = true; if (buf[i] == '0' && nd == 0) { dp -= 1; @@ -253,10 +253,10 @@ fn fast_parse(s: str) (fast_parsed_float | void | invalid) = { expsign = -1; i += 1; }; - if (i >= len(s) || !ascii::isdigit(buf[i]: u32: rune)) + if (i >= len(s) || !ascii::isdigit(buf[i]: rune)) return i: invalid; let e: int = 0; - for (i < len(s) && ascii::isdigit(buf[i]: u32: rune); i += 1) { + for (i < len(s) && ascii::isdigit(buf[i]: rune); i += 1) { if (e < 10000) { e = e * 10 + (buf[i] - '0'): int; }; @@ -294,7 +294,7 @@ fn decimal_parse(d: *decimal, s: str) (void | invalid) = { if (sawdot) return i: invalid; sawdot = true; d.decimal_point = d.num_digits: int; - } else if (ascii::isdigit(buf[i]: u32: rune)) { + } else if (ascii::isdigit(buf[i]: rune)) { sawdigits = true; if (buf[i] == '0' && d.num_digits == 0) { d.decimal_point -= 1; @@ -322,10 +322,10 @@ fn decimal_parse(d: *decimal, s: str) (void | invalid) = { expsign = -1; i += 1; }; - if (i >= len(s) || !ascii::isdigit(buf[i]: u32: rune)) + if (i >= len(s) || !ascii::isdigit(buf[i]: rune)) return i: invalid; let e: int = 0; - for (i < len(s) && ascii::isdigit(buf[i]: u32: rune); i += 1) { + for (i < len(s) && ascii::isdigit(buf[i]: rune); i += 1) { if (e < 10000) { e = e * 10 + (buf[i] - '0'): int; }; diff --git a/strconv/utos.ha b/strconv/utos.ha @@ -33,7 +33,7 @@ export fn u64tosb(u: u64, b: base) const str = { }; for (u > 0u64) { - buf[s.length] = lut[u % b: u64]: u32: u8; + buf[s.length] = lut[u % b: u64]: u8; s.length += 1; u /= b; }; diff --git a/strings/index.ha b/strings/index.ha @@ -130,7 +130,7 @@ export fn byteindex(haystack: str, needle: (str | rune)) (size | void) = { case let s: str => yield toutf8(s); case let r: rune => - yield if (r: u32 <= 0x7f) r: u32: u8 else utf8::encoderune(r); + yield if (r: u32 <= 0x7f) r: u8 else utf8::encoderune(r); }); }; @@ -141,7 +141,7 @@ export fn rbyteindex(haystack: str, needle: (str | rune)) (size | void) = { case let s: str => yield toutf8(s); case let r: rune => - yield if (r: u32 <= 0x7f) r: u32: u8 else utf8::encoderune(r); + yield if (r: u32 <= 0x7f) r: u8 else utf8::encoderune(r); }); };