aboutsummaryrefslogtreecommitdiff
path: root/src/userspace/mlibc/stdlib/atoi.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/userspace/mlibc/stdlib/atoi.c')
-rw-r--r--src/userspace/mlibc/stdlib/atoi.c28
1 files changed, 16 insertions, 12 deletions
diff --git a/src/userspace/mlibc/stdlib/atoi.c b/src/userspace/mlibc/stdlib/atoi.c
index 67a603e..f1c3755 100644
--- a/src/userspace/mlibc/stdlib/atoi.c
+++ b/src/userspace/mlibc/stdlib/atoi.c
@@ -5,20 +5,24 @@
int atoi(char *str)
{
- size_t s_str = strlen(str);
- if (!s_str) return 0;
+ size_t s_str = strlen(str);
+ if (!s_str)
+ return 0;
- uint8_t negative = 0;
- if (str[0] == '-') negative = 1;
+ uint8_t negative = 0;
+ if (str[0] == '-')
+ negative = 1;
- size_t i = 0;
- if (negative) i++;
+ size_t i = 0;
+ if (negative)
+ i++;
- int ret = 0;
- for (; i < s_str; i++) {
- ret += (str[i] - '0') * pow(10, (s_str - i) - 1);
- }
+ int ret = 0;
+ for (; i < s_str; i++) {
+ ret += (str[i] - '0') * pow(10, (s_str - i) - 1);
+ }
- if (negative) ret *= -1;
- return ret;
+ if (negative)
+ ret *= -1;
+ return ret;
} \ No newline at end of file