summaryrefslogtreecommitdiff
path: root/Userland/kill.cpp
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-05-08 19:21:51 +0200
committerAndreas Kling <awesomekling@gmail.com>2019-05-08 19:21:51 +0200
commitb5b44a29bbfbf83e348ab0007d04039fb252bbe5 (patch)
tree4138c5d79961cf8d5582bdb46ca712ac1f246b9b /Userland/kill.cpp
parentcea631d90c4808b3d161fa25bbf09af65a72ef62 (diff)
downloadserenity-b5b44a29bbfbf83e348ab0007d04039fb252bbe5.zip
Replace various copies of parse_uint(String) with String::to_uint().
Diffstat (limited to 'Userland/kill.cpp')
-rw-r--r--Userland/kill.cpp23
1 files changed, 2 insertions, 21 deletions
diff --git a/Userland/kill.cpp b/Userland/kill.cpp
index ddc6bdda91..7b1cb9a1d1 100644
--- a/Userland/kill.cpp
+++ b/Userland/kill.cpp
@@ -4,25 +4,6 @@
#include <stdlib.h>
#include <AK/AKString.h>
-static unsigned parse_uint(const String& str, bool& ok)
-{
- if (str.is_empty()) {
- ok = false;
- return 0;
- }
- 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 += (unsigned)(str[i] - '0');
- }
- ok = true;
- return value;
-}
-
static void print_usage_and_exit()
{
printf("usage: kill [-signal] <PID>\n");
@@ -40,13 +21,13 @@ int main(int argc, char** argv)
pid_argi = 2;
if (argv[1][0] != '-')
print_usage_and_exit();
- signum = parse_uint(&argv[1][1], ok);
+ signum = String(&argv[1][1]).to_uint(ok);
if (!ok) {
printf("'%s' is not a valid signal number\n", &argv[1][1]);
return 2;
}
}
- unsigned pid = parse_uint(argv[pid_argi], ok);
+ unsigned pid = String(argv[pid_argi]).to_uint(ok);
if (!ok) {
printf("'%s' is not a valid PID\n", argv[pid_argi]);
return 3;