From: Orvid King Date: Tue, 18 Aug 2015 18:53:33 +0000 (-0700) Subject: Adjust Format-inl.h to work with MSVC X-Git-Tag: v0.55.0~14 X-Git-Url: http://plrg.eecs.uci.edu/git/?p=folly.git;a=commitdiff_plain;h=bae1869791b9fad1d53a45e18124e636b4ced923 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 --- 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);