diff options
| author | Charles Cabergs <me@cacharle.xyz> | 2020-10-11 14:05:28 +0200 |
|---|---|---|
| committer | Charles Cabergs <me@cacharle.xyz> | 2020-10-11 14:05:28 +0200 |
| commit | 783260a4c01ebfe4b4bcfc56d57a4d99603f904f (patch) | |
| tree | 6ba1739662577db701969e33a79676c8f0460413 /src | |
| parent | c33343322ef66d96337533082313b1256862023a (diff) | |
| download | libft-783260a4c01ebfe4b4bcfc56d57a4d99603f904f.tar.gz libft-783260a4c01ebfe4b4bcfc56d57a4d99603f904f.tar.bz2 libft-783260a4c01ebfe4b4bcfc56d57a4d99603f904f.zip | |
Norming and removing ft_printf,heapsort
Diffstat (limited to 'src')
30 files changed, 6 insertions, 1245 deletions
diff --git a/src/algo/ft_heapsort.c b/src/algo/ft_heapsort.c deleted file mode 100644 index d309624..0000000 --- a/src/algo/ft_heapsort.c +++ /dev/null @@ -1,54 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_heapsort.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2020/02/10 02:59:22 by cacharle #+# #+# */ -/* Updated: 2020/02/10 04:22:19 by cacharle ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft_algo.h" - -/* static void st_build_max_heap(void *base, size_t nel, size_t width, */ -/* int (*compar)(const void *, const void *)) */ -/* { */ -/* int i; */ -/* */ -/* i = 1; */ -/* while (i < nel) */ -/* { */ -/* compar(base + i * width, base + 2 * i * width) */ -/* */ -/* i++; */ -/* } */ -/* } */ -/* */ -/* static void st_heapify(void *base, size_t nel, size_t width, */ -/* int (*compar)(const void *, const void *)) */ -/* { */ -/* */ -/* } */ - -int ft_heapsort(void *base, size_t nel, size_t width, - int (*compar)(const void *, const void *)) -{ - (void)base; - (void)nel; - (void)width; - (void)compar; - /* size_t i; */ - /* */ - /* if (nel < 2) */ - /* return (0); */ - /* st_build_max_heap(base, nel, width, compar); */ - /* i = -1; */ - /* while (++i < nel) */ - /* { */ - /* ft_memswap(base, base + (nel - i - 1) * width); */ - /* st_heapify(base, nel - i - 1, width, compar); */ - /* } */ - return (0); -} diff --git a/src/dstr/ft_dstrerase.c b/src/dstr/ft_dstrerase.c index 3d4732b..b758d3a 100644 --- a/src/dstr/ft_dstrerase.c +++ b/src/dstr/ft_dstrerase.c @@ -6,7 +6,7 @@ /* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/04/05 00:39:12 by charles #+# #+# */ -/* Updated: 2020/04/05 01:11:07 by charles ### ########.fr */ +/* Updated: 2020/10/11 14:00:29 by cacharle ### ########.fr */ /* */ /* ************************************************************************** */ @@ -28,8 +28,7 @@ void ft_dstrerase(t_ftdstr *dstr, size_t start, size_t len) ft_memmove( dstr->str + start, dstr->str + start + len, - dstr->length - start - len - ); + dstr->length - start - len); dstr->length -= len; dstr->str[dstr->length] = '\0'; } diff --git a/src/ht/ft_hthash.c b/src/ht/ft_hthash.c index c5d42ea..200252f 100644 --- a/src/ht/ft_hthash.c +++ b/src/ht/ft_hthash.c @@ -6,7 +6,7 @@ /* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/01/30 09:56:01 by cacharle #+# #+# */ -/* Updated: 2020/01/30 10:34:27 by cacharle ### ########.fr */ +/* Updated: 2020/10/11 14:00:00 by cacharle ### ########.fr */ /* */ /* ************************************************************************** */ @@ -19,7 +19,6 @@ ** \return Hash */ -// maybe use a less efficient but understandable function size_t ft_hthash(t_ftht *ht, char *key) { size_t digest; diff --git a/src/io/ft_printf/ft_asprintf.c b/src/io/ft_printf/ft_asprintf.c deleted file mode 100644 index 5eb62d9..0000000 --- a/src/io/ft_printf/ft_asprintf.c +++ /dev/null @@ -1,24 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_asprintf.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2019/11/21 02:30:33 by cacharle #+# #+# */ -/* Updated: 2019/11/21 03:43:08 by cacharle ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -int ft_asprintf(char **ret, const char *format, ...) -{ - int vret; - va_list ap; - - va_start(ap, format); - vret = ft_vasprintf(ret, format, ap); - va_end(ap); - return (vret); -} diff --git a/src/io/ft_printf/ft_dprintf.c b/src/io/ft_printf/ft_dprintf.c deleted file mode 100644 index 8e60970..0000000 --- a/src/io/ft_printf/ft_dprintf.c +++ /dev/null @@ -1,24 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_dprintf.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2019/11/21 02:29:11 by cacharle #+# #+# */ -/* Updated: 2019/11/21 03:42:05 by cacharle ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -int ft_dprintf(int fd, const char *format, ...) -{ - int ret; - va_list ap; - - va_start(ap, format); - ret = ft_vdprintf(fd, format, ap); - va_end(ap); - return (ret); -} diff --git a/src/io/ft_printf/ft_printf.c b/src/io/ft_printf/ft_printf.c deleted file mode 100644 index 1b92bb2..0000000 --- a/src/io/ft_printf/ft_printf.c +++ /dev/null @@ -1,24 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_printf.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2019/11/21 02:31:32 by cacharle #+# #+# */ -/* Updated: 2019/11/21 03:41:54 by cacharle ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -int ft_printf(const char *format, ...) -{ - int ret; - va_list ap; - - va_start(ap, format); - ret = ft_vprintf(format, ap); - va_end(ap); - return (ret); -} diff --git a/src/io/ft_printf/ft_snprintf.c b/src/io/ft_printf/ft_snprintf.c deleted file mode 100644 index e1fdfbd..0000000 --- a/src/io/ft_printf/ft_snprintf.c +++ /dev/null @@ -1,24 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_snprintf.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2019/11/21 02:27:55 by cacharle #+# #+# */ -/* Updated: 2019/11/21 03:41:49 by cacharle ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -int ft_snprintf(char *str, size_t size, const char *format, ...) -{ - int ret; - va_list ap; - - va_start(ap, format); - ret = ft_vsnprintf(str, size, format, ap); - va_end(ap); - return (ret); -} diff --git a/src/io/ft_printf/ft_sprintf.c b/src/io/ft_printf/ft_sprintf.c deleted file mode 100644 index 31da75e..0000000 --- a/src/io/ft_printf/ft_sprintf.c +++ /dev/null @@ -1,24 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_sprintf.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2019/11/21 02:17:21 by cacharle #+# #+# */ -/* Updated: 2019/11/21 03:42:28 by cacharle ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -int ft_sprintf(char *str, const char *format, ...) -{ - int ret; - va_list ap; - - va_start(ap, format); - ret = ft_vsprintf(str, format, ap); - va_end(ap); - return (ret); -} diff --git a/src/io/ft_printf/ft_vasprintf.c b/src/io/ft_printf/ft_vasprintf.c deleted file mode 100644 index 85f66bc..0000000 --- a/src/io/ft_printf/ft_vasprintf.c +++ /dev/null @@ -1,21 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_vasprintf.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2019/11/21 02:49:56 by cacharle #+# #+# */ -/* Updated: 2019/11/21 03:45:39 by cacharle ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -int ft_vasprintf(char **ret, const char *format, va_list ap) -{ - (void)ret; - (void)format; - (void)ap; - return (0); -} diff --git a/src/io/ft_printf/ft_vasprintf.h b/src/io/ft_printf/ft_vasprintf.h deleted file mode 100644 index 2d364c8..0000000 --- a/src/io/ft_printf/ft_vasprintf.h +++ /dev/null @@ -1,155 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* header.h :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2019/10/29 00:06:46 by cacharle #+# #+# */ -/* Updated: 2020/01/15 11:39:15 by cacharle ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#ifndef FT_VASPRINTF_H -# define FT_VASPRINTF_H - -# include <unistd.h> -# include <stdlib.h> -# include <stdarg.h> -# include "libft.h" - -# define STATUS_ERROR -1 - -# define SPECIFIERS_STR "nfcspdiuxX%" -# define FLAGS_STR "#0- +'" - -# define IS_STANDALONE_FLAG(c) (ft_strchr(FLAGS_STR, c) != NULL) - -# define FLAG_MINUS (1 << 0) -# define FLAG_ZERO (1 << 1) -# define FLAG_SIGNED (1 << 2) -# define FLAG_SPACE (1 << 3) -# define FLAG_ALTERNATE (1 << 4) -# define FLAG_SHORT (1 << 5) -# define FLAG_SHORT_SHORT (1 << 6) -# define FLAG_LONG (1 << 7) -# define FLAG_LONG_LONG (1 << 8) -# define FLAG_WIDTH_WILDCARD (1 << 9) -# define FLAG_PRECISION_WILDCARD (1 << 10) -# define FLAG_WIDTH_OVERWRITE (1 << 11) - -# define ITOA_HEX_LOW(x) (ft_itoa_unsigned_base(x, "0123456789abcdef")) -# define ITOA_HEX_UP(x) (ft_itoa_unsigned_base(x, "0123456789ABCDEF")) -# define ITOA_DEC(x) (ft_itoa_base(x, "0123456789")) - -typedef int t_bool; -typedef short t_flags; -typedef long long int t_big_int; -typedef long long unsigned int t_big_uint; - -typedef struct -{ - int precision; - int width; - t_flags flags; - char specifier; - int fmt_len; - int size; - long long int *written; -} t_pformat; - -typedef struct s_flist -{ - struct s_flist *next; - t_pformat *content; -} t_flist; - -typedef struct s_printf_status -{ - va_list ap; - t_flist *flist; - const char *format; - char *out; - int out_size; -} t_printf_status; - -/* -** ft_printf.c -*/ - -int ft_printf(const char *format, ...); -const char *add_conversion(t_printf_status *status, - t_pformat *pformat); -const char *add_between(t_printf_status *status); -int destroy_status_error(t_printf_status *status); - -/* -** parse.c -*/ - -int parse(const char *format, t_flist **flist); -t_pformat *parse_reduced(const char *fmt); - -/* -** printer.c -*/ - -char *convert(t_pformat *pformat, va_list ap); -char *convert_specifier(va_list ap, t_pformat *pformat); -char *handle_width(t_pformat *pformat, char *str); -char *handle_precision(t_pformat *pformat, char *str); - -/* -** utils.c -*/ - -char *ft_itoa_base(long long int n, char *base); -char *ft_itoa_unsigned_base(long long unsigned int n, - char *base); -void *ft_memjoin_free(void *dst, int dst_size, void *src, - int src_size); - -/* -** extract.c -*/ - -const char *extract_flags(t_pformat *pformat, const char *fmt); -const char *extract_width(t_pformat *pformat, const char *fmt); -const char *extract_precision(t_pformat *pformat, const char *fmt); -const char *extract_length_modifier(t_pformat *pformat, - const char *fmt); - -/* -** list.c -*/ - -t_flist *list_new(t_pformat *content); -void *list_destroy(t_flist **lst); -void list_push_front(t_flist **lst, t_flist *new); -void list_pop_front(t_flist **lst); -t_flist *list_reverse(t_flist *lst); - -/* -** convert_*.c -*/ - -char *convert_char(va_list ap, t_pformat *pformat); -char *convert_str(va_list ap, t_pformat *pformat); -char *convert_ptr(va_list ap, t_pformat *pformat); -char *convert_int(va_list ap, t_pformat *pformat); -char *convert_uint(va_list ap, t_pformat *pformat); -char *convert_hex(va_list ap, t_pformat *pformat); -char *convert_percent(va_list ap, t_pformat *pformat); -char *convert_written(va_list ap, t_pformat *pformat); -char *convert_double(va_list ap, t_pformat *pformat); -char *convert_none(va_list ap, t_pformat *pformat); - -/* -** length_modifier.c -*/ - -t_big_uint length_modifier_unsigned_int( - va_list ap, t_pformat *pformat); -t_big_int length_modifier_int(va_list ap, t_pformat *pformat); - -#endif diff --git a/src/io/ft_printf/ft_vdprintf.c b/src/io/ft_printf/ft_vdprintf.c deleted file mode 100644 index a5e5ebf..0000000 --- a/src/io/ft_printf/ft_vdprintf.c +++ /dev/null @@ -1,24 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_vdprintf.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2019/11/21 02:40:03 by cacharle #+# #+# */ -/* Updated: 2019/11/21 03:46:00 by cacharle ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -int ft_vdprintf(int fd, const char *format, va_list ap) -{ - int out_len; - char *out; - - if ((out_len = ft_vasprintf(&out, format, ap)) == -1) - return (-1); - write(fd, out, out_len); - return (out_len); -} diff --git a/src/io/ft_printf/ft_vprintf.c b/src/io/ft_printf/ft_vprintf.c deleted file mode 100644 index b98670b..0000000 --- a/src/io/ft_printf/ft_vprintf.c +++ /dev/null @@ -1,18 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_vprintf.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2019/11/21 02:32:44 by cacharle #+# #+# */ -/* Updated: 2019/11/21 03:44:11 by cacharle ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -int ft_vprintf(const char *format, va_list ap) -{ - return (ft_vdprintf(STDOUT_FILENO, format, ap)); -} diff --git a/src/io/ft_printf/ft_vsnprintf.c b/src/io/ft_printf/ft_vsnprintf.c deleted file mode 100644 index 7db988c..0000000 --- a/src/io/ft_printf/ft_vsnprintf.c +++ /dev/null @@ -1,26 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_vsnprintf.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2019/11/21 02:36:32 by cacharle #+# #+# */ -/* Updated: 2019/11/21 03:45:14 by cacharle ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -int ft_vsnprintf(char *str, size_t size, const char *format, va_list ap) -{ - int ret; - int full_out_len; - char *full_out; - - full_out_len = ft_vasprintf(&full_out, format, ap); - ft_strncpy(str, full_out, size); - ret = MIN((size_t)full_out_len, size); - free(full_out); - return (ret); -} diff --git a/src/io/ft_printf/ft_vsprintf.c b/src/io/ft_printf/ft_vsprintf.c deleted file mode 100644 index 91b4815..0000000 --- a/src/io/ft_printf/ft_vsprintf.c +++ /dev/null @@ -1,18 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_vsprintf.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2019/11/21 02:34:17 by cacharle #+# #+# */ -/* Updated: 2019/11/21 03:44:24 by cacharle ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -int ft_vsprintf(char *str, const char *format, va_list ap) -{ - return (ft_vsnprintf(str, INT_MAX + 1, format, ap)); -} diff --git a/src/io/ft_printf/internals/convert.c b/src/io/ft_printf/internals/convert.c deleted file mode 100644 index 398c754..0000000 --- a/src/io/ft_printf/internals/convert.c +++ /dev/null @@ -1,122 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* printer.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2019/10/28 23:19:24 by cacharle #+# #+# */ -/* Updated: 2019/11/14 10:22:04 by cacharle ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include <unistd.h> -#include <stdlib.h> -#include <stdarg.h> -#include "libft.h" -#include "ft_vasprintf.h" - -char *convert(t_pformat *pformat, va_list ap) -{ - char *str; - - if (pformat == NULL) - return (NULL); - if (pformat->flags & FLAG_WIDTH_WILDCARD) - { - if (pformat->flags & FLAG_WIDTH_OVERWRITE) - (void)va_arg(ap, int); - else - pformat->width = va_arg(ap, int); - if (pformat->width < 0) - { - pformat->flags |= FLAG_MINUS; - pformat->width *= -1; - } - } - if (pformat->flags & FLAG_PRECISION_WILDCARD) - pformat->precision = va_arg(ap, int); - if ((str = convert_specifier(ap, pformat)) == NULL) - return (NULL); - return (str); -} - -char *convert_specifier(va_list ap, t_pformat *pformat) -{ - if (pformat->specifier == 'c') - return (convert_char(ap, pformat)); - if (pformat->specifier == 's') - return (convert_str(ap, pformat)); - if (pformat->specifier == 'p') - return (convert_ptr(ap, pformat)); - if (pformat->specifier == 'd' || pformat->specifier == 'i') - return (convert_int(ap, pformat)); - if (pformat->specifier == 'u') - return (convert_uint(ap, pformat)); - if (pformat->specifier == 'x') - return (convert_hex(ap, pformat)); - if (pformat->specifier == 'X') - return (convert_hex(ap, pformat)); - if (pformat->specifier == '%') - return (convert_percent(ap, pformat)); - if (pformat->specifier == 'n') - return (convert_written(ap, pformat)); - else - return (convert_none(ap, pformat)); - return (NULL); -} - -char *handle_width(t_pformat *pformat, char *str) -{ - char *tmp; - int len; - int i; - - if ((len = ft_strlen(str)) >= pformat->width) - return (str); - if ((tmp = (char*)malloc(sizeof(char) * (pformat->width + 1))) == NULL) - return (NULL); - if (pformat->flags & FLAG_MINUS) - { - i = len; - ft_strcpy(tmp, str); - while (i < pformat->width) - tmp[i++] = ' '; - tmp[i] = 0; - } - else - { - i = 0; - while (i <= pformat->width - len) - tmp[i++] = pformat->flags & FLAG_ZERO ? '0' : ' '; - ft_strcpy(tmp + i - 1, str); - } - free(str); - return (tmp); -} - -char *handle_precision(t_pformat *pformat, char *str) -{ - int len; - char *tmp; - - if (pformat == NULL || str == NULL) - return (NULL); - if (ft_strchr("diuxX", pformat->specifier) && pformat->precision >= 0) - pformat->flags &= ~FLAG_ZERO; - len = ft_strlen(str); - if (pformat->precision == 0 && str[0] == '0') - { - free(str); - return (ft_strdup("")); - } - if (!ft_strchr("diuxXp", pformat->specifier) || len >= pformat->precision) - return (str); - if ((tmp = (char*)malloc(sizeof(char) * (pformat->precision + 1))) == NULL) - return (NULL); - ft_strcpy(tmp + pformat->precision - len, str); - while (pformat->precision-- > len) - tmp[pformat->precision - len] = '0'; - free(str); - return (tmp); -} diff --git a/src/io/ft_printf/internals/convert_char.c b/src/io/ft_printf/internals/convert_char.c deleted file mode 100644 index c5f3a93..0000000 --- a/src/io/ft_printf/internals/convert_char.c +++ /dev/null @@ -1,53 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* convert_char.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2019/10/30 23:22:29 by cacharle #+# #+# */ -/* Updated: 2019/11/05 23:44:42 by cacharle ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_vasprintf.h" - -static char *handle_width_char(t_pformat *pformat, char *str) -{ - char *tmp; - int i; - - pformat->size = 1; - if (1 >= pformat->width) - return (str); - if ((tmp = (char*)malloc(sizeof(char) * (pformat->width + 1))) == NULL) - return (NULL); - if (pformat->flags & FLAG_MINUS) - { - ft_memcpy(tmp, str, (i = 1) + 1); - while (i < pformat->width) - tmp[i++] = ' '; - tmp[i] = 0; - } - else - { - i = 0; - while (i <= pformat->width - 1) - tmp[i++] = pformat->flags & FLAG_ZERO ? '0' : ' '; - ft_memcpy(tmp + i - 1, str, 2); - } - free(str); - pformat->size = pformat->width; - return (tmp); -} - -char *convert_char(va_list ap, t_pformat *pformat) -{ - char *str; - - if ((str = ft_strnew(2)) == NULL) - return (NULL); - str[0] = va_arg(ap, int); - str[1] = '\0'; - return (handle_width_char(pformat, str)); -} diff --git a/src/io/ft_printf/internals/convert_hex.c b/src/io/ft_printf/internals/convert_hex.c deleted file mode 100644 index 0464dc7..0000000 --- a/src/io/ft_printf/internals/convert_hex.c +++ /dev/null @@ -1,34 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* convert_hex.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2019/10/30 23:23:06 by cacharle #+# #+# */ -/* Updated: 2019/11/05 23:58:59 by cacharle ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_vasprintf.h" - -char *convert_hex(va_list ap, t_pformat *pformat) -{ - char *str; - long long unsigned int n; - - n = length_modifier_unsigned_int(ap, pformat); - str = pformat->specifier == 'x' ? ITOA_HEX_LOW(n) : ITOA_HEX_UP(n); - str = handle_precision(pformat, str); - if (pformat->flags & FLAG_ZERO) - { - if (pformat->flags & FLAG_ALTERNATE && n != 0) - pformat->width -= 2; - str = handle_width(pformat, str); - } - if (pformat->flags & FLAG_ALTERNATE && n != 0) - str = ft_strjoin_free_snd(pformat->specifier == 'X' ? "0X" : "0x", str); - if (!(pformat->flags & FLAG_ZERO)) - str = handle_width(pformat, str); - return (str); -} diff --git a/src/io/ft_printf/internals/convert_int.c b/src/io/ft_printf/internals/convert_int.c deleted file mode 100644 index 2345f76..0000000 --- a/src/io/ft_printf/internals/convert_int.c +++ /dev/null @@ -1,40 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* convert_int.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2019/10/30 23:29:53 by cacharle #+# #+# */ -/* Updated: 2019/11/06 00:00:09 by cacharle ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_vasprintf.h" - -char *convert_int(va_list ap, t_pformat *pformat) -{ - int is_neg; - long long int n; - char *str; - - n = length_modifier_int(ap, pformat); - is_neg = n < 0; - str = ITOA_DEC(n); - if (is_neg) - ft_strcpy(str, str + 1); - str = handle_precision(pformat, str); - if (pformat->flags & FLAG_ZERO) - { - if (is_neg || pformat->flags & (FLAG_SIGNED | FLAG_SPACE)) - pformat->width--; - str = handle_width(pformat, str); - } - if (is_neg) - str = ft_strjoin_free_snd("-", str); - else if (pformat->flags & (FLAG_SIGNED | FLAG_SPACE)) - str = ft_strjoin_free_snd(pformat->flags & FLAG_SPACE ? " " : "+", str); - if (!(pformat->flags & FLAG_ZERO)) - str = handle_width(pformat, str); - return (str); -} diff --git a/src/io/ft_printf/internals/convert_none.c b/src/io/ft_printf/internals/convert_none.c deleted file mode 100644 index 358ef1b..0000000 --- a/src/io/ft_printf/internals/convert_none.c +++ /dev/null @@ -1,25 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* convert_none.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2019/11/04 19:30:25 by cacharle #+# #+# */ -/* Updated: 2019/11/05 23:44:13 by cacharle ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_vasprintf.h" - -char *convert_none(va_list ap, t_pformat *pformat) -{ - char *str; - - (void)ap; - if ((str = ft_strdup("")) == NULL) - return (NULL); - str = handle_precision(pformat, str); - str = handle_width(pformat, str); - return (str); -} diff --git a/src/io/ft_printf/internals/convert_percent.c b/src/io/ft_printf/internals/convert_percent.c deleted file mode 100644 index 813bb77..0000000 --- a/src/io/ft_printf/internals/convert_percent.c +++ /dev/null @@ -1,23 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* convert_percent.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2019/10/30 23:23:27 by cacharle #+# #+# */ -/* Updated: 2019/11/05 23:44:07 by cacharle ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_vasprintf.h" - -char *convert_percent(va_list ap, t_pformat *pformat) -{ - char *str; - - (void)ap; - str = ft_strdup("%"); - str = handle_width(pformat, str); - return (str); -} diff --git a/src/io/ft_printf/internals/convert_ptr.c b/src/io/ft_printf/internals/convert_ptr.c deleted file mode 100644 index 63babb9..0000000 --- a/src/io/ft_printf/internals/convert_ptr.c +++ /dev/null @@ -1,29 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* convert_ptr.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2019/10/30 23:24:08 by cacharle #+# #+# */ -/* Updated: 2019/11/05 23:43:45 by cacharle ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_vasprintf.h" - -char *convert_ptr(va_list ap, t_pformat *pformat) -{ - char *str; - - str = ITOA_HEX_LOW((long long unsigned int)va_arg(ap, void*)); - str = handle_precision(pformat, str); - if (!(pformat->flags & FLAG_ZERO)) - str = ft_strjoin_free_snd("0x", str); - if (pformat->flags & FLAG_ZERO) - pformat->width -= 2; - str = handle_width(pformat, str); - if (pformat->flags & FLAG_ZERO) - str = ft_strjoin_free_snd("0x", str); - return (str); -} diff --git a/src/io/ft_printf/internals/convert_str.c b/src/io/ft_printf/internals/convert_str.c deleted file mode 100644 index 7d51a5e..0000000 --- a/src/io/ft_printf/internals/convert_str.c +++ /dev/null @@ -1,25 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* convert_str.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2019/10/30 23:22:25 by cacharle #+# #+# */ -/* Updated: 2019/11/09 01:07:24 by cacharle ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_vasprintf.h" - -char *convert_str(va_list ap, t_pformat *pformat) -{ - char *str; - - str = va_arg(ap, char*); - str = str == NULL ? ft_strdup("(null)") : ft_strdup(str); - if (pformat->precision >= 0 && pformat->precision < (int)ft_strlen(str)) - str[pformat->precision] = '\0'; - str = handle_width(pformat, str); - return (str); -} diff --git a/src/io/ft_printf/internals/convert_uint.c b/src/io/ft_printf/internals/convert_uint.c deleted file mode 100644 index 4207165..0000000 --- a/src/io/ft_printf/internals/convert_uint.c +++ /dev/null @@ -1,34 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* convert_uint.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2019/10/30 23:25:40 by cacharle #+# #+# */ -/* Updated: 2019/11/05 23:44:19 by cacharle ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_vasprintf.h" - -char *convert_uint(va_list ap, t_pformat *pformat) -{ - char *str; - long long unsigned int n; - - if (pformat->flags & FLAG_SHORT) - n = (unsigned short)va_arg(ap, int); - else if (pformat->flags & FLAG_SHORT_SHORT) - n = (unsigned char)va_arg(ap, int); - else if (pformat->flags & FLAG_LONG) - n = va_arg(ap, long unsigned int); - else if (pformat->flags & FLAG_LONG_LONG) - n = va_arg(ap, long long unsigned int); - else - n = va_arg(ap, unsigned int); - str = ft_itoa_unsigned_base(n, "0123456789"); - str = handle_precision(pformat, str); - str = handle_width(pformat, str); - return (str); -} diff --git a/src/io/ft_printf/internals/convert_written.c b/src/io/ft_printf/internals/convert_written.c deleted file mode 100644 index 4beeaef..0000000 --- a/src/io/ft_printf/internals/convert_written.c +++ /dev/null @@ -1,28 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* convert_written.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2019/10/30 23:38:28 by cacharle #+# #+# */ -/* Updated: 2019/11/05 23:59:24 by cacharle ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_vasprintf.h" - -char *convert_written(va_list ap, t_pformat *pformat) -{ - if (pformat->flags & FLAG_SHORT) - pformat->written = (long long int*)va_arg(ap, signed char*); - if (pformat->flags & FLAG_SHORT_SHORT) - pformat->written = (long long int*)va_arg(ap, short*); - if (pformat->flags & FLAG_LONG) - pformat->written = (long long int*)va_arg(ap, long int*); - if (pformat->flags & FLAG_LONG_LONG) - pformat->written = va_arg(ap, long long int*); - else - pformat->written = (long long int*)va_arg(ap, int*); - return (NULL); -} diff --git a/src/io/ft_printf/internals/extract.c b/src/io/ft_printf/internals/extract.c deleted file mode 100644 index c56a777..0000000 --- a/src/io/ft_printf/internals/extract.c +++ /dev/null @@ -1,98 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* extract.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2019/10/29 00:10:36 by cacharle #+# #+# */ -/* Updated: 2019/11/10 10:33:33 by cacharle ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_vasprintf.h" - -const char *extract_flags(t_pformat *pformat, const char *fmt) -{ - if (*fmt == '\0') - return (fmt); - while (ft_strchr(FLAGS_STR, *fmt) != NULL) - { - if (*fmt == '0') - pformat->flags |= FLAG_ZERO; - if (*fmt == '-') - pformat->flags |= FLAG_MINUS; - if (*fmt == '+') - pformat->flags |= FLAG_SIGNED; - if (*fmt == ' ') - pformat->flags |= FLAG_SPACE; - if (*fmt == '#') - pformat->flags |= FLAG_ALTERNATE; - if (*fmt == '\'') - ; - fmt++; - } - if (pformat->flags & FLAG_SIGNED) - pformat->flags &= ~FLAG_SPACE; - return (fmt); -} - -const char *extract_width(t_pformat *pformat, const char *fmt) -{ - if (*fmt == '\0') - return (fmt); - if (*fmt == '*') - { - pformat->flags |= FLAG_WIDTH_WILDCARD; - fmt++; - } - if (!ft_isdigit(*fmt)) - return (fmt); - pformat->width = ft_atoi(fmt); - while (*fmt && ft_isdigit(*fmt)) - fmt++; - if (pformat->flags & FLAG_WIDTH_WILDCARD) - pformat->flags |= FLAG_WIDTH_OVERWRITE; - return (fmt); -} - -const char *extract_precision(t_pformat *pformat, const char *fmt) -{ - if (*fmt == '\0' || *fmt != '.') - return (fmt); - fmt++; - if (*fmt == '*') - { - pformat->flags |= FLAG_PRECISION_WILDCARD; - fmt++; - } - pformat->precision = ft_atoi(fmt); - while (*fmt && ft_isdigit(*fmt)) - fmt++; - return (fmt); -} - -const char *extract_length_modifier(t_pformat *pformat, const char *fmt) -{ - if (fmt[0] && fmt[0] == 'l') - { - if (fmt[1] && fmt[1] == 'l') - { - pformat->flags |= FLAG_LONG_LONG; - return (fmt + 2); - } - pformat->flags |= FLAG_LONG; - return (fmt + 1); - } - if (fmt[0] && fmt[0] == 'h') - { - if (fmt[1] && fmt[1] == 'h') - { - pformat->flags |= FLAG_SHORT_SHORT; - return (fmt + 2); - } - pformat->flags |= FLAG_SHORT; - return (fmt + 1); - } - return (fmt); -} diff --git a/src/io/ft_printf/internals/length_modifier.c b/src/io/ft_printf/internals/length_modifier.c deleted file mode 100644 index 88226da..0000000 --- a/src/io/ft_printf/internals/length_modifier.c +++ /dev/null @@ -1,39 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* length_modifier.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2019/11/05 23:56:07 by cacharle #+# #+# */ -/* Updated: 2019/11/09 00:50:06 by cacharle ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_vasprintf.h" - -t_big_uint length_modifier_unsigned_int(va_list ap, t_pformat *pformat) -{ - if (pformat->flags & FLAG_SHORT) - return ((unsigned short)va_arg(ap, int)); - else if (pformat->flags & FLAG_SHORT_SHORT) - return ((unsigned char)va_arg(ap, int)); - else if (pformat->flags & FLAG_LONG) - return (va_arg(ap, long unsigned int)); - else if (pformat->flags & FLAG_LONG_LONG) - return (va_arg(ap, long long unsigned int)); - return (va_arg(ap, unsigned int)); -} - -t_big_int length_modifier_int(va_list ap, t_pformat *pformat) -{ - if (pformat->flags & FLAG_SHORT) - return ((short)va_arg(ap, int)); - else if (pformat->flags & FLAG_SHORT_SHORT) - return ((signed char)va_arg(ap, int)); - else if (pformat->flags & FLAG_LONG) - return (va_arg(ap, long int)); - else if (pformat->flags & FLAG_LONG_LONG) - return (va_arg(ap, long long int)); - return (va_arg(ap, int)); -} diff --git a/src/io/ft_printf/internals/list.c b/src/io/ft_printf/internals/list.c deleted file mode 100644 index 37f8013..0000000 --- a/src/io/ft_printf/internals/list.c +++ /dev/null @@ -1,67 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* list.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2019/10/29 00:14:50 by cacharle #+# #+# */ -/* Updated: 2019/11/05 23:45:42 by cacharle ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_vasprintf.h" - -t_flist *list_new(t_pformat *content) -{ - t_flist *lst; - - if ((lst = (t_flist*)malloc(sizeof(t_flist))) == NULL) - return (NULL); - lst->data = content; - lst->next = NULL; - return (lst); -} - -void *list_destroy(t_flist **lst) -{ - if (lst == NULL) - return (NULL); - while (*lst != NULL) - list_pop_front(lst); - return (NULL); -} - -void list_push_front(t_flist **lst, t_flist *new) -{ - if (lst == NULL || new == NULL) - return ; - new->next = *lst; - *lst = new; -} - -void list_pop_front(t_flist **lst) -{ - t_flist *tmp; - - if (lst == NULL || *lst == NULL) - return ; - tmp = (*lst)->next; - free((*lst)->data); - free(*lst); - *lst = tmp; -} - -t_flist *list_reverse(t_flist *lst) -{ - t_flist *tmp; - - if (lst == NULL) - return (NULL); - if (lst->next == NULL) - return (lst); - tmp = list_reverse(lst->next); - lst->next->next = lst; - lst->next = NULL; - return (tmp); -} diff --git a/src/io/ft_printf/internals/parse.c b/src/io/ft_printf/internals/parse.c deleted file mode 100644 index 4650481..0000000 --- a/src/io/ft_printf/internals/parse.c +++ /dev/null @@ -1,61 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* parse.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2019/10/29 00:11:33 by cacharle #+# #+# */ -/* Updated: 2019/11/13 08:13:02 by cacharle ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_vasprintf.h" - -int parse(const char *format, t_flist **flist) -{ - t_flist *tmp; - t_pformat *parsed; - - *flist = NULL; - while (*format) - { - format++; - if (format[-1] != '%') - continue; - if ((parsed = parse_reduced(format)) == NULL) - return ((int)list_destroy(flist)); - if ((tmp = list_new(parsed)) == NULL) - return ((int)list_destroy(flist)); - list_push_front(flist, tmp); - format += (*flist)->data->fmt_len; - } - *flist = list_reverse(*flist); - return (1); -} - -t_pformat *parse_reduced(const char *fmt) -{ - t_pformat *pformat; - const char *start; - - if ((pformat = (t_pformat*)malloc(sizeof(t_pformat))) == NULL) - return (NULL); - pformat->precision = -1; - pformat->width = -1; - pformat->flags = 0; - start = fmt; - fmt = extract_flags(pformat, fmt); - fmt = extract_width(pformat, fmt); - fmt = extract_precision(pformat, fmt); - fmt = extract_length_modifier(pformat, fmt); - pformat->fmt_len = fmt - start + 1; - if (*fmt == '\0' || ft_strchr(SPECIFIERS_STR, *fmt) == NULL) - { - pformat->fmt_len--; - pformat->specifier = '_'; - } - else - pformat->specifier = *ft_strchr(SPECIFIERS_STR, *fmt); - return (pformat); -} diff --git a/src/io/ft_printf/internals/utils.c b/src/io/ft_printf/internals/utils.c deleted file mode 100644 index ad44980..0000000 --- a/src/io/ft_printf/internals/utils.c +++ /dev/null @@ -1,115 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* utils.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2019/10/29 00:12:40 by cacharle #+# #+# */ -/* Updated: 2019/11/13 08:49:58 by cacharle ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_vasprintf.h" - -static int nbrlen_radix(long long int nbr, int radix) -{ - int counter; - long long unsigned int u_nbr; - - if (nbr == 0) - return (1); - counter = 0; - u_nbr = nbr; - if (nbr < 0) - { - counter++; - u_nbr = -nbr; - } - while (u_nbr > 0) - { - u_nbr /= radix; - counter++; - } - return (counter); -} - -char *ft_itoa_base(long long int n, char *base) -{ - char *str; - int len; - int radix; - long long unsigned int u_nbr; - - radix = ft_strlen(base); - len = nbrlen_radix(n, radix); - if ((str = (char*)malloc(sizeof(char) * (len + 1))) == NULL) - return (NULL); - str[len] = '\0'; - u_nbr = n < 0 ? -n : n; - if (n < 0) - str[0] = '-'; - while (--len >= (n < 0 ? 1 : 0)) - { - str[len] = base[u_nbr % radix]; - u_nbr /= radix; - } - return (str); -} - -static int nbrlen_unsigned_radix(long long unsigned int nbr, int radix) -{ - int counter; - - if (nbr == 0) - return (1); - counter = 0; - while (nbr > 0) - { - nbr /= radix; - counter++; - } - return (counter); -} - -char *ft_itoa_unsigned_base(long long unsigned int n, char *base) -{ - char *str; - int len; - int radix; - - radix = ft_strlen(base); - len = nbrlen_unsigned_radix(n, radix); - if ((str = (char*)malloc(sizeof(char) * (len + 1))) == NULL) - return (NULL); - str[len] = '\0'; - while (--len >= 0) - { - str[len] = base[n % radix]; - n /= radix; - } - return (str); -} - -void *ft_memjoin_free(void *dst, int dst_size, void *src, int src_size) -{ - void *clone; - - if (dst == NULL) - { - if ((dst = malloc(src_size)) == NULL) - return (NULL); - ft_memcpy(dst, src, src_size); - return (dst); - } - if ((clone = malloc(dst_size)) == NULL) - return (NULL); - ft_memcpy(clone, dst, dst_size); - free(dst); - if ((dst = malloc(dst_size + src_size)) == NULL) - return (NULL); - ft_memcpy(dst, clone, dst_size); - free(clone); - ft_memcpy(dst + dst_size, src, src_size); - return (dst); -} 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; |
