aboutsummaryrefslogtreecommitdiff
path: root/src/str/ft_strtol.c
diff options
context:
space:
mode:
authorCharles Cabergs <me@cacharle.xyz>2020-10-11 14:05:28 +0200
committerCharles Cabergs <me@cacharle.xyz>2020-10-11 14:05:28 +0200
commit783260a4c01ebfe4b4bcfc56d57a4d99603f904f (patch)
tree6ba1739662577db701969e33a79676c8f0460413 /src/str/ft_strtol.c
parentc33343322ef66d96337533082313b1256862023a (diff)
downloadlibft-783260a4c01ebfe4b4bcfc56d57a4d99603f904f.tar.gz
libft-783260a4c01ebfe4b4bcfc56d57a4d99603f904f.tar.bz2
libft-783260a4c01ebfe4b4bcfc56d57a4d99603f904f.zip
Norming and removing ft_printf,heapsort
Diffstat (limited to 'src/str/ft_strtol.c')
-rw-r--r--src/str/ft_strtol.c14
1 files changed, 3 insertions, 11 deletions
diff --git a/src/str/ft_strtol.c b/src/str/ft_strtol.c
index 925c66d..7e4cb30 100644
--- a/src/str/ft_strtol.c
+++ b/src/str/ft_strtol.c
@@ -6,7 +6,7 @@
/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/01/15 10:26:45 by cacharle #+# #+# */
-/* Updated: 2020/07/17 16:29:33 by charles ### ########.fr */
+/* Updated: 2020/10/11 14:03:49 by cacharle ### ########.fr */
/* */
/* ************************************************************************** */
@@ -70,17 +70,9 @@ long ft_strtol(const char *str, char **endptr, int base)
while (*str != '\0' && ft_strchr(base_str, *str) != NULL)
{
nb *= base;
- if (is_negative ? (nb > -(unsigned long long)LONG_MIN) : (nb > LONG_MAX))
- {
- errno = ERANGE;
- return (is_negative ? LONG_MIN : LONG_MAX);
- }
+ if (is_negative ? (nb > -(unsigned long)LONG_MIN) : (nb > LONG_MAX))
+ return (st_errno_return(ERANGE, is_negative ? LONG_MIN : LONG_MAX));
nb += ft_strchr(base_str, ft_tolower(*str++)) - base_str;
- if (is_negative ? (nb > -(unsigned long long)LONG_MIN) : (nb > LONG_MAX))
- {
- errno = ERANGE;
- return (is_negative ? LONG_MIN : LONG_MAX);
- }
}
if (endptr != NULL)
*endptr = (char*)str;