From 544609b40f0633f451ae94c60cf29005edddfad2 Mon Sep 17 00:00:00 2001 From: Brian Gianforcaro Date: Sun, 20 Mar 2022 13:30:32 -0700 Subject: [PATCH] printf: Port to LibMain --- Userland/Utilities/CMakeLists.txt | 1 + Userland/Utilities/printf.cpp | 10 +++++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/Userland/Utilities/CMakeLists.txt b/Userland/Utilities/CMakeLists.txt index 7a0c2de72d..e7e60f4aa1 100644 --- a/Userland/Utilities/CMakeLists.txt +++ b/Userland/Utilities/CMakeLists.txt @@ -162,6 +162,7 @@ target_link_libraries(ping LibMain) target_link_libraries(pls LibCrypt LibMain) target_link_libraries(pmap LibMain) target_link_libraries(pmemdump LibMain) +target_link_libraries(printf LibMain) target_link_libraries(pro LibMain LibProtocol) target_link_libraries(profile LibMain) target_link_libraries(ps LibMain) diff --git a/Userland/Utilities/printf.cpp b/Userland/Utilities/printf.cpp index 1ea46d54b4..36099d4e7d 100644 --- a/Userland/Utilities/printf.cpp +++ b/Userland/Utilities/printf.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include #include @@ -253,10 +254,13 @@ static String handle_escapes(const char* string) return builder.build(); } -int main(int argc, char** argv) +ErrorOr serenity_main(Main::Arguments arguments) { - if (argc < 2) - return 1; + if (arguments.argc < 2) + return Error::from_errno(EINVAL); + + auto argc = arguments.argc; + auto argv = arguments.argv; ++argv; String format = handle_escapes(*(argv++));