mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-21 12:05:15 +00:00
expr: Port to LibMain
This commit is contained in:
parent
0edceb91c4
commit
c5c0c7c620
Notes:
sideshowbarker
2024-07-17 22:43:40 +09:00
Author: https://github.com/kennethmyhra Commit: https://github.com/SerenityOS/serenity/commit/c5c0c7c6206 Pull-request: https://github.com/SerenityOS/serenity/pull/11253 Reviewed-by: https://github.com/alimpfard Reviewed-by: https://github.com/bgianfo ✅
2 changed files with 9 additions and 14 deletions
|
@ -86,7 +86,7 @@ target_link_libraries(dirname LibMain)
|
|||
target_link_libraries(disasm LibX86)
|
||||
target_link_libraries(dmesg LibMain)
|
||||
target_link_libraries(echo LibMain)
|
||||
target_link_libraries(expr LibRegex)
|
||||
target_link_libraries(expr LibRegex LibMain)
|
||||
target_link_libraries(fdtdump LibDeviceTree LibMain)
|
||||
target_link_libraries(file LibGfx LibIPC LibCompress LibMain)
|
||||
target_link_libraries(find LibMain)
|
||||
|
|
|
@ -11,6 +11,8 @@
|
|||
#include <AK/Queue.h>
|
||||
#include <AK/String.h>
|
||||
#include <AK/StringView.h>
|
||||
#include <LibCore/System.h>
|
||||
#include <LibMain/Main.h>
|
||||
#include <LibRegex/Regex.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
@ -571,24 +573,17 @@ NonnullOwnPtr<Expression> Expression::parse(Queue<StringView>& args, Precedence
|
|||
fail("Invalid expression");
|
||||
}
|
||||
|
||||
int main(int argc, char** argv)
|
||||
ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
{
|
||||
if (pledge("stdio", nullptr) < 0) {
|
||||
perror("pledge");
|
||||
return 3;
|
||||
}
|
||||
TRY(Core::System::pledge("stdio"sv));
|
||||
TRY(Core::System::unveil(nullptr, nullptr));
|
||||
|
||||
if (unveil(nullptr, nullptr) < 0) {
|
||||
perror("unveil");
|
||||
return 3;
|
||||
}
|
||||
|
||||
if ((argc == 2 && "--help"sv == argv[1]) || argc == 1)
|
||||
if ((arguments.strings.size() == 2 && "--help"sv == arguments.strings[1]) || arguments.strings.size() == 1)
|
||||
print_help_and_exit();
|
||||
|
||||
Queue<StringView> args;
|
||||
for (int i = 1; i < argc; ++i)
|
||||
args.enqueue(argv[i]);
|
||||
for (size_t i = 1; i < arguments.strings.size(); ++i)
|
||||
args.enqueue(arguments.strings[i]);
|
||||
|
||||
auto expression = Expression::parse(args);
|
||||
if (!args.is_empty())
|
||||
|
|
Loading…
Add table
Reference in a new issue