1 //===-- String Converter for printf -----------------------------*- C++ -*-===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 9 #include "src/stdio/printf_core/core_structs.h" 10 #include "src/stdio/printf_core/writer.h" 11 12 namespace __llvm_libc { 13 namespace printf_core { 14 15 void convert_char(Writer *writer, FormatSection to_conv) { 16 char c = to_conv.conv_val_raw; 17 18 if (to_conv.min_width > 1) { 19 if ((to_conv.flags & FormatFlags::LEFT_JUSTIFIED) == 20 FormatFlags::LEFT_JUSTIFIED) { 21 writer->write(&c, 1); 22 writer->write_chars(' ', to_conv.min_width - 1); 23 } else { 24 writer->write_chars(' ', to_conv.min_width - 1); 25 writer->write(&c, 1); 26 } 27 } else { 28 writer->write(&c, 1); 29 } 30 } 31 32 } // namespace printf_core 33 } // namespace __llvm_libc 34