mirror of
https://github.com/SerenityOS/serenity
synced 2024-10-15 04:13:11 +00:00
LibC: Set PRI[xX]8/PRI[xX]16 macros to x
and X
Described in:
<https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/
inttypes.h.html>
The macros were first added in a7a456002e
,
but it is not clear why the PRIx16/32 macros were defined as 'b' & 'w'.
PrintfImplementation was never able to parse these values.
This commit is contained in:
parent
97cfb9934b
commit
6c06b70911
|
@ -10,6 +10,8 @@
|
|||
#include <AK/Random.h>
|
||||
#include <AK/StringBuilder.h>
|
||||
#include <ctype.h>
|
||||
#include <inttypes.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#pragma GCC diagnostic ignored "-Wformat-nonliteral"
|
||||
|
@ -263,3 +265,11 @@ TEST_CASE(hexadecimal_values)
|
|||
EXPECT(test_single<int>({ LITERAL("xxx\0"), "|%x|", 0, 3, LITERAL("|0|\0") }));
|
||||
EXPECT(test_single<int>({ LITERAL("xxx\0"), "|%#x|", 0, 3, LITERAL("|0|\0") }));
|
||||
}
|
||||
|
||||
TEST_CASE(inttypes_macros)
|
||||
{
|
||||
EXPECT(test_single<uint8_t>({ LITERAL("xxxxx"), "|%" PRIx8 "|", 0xAB, 4, LITERAL("|ab|\0") }));
|
||||
EXPECT(test_single<uint8_t>({ LITERAL("xxxxx"), "|%" PRIX8 "|", 0xAB, 4, LITERAL("|AB|\0") }));
|
||||
EXPECT(test_single<uint16_t>({ LITERAL("xxxxxxx"), "|%" PRIx16 "|", 0xC0DE, 6, LITERAL("|c0de|\0") }));
|
||||
EXPECT(test_single<uint16_t>({ LITERAL("xxxxxxx"), "|%" PRIX16 "|", 0xC0DE, 6, LITERAL("|C0DE|\0") }));
|
||||
}
|
||||
|
|
|
@ -41,10 +41,10 @@ __BEGIN_DECLS
|
|||
# define PRIu64 "lu"
|
||||
# define PRIuPTR "lx"
|
||||
#endif
|
||||
#define PRIx8 "b"
|
||||
#define PRIX8 "hhX"
|
||||
#define PRIx16 "w"
|
||||
#define PRIX16 "hX"
|
||||
#define PRIx8 "x"
|
||||
#define PRIX8 "X"
|
||||
#define PRIx16 "x"
|
||||
#define PRIX16 "X"
|
||||
#define PRIx32 "x"
|
||||
#define PRIX32 "X"
|
||||
#ifndef __x86_64__
|
||||
|
|
Loading…
Reference in a new issue