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:
parent
cea631d90c
commit
b5b44a29bb
4 changed files with 6 additions and 70 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue