[Workflow] Roll back some settings since they caused more issues
[llvm-project.git] / libc / src / stdio / printf_core / printf_main.cpp
blob60d1e210eee4cf86de9087f12cd6feb60c3678c0
1 //===-- Starting point 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 //===----------------------------------------------------------------------===//
9 #include "src/stdio/printf_core/printf_main.h"
11 #include "src/__support/arg_list.h"
12 #include "src/stdio/printf_core/converter.h"
13 #include "src/stdio/printf_core/core_structs.h"
14 #include "src/stdio/printf_core/parser.h"
15 #include "src/stdio/printf_core/writer.h"
17 #include <stddef.h>
19 namespace __llvm_libc {
20 namespace printf_core {
22 int printf_main(Writer *writer, const char *__restrict str,
23 internal::ArgList &args) {
24 Parser<internal::ArgList> parser(str, args);
25 int result = 0;
26 for (FormatSection cur_section = parser.get_next_section();
27 !cur_section.raw_string.empty();
28 cur_section = parser.get_next_section()) {
29 if (cur_section.has_conv)
30 result = convert(writer, cur_section);
31 else
32 result = writer->write(cur_section.raw_string);
34 if (result < 0)
35 return result;
38 return writer->get_chars_written();
41 } // namespace printf_core
42 } // namespace __llvm_libc