From bae1869791b9fad1d53a45e18124e636b4ced923 Mon Sep 17 00:00:00 2001 From: Orvid King Date: Tue, 18 Aug 2015 11:53:33 -0700 Subject: [PATCH] Adjust Format-inl.h to work with MSVC Summary: Originally #247, which was closed before being merged, this doesn't change the behavior of the formatting function now. Closes #297 Reviewed By: @yfeldblum Differential Revision: D2340712 Pulled By: @sgolemon --- folly/Format-inl.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/folly/Format-inl.h b/folly/Format-inl.h index 56adcd01..64591d6a 100644 --- a/folly/Format-inl.h +++ b/folly/Format-inl.h @@ -490,8 +490,21 @@ class FormatValue< "' specifier"); valBufBegin = valBuf + 3; // room for sign and base prefix +#ifdef _MSC_VER + char valBuf2[valBufSize]; + snprintf(valBuf2, valBufSize, "%ju", static_cast(uval)); + int len = GetNumberFormat( + LOCALE_USER_DEFAULT, + 0, + valBuf2, + nullptr, + valBufBegin, + (int)((valBuf + valBufSize) - valBufBegin) + ); +#else int len = snprintf(valBufBegin, (valBuf + valBufSize) - valBufBegin, "%'ju", static_cast(uval)); +#endif // valBufSize should always be big enough, so this should never // happen. assert(len < valBuf + valBufSize - valBufBegin); -- 2.34.1