aboutsummaryrefslogtreecommitdiff
path: root/src/common/libc
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2017-04-21 14:57:53 +0200
committerAlex Auvolat <alex@adnab.me>2017-04-21 14:57:53 +0200
commitec08d0410730a16836eb40f5e46082b3bbaf45f6 (patch)
tree1191271926f1fe42049b974f4bd9bdf56a2945bb /src/common/libc
parent59ecab36f634a00cc6e2c4194bf2d5ebc4ec70eb (diff)
downloadkogata-ec08d0410730a16836eb40f5e46082b3bbaf45f6.tar.gz
kogata-ec08d0410730a16836eb40f5e46082b3bbaf45f6.zip
include lua_cmsgpack and implement select binding
Diffstat (limited to 'src/common/libc')
-rw-r--r--src/common/libc/printf.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/src/common/libc/printf.c b/src/common/libc/printf.c
index fbebafe..8ec78d7 100644
--- a/src/common/libc/printf.c
+++ b/src/common/libc/printf.c
@@ -1,5 +1,6 @@
#include <stdarg.h>
#include <stdbool.h>
+#include <ctype.h>
#include <kogata/debug.h>
#include <kogata/printf.h>
@@ -59,8 +60,11 @@ int vcprintf(int (*putc_fun)(int c, void* p), void* p, const char* format, va_li
for(i = 0; format[i] != '\0' ; i++) {
if (format[i] == '%') {
i++;
+ int na = -1;
+ int nb = -1;
int u = 0;
int l = 0;
+ bool dotspec = false;
bool spec = true;
while (spec) {
if (format[i] == 'l') {
@@ -69,6 +73,18 @@ int vcprintf(int (*putc_fun)(int c, void* p), void* p, const char* format, va_li
} else if (format[i] == 'u') {
u = 1;
i++;
+ } else if (isdigit(format[i])) {
+ if (dotspec) {
+ if (nb == -1) nb = 0;
+ nb = nb * 10 + (format[i] - '0');
+ } else {
+ if (na == -1) na = 0;
+ na = na * 10 + (format[i] - '0');
+ }
+ i++;
+ } else if (format[i] == '.') {
+ dotspec = true;
+ i++;
} else {
spec = false;
}
@@ -112,7 +128,11 @@ int vcprintf(int (*putc_fun)(int c, void* p), void* p, const char* format, va_li
for(; *string != '\0' ; string++)
PUTCHAR(*string);
} else if (format[i] == 'x') {
- unsigned int hexa = va_arg(ap,int);
+ unsigned long long int hexa;
+ if (l == 0) hexa = va_arg(ap, unsigned int);
+ if (l == 1) hexa = va_arg(ap, unsigned long int);
+ if (l == 2) hexa = va_arg(ap, unsigned long long int);
+
int had_nonzero = 0;
for(int j = 0; j < 8; j++) {
unsigned int nb = (unsigned int)(hexa << (j*4));