aboutsummaryrefslogtreecommitdiff
path: root/src/common
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
parent59ecab36f634a00cc6e2c4194bf2d5ebc4ec70eb (diff)
downloadkogata-ec08d0410730a16836eb40f5e46082b3bbaf45f6.tar.gz
kogata-ec08d0410730a16836eb40f5e46082b3bbaf45f6.zip
include lua_cmsgpack and implement select binding
Diffstat (limited to 'src/common')
-rw-r--r--src/common/include/assert.h1
-rw-r--r--src/common/libc/printf.c22
2 files changed, 22 insertions, 1 deletions
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 <kogata/debug.h>
+#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 <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));