From 04b08da9af0c450d645ab7389d1467308cfc2db8 Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Mon, 4 Mar 2013 21:27:36 +0100 Subject: Imported Upstream version 1.1~hg20130304 --- src/pkg/runtime/print.c | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-) (limited to 'src/pkg/runtime/print.c') diff --git a/src/pkg/runtime/print.c b/src/pkg/runtime/print.c index 6702c3cde..5b601599b 100644 --- a/src/pkg/runtime/print.c +++ b/src/pkg/runtime/print.c @@ -18,10 +18,10 @@ gwrite(void *v, int32 n) runtime·write(2, v, n); return; } - + if(g->writenbuf == 0) return; - + if(n > g->writenbuf) n = g->writenbuf; runtime·memmove(g->writebuf, v, n); @@ -84,40 +84,41 @@ vprintf(int8 *s, byte *base) narg = 0; switch(*p) { case 't': + case 'c': narg = arg + 1; break; case 'd': // 32-bit case 'x': - arg = runtime·rnd(arg, 4); + arg = ROUND(arg, 4); narg = arg + 4; break; case 'D': // 64-bit case 'U': case 'X': case 'f': - arg = runtime·rnd(arg, sizeof(uintptr)); + arg = ROUND(arg, sizeof(uintptr)); narg = arg + 8; break; case 'C': - arg = runtime·rnd(arg, sizeof(uintptr)); + arg = ROUND(arg, sizeof(uintptr)); narg = arg + 16; break; case 'p': // pointer-sized case 's': - arg = runtime·rnd(arg, sizeof(uintptr)); + arg = ROUND(arg, sizeof(uintptr)); narg = arg + sizeof(uintptr); break; case 'S': // pointer-aligned but bigger - arg = runtime·rnd(arg, sizeof(uintptr)); + arg = ROUND(arg, sizeof(uintptr)); narg = arg + sizeof(String); break; case 'a': // pointer-aligned but bigger - arg = runtime·rnd(arg, sizeof(uintptr)); + arg = ROUND(arg, sizeof(uintptr)); narg = arg + sizeof(Slice); break; case 'i': // pointer-aligned but bigger case 'e': - arg = runtime·rnd(arg, sizeof(uintptr)); + arg = ROUND(arg, sizeof(uintptr)); narg = arg + sizeof(Eface); break; } @@ -126,6 +127,9 @@ vprintf(int8 *s, byte *base) case 'a': runtime·printslice(*(Slice*)v); break; + case 'c': + runtime·printbyte(*(int8*)v); + break; case 'd': runtime·printint(*(int32*)v); break; @@ -202,6 +206,12 @@ runtime·printbool(bool v) gwrite((byte*)"false", 5); } +void +runtime·printbyte(int8 c) +{ + gwrite(&c, 1); +} + void runtime·printfloat(float64 v) { @@ -209,15 +219,15 @@ runtime·printfloat(float64 v) int32 e, s, i, n; float64 h; - if(runtime·isNaN(v)) { + if(ISNAN(v)) { gwrite("NaN", 3); return; } - if(runtime·isInf(v, 1)) { + if(v == runtime·posinf) { gwrite("+Inf", 4); return; } - if(runtime·isInf(v, -1)) { + if(v == runtime·neginf) { gwrite("-Inf", 4); return; } @@ -343,7 +353,7 @@ runtime·printstring(String v) extern uint32 runtime·maxstring; if(v.len > runtime·maxstring) { - gwrite("[invalid string]", 16); + gwrite("[string too long]", 17); return; } if(v.len > 0) -- cgit v1.2.3