Add vsnprintf %c format
authorJack Miller <jack@codezen.org>
Sun, 20 Mar 2016 01:27:05 +0000 (20:27 -0500)
committerJack Miller <jack@codezen.org>
Sun, 20 Mar 2016 01:27:05 +0000 (20:27 -0500)
kernel/string.c

index 3b4e8ae..9abd95e 100644 (file)
@@ -76,6 +76,7 @@ void vsnprintf(char *buf, u32 size, char *format, va_list ap)
        char padding[16];
        char fill;
        char *s;
+       char c;
 
        unsigned long long val;
        s32 fieldwidth = -1;
@@ -99,6 +100,11 @@ void vsnprintf(char *buf, u32 size, char *format, va_list ap)
 
                if (escaped) {
                        switch(format[i]) {
+                               case 'c': c = (char) va_arg(ap, int);
+                                                 *str++ = c;
+                                                 fieldwidth = -1;
+                                                 escaped = 0;
+                                                 break;
                                case 's': s = va_arg(ap, char *);
                                                  if(fieldwidth == -1)
                                                          fieldwidth = (size - i);