diff options
author | Peter Hutterer <peter.hutterer@who-t.net> | 2013-01-10 13:20:12 +1000 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@who-t.net> | 2013-01-17 17:17:41 +1000 |
commit | cde7cbe9674e8a771f9a4e646c1772a46a8230fb (patch) | |
tree | 6614374b40805df9eddbd83bb7eb1994765daa23 /os/log.c | |
parent | 20def57632583aef095ca18792c7fce16d2d9004 (diff) |
os: add support for %f to pnprintf
This is the lazy man's %f support. Print the decimal part of the number,
then append a decimal point, then print the first two digits of the
fractional part. So %f in sigsafe printing is really %.2f.
No boundary checks in place here.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'os/log.c')
-rw-r--r-- | os/log.c | 11 |
1 files changed, 10 insertions, 1 deletions
@@ -351,7 +351,16 @@ pnprintf(char *string, size_t size, const char *f, va_list args) for (i = 0; i < p_len && s_idx < size - 1; i++) string[s_idx++] = number[i]; break; - + case 'f': + { + double d = va_arg(args, double); + FormatDouble(d, number); + p_len = strlen_sigsafe(number); + + for (i = 0; i < p_len && s_idx < size - 1; i++) + string[s_idx++] = number[i]; + } + break; default: va_arg(args, char*); string[s_idx++] = '%'; |