diff options
author | Benji Dial <benji6283@gmail.com> | 2021-02-16 20:38:53 -0500 |
---|---|---|
committer | Benji Dial <benji6283@gmail.com> | 2021-02-16 20:38:53 -0500 |
commit | 47513bd32c256c4f35e3a8ced7d9fd7e15903530 (patch) | |
tree | cafdf75d52a954814726e07445063c41bb6599f9 /src/user/knob/format.c | |
parent | bd7facc4b5f53481dc85a15ba123361b2758655b (diff) | |
download | portland-os-47513bd32c256c4f35e3a8ced7d9fd7e15903530.tar.gz |
terminal application with ipc, shift+pause state dumper, hello world for terminal, meminfo popup program
Diffstat (limited to 'src/user/knob/format.c')
-rw-r--r-- | src/user/knob/format.c | 19 |
1 files changed, 15 insertions, 4 deletions
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); |