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

@ -14,16 +14,16 @@
ErrorOr<int> serenity_main(Main::Arguments args)
{
char const* hostname = nullptr;
StringView hostname {};
Core::ArgsParser args_parser;
args_parser.add_positional_argument(hostname, "Hostname to set", "hostname", Core::ArgsParser::Required::No);
args_parser.parse(args);
if (!hostname) {
if (hostname.is_empty()) {
outln("{}", TRY(Core::System::gethostname()));
} else {
if (strlen(hostname) >= HOST_NAME_MAX) {
if (hostname.length() >= HOST_NAME_MAX) {
warnln("Hostname must be less than {} characters", HOST_NAME_MAX);
return 1;
}