Fix compile error on OpenBSD

This commit is contained in:
Michael Nickerson 2022-08-03 20:32:38 -04:00 committed by Johannes Altmanninger
parent d1f08d4944
commit b08a962edb
3 changed files with 17 additions and 0 deletions

View File

@ -648,6 +648,16 @@ void format_long_safe(wchar_t buff[64], long val) {
}
}
void format_llong_safe(wchar_t buff[64], long long val) {
unsigned long long uval = absolute_value(val);
if (val >= 0) {
format_safe_impl(buff, 64, uval);
} else {
buff[0] = '-';
format_safe_impl(buff + 1, 63, uval);
}
}
void format_ullong_safe(wchar_t buff[64], unsigned long long val) {
return format_safe_impl(buff, 64, val);
}

View File

@ -329,6 +329,7 @@ void format_size_safe(char buff[128], unsigned long long sz);
/// Writes out a long safely.
void format_long_safe(char buff[64], long val);
void format_long_safe(wchar_t buff[64], long val);
void format_llong_safe(wchar_t buff[64], long long val);
void format_ullong_safe(wchar_t buff[64], unsigned long long val);
/// "Narrows" a wide character string. This just grabs any ASCII characters and trunactes.

View File

@ -139,6 +139,12 @@ inline wcstring to_string(long x) {
return wcstring(buff);
}
inline wcstring to_string(long long x) {
wchar_t buff[64];
format_llong_safe(buff, x);
return wcstring(buff);
}
inline wcstring to_string(unsigned long long x) {
wchar_t buff[64];
format_ullong_safe(buff, x);