- case 'n': {
- arg.enforce(!arg.basePrefix,
- "base prefix not allowed with '", presentation,
- "' specifier");
-
- arg.enforce(!arg.thousandsSeparator,
- "cannot use ',' with the '", presentation,
- "' specifier");
-
- valBufBegin = valBuf + 3; // room for sign and base prefix
- int len = snprintf(valBufBegin, (valBuf + valBufSize) - valBufBegin,
- "%'ju", static_cast<uintmax_t>(uval));
- // valBufSize should always be big enough, so this should never
- // happen.
- assert(len < valBuf + valBufSize - valBufBegin);
- valBufEnd = valBufBegin + len;
- break;
- }
- case 'd':
- arg.enforce(!arg.basePrefix,
- "base prefix not allowed with '", presentation,
- "' specifier");
- valBufBegin = valBuf + 3; // room for sign and base prefix
-
- // Use uintToBuffer, faster than sprintf
- valBufEnd = valBufBegin + uint64ToBufferUnsafe(uval, valBufBegin);
- if (arg.thousandsSeparator) {
- detail::insertThousandsGroupingUnsafe(valBufBegin, &valBufEnd);
- }
- break;
- case 'c':
- arg.enforce(!arg.basePrefix,
- "base prefix not allowed with '", presentation,
- "' specifier");
- arg.enforce(!arg.thousandsSeparator,
- "thousands separator (',') not allowed with '",
- presentation, "' specifier");
- valBufBegin = valBuf + 3;
- *valBufBegin = static_cast<char>(uval);
- valBufEnd = valBufBegin + 1;
- break;
- case 'o':
- case 'O':
- arg.enforce(!arg.thousandsSeparator,
- "thousands separator (',') not allowed with '",
- presentation, "' specifier");
- valBufEnd = valBuf + valBufSize - 1;
- valBufBegin = valBuf + detail::uintToOctal(valBuf, valBufSize - 1, uval);
- if (arg.basePrefix) {
- *--valBufBegin = '0';
- prefixLen = 1;
- }
- break;
- case 'x':
- arg.enforce(!arg.thousandsSeparator,
- "thousands separator (',') not allowed with '",
- presentation, "' specifier");
- valBufEnd = valBuf + valBufSize - 1;
- valBufBegin = valBuf + detail::uintToHexLower(valBuf, valBufSize - 1,
- uval);
- if (arg.basePrefix) {
- *--valBufBegin = 'x';
- *--valBufBegin = '0';
- prefixLen = 2;
- }
- break;
- case 'X':
- arg.enforce(!arg.thousandsSeparator,
- "thousands separator (',') not allowed with '",
- presentation, "' specifier");
- valBufEnd = valBuf + valBufSize - 1;
- valBufBegin = valBuf + detail::uintToHexUpper(valBuf, valBufSize - 1,
- uval);
- if (arg.basePrefix) {
- *--valBufBegin = 'X';
- *--valBufBegin = '0';
- prefixLen = 2;
- }
- break;
- case 'b':
- case 'B':
- arg.enforce(!arg.thousandsSeparator,
- "thousands separator (',') not allowed with '",
- presentation, "' specifier");
- valBufEnd = valBuf + valBufSize - 1;
- valBufBegin = valBuf + detail::uintToBinary(valBuf, valBufSize - 1,
- uval);
- if (arg.basePrefix) {
- *--valBufBegin = presentation; // 0b or 0B
- *--valBufBegin = '0';
- prefixLen = 2;
+ case 'n': {
+ arg.enforce(
+ !arg.basePrefix,
+ "base prefix not allowed with '",
+ presentation,
+ "' specifier");
+
+ arg.enforce(
+ !arg.thousandsSeparator,
+ "cannot use ',' with the '",
+ presentation,
+ "' specifier");
+
+ valBufBegin = valBuf + 3; // room for sign and base prefix
+#if defined(__ANDROID__)
+ int len = snprintf(
+ valBufBegin,
+ (valBuf + valBufSize) - valBufBegin,
+ "%" PRIuMAX,
+ static_cast<uintmax_t>(uval));
+#else
+ int len = snprintf(
+ valBufBegin,
+ size_t((valBuf + valBufSize) - valBufBegin),
+ "%ju",
+ static_cast<uintmax_t>(uval));
+#endif
+ // valBufSize should always be big enough, so this should never
+ // happen.
+ assert(len < valBuf + valBufSize - valBufBegin);
+ valBufEnd = valBufBegin + len;
+ break;