1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-14 09:14:58 +00:00

Userland: Convert command line arguments to String/StringView

StringView was used where possible. Some utilities still use libc
functions which expect null-terminated strings, so String objects were
used there instead.
This commit is contained in:
sin-ack 2022-07-11 20:42:03 +00:00 committed by Andreas Kling
parent fded8f861d
commit 60f6bc902b
25 changed files with 101 additions and 100 deletions

View file

@ -42,7 +42,7 @@ ErrorOr<int> serenity_main(Main::Arguments main_arguments)
{
TRY(Core::System::pledge("stdio rpath proc exec"));
char const* placeholder = nullptr;
StringView placeholder;
bool split_with_nulls = false;
char const* specified_delimiter = "\n";
Vector<String> arguments;
@ -74,15 +74,13 @@ ErrorOr<int> serenity_main(Main::Arguments main_arguments)
char entry_separator = split_with_nulls ? '\0' : *specified_delimiter;
StringView placeholder_view { placeholder };
if (!placeholder_view.is_empty())
if (!placeholder.is_empty())
max_lines = 1;
if (arguments.is_empty())
arguments.append("echo");
ParsedInitialArguments initial_arguments(arguments, placeholder_view);
ParsedInitialArguments initial_arguments(arguments, placeholder);
FILE* fp = stdin;
bool is_stdin = true;