]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: add conversion specifier to printf for char values
authorCarl Shapiro <cshapiro@google.com>
Wed, 20 Feb 2013 02:05:44 +0000 (18:05 -0800)
committerCarl Shapiro <cshapiro@google.com>
Wed, 20 Feb 2013 02:05:44 +0000 (18:05 -0800)
R=r, golang-dev
CC=golang-dev
https://golang.org/cl/7327053

src/pkg/runtime/print.c
src/pkg/runtime/runtime.h

index b642999a1d59a6b9d002b757cc9d82331ecfbfd4..5b601599bc9a68d6ef9f5f0a1d32fc3555c5547c 100644 (file)
@@ -84,6 +84,7 @@ vprintf(int8 *s, byte *base)
                narg = 0;
                switch(*p) {
                case 't':
+               case 'c':
                        narg = arg + 1;
                        break;
                case 'd':       // 32-bit
@@ -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)
 {
index 77f60cb4b58f4bc95450938b2f7534cb52555e47..a787cad563d45ff81106100fa14c6e1db903fb03 100644 (file)
@@ -817,6 +817,7 @@ void*       runtime·getcallerpc(void*);
  * runtime go-called
  */
 void   runtime·printbool(bool);
+void   runtime·printbyte(int8);
 void   runtime·printfloat(float64);
 void   runtime·printint(int64);
 void   runtime·printiface(Iface);