aboutsummaryrefslogtreecommitdiff
path: root/src/str/ft_strtol.c
diff options
context:
space:
mode:
authorCharles <sircharlesaze@gmail.com>2020-01-15 14:16:36 +0100
committerCharles <sircharlesaze@gmail.com>2020-01-15 14:16:36 +0100
commite8a7d07f1c99b5ce6210603d88098580af95fb13 (patch)
treecd442d7e351c20bcc6a6dc9f0b4619100750932a /src/str/ft_strtol.c
parent496afe8e8a82d6db730bf835eb5fbe1ef3a142be (diff)
downloadlibft-e8a7d07f1c99b5ce6210603d88098580af95fb13.tar.gz
libft-e8a7d07f1c99b5ce6210603d88098580af95fb13.tar.bz2
libft-e8a7d07f1c99b5ce6210603d88098580af95fb13.zip
Fix strtol, Added list reverse functions
Diffstat (limited to 'src/str/ft_strtol.c')
-rw-r--r--src/str/ft_strtol.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/str/ft_strtol.c b/src/str/ft_strtol.c
index 447f1af..0fb5261 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/01/15 11:39:34 by cacharle ### ########.fr */
+/* Updated: 2020/01/15 14:15:40 by cacharle ### ########.fr */
/* */
/* ************************************************************************** */
@@ -65,12 +65,12 @@ long ft_strtol(const char *str, char **endptr, int base)
base = strtol_handle_base(base, &str);
ft_strncpy(base_str, STRTOL_STD_BASE, base);
nb = 0;
- while (ft_strchr(base_str, *str) != NULL)
+ while (ft_strchr(base_str, *str) != base_str + base)
{
nb *= base;
- nb += ft_strchr(base_str, ft_tolower(*str)) - base_str;
+ nb += ft_strchr(base_str, ft_tolower(*str++)) - base_str;
if (((long)nb ^ (long)(nb / base)) < 0)
- return (errno_return(ERANGE));
+ errno = ERANGE;
}
if (endptr != NULL)
*endptr = (char*)str;