summaryrefslogtreecommitdiff
path: root/rushs/evalexpr/my_atoi
diff options
context:
space:
mode:
authorMartial Simon <msimon_fr@hotmail.com>2025-10-11 22:19:00 +0200
committerMartial Simon <msimon_fr@hotmail.com>2025-10-11 22:19:00 +0200
commit73c2b00a10c5786ddeeacc915e233fd4df1c9321 (patch)
treee299ea4e8ac161b2b21170172ff8f182c1c3fe1a /rushs/evalexpr/my_atoi
parentc9b6b9a5ca082fe7c1b6f58d7713f785a9eb6a5c (diff)
fix: evalexpr & tinyprintf contenaient toute la piscine
Diffstat (limited to 'rushs/evalexpr/my_atoi')
-rw-r--r--rushs/evalexpr/my_atoi/my_atoi.c61
-rw-r--r--rushs/evalexpr/my_atoi/my_atoi.h8
2 files changed, 0 insertions, 69 deletions
diff --git a/rushs/evalexpr/my_atoi/my_atoi.c b/rushs/evalexpr/my_atoi/my_atoi.c
deleted file mode 100644
index ca185a5..0000000
--- a/rushs/evalexpr/my_atoi/my_atoi.c
+++ /dev/null
@@ -1,61 +0,0 @@
-#include "my_atoi.h"
-
-int my_atoi(const char *str)
-{
- int res = 0;
-
- // str error check
- if (str == NULL || *str == '0')
- {
- return 0;
- }
-
- // trim whitespaces
- for (; *str && *str == ' '; str++)
- {
- continue;
- }
-
- // move to end of str
- size_t l;
- for (l = 0; str[l]; l++)
- {
- continue;
- }
- l--;
-
- // prepare for calculations
- int factor = 1;
-
- // actual conversion of up to the second element of str (potential sign)
- for (; l > 0; l--)
- {
- char val = str[l];
- if (val < '0' || val > '9')
- {
- return 0;
- }
- val -= '0';
- res += val * factor;
-
- factor *= 10;
- }
-
- // l should be 0 by now
- if (str[l] == '-')
- {
- return -res;
- }
- else if (str[l] != '+')
- {
- int val = str[l];
- if (val < '0' || val > '9')
- {
- return 0;
- }
- val -= '0';
- return res + val * factor;
- }
-
- return res;
-}
diff --git a/rushs/evalexpr/my_atoi/my_atoi.h b/rushs/evalexpr/my_atoi/my_atoi.h
deleted file mode 100644
index b520d09..0000000
--- a/rushs/evalexpr/my_atoi/my_atoi.h
+++ /dev/null
@@ -1,8 +0,0 @@
-#ifndef MY_ATOI_H
-#define MY_ATOI_H
-
-#include <stddef.h>
-
-int my_atoi(const char *str);
-
-#endif /* ! MY_ATOI_H */