Format.cpp 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637
  1. /*
  2. * Copyright (c) 2020, the SerenityOS developers.
  3. * All rights reserved.
  4. *
  5. * Redistribution and use in source and binary forms, with or without
  6. * modification, are permitted provided that the following conditions are met:
  7. *
  8. * 1. Redistributions of source code must retain the above copyright notice, this
  9. * list of conditions and the following disclaimer.
  10. *
  11. * 2. Redistributions in binary form must reproduce the above copyright notice,
  12. * this list of conditions and the following disclaimer in the documentation
  13. * and/or other materials provided with the distribution.
  14. *
  15. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  16. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  17. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  18. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  19. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  20. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  21. * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  22. * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  23. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  24. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  25. */
  26. #include <AK/Format.h>
  27. #include <AK/GenericLexer.h>
  28. #include <AK/String.h>
  29. #include <AK/StringBuilder.h>
  30. #include <ctype.h>
  31. #ifdef KERNEL
  32. # include <Kernel/Process.h>
  33. # include <Kernel/Thread.h>
  34. #else
  35. # include <stdio.h>
  36. # include <unistd.h>
  37. #endif
  38. namespace AK {
  39. namespace {
  40. constexpr size_t use_next_index = NumericLimits<size_t>::max();
  41. // The worst case is that we have the largest 64-bit value formatted as binary number, this would take
  42. // 65 bytes. Choosing a larger power of two won't hurt and is a bit of mitigation against out-of-bounds accesses.
  43. inline size_t convert_unsigned_to_string(u64 value, Array<u8, 128>& buffer, u8 base, bool upper_case)
  44. {
  45. ASSERT(base >= 2 && base <= 16);
  46. static constexpr const char* lowercase_lookup = "0123456789abcdef";
  47. static constexpr const char* uppercase_lookup = "0123456789ABCDEF";
  48. if (value == 0) {
  49. buffer[0] = '0';
  50. return 1;
  51. }
  52. size_t used = 0;
  53. while (value > 0) {
  54. if (upper_case)
  55. buffer[used++] = uppercase_lookup[value % base];
  56. else
  57. buffer[used++] = lowercase_lookup[value % base];
  58. value /= base;
  59. }
  60. for (size_t i = 0; i < used / 2; ++i)
  61. swap(buffer[i], buffer[used - i - 1]);
  62. return used;
  63. }
  64. void vformat_impl(TypeErasedFormatParams& params, FormatBuilder& builder, FormatParser& parser)
  65. {
  66. const auto literal = parser.consume_literal();
  67. builder.put_literal(literal);
  68. FormatParser::FormatSpecifier specifier;
  69. if (!parser.consume_specifier(specifier)) {
  70. ASSERT(parser.is_eof());
  71. return;
  72. }
  73. if (specifier.index == use_next_index)
  74. specifier.index = params.take_next_index();
  75. auto& parameter = params.parameters().at(specifier.index);
  76. FormatParser argparser { specifier.flags };
  77. parameter.formatter(params, builder, argparser, parameter.value);
  78. vformat_impl(params, builder, parser);
  79. }
  80. } // namespace AK::{anonymous}
  81. size_t TypeErasedFormatParams::decode(size_t value, size_t default_value)
  82. {
  83. if (value == StandardFormatter::value_not_set)
  84. return default_value;
  85. if (value == StandardFormatter::value_from_next_arg)
  86. value = StandardFormatter::value_from_arg + take_next_index();
  87. if (value >= StandardFormatter::value_from_arg) {
  88. const auto parameter = parameters().at(value - StandardFormatter::value_from_arg);
  89. Optional<i64> svalue;
  90. if (parameter.type == TypeErasedParameter::Type::UInt8)
  91. value = *reinterpret_cast<const u8*>(parameter.value);
  92. else if (parameter.type == TypeErasedParameter::Type::UInt16)
  93. value = *reinterpret_cast<const u16*>(parameter.value);
  94. else if (parameter.type == TypeErasedParameter::Type::UInt32)
  95. value = *reinterpret_cast<const u32*>(parameter.value);
  96. else if (parameter.type == TypeErasedParameter::Type::UInt64)
  97. value = *reinterpret_cast<const u64*>(parameter.value);
  98. else if (parameter.type == TypeErasedParameter::Type::Int8)
  99. svalue = *reinterpret_cast<const i8*>(parameter.value);
  100. else if (parameter.type == TypeErasedParameter::Type::Int16)
  101. svalue = *reinterpret_cast<const i16*>(parameter.value);
  102. else if (parameter.type == TypeErasedParameter::Type::Int32)
  103. svalue = *reinterpret_cast<const i32*>(parameter.value);
  104. else if (parameter.type == TypeErasedParameter::Type::Int64)
  105. svalue = *reinterpret_cast<const i64*>(parameter.value);
  106. else
  107. ASSERT_NOT_REACHED();
  108. if (svalue.has_value()) {
  109. ASSERT(svalue.value() >= 0);
  110. value = static_cast<size_t>(svalue.value());
  111. }
  112. }
  113. return value;
  114. }
  115. FormatParser::FormatParser(StringView input)
  116. : GenericLexer(input)
  117. {
  118. }
  119. StringView FormatParser::consume_literal()
  120. {
  121. const auto begin = tell();
  122. while (!is_eof()) {
  123. if (consume_specific("{{"))
  124. continue;
  125. if (consume_specific("}}"))
  126. continue;
  127. if (next_is(is_any_of("{}")))
  128. return m_input.substring_view(begin, tell() - begin);
  129. consume();
  130. }
  131. return m_input.substring_view(begin);
  132. }
  133. bool FormatParser::consume_number(size_t& value)
  134. {
  135. value = 0;
  136. bool consumed_at_least_one = false;
  137. while (next_is(isdigit)) {
  138. value *= 10;
  139. value += consume() - '0';
  140. consumed_at_least_one = true;
  141. }
  142. return consumed_at_least_one;
  143. }
  144. bool FormatParser::consume_specifier(FormatSpecifier& specifier)
  145. {
  146. ASSERT(!next_is('}'));
  147. if (!consume_specific('{'))
  148. return false;
  149. if (!consume_number(specifier.index))
  150. specifier.index = use_next_index;
  151. if (consume_specific(':')) {
  152. const auto begin = tell();
  153. size_t level = 1;
  154. while (level > 0) {
  155. ASSERT(!is_eof());
  156. if (consume_specific('{')) {
  157. ++level;
  158. continue;
  159. }
  160. if (consume_specific('}')) {
  161. --level;
  162. continue;
  163. }
  164. consume();
  165. }
  166. specifier.flags = m_input.substring_view(begin, tell() - begin - 1);
  167. } else {
  168. if (!consume_specific('}'))
  169. ASSERT_NOT_REACHED();
  170. specifier.flags = "";
  171. }
  172. return true;
  173. }
  174. bool FormatParser::consume_replacement_field(size_t& index)
  175. {
  176. if (!consume_specific('{'))
  177. return false;
  178. if (!consume_number(index))
  179. index = use_next_index;
  180. if (!consume_specific('}'))
  181. ASSERT_NOT_REACHED();
  182. return true;
  183. }
  184. void FormatBuilder::put_padding(char fill, size_t amount)
  185. {
  186. for (size_t i = 0; i < amount; ++i)
  187. m_builder.append(fill);
  188. }
  189. void FormatBuilder::put_literal(StringView value)
  190. {
  191. for (size_t i = 0; i < value.length(); ++i) {
  192. m_builder.append(value[i]);
  193. if (value[i] == '{' || value[i] == '}')
  194. ++i;
  195. }
  196. }
  197. void FormatBuilder::put_string(
  198. StringView value,
  199. Align align,
  200. size_t min_width,
  201. size_t max_width,
  202. char fill)
  203. {
  204. const auto used_by_string = min(max_width, value.length());
  205. const auto used_by_padding = max(min_width, used_by_string) - used_by_string;
  206. if (used_by_string < value.length())
  207. value = value.substring_view(0, used_by_string);
  208. if (align == Align::Left || align == Align::Default) {
  209. m_builder.append(value);
  210. put_padding(fill, used_by_padding);
  211. } else if (align == Align::Center) {
  212. const auto used_by_left_padding = used_by_padding / 2;
  213. const auto used_by_right_padding = ceil_div<size_t, size_t>(used_by_padding, 2);
  214. put_padding(fill, used_by_left_padding);
  215. m_builder.append(value);
  216. put_padding(fill, used_by_right_padding);
  217. } else if (align == Align::Right) {
  218. put_padding(fill, used_by_padding);
  219. m_builder.append(value);
  220. }
  221. }
  222. void FormatBuilder::put_u64(
  223. u64 value,
  224. u8 base,
  225. bool prefix,
  226. bool upper_case,
  227. bool zero_pad,
  228. Align align,
  229. size_t min_width,
  230. char fill,
  231. SignMode sign_mode,
  232. bool is_negative)
  233. {
  234. if (align == Align::Default)
  235. align = Align::Right;
  236. Array<u8, 128> buffer;
  237. const auto used_by_digits = convert_unsigned_to_string(value, buffer, base, upper_case);
  238. size_t used_by_prefix = 0;
  239. if (align == Align::Right && zero_pad) {
  240. // We want String::formatted("{:#08x}", 32) to produce '0x00000020' instead of '0x000020'. This
  241. // behaviour differs from both fmtlib and printf, but is more intuitive.
  242. used_by_prefix = 0;
  243. } else {
  244. if (is_negative || sign_mode != SignMode::OnlyIfNeeded)
  245. used_by_prefix += 1;
  246. if (prefix) {
  247. if (base == 8)
  248. used_by_prefix += 1;
  249. else if (base == 16)
  250. used_by_prefix += 2;
  251. else if (base == 2)
  252. used_by_prefix += 2;
  253. }
  254. }
  255. const auto used_by_field = used_by_prefix + used_by_digits;
  256. const auto used_by_padding = max(used_by_field, min_width) - used_by_field;
  257. const auto put_prefix = [&]() {
  258. if (is_negative)
  259. m_builder.append('-');
  260. else if (sign_mode == SignMode::Always)
  261. m_builder.append('+');
  262. else if (sign_mode == SignMode::Reserved)
  263. m_builder.append(' ');
  264. if (prefix) {
  265. if (base == 2) {
  266. if (upper_case)
  267. m_builder.append("0B");
  268. else
  269. m_builder.append("0b");
  270. } else if (base == 8) {
  271. m_builder.append("0");
  272. } else if (base == 16) {
  273. if (upper_case)
  274. m_builder.append("0X");
  275. else
  276. m_builder.append("0x");
  277. }
  278. }
  279. };
  280. const auto put_digits = [&]() {
  281. for (size_t i = 0; i < used_by_digits; ++i)
  282. m_builder.append(buffer[i]);
  283. };
  284. if (align == Align::Left) {
  285. const auto used_by_right_padding = used_by_padding;
  286. put_prefix();
  287. put_digits();
  288. put_padding(fill, used_by_right_padding);
  289. } else if (align == Align::Center) {
  290. const auto used_by_left_padding = used_by_padding / 2;
  291. const auto used_by_right_padding = ceil_div<size_t, size_t>(used_by_padding, 2);
  292. put_padding(fill, used_by_left_padding);
  293. put_prefix();
  294. put_digits();
  295. put_padding(fill, used_by_right_padding);
  296. } else if (align == Align::Right) {
  297. const auto used_by_left_padding = used_by_padding;
  298. if (zero_pad) {
  299. put_prefix();
  300. put_padding('0', used_by_left_padding);
  301. put_digits();
  302. } else {
  303. put_padding(fill, used_by_left_padding);
  304. put_prefix();
  305. put_digits();
  306. }
  307. }
  308. }
  309. void FormatBuilder::put_i64(
  310. i64 value,
  311. u8 base,
  312. bool prefix,
  313. bool upper_case,
  314. bool zero_pad,
  315. Align align,
  316. size_t min_width,
  317. char fill,
  318. SignMode sign_mode)
  319. {
  320. const auto is_negative = value < 0;
  321. value = is_negative ? -value : value;
  322. put_u64(static_cast<size_t>(value), base, prefix, upper_case, zero_pad, align, min_width, fill, sign_mode, is_negative);
  323. }
  324. void vformat(StringBuilder& builder, StringView fmtstr, TypeErasedFormatParams params)
  325. {
  326. FormatBuilder fmtbuilder { builder };
  327. FormatParser parser { fmtstr };
  328. vformat_impl(params, fmtbuilder, parser);
  329. }
  330. void vformat(const LogStream& stream, StringView fmtstr, TypeErasedFormatParams params)
  331. {
  332. StringBuilder builder;
  333. vformat(builder, fmtstr, params);
  334. stream << builder.to_string();
  335. }
  336. void StandardFormatter::parse(TypeErasedFormatParams& params, FormatParser& parser)
  337. {
  338. if (StringView { "<^>" }.contains(parser.peek(1))) {
  339. ASSERT(!parser.next_is(is_any_of("{}")));
  340. m_fill = parser.consume();
  341. }
  342. if (parser.consume_specific('<'))
  343. m_align = FormatBuilder::Align::Left;
  344. else if (parser.consume_specific('^'))
  345. m_align = FormatBuilder::Align::Center;
  346. else if (parser.consume_specific('>'))
  347. m_align = FormatBuilder::Align::Right;
  348. if (parser.consume_specific('-'))
  349. m_sign_mode = FormatBuilder::SignMode::OnlyIfNeeded;
  350. else if (parser.consume_specific('+'))
  351. m_sign_mode = FormatBuilder::SignMode::Always;
  352. else if (parser.consume_specific(' '))
  353. m_sign_mode = FormatBuilder::SignMode::Reserved;
  354. if (parser.consume_specific('#'))
  355. m_alternative_form = true;
  356. if (parser.consume_specific('0'))
  357. m_zero_pad = true;
  358. if (size_t index = 0; parser.consume_replacement_field(index)) {
  359. if (index == use_next_index)
  360. index = params.take_next_index();
  361. m_width = value_from_arg + index;
  362. } else if (size_t width = 0; parser.consume_number(width)) {
  363. m_width = width;
  364. }
  365. if (parser.consume_specific('.')) {
  366. if (size_t index = 0; parser.consume_replacement_field(index)) {
  367. if (index == use_next_index)
  368. index = params.take_next_index();
  369. m_precision = value_from_arg + index;
  370. } else if (size_t precision = 0; parser.consume_number(precision)) {
  371. m_precision = precision;
  372. }
  373. }
  374. if (parser.consume_specific('b'))
  375. m_mode = Mode::Binary;
  376. else if (parser.consume_specific('B'))
  377. m_mode = Mode::BinaryUppercase;
  378. else if (parser.consume_specific('d'))
  379. m_mode = Mode::Decimal;
  380. else if (parser.consume_specific('o'))
  381. m_mode = Mode::Octal;
  382. else if (parser.consume_specific('x'))
  383. m_mode = Mode::Hexadecimal;
  384. else if (parser.consume_specific('X'))
  385. m_mode = Mode::HexadecimalUppercase;
  386. else if (parser.consume_specific('c'))
  387. m_mode = Mode::Character;
  388. else if (parser.consume_specific('s'))
  389. m_mode = Mode::String;
  390. else if (parser.consume_specific('p'))
  391. m_mode = Mode::Pointer;
  392. if (!parser.is_eof())
  393. dbgln("{} did not consume '{}'", __PRETTY_FUNCTION__, parser.remaining());
  394. ASSERT(parser.is_eof());
  395. }
  396. void Formatter<StringView>::format(TypeErasedFormatParams& params, FormatBuilder& builder, StringView value)
  397. {
  398. if (m_sign_mode != FormatBuilder::SignMode::Default)
  399. ASSERT_NOT_REACHED();
  400. if (m_alternative_form)
  401. ASSERT_NOT_REACHED();
  402. if (m_zero_pad)
  403. ASSERT_NOT_REACHED();
  404. if (m_mode != Mode::Default && m_mode != Mode::String)
  405. ASSERT_NOT_REACHED();
  406. if (m_width != value_not_set && m_precision != value_not_set)
  407. ASSERT_NOT_REACHED();
  408. const auto width = params.decode(m_width);
  409. const auto precision = params.decode(m_precision, NumericLimits<size_t>::max());
  410. builder.put_string(value, m_align, width, precision, m_fill);
  411. }
  412. template<typename T>
  413. void Formatter<T, typename EnableIf<IsIntegral<T>::value>::Type>::format(TypeErasedFormatParams& params, FormatBuilder& builder, T value)
  414. {
  415. if (m_mode == Mode::Character) {
  416. // FIXME: We just support ASCII for now, in the future maybe unicode?
  417. ASSERT(value >= 0 && value <= 127);
  418. m_mode = Mode::String;
  419. Formatter<StringView> formatter { *this };
  420. return formatter.format(params, builder, StringView { reinterpret_cast<const char*>(&value), 1 });
  421. }
  422. if (m_precision != NumericLimits<size_t>::max())
  423. ASSERT_NOT_REACHED();
  424. if (m_mode == Mode::Pointer) {
  425. if (m_sign_mode != FormatBuilder::SignMode::Default)
  426. ASSERT_NOT_REACHED();
  427. if (m_align != FormatBuilder::Align::Default)
  428. ASSERT_NOT_REACHED();
  429. if (m_alternative_form)
  430. ASSERT_NOT_REACHED();
  431. if (m_width != value_not_set)
  432. ASSERT_NOT_REACHED();
  433. m_mode = Mode::Hexadecimal;
  434. m_alternative_form = true;
  435. m_width = 2 * sizeof(void*);
  436. m_zero_pad = true;
  437. }
  438. u8 base = 0;
  439. bool upper_case = false;
  440. if (m_mode == Mode::Binary) {
  441. base = 2;
  442. } else if (m_mode == Mode::BinaryUppercase) {
  443. base = 2;
  444. upper_case = true;
  445. } else if (m_mode == Mode::Octal) {
  446. base = 8;
  447. } else if (m_mode == Mode::Decimal || m_mode == Mode::Default) {
  448. base = 10;
  449. } else if (m_mode == Mode::Hexadecimal) {
  450. base = 16;
  451. } else if (m_mode == Mode::HexadecimalUppercase) {
  452. base = 16;
  453. upper_case = true;
  454. } else {
  455. ASSERT_NOT_REACHED();
  456. }
  457. const auto width = params.decode(m_width);
  458. if (IsSame<typename MakeUnsigned<T>::Type, T>::value)
  459. builder.put_u64(value, base, m_alternative_form, upper_case, m_zero_pad, m_align, width, m_fill, m_sign_mode);
  460. else
  461. builder.put_i64(value, base, m_alternative_form, upper_case, m_zero_pad, m_align, width, m_fill, m_sign_mode);
  462. }
  463. void Formatter<char>::format(TypeErasedFormatParams& params, FormatBuilder& builder, char value)
  464. {
  465. if (m_mode == Mode::Binary || m_mode == Mode::BinaryUppercase || m_mode == Mode::Decimal || m_mode == Mode::Octal || m_mode == Mode::Hexadecimal || m_mode == Mode::HexadecimalUppercase) {
  466. // Trick: signed char != char. (Sometimes weird features are actually helpful.)
  467. Formatter<signed char> formatter { *this };
  468. return formatter.format(params, builder, static_cast<signed char>(value));
  469. } else {
  470. Formatter<StringView> formatter { *this };
  471. return formatter.format(params, builder, { &value, 1 });
  472. }
  473. }
  474. void Formatter<bool>::format(TypeErasedFormatParams& params, FormatBuilder& builder, bool value)
  475. {
  476. if (m_mode == Mode::Binary || m_mode == Mode::BinaryUppercase || m_mode == Mode::Decimal || m_mode == Mode::Octal || m_mode == Mode::Hexadecimal || m_mode == Mode::HexadecimalUppercase) {
  477. Formatter<u8> formatter { *this };
  478. return formatter.format(params, builder, static_cast<u8>(value));
  479. } else {
  480. Formatter<StringView> formatter { *this };
  481. return formatter.format(params, builder, value ? "true" : "false");
  482. }
  483. }
  484. #ifndef KERNEL
  485. void vout(FILE* file, StringView fmtstr, TypeErasedFormatParams params, bool newline)
  486. {
  487. StringBuilder builder;
  488. vformat(builder, fmtstr, params);
  489. if (newline)
  490. builder.append('\n');
  491. const auto string = builder.string_view();
  492. const auto retval = ::fwrite(string.characters_without_null_termination(), 1, string.length(), file);
  493. ASSERT(static_cast<size_t>(retval) == string.length());
  494. }
  495. #endif
  496. void vdbgln(StringView fmtstr, TypeErasedFormatParams params)
  497. {
  498. StringBuilder builder;
  499. // FIXME: This logic is redundant with the stuff in LogStream.cpp.
  500. #if defined(__serenity__)
  501. # ifdef KERNEL
  502. if (Kernel::Processor::is_initialized() && Kernel::Thread::current()) {
  503. auto& thread = *Kernel::Thread::current();
  504. builder.appendff("\033[34;1m[{}({}:{})]\033[0m: ", thread.process().name(), thread.pid().value(), thread.tid().value());
  505. } else {
  506. builder.appendff("\033[34;1m[Kernel]\033[0m: ");
  507. }
  508. # else
  509. static TriState got_process_name = TriState::Unknown;
  510. static char process_name_buffer[256];
  511. if (got_process_name == TriState::Unknown) {
  512. if (get_process_name(process_name_buffer, sizeof(process_name_buffer)) == 0)
  513. got_process_name = TriState::True;
  514. else
  515. got_process_name = TriState::False;
  516. }
  517. if (got_process_name == TriState::True)
  518. builder.appendff("\033[33;1m{}({})\033[0m: ", process_name_buffer, getpid());
  519. # endif
  520. #endif
  521. vformat(builder, fmtstr, params);
  522. builder.append('\n');
  523. const auto string = builder.string_view();
  524. const auto retval = dbgputstr(string.characters_without_null_termination(), string.length());
  525. ASSERT(retval == 0);
  526. }
  527. template struct Formatter<unsigned char, void>;
  528. template struct Formatter<unsigned short, void>;
  529. template struct Formatter<unsigned int, void>;
  530. template struct Formatter<unsigned long, void>;
  531. template struct Formatter<unsigned long long, void>;
  532. template struct Formatter<short, void>;
  533. template struct Formatter<int, void>;
  534. template struct Formatter<long, void>;
  535. template struct Formatter<long long, void>;
  536. template struct Formatter<signed char, void>;
  537. } // namespace AK