mirror of
https://github.com/boykopovar/AnyPS5.git
synced 2026-10-27 00:28:14 +00:00
Merge pull request #9959 from JJenkx/windows/wprintf-unsigned-flags
fix(libc): ignore the space and plus flags on wide unsigned conversions
This commit is contained in:
2 files changed
+10
No files matched your search
@@ -1,3 +1,4 @@
|
||||
#include <algorithm>
|
||||
#include "prx/libc/include/Api.hpp"
|
||||
#include <cerrno>
|
||||
#include <climits>
|
||||
@@ -183,6 +184,8 @@ std::u16string FormatWide(const char16_t* format, VaList* source, bool secure =
|
||||
} else value = args.Next<unsigned long long>();
|
||||
if (conversion == u'o' && value == 0 && precision == 0 && spec.find('#') != std::string::npos)
|
||||
spec = spec.substr(0, spec.find('.')) + ".1";
|
||||
const auto flags = spec.begin() + static_cast<std::ptrdiff_t>(std::min(spec.find_first_not_of("-+ #0", 1), spec.size()));
|
||||
spec.erase(std::remove_if(spec.begin() + 1, flags, [](char flag) { return flag == ' ' || flag == '+'; }), flags);
|
||||
AppendNumber(out, spec + "ll" + static_cast<char>(conversion), value);
|
||||
} else if (In(conversion, "aAeEfFgG")) {
|
||||
const char narrow = static_cast<char>(conversion);
|
||||
|
||||
@@ -138,6 +138,12 @@ static void CheckCount() {
|
||||
Require(Format(buffer, 16, u"a%n", nullCount) < 0, "vswprintf null %n argument");
|
||||
}
|
||||
|
||||
static void CheckUnsignedSignFlags() {
|
||||
char16_t buffer[32];
|
||||
Require(swprintf_nid_postfix(buffer, 32, u"[% u|%+u|% lu|% 5u|%+x|% #o]", 7u, 7u, 7ul, 7u, 7u, 7u) == 18 &&
|
||||
buffer == std::u16string(u"[7|7|7| 7|7|07]"), "unsigned conversions ignore the space and plus flags");
|
||||
}
|
||||
|
||||
static void CheckGroupingFlag() {
|
||||
char16_t buffer[48];
|
||||
Require(swprintf_nid_postfix(buffer, 48, u"%'d|%'-6u|%'.2f|%'+05d|%'g", 1234567, 42u, 1234.5, 12, 1e6) == 34 &&
|
||||
@@ -340,4 +346,5 @@ int main() {
|
||||
Check(u"%.1s", "\xf0\x9f\x98\x80x", u"");
|
||||
Check(u"%.3s", "\xf0\x9f\x98\x80x", u"\U0001f600x");
|
||||
CheckGroupingFlag();
|
||||
CheckUnsignedSignFlags();
|
||||
}
|
||||
Reference in new issue
Block a user