diff --git a/lib/std/io/io_formatter_private.c3 b/lib/std/io/io_formatter_private.c3 index 1e75c1414..991497aa3 100644 --- a/lib/std/io/io_formatter_private.c3 +++ b/lib/std/io/io_formatter_private.c3 @@ -128,7 +128,7 @@ fn uint simple_atoi(char* buf, usz maxlen, usz* len_ptr) @inline @private while (len < maxlen) { char c = buf[len]; - if (c < '0' || c > '9') break; + if (!c.is_digit()) break; i = i * 10 + c - '0'; len++; } @@ -657,7 +657,7 @@ fn int! printf_parse_format_field( char* format_ptr, usz format_len, usz* index_ptr) @inline @private { char c = format_ptr[*index_ptr]; - if (c >= '0' && c <= '9') return simple_atoi(format_ptr, format_len, index_ptr); + if (c.is_digit()) return simple_atoi(format_ptr, format_len, index_ptr); if (c != '*') return 0; printf_advance_format(format_len, index_ptr)!; any val = next_any(args_ptr, args_len, args_index_ptr)!; diff --git a/lib/std/io/io_stream.c3 b/lib/std/io/io_stream.c3 index 0204bd4e4..a10ac04db 100644 --- a/lib/std/io/io_stream.c3 +++ b/lib/std/io/io_stream.c3 @@ -46,6 +46,8 @@ fn bool Stream.supports_read_from(s) @inline => (bool)s.fns.read_stream_fn; fn bool Stream.supports_write_to(s) @inline => (bool)s.fns.write_stream_fn; fn bool Stream.supports_pushback_byte(s) @inline => s.fns.pushback_byte_fn || s.fns.seek_fn; fn bool Stream.supports_write(s) @inline => s.fns.write_fn || s.fns.write_byte_fn; +fn bool Stream.supports_read_byte(s) @inline => (bool)s.fns.read_byte_fn; +fn bool Stream.supports_write_byte(s) @inline => (bool)s.fns.write_byte_fn; fn void! Stream.destroy(self) @inline @maydiscard { @@ -127,6 +129,13 @@ fn usz! Stream.read_all(self, char[] buffer) @inline return n; } +fn usz! Stream.write_all(self, char[] buffer) @inline +{ + usz n = self.write(buffer)!; + if (n != buffer.len) return IoError.INCOMPLETE_WRITE?; + return n; +} + fn String! Stream.treadline(self) => self.readline(mem::temp()) @inline; fn String! Stream.readline(self, Allocator* using = mem::heap())