summaryrefslogtreecommitdiff
path: root/include/fud_format.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'include/fud_format.hpp')
-rw-r--r--include/fud_format.hpp21
1 files changed, 14 insertions, 7 deletions
diff --git a/include/fud_format.hpp b/include/fud_format.hpp
index 2102dc9..9be3dd9 100644
--- a/include/fud_format.hpp
+++ b/include/fud_format.hpp
@@ -32,8 +32,10 @@
#include <concepts>
#include <cstdint>
+#include <format>
#include <limits>
#include <variant>
+#include <cstdio>
namespace fud {
@@ -716,21 +718,24 @@ FudStatus fillSignedBuffer(IntCharArray& buffer, T value, uint8_t& bufferLength,
{
static_assert(sizeof(T) <= sizeof(uint64_t));
static_assert(std::is_signed_v<T>);
+ uint64_t unsignedValue{};
if (value < 0) {
value++;
- value = -value;
- value++;
+ unsignedValue = static_cast<uint64_t>(-value);
+ unsignedValue++;
+ } else {
+ unsignedValue = static_cast<uint64_t>(value);
}
if constexpr (std::is_same_v<T, char>) {
- return fillUnsignedBuffer(buffer, static_cast<uint8_t>(value), bufferLength, radix, uppercase);
+ return fillUnsignedBuffer(buffer, static_cast<uint8_t>(unsignedValue), bufferLength, radix, uppercase);
} else if constexpr (std::is_same_v<T, int8_t>) {
- return fillUnsignedBuffer(buffer, static_cast<uint8_t>(value), bufferLength, radix, uppercase);
+ return fillUnsignedBuffer(buffer, static_cast<uint8_t>(unsignedValue), bufferLength, radix, uppercase);
} else if constexpr (std::is_same_v<T, int16_t>) {
- return fillUnsignedBuffer(buffer, static_cast<uint16_t>(value), bufferLength, radix, uppercase);
+ return fillUnsignedBuffer(buffer, static_cast<uint16_t>(unsignedValue), bufferLength, radix, uppercase);
} else if constexpr (std::is_same_v<T, int32_t>) {
- return fillUnsignedBuffer(buffer, static_cast<uint32_t>(value), bufferLength, radix, uppercase);
+ return fillUnsignedBuffer(buffer, static_cast<uint32_t>(unsignedValue), bufferLength, radix, uppercase);
} else if constexpr (std::is_same_v<T, int64_t>) {
- return fillUnsignedBuffer(buffer, static_cast<uint64_t>(value), bufferLength, radix, uppercase);
+ return fillUnsignedBuffer(buffer, static_cast<uint64_t>(unsignedValue), bufferLength, radix, uppercase);
}
}
@@ -1441,6 +1446,8 @@ FormatResult format(Sink& sink, FormatCharMode formatMode, const FormatSpec& for
return result;
}
+ // printf("From format(sink, mode, spec, stringview arg): Arg contents are %p %zu?\n\n", arg.c_str(), arg.length());
+ // printf("From format(sink, mode, spec, stringview arg): What?\n%s\n", std::format("{}", std::string_view{arg.c_str(), arg.length()}).c_str());
auto drainViewResult = sink.drain(arg);
result.bytesDrained += drainViewResult.bytesDrained;
result.status = drainViewResult.status;