From ec08d0410730a16836eb40f5e46082b3bbaf45f6 Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Fri, 21 Apr 2017 14:57:53 +0200 Subject: include lua_cmsgpack and implement select binding --- src/common/include/assert.h | 1 + src/common/libc/printf.c | 22 +++++++++++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) (limited to 'src/common') diff --git a/src/common/include/assert.h b/src/common/include/assert.h index 655d6f6..0e126dd 100644 --- a/src/common/include/assert.h +++ b/src/common/include/assert.h @@ -1,5 +1,6 @@ #pragma once #include +#define assert ASSERT /* vim: set sts=0 ts=4 sw=4 tw=0 noet :*/ 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 #include +#include #include #include @@ -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)); -- cgit v1.2.3