mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 06:47:35 +00:00
LibCore+Everywhere: Remove ArgsParser::add*(char const*&)
This is not guaranteed to always work correctly as ArgsParser deals in StringViews and might have a non-properly-null-terminated string as a value. As a bonus, using StringView (and DeprecatedString where necessary) leads to nicer looking code too :^)
This commit is contained in:
parent
60908adcbe
commit
500044906d
43 changed files with 122 additions and 145 deletions
|
@ -19,7 +19,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
bool print_iso_8601 = false;
|
||||
bool print_rfc_3339 = false;
|
||||
bool print_rfc_5322 = false;
|
||||
char const* set_date = nullptr;
|
||||
StringView set_date;
|
||||
StringView format_string;
|
||||
|
||||
Core::ArgsParser args_parser;
|
||||
|
@ -31,8 +31,8 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
args_parser.add_positional_argument(format_string, "Custom format to print the date in", "format-string", Core::ArgsParser::Required::No);
|
||||
args_parser.parse(arguments);
|
||||
|
||||
if (set_date != nullptr) {
|
||||
auto number = DeprecatedString(set_date).to_uint();
|
||||
if (!set_date.is_empty()) {
|
||||
auto number = set_date.to_uint();
|
||||
|
||||
if (!number.has_value()) {
|
||||
warnln("date: Invalid timestamp value");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue