hare

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

commit 6eb28dcfbb7baccb4989305dc2ed3a5db1b09d86
parent a14fe44839ad6ee2cece80d49d20c43e687c2cc2
Author: Sebastian <sebastian@sebsite.pw>
Date:   Sat, 20 May 2023 22:45:46 -0400

strconv: give base type a default value

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

Diffstat:
Mfmt/fmt.ha | 4----
Mstrconv/types.ha | 4++--
Mstrconv/utos.ha | 2++
3 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/fmt/fmt.ha b/fmt/fmt.ha @@ -265,10 +265,6 @@ export fn fprintf( case void => void; }; - if (mod.base == 0) { - mod.base = strconv::base::DEC; - }; - n += format(h, arg, mod)?; } else if (r == '}') { match (strings::next(&iter)) { diff --git a/strconv/types.ha b/strconv/types.ha @@ -20,8 +20,8 @@ export type base = enum uint { BIN = 2, // Base 8, octal OCT = 8, - // Base 10, decimal - DEC = 10, + // Base 10, decimal (default) + DEC = 0, // Base 16, UPPERCASE hexadecimal HEX_UPPER = 16, // Alias for HEX_UPPER diff --git a/strconv/utos.ha b/strconv/utos.ha @@ -24,6 +24,8 @@ export fn u64tosb(u: u64, b: base) const str = { yield &lut_lower; }; + const b: uint = if (b == base::DEC) 10 else b; + let s = types::string { data = &buf, ... }; if (u == 0) { buf[s.length] = '0';