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

Replace various copies of parse_uint(String) with String::to_uint().

This commit is contained in:
Andreas Kling 2019-05-08 19:21:51 +02:00
parent cea631d90c
commit b5b44a29bb
4 changed files with 6 additions and 70 deletions

View file

@ -3,21 +3,6 @@
#include <signal.h>
#include <AK/AKString.h>
static unsigned parse_uint(const String& str, bool& ok)
{
unsigned value = 0;
for (int i = 0; i < str.length(); ++i) {
if (str[i] < '0' || str[i] > '9') {
ok = false;
return 0;
}
value = value * 10;
value += str[i] - '0';
}
ok = true;
return value;
}
void handle_sigint(int)
{
}
@ -29,7 +14,7 @@ int main(int argc, char** argv)
return 1;
}
bool ok;
unsigned secs = parse_uint(argv[1], ok);
unsigned secs = String(argv[1]).to_uint(ok);
if (!ok) {
fprintf(stderr, "Not a valid number of seconds: \"%s\"\n", argv[1]);
return 1;