aboutsummaryrefslogtreecommitdiff
path: root/pk/string.c
diff options
context:
space:
mode:
Diffstat (limited to 'pk/string.c')
-rw-r--r--pk/string.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/pk/string.c b/pk/string.c
index 40b62e9..b1b9abc 100644
--- a/pk/string.c
+++ b/pk/string.c
@@ -1,5 +1,6 @@
#include <string.h>
#include <stdint.h>
+#include <ctype.h>
void* memcpy(void* dest, const void* src, size_t len)
{
@@ -51,3 +52,24 @@ char* strcpy(char* dest, const char* src)
;
return dest;
}
+
+long atol(const char* str)
+{
+ long res = 0;
+ int sign = 0;
+
+ while (*str == ' ')
+ str++;
+
+ if (*str == '-' || *str == '+') {
+ sign = *str == '-';
+ str++;
+ }
+
+ while (*str) {
+ res *= 10;
+ res += *str++ - '0';
+ }
+
+ return sign ? -res : res;
+}