mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-05-30 17:22:27 +00:00
Fix vfprintf and derived functions badly handling +/` flag conflict (#1269)
This commit is contained in:
parent
06a1193b4d
commit
6baf6cdb10
2 changed files with 9 additions and 1 deletions
|
@ -76,9 +76,9 @@
|
||||||
#define FLAGS_PRECISION 0x20
|
#define FLAGS_PRECISION 0x20
|
||||||
#define FLAGS_ISSIGNED 0x40
|
#define FLAGS_ISSIGNED 0x40
|
||||||
#define FLAGS_NOQUOTE 0x80
|
#define FLAGS_NOQUOTE 0x80
|
||||||
|
#define FLAGS_REPR 0x100
|
||||||
#define FLAGS_QUOTE FLAGS_SPACE
|
#define FLAGS_QUOTE FLAGS_SPACE
|
||||||
#define FLAGS_GROUPING FLAGS_NOQUOTE
|
#define FLAGS_GROUPING FLAGS_NOQUOTE
|
||||||
#define FLAGS_REPR FLAGS_PLUS
|
|
||||||
|
|
||||||
#define __FMT_PUT(C) \
|
#define __FMT_PUT(C) \
|
||||||
do { \
|
do { \
|
||||||
|
|
|
@ -27,3 +27,11 @@ TEST(snprintf, testVeryLargePrecision) {
|
||||||
ASSERT_EQ(i, 9999);
|
ASSERT_EQ(i, 9999);
|
||||||
ASSERT_EQ(strlen(buf), 511);
|
ASSERT_EQ(strlen(buf), 511);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(snprintf, testPlusFlagOnChar) {
|
||||||
|
char buf[10] = {};
|
||||||
|
int i = snprintf(buf, sizeof(buf), "%+c", '=');
|
||||||
|
|
||||||
|
ASSERT_EQ(i, 1);
|
||||||
|
ASSERT_STREQ(buf, "=");
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue