Support printf %n directive

This commit is contained in:
Justine Tunney 2024-07-28 22:27:06 -07:00
parent c1a0b017e9
commit 01b09bc817
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
8 changed files with 21 additions and 8 deletions

View file

@ -20,6 +20,7 @@
#include "libc/log/log.h"
#include "libc/math.h"
#include "libc/mem/gc.h"
#include "libc/stdio/stdio.h"
#include "libc/str/str.h"
#include "libc/testlib/testlib.h"
#include "libc/x/xasprintf.h"
@ -431,3 +432,10 @@ TEST(fmt, regress) {
"User-Agent: hurl/1.o (https://github.com/jart/cosmopolitan)\r\n",
buf);
}
TEST(fmt, n) {
int n;
char buf[8];
snprintf(buf, 8, ".%c%c.%n", 0, 1, &n);
ASSERT_EQ(4, n);
}