From ae1412fdc283e442a0869aa7d63778449a7e5cfe Mon Sep 17 00:00:00 2001 From: Charles Date: Thu, 16 Jan 2020 00:51:22 +0100 Subject: Features toggle to avoid bloat and unauthorized functions, config file, script to generate a rendu branch --- src/str/ft_atoi_strict.c | 39 +++++++++++++++++++++++++++++++++++++++ src/str/ft_strict_atoi.c | 39 --------------------------------------- 2 files changed, 39 insertions(+), 39 deletions(-) create mode 100644 src/str/ft_atoi_strict.c delete mode 100644 src/str/ft_strict_atoi.c (limited to 'src') diff --git a/src/str/ft_atoi_strict.c b/src/str/ft_atoi_strict.c new file mode 100644 index 0000000..6156b03 --- /dev/null +++ b/src/str/ft_atoi_strict.c @@ -0,0 +1,39 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_strict_atoi.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: cacharle +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/01/15 10:06:29 by cacharle #+# #+# */ +/* Updated: 2020/01/15 14:09:03 by cacharle ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "libft.h" + +#include +int ft_strict_atoi(const char *s) +{ + char *end; + long ret; + + if (*s != '-' && !ft_isdigit(*s)) + { + errno = EINVAL; + return (0); + } + errno = 0; + ret = ft_strtol(s, &end, 10); + if (errno == ERANGE || ret > INT_MAX || ret < INT_MIN) + { + errno = ERANGE; + return (0); + } + if (*end != '\0') + { + errno = EINVAL; + return (0); + } + return (ret); +} diff --git a/src/str/ft_strict_atoi.c b/src/str/ft_strict_atoi.c deleted file mode 100644 index 6156b03..0000000 --- a/src/str/ft_strict_atoi.c +++ /dev/null @@ -1,39 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_strict_atoi.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: cacharle +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2020/01/15 10:06:29 by cacharle #+# #+# */ -/* Updated: 2020/01/15 14:09:03 by cacharle ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -#include -int ft_strict_atoi(const char *s) -{ - char *end; - long ret; - - if (*s != '-' && !ft_isdigit(*s)) - { - errno = EINVAL; - return (0); - } - errno = 0; - ret = ft_strtol(s, &end, 10); - if (errno == ERANGE || ret > INT_MAX || ret < INT_MIN) - { - errno = ERANGE; - return (0); - } - if (*end != '\0') - { - errno = EINVAL; - return (0); - } - return (ret); -} -- cgit