Fix API usage

This commit is contained in:
Alex Kotov 2022-01-19 17:01:21 +05:00
parent 1a0c46b03d
commit a4fc6661e3
4 changed files with 9 additions and 5 deletions

View File

@ -1,6 +1,7 @@
#include <kernaux/printf.h> #include <kernaux/printf.h>
#include <assert.h> #include <assert.h>
#include <stddef.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
@ -17,7 +18,7 @@ static void my_putchar(const char chr)
int main() int main()
{ {
kernaux_printf(my_putchar, "Hello, %s! Session ID: %u.", "Alex", 123); kernaux_printf(my_putchar, NULL, "Hello, %s! Session ID: %u.", "Alex", 123);
assert(strcmp(buffer, "Hello, Alex! Session ID: 123.") == 0); assert(strcmp(buffer, "Hello, Alex! Session ID: 123.") == 0);
return 0; return 0;
} }

View File

@ -1,6 +1,7 @@
#include <kernaux/printf.h> #include <kernaux/printf.h>
#include <assert.h> #include <assert.h>
#include <stddef.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
@ -19,7 +20,7 @@ static void my_printf(const char *const format, ...)
{ {
va_list va; va_list va;
va_start(va, format); va_start(va, format);
kernaux_printf_va(my_putchar, format, va); kernaux_vprintf(my_putchar, NULL, format, va);
va_end(va); va_end(va);
} }

View File

@ -15,6 +15,8 @@
#include <kernaux/printf.h> #include <kernaux/printf.h>
#endif #endif
#include <stddef.h>
void kernaux_console_putc(const char c __attribute__((unused))) void kernaux_console_putc(const char c __attribute__((unused)))
{ {
#ifdef ASM_I386 #ifdef ASM_I386
@ -37,7 +39,7 @@ void kernaux_console_printf(const char *format, ...)
{ {
va_list va; va_list va;
va_start(va, format); va_start(va, format);
kernaux_printf_va(kernaux_console_putc, format, va); kernaux_vprintf(kernaux_console_putc, NULL, format, va);
va_end(va); va_end(va);
} }
#endif #endif

View File

@ -30,7 +30,7 @@ static void test(const char *const expected, const char *const format, ...)
buffer_index = 0; buffer_index = 0;
va_list va; va_list va;
va_start(va, format); va_start(va, format);
kernaux_printf_va(test_putchar, format, va); kernaux_vprintf(test_putchar, NULL, format, va);
va_end(va); va_end(va);
assert(strcmp(expected, buffer) == 0); assert(strcmp(expected, buffer) == 0);
} }
@ -39,7 +39,7 @@ int main()
{ {
memset(buffer, '\0', sizeof(buffer)); memset(buffer, '\0', sizeof(buffer));
buffer_index = 0; buffer_index = 0;
kernaux_printf(test_putchar, "Hello, World!"); kernaux_printf(test_putchar, NULL, "Hello, World!");
assert(strcmp("Hello, World!", buffer) == 0); assert(strcmp("Hello, World!", buffer) == 0);
test("", ""); test("", "");