From 3ed17b079250962762f4c4baa3639ab884205471 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sat, 22 Jun 2019 16:30:32 +0200 Subject: [PATCH] printf: Support %zu (the 'z' is really just ignored.) --- AK/PrintfImplementation.h | 7 +++++++ LibC/malloc.cpp | 2 +- Userland/tc.cpp | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/AK/PrintfImplementation.h b/AK/PrintfImplementation.h index e6a9495a3d..c9bde97056 100644 --- a/AK/PrintfImplementation.h +++ b/AK/PrintfImplementation.h @@ -200,6 +200,8 @@ template bool zeroPad = false; unsigned fieldWidth = 0; unsigned long_qualifiers = 0; + bool size_qualifier = false; + (void)size_qualifier; bool alternate_form = 0; if (*p == '%' && *(p + 1)) { one_more: @@ -225,6 +227,11 @@ template if (*(p + 1)) goto one_more; } + if (*p == 'z') { + size_qualifier = true; + if (*(p + 1)) + goto one_more; + } if (*p == '#') { alternate_form = true; if (*(p + 1)) diff --git a/LibC/malloc.cpp b/LibC/malloc.cpp index c089a3fd20..6d717deade 100644 --- a/LibC/malloc.cpp +++ b/LibC/malloc.cpp @@ -168,7 +168,7 @@ void* malloc(size_t size) if (!block) { char buffer[64]; - snprintf(buffer, sizeof(buffer), "malloc: ChunkedBlock(%u)", good_size); + snprintf(buffer, sizeof(buffer), "malloc: ChunkedBlock(%zu)", good_size); block = (ChunkedBlock*)os_alloc(PAGE_SIZE, buffer); new (block) ChunkedBlock(good_size); allocator->usable_blocks.append(block); diff --git a/Userland/tc.cpp b/Userland/tc.cpp index 7abf31c9af..857d861e65 100644 --- a/Userland/tc.cpp +++ b/Userland/tc.cpp @@ -80,7 +80,7 @@ int main(int argc, char** argv) printf("\033[36;1m%s\033[0m", buffer); } - printf("(%u bytes received)\n", total_recv); + printf("(%zu bytes received)\n", total_recv); rc = close(fd); if (rc < 0) { perror("close");