From 47513bd32c256c4f35e3a8ced7d9fd7e15903530 Mon Sep 17 00:00:00 2001 From: Benji Dial Date: Tue, 16 Feb 2021 20:38:53 -0500 Subject: terminal application with ipc, shift+pause state dumper, hello world for terminal, meminfo popup program --- src/user/knob/format.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'src/user/knob/format.c') diff --git a/src/user/knob/format.c b/src/user/knob/format.c index 54d50ef..c5d2447 100644 --- a/src/user/knob/format.c +++ b/src/user/knob/format.c @@ -81,6 +81,8 @@ static const char *get_format(const char *from, struct format_spec *format_out) return from + 1; } +//char debug[] = "-- format_v: fmt = \" \"..."; + //allocates new memory char *format_v(const char *fmt, va_list args) { buf = get_block(FORMAT_BUF_INIT_SIZE); @@ -90,6 +92,11 @@ char *format_v(const char *fmt, va_list args) { buf_i = buf; while (*fmt) { + //debug[20] = *fmt; + //debug[21] = fmt[1]; + //debug[22] = fmt[2]; + //_system_log(debug); + if (*fmt != '%') { ensure(1); *(buf_i++) = *(fmt++); @@ -133,11 +140,15 @@ char *format_v(const char *fmt, va_list args) { case UNSIGNED_DECIMAL: k = va_arg(args, uint32_t); if (!form.len) { - uint32_t n = 10; - ++form.len; - while (k >= n) { + if (k >= 1000000000) + form.len = 10; + else { + uint32_t n = 10; ++form.len; - n *= 10; + while (k >= n) { + ++form.len; + n *= 10; + } } } ensure(form.len); -- cgit v1.2.3