1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 09:17:35 +00:00

AK: Make string-to-number conversion helpers return Optional

Get rid of the weird old signature:

- int StringType::to_int(bool& ok) const

And replace it with sensible new signature:

- Optional<int> StringType::to_int() const
This commit is contained in:
Andreas Kling 2020-06-12 21:07:52 +02:00
parent 15f4043a7a
commit fdfda6dec2
55 changed files with 354 additions and 455 deletions

View file

@ -74,15 +74,16 @@ int main(int argc, char** argv)
pid_t pid_to_omit = 0;
if (omit_pid_value) {
bool ok = true;
if (!strcmp(omit_pid_value, "%PPID"))
if (!strcmp(omit_pid_value, "%PPID")) {
pid_to_omit = getppid();
else
pid_to_omit = StringView(omit_pid_value).to_uint(ok);
if (!ok) {
fprintf(stderr, "Invalid value for -o\n");
args_parser.print_usage(stderr, argv[0]);
return 1;
} else {
auto number = StringView(omit_pid_value).to_uint();
if (!number.has_value()) {
fprintf(stderr, "Invalid value for -o\n");
args_parser.print_usage(stderr, argv[0]);
return 1;
}
pid_to_omit = number.value();
}
}
return pid_of(process_name, single_shot, omit_pid_value != nullptr, pid_to_omit);