commit 713001b4f7a02ab82f7851ea9b8b24cf91c4f0c2
parent 911ecbd8f2e4f577b5bc542460e8fcd291ceeade
Author: Bor Grošelj Simić <bgs@turminal.net>
Date: Fri, 8 Apr 2022 02:32:39 +0200
all: update for RCONST
Signed-off-by: Bor Grošelj Simić <bgs@turminal.net>
Diffstat:
24 files changed, 59 insertions(+), 59 deletions(-)
diff --git a/ascii/ctype.ha b/ascii/ctype.ha
@@ -87,7 +87,7 @@ export fn isascii(c: rune) bool = c: u32 <= 0o177;
// if it was not a lowercase letter (or was not ASCII).
export fn toupper(c: rune) rune = {
return if (islower(c)) {
- yield (c: u32 - ('a': u32) + ('A': u32)): rune;
+ yield (c: u32 - 'a' + 'A'): rune;
} else c;
};
@@ -95,7 +95,7 @@ export fn toupper(c: rune) rune = {
// if it was not an uppercase letter (or was not ASCII).
export fn tolower(c: rune) rune = {
return if (isupper(c)) {
- yield (c: u32 - ('A': u32) + ('a': u32)): rune;
+ yield (c: u32 - 'A' + 'a'): rune;
} else c;
};
diff --git a/bufio/buffered.ha b/bufio/buffered.ha
@@ -40,7 +40,7 @@ export fn buffered(
rbuf: []u8,
wbuf: []u8,
) bufstream = {
- static let flush_default = ['\n': u32: u8];
+ static let flush_default = ['\n': u8];
let s = bufstream {
stream = io::stream {
closer = &buffered_close_static,
diff --git a/bufio/scanner.ha b/bufio/scanner.ha
@@ -50,7 +50,7 @@ export fn scantok(file: io::handle, delim: u8...) ([]u8 | io::EOF | io::error) =
// Reads a slice of bytes until a newline character (\n, 0x10). Newline itself
// is not included. The return value must be freed by the caller.
export fn scanline(file: io::handle) ([]u8 | io::EOF | io::error) =
- scantok(file, '\n': u32: u8);
+ scantok(file, '\n');
// Reads a rune from a UTF-8 stream.
export fn scanrune(
diff --git a/encoding/hex/hex.ha b/encoding/hex/hex.ha
@@ -21,7 +21,7 @@ export fn encode(sink: io::handle, b: []u8) (size | io::error) = {
for (let i = 0z; i < len(b); i += 1) {
let s = strconv::u8tosb(b[i], strconv::base::HEX_LOWER);
if (len(s) == 1) {
- z += io::write(sink, ['0': u32: u8])?;
+ z += io::write(sink, ['0'])?;
};
z += io::write(sink, strings::toutf8(s))?;
};
diff --git a/fmt/fmt.ha b/fmt/fmt.ha
@@ -70,7 +70,7 @@ export fn fprintfln(
fmt: str,
args: field...
) (io::error | size) = {
- return fprintf(h, fmt, args...)? + io::write(h, ['\n': u32: u8])?;
+ return fprintf(h, fmt, args...)? + io::write(h, ['\n'])?;
};
// Formats values for printing using the default format modifiers and writes
@@ -114,7 +114,7 @@ export fn bsprint(buf: []u8, args: formattable...) str = {
// Formats values for printing using the default format modifiers and writes
// them to an [[io::handle]] separated by spaces and followed by a line feed.
export fn fprintln(h: io::handle, args: formattable...) (io::error | size) = {
- return fprint(h, args...)? + io::write(h, ['\n': u32: u8])?;
+ return fprint(h, args...)? + io::write(h, ['\n'])?;
};
// Formats values for printing using the default format modifiers and writes
@@ -125,7 +125,7 @@ export fn fprint(h: io::handle, args: formattable...) (io::error | size) = {
for (let i = 0z; i < len(args); i += 1) {
n += format(h, args[i], &mod)?;
if (i != len(args) - 1) {
- n += io::write(h, [' ': u32: u8])?;
+ n += io::write(h, [' '])?;
};
};
return n;
diff --git a/hare/lex/lex.ha b/hare/lex/lex.ha
@@ -568,7 +568,7 @@ fn lex_literal(lex: *lexer) (token | error) = {
case strconv::invalid =>
abort();
case strconv::overflow =>
- yield if (chars[0] != '-': u32: u8) {
+ yield if (chars[0] != '-') {
suff = ltok::LIT_U64;
yield strconv::stou64b(val, base);
} else strconv::overflow;
diff --git a/os/+freebsd/environ.ha b/os/+freebsd/environ.ha
@@ -41,7 +41,7 @@ export fn getenv(name: const str) (str | void) = {
for (let i = 0z; rt::envp[i] != null; i += 1) {
const item = rt::envp[i]: *[*]u8;
const ln = strings::cstrlen(item: *char);
- const eq: size = match (bytes::index(item[..ln], '=': u8)) {
+ const eq: size = match (bytes::index(item[..ln], '=')) {
case void =>
abort("Environment violates System-V invariants");
case let i: size =>
diff --git a/os/+linux/environ+libc.ha b/os/+linux/environ+libc.ha
@@ -41,7 +41,7 @@ export fn getenv(name: const str) (str | void) = {
for (let i = 0z; rt::envp[i] != null; i += 1) {
const item = rt::envp[i]: *[*]u8;
const ln = strings::cstrlen(item: *char);
- const eq: size = match (bytes::index(item[..ln], '=': u8)) {
+ const eq: size = match (bytes::index(item[..ln], '=')) {
case void =>
abort("Environment violates System-V invariants");
case let i: size =>
diff --git a/os/+linux/environ.ha b/os/+linux/environ.ha
@@ -41,7 +41,7 @@ export fn getenv(name: const str) (str | void) = {
for (let i = 0z; rt::envp[i] != null; i += 1) {
const item = rt::envp[i]: *[*]u8;
const ln = strings::cstrlen(item: *char);
- const eq: size = match (bytes::index(item[..ln], '=': u8)) {
+ const eq: size = match (bytes::index(item[..ln], '=')) {
case void =>
abort("Environment violates System-V invariants");
case let i: size =>
diff --git a/path/+freebsd.ha b/path/+freebsd.ha
@@ -2,7 +2,7 @@
// (c) 2021-2022 Drew DeVault <sir@cmpwn.com>
// Platform-specific path separator.
-export def PATHSEP: u8 = '/': u32: u8;
+export def PATHSEP: u8 = '/';
// Maximum length of a file path for this platform.
export def PATH_MAX: size = 4096;
diff --git a/path/+linux.ha b/path/+linux.ha
@@ -2,7 +2,7 @@
// (c) 2021-2022 Drew DeVault <sir@cmpwn.com>
// Platform-specific path separator.
-export def PATHSEP: u8 = '/': u32: u8;
+export def PATHSEP: u8 = '/';
// Maximum length of a file path for this platform.
export def PATH_MAX: size = 4096;
diff --git a/path/buffer.ha b/path/buffer.ha
@@ -72,9 +72,9 @@ export fn allocate(buf: *buffer) str = {
return strings::dup(string(buf));
};
-const dot: []u8 = ['.': u8];
-const dotdot: []u8 = ['.': u8, '.': u8];
-const dotdotslash: []u8 = ['.': u8, '.': u8, PATHSEP];
+const dot: []u8 = ['.'];
+const dotdot: []u8 = ['.', '.'];
+const dotdotslash: []u8 = ['.', '.', PATHSEP];
// Normalizes and appends a path component to a buffer.
//
diff --git a/path/iter.ha b/path/iter.ha
@@ -51,7 +51,7 @@ export fn next(iter: *iterator) (str | void) = {
};
@test fn iter() void = {
- assert(PATHSEP == '/': u32: u8); // meh
+ assert(PATHSEP == '/'); // meh
let i = iter("/foo/bar/baz");
assert(next(&i) as str == "/");
assert(next(&i) as str == "foo");
diff --git a/path/names.ha b/path/names.ha
@@ -109,7 +109,7 @@ export fn extension(p: (str | *buffer)) (str, str) = {
if (len(b) == 0 || b[len(b) - 1] == PATHSEP) {
return (p, "");
};
- let i = match (bytes::index(b, '.': u32: u8)) {
+ let i = match (bytes::index(b, '.')) {
case void =>
return (p, "");
case let z: size =>
diff --git a/rt/+test/ztos.ha b/rt/+test/ztos.ha
@@ -25,12 +25,12 @@ fn ztos(u: size) const str = {
};
if (u == 0) {
- s.b[s.l] = '0': u32: u8;
+ s.b[s.l] = '0';
s.l += 1;
};
for (u > 0) {
- s.b[s.l] = '0': u32: u8 + (u % 10): u8;
+ s.b[s.l] = '0' + (u % 10): u8;
s.l += 1;
u /= 10;
};
diff --git a/strconv/ftos.ha b/strconv/ftos.ha
@@ -521,7 +521,7 @@ def F32_DECIMAL_DIGITS: i32 = 9;
def F64_DECIMAL_DIGITS: i32 = 17;
fn encode_base10(buf: []u8, mantissa: u64, exponent: i32, digits: i32) size = {
- const zch = '0': u32: u8;
+ const zch = '0': u8;
const n = mantissa, e = exponent, olen = declen(n);
const exp = e + olen: i32 - 1;
// use scientific notation for numbers whose exponent is beyond the
@@ -543,7 +543,7 @@ fn encode_base10(buf: []u8, mantissa: u64, exponent: i32, digits: i32) size = {
return (e + olen: i32): size;
} else if (exp < 0) {
buf[0] = zch;
- buf[1] = '.': u32: u8;
+ buf[1] = '.';
let k = -e + 1;
let m = n;
for (let a = olen: i32; a > 0; a -= 1) {
@@ -567,7 +567,7 @@ fn encode_base10(buf: []u8, mantissa: u64, exponent: i32, digits: i32) size = {
k -= 1;
m = mby10;
};
- buf[k] = '.': u32: u8;
+ buf[k] = '.';
k -= 1;
for (k >= 0; k -= 1) {
const mby10 = m / 10;
@@ -592,14 +592,14 @@ fn encode_base10(buf: []u8, mantissa: u64, exponent: i32, digits: i32) size = {
k -= 1;
m = mby10;
};
- buf[k] = '.': u32: u8;
+ buf[k] = '.';
buf[0] = zch + m: u8;
h = olen: i32 + 1;
};
- buf[h] = 'e': u32: u8;
+ buf[h] = 'e';
h += 1;
let ex = if (exp < 0) {
- buf[h] = '-': u32: u8;
+ buf[h] = '-';
h += 1;
yield -exp;
} else exp;
@@ -643,7 +643,7 @@ export fn f64tos(n: f64) const str = {
};
const d = f64todecf64(mantissa, exponent);
if (sign != 0) {
- buf[0] = '-': u32: u8;
+ buf[0] = '-';
};
let z = encode_base10(buf[sign..], d.mantissa, d.exponent,
F64_DECIMAL_DIGITS) + sign;
@@ -677,7 +677,7 @@ export fn f32tos(n: f32) const str = {
};
const d = f32todecf32(mantissa, exponent);
if (sign != 0) {
- buf[0] = '-': u32: u8;
+ buf[0] = '-';
};
let z = encode_base10(buf[sign..], d.mantissa, d.exponent,
F32_DECIMAL_DIGITS) + sign;
diff --git a/strconv/itos.ha b/strconv/itos.ha
@@ -17,7 +17,7 @@ export fn i64tosb(i: i64, b: base) const str = {
let s = types::string { data = &buf, ... };
- buf[0] = '-': u32: u8;
+ buf[0] = '-';
s.length = 1;
let u = strings::toutf8(u64tosb((-i): u64, b));
diff --git a/strconv/stof.ha b/strconv/stof.ha
@@ -210,31 +210,31 @@ fn fast_parse(s: str) (fast_parsed_float | void | invalid) = {
};
let buf = strings::toutf8(s);
let i = 0z, neg = false, trunc = false;
- if (buf[i] == '-': u32: u8) {
+ if (buf[i] == '-') {
neg = true;
i += 1;
- } else if (buf[i] == '+': u32: u8) {
+ } else if (buf[i] == '+') {
i += 1;
};
let sawdot = false, sawdigits = false;
let nd = 0, ndmant = 0, dp = 0;
let mant = 0u64, exp = 0i32;
for (i < len(s); i += 1) {
- if (buf[i] == '.': u32: u8) {
+ if (buf[i] == '.') {
if (sawdot) return i: invalid;
sawdot = true;
dp = nd;
} else if (ascii::isdigit(buf[i]: u32: rune)) {
sawdigits = true;
- if (buf[i] == '0': u32: u8 && nd == 0) {
+ if (buf[i] == '0' && nd == 0) {
dp -= 1;
continue;
};
nd += 1;
if (ndmant < 19) {
- mant = mant * 10 + buf[i] - '0': u32: u8;
+ mant = mant * 10 + buf[i] - '0';
ndmant += 1;
- } else if (buf[i] != '0': u32: u8) {
+ } else if (buf[i] != '0') {
trunc = true;
};
} else break;
@@ -243,13 +243,13 @@ fn fast_parse(s: str) (fast_parsed_float | void | invalid) = {
if (!sawdot) {
dp = nd;
};
- if (i < len(s) && (buf[i] == 'e': u32: u8 || buf[i] == 'E': u32: u8)) {
+ if (i < len(s) && (buf[i] == 'e' || buf[i] == 'E')) {
i += 1;
if (i >= len(s)) return i: invalid;
let expsign: int = 1;
- if (buf[i] == '+': u32: u8) {
+ if (buf[i] == '+') {
i += 1;
- } else if (buf[i] == '-': u32: u8) {
+ } else if (buf[i] == '-') {
expsign = -1;
i += 1;
};
@@ -258,7 +258,7 @@ fn fast_parse(s: str) (fast_parsed_float | void | invalid) = {
let e: int = 0;
for (i < len(s) && ascii::isdigit(buf[i]: u32: rune); i += 1) {
if (e < 10000) {
- e = e * 10 + buf[i]: int - '0': u32: int;
+ e = e * 10 + (buf[i] - '0'): int;
};
};
dp += e * expsign;
@@ -281,29 +281,29 @@ fn decimal_parse(d: *decimal, s: str) (void | invalid) = {
const buf = strings::toutf8(s);
d.negative = false;
d.truncated = false;
- if (buf[0] == '+': u32: u8) {
+ if (buf[0] == '+') {
i += 1;
- } else if (buf[0] == '-': u32: u8) {
+ } else if (buf[0] == '-') {
d.negative = true;
i += 1;
};
let sawdot = false, sawdigits = false;
let nd: u32 = 0, dp: i32 = 0;
for (i < len(s); i += 1) {
- if (buf[i] == '.': u32: u8) {
+ if (buf[i] == '.') {
if (sawdot) return i: invalid;
sawdot = true;
d.decimal_point = d.num_digits: int;
} else if (ascii::isdigit(buf[i]: u32: rune)) {
sawdigits = true;
- if (buf[i] == '0': u32: u8 && d.num_digits == 0) {
+ if (buf[i] == '0' && d.num_digits == 0) {
d.decimal_point -= 1;
continue;
};
if (d.num_digits < len(d.digits)) {
- d.digits[d.num_digits] = buf[i] - '0': u32: u8;
+ d.digits[d.num_digits] = buf[i] - '0';
d.num_digits += 1;
- } else if (buf[i] != '0': u32: u8) {
+ } else if (buf[i] != '0') {
d.truncated = true;
};
} else break;
@@ -312,13 +312,13 @@ fn decimal_parse(d: *decimal, s: str) (void | invalid) = {
if (!sawdot) {
d.decimal_point = d.num_digits: int;
};
- if (i < len(s) && (buf[i] == 'e': u32: u8 || buf[i] == 'E': u32: u8)) {
+ if (i < len(s) && (buf[i] == 'e' || buf[i] == 'E')) {
i += 1;
if (i >= len(s)) return i: invalid;
let expsign: int = 1;
- if (buf[i] == '+': u32: u8) {
+ if (buf[i] == '+') {
i += 1;
- } else if (buf[i] == '-': u32: u8) {
+ } else if (buf[i] == '-') {
expsign = -1;
i += 1;
};
@@ -327,7 +327,7 @@ fn decimal_parse(d: *decimal, s: str) (void | invalid) = {
let e: int = 0;
for (i < len(s) && ascii::isdigit(buf[i]: u32: rune); i += 1) {
if (e < 10000) {
- e = e * 10 + buf[i]: int - '0': u32: int;
+ e = e * 10 + (buf[i] - '0'): int;
};
};
d.decimal_point += e * expsign;
diff --git a/strconv/stoi.ha b/strconv/stoi.ha
@@ -16,11 +16,11 @@ export fn stoi64b(s: str, base: uint) (i64 | invalid | overflow) = {
let sign = 1i64;
let max = types::I64_MAX: u64;
let start = 0z;
- if (b[0] == '-': u32: u8) {
+ if (b[0] == '-') {
sign = -1;
max += 1;
start = 1;
- } else if (b[0] == '+': u32: u8) {
+ } else if (b[0] == '+') {
start = 1;
};
let u = stou64b(strings::fromutf8_unsafe(b[start..]), base);
diff --git a/strconv/stou.ha b/strconv/stou.ha
@@ -9,11 +9,11 @@ use encoding::utf8;
fn rune_to_integer(r: rune) (u64 | void) = {
if (ascii::isdigit(r))
- return (r: u32 - '0': u32): u64
+ return (r: u32 - '0'): u64
else if (ascii::isalpha(r) && ascii::islower(r))
- return (r: u32 - 'a': u32): u64 + 10
+ return (r: u32 - 'a'): u64 + 10
else if (ascii::isalpha(r) && ascii::isupper(r))
- return (r: u32 - 'A': u32): u64 + 10;
+ return (r: u32 - 'A'): u64 + 10;
};
// Converts a string to a u64 in the given base, If the string contains any
diff --git a/strconv/utos.ha b/strconv/utos.ha
@@ -26,7 +26,7 @@ export fn u64tosb(u: u64, b: base) const str = {
let s = types::string { data = &buf, ... };
if (u == 0) {
- buf[s.length] = '0': u32: u8;
+ buf[s.length] = '0';
s.length += 1z;
};
diff --git a/unix/hosts/lookup.ha b/unix/hosts/lookup.ha
@@ -28,7 +28,7 @@ export fn lookup(name: str) []ip::addr = {
yield line;
};
defer free(line);
- if (len(line) == 0 || line[0] == '#': u32: u8) {
+ if (len(line) == 0 || line[0] == '#') {
continue;
};
diff --git a/unix/resolvconf/load.ha b/unix/resolvconf/load.ha
@@ -37,7 +37,7 @@ export fn load() []ip::addr = {
yield line;
};
defer free(line);
- if (len(line) == 0 || line[0] == '#': u32: u8) {
+ if (len(line) == 0 || line[0] == '#') {
continue;
};
diff --git a/uuid/uuid.ha b/uuid/uuid.ha
@@ -138,7 +138,7 @@ export fn decode(in: io::handle) (uuid | invalid | io::error) = {
case let z: size =>
assert(z == 1);
};
- if (buf[0] != '-': u32: u8) {
+ if (buf[0] != '-') {
return invalid;
};
};