mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-03-03 15:38:22 +00:00
* Implement S conversion specifier for printf-related functions POSIX specifies that a conversion specifier of S must be interpreted the same way as %ls. This patch implements this. * clang-format --------- Co-authored-by: Gavin Hayes <gavin@computoid.com>
This commit is contained in:
parent
58b2f9bd6b
commit
2d6ea2fbc9
2 changed files with 10 additions and 0 deletions
|
@ -359,10 +359,15 @@ _Hide int __fmt(void *fn, void *arg, const char *format, va_list va) {
|
|||
p = "\r\e[K";
|
||||
goto FormatString;
|
||||
}
|
||||
case 'S':
|
||||
// Specified by POSIX to be equivalent to %ls
|
||||
signbit = 63;
|
||||
goto FormatStringPNotFetchedYet;
|
||||
case 'q':
|
||||
flags |= FLAGS_QUOTE;
|
||||
// fallthrough
|
||||
case 's':
|
||||
FormatStringPNotFetchedYet:
|
||||
p = va_arg(va, void *);
|
||||
FormatString:
|
||||
if (__fmt_stoa(out, arg, p, flags, prec, width, signbit, qchar) == -1) {
|
||||
|
|
|
@ -64,6 +64,11 @@ TEST(fmt, d) {
|
|||
EXPECT_STREQ("-2147483648", _gc(xasprintf("% d", INT_MIN)));
|
||||
}
|
||||
|
||||
TEST(fmt, s) {
|
||||
EXPECT_STREQ("Wide character output test",
|
||||
_gc(xasprintf("%S", L"Wide character output test")));
|
||||
}
|
||||
|
||||
TEST(fmt, g) {
|
||||
EXPECT_STREQ("1", _gc(xasprintf("%g", 1.)));
|
||||
EXPECT_STREQ(" 1", _gc(xasprintf("% g", 1.)));
|
||||
|
|
Loading…
Add table
Reference in a new issue