From 73c2b00a10c5786ddeeacc915e233fd4df1c9321 Mon Sep 17 00:00:00 2001 From: Martial Simon Date: Sat, 11 Oct 2025 22:19:00 +0200 Subject: fix: evalexpr & tinyprintf contenaient toute la piscine --- rushs/tinyprintf/my_atoi_base/my_atoi_base.c | 86 ---------------------------- rushs/tinyprintf/my_atoi_base/my_atoi_base.h | 8 --- 2 files changed, 94 deletions(-) delete mode 100644 rushs/tinyprintf/my_atoi_base/my_atoi_base.c delete mode 100644 rushs/tinyprintf/my_atoi_base/my_atoi_base.h (limited to 'rushs/tinyprintf/my_atoi_base') diff --git a/rushs/tinyprintf/my_atoi_base/my_atoi_base.c b/rushs/tinyprintf/my_atoi_base/my_atoi_base.c deleted file mode 100644 index 46b4560..0000000 --- a/rushs/tinyprintf/my_atoi_base/my_atoi_base.c +++ /dev/null @@ -1,86 +0,0 @@ -#include "my_atoi_base.h" - -int val_in_base(char c, const char *base) -{ - size_t i; - for (i = 0; base[i] && base[i] != c; i++) - { - continue; - } - - if (base[i]) - { - return i; - } - - return -1; -} - -int base_size(const char *base) -{ - int res; - for (res = 0; base[res]; res++) - { - continue; - } - return res; -} - -int my_atoi_base(const char *str, const char *base) -{ - 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 b = base_size(base); - int factor = 1; - - // actual conversion of up to the second element of str (potential sign) - for (; l > 0; l--) - { - int val = val_in_base(str[l], base); - if (val == -1) - { - return 0; - } - res += val * factor; - - factor *= b; - } - - // l should be 0 by now - if (str[l] == '-') - { - return -res; - } - else if (str[l] != '+') - { - int val = val_in_base(str[l], base); - if (val == -1) - { - return 0; - } - return res + val * factor; - } - - return res; -} diff --git a/rushs/tinyprintf/my_atoi_base/my_atoi_base.h b/rushs/tinyprintf/my_atoi_base/my_atoi_base.h deleted file mode 100644 index 296ae23..0000000 --- a/rushs/tinyprintf/my_atoi_base/my_atoi_base.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef MY_ATOI_BASE_H -#define MY_ATOI_BASE_H - -#include - -int my_atoi_base(const char *str, const char *base); - -#endif /* ! MY_ATOI_BASE_H */ -- cgit v1.2.3