From 669087cbff78d790fc133a7aa759c2a7d38e2d0b Mon Sep 17 00:00:00 2001 From: Tsunghao Date: Mon, 2 Sep 2024 18:29:13 +0200 Subject: [PATCH] Removed unused libft stuff --- libft/ft_atoi.c | 38 ----------- libft/ft_bzero.c | 27 -------- libft/ft_calloc.c | 28 -------- libft/ft_isalnum.c | 20 ------ libft/ft_isalpha.c | 18 ----- libft/ft_isascii.c | 18 ----- libft/ft_isdigit.c | 18 ----- libft/ft_isprint.c | 18 ----- libft/ft_itoa.c | 63 ------------------ libft/ft_lstadd_back_bonus.c | 28 -------- libft/ft_lstadd_front_bonus.c | 19 ------ libft/ft_lstclear_bonus.c | 27 -------- libft/ft_lstdelone_bonus.c | 19 ------ libft/ft_lstiter_bonus.c | 22 ------- libft/ft_lstlast_bonus.c | 29 --------- libft/ft_lstmap_bonus.c | 36 ---------- libft/ft_lstnew_bonus.c | 25 ------- libft/ft_lstsize_bonus.c | 28 -------- libft/ft_memchr.c | 29 --------- libft/ft_memcmp.c | 31 --------- libft/ft_memcpy.c | 32 --------- libft/ft_memmove.c | 57 ---------------- libft/ft_memset.c | 28 -------- libft/ft_putchar_fd.c | 18 ----- libft/ft_putendl_fd.c | 19 ------ libft/ft_putnbr_fd.c | 33 ---------- libft/ft_putstr_fd.c | 25 ------- libft/ft_split.c | 119 ---------------------------------- libft/ft_strarrjoin.c | 51 --------------- libft/ft_strchr.c | 29 --------- libft/ft_strcmp.c | 29 --------- libft/ft_strdup.c | 25 ------- libft/ft_striteri.c | 25 ------- libft/ft_strjoin.c | 39 ----------- libft/ft_strjoin3.c | 30 --------- libft/ft_strlcat.c | 35 ---------- libft/ft_strlcpy.c | 34 ---------- libft/ft_strlen.c | 23 ------- libft/ft_strmapi.c | 31 --------- libft/ft_strncmp.c | 40 ------------ libft/ft_strnstr.c | 37 ----------- libft/ft_strrchr.c | 27 -------- libft/ft_strreplacejoin.c | 33 ---------- libft/ft_strtrim.c | 50 -------------- libft/ft_substr.c | 41 ------------ libft/ft_tolower.c | 20 ------ libft/ft_toupper.c | 20 ------ libft/libft.h | 88 ------------------------- 48 files changed, 1579 deletions(-) delete mode 100644 libft/ft_atoi.c delete mode 100644 libft/ft_bzero.c delete mode 100644 libft/ft_calloc.c delete mode 100644 libft/ft_isalnum.c delete mode 100644 libft/ft_isalpha.c delete mode 100644 libft/ft_isascii.c delete mode 100644 libft/ft_isdigit.c delete mode 100644 libft/ft_isprint.c delete mode 100644 libft/ft_itoa.c delete mode 100644 libft/ft_lstadd_back_bonus.c delete mode 100644 libft/ft_lstadd_front_bonus.c delete mode 100644 libft/ft_lstclear_bonus.c delete mode 100644 libft/ft_lstdelone_bonus.c delete mode 100644 libft/ft_lstiter_bonus.c delete mode 100644 libft/ft_lstlast_bonus.c delete mode 100644 libft/ft_lstmap_bonus.c delete mode 100644 libft/ft_lstnew_bonus.c delete mode 100644 libft/ft_lstsize_bonus.c delete mode 100644 libft/ft_memchr.c delete mode 100644 libft/ft_memcmp.c delete mode 100644 libft/ft_memcpy.c delete mode 100644 libft/ft_memmove.c delete mode 100644 libft/ft_memset.c delete mode 100644 libft/ft_putchar_fd.c delete mode 100644 libft/ft_putendl_fd.c delete mode 100644 libft/ft_putnbr_fd.c delete mode 100644 libft/ft_putstr_fd.c delete mode 100644 libft/ft_split.c delete mode 100644 libft/ft_strarrjoin.c delete mode 100644 libft/ft_strchr.c delete mode 100644 libft/ft_strcmp.c delete mode 100644 libft/ft_strdup.c delete mode 100644 libft/ft_striteri.c delete mode 100644 libft/ft_strjoin.c delete mode 100644 libft/ft_strjoin3.c delete mode 100644 libft/ft_strlcat.c delete mode 100644 libft/ft_strlcpy.c delete mode 100644 libft/ft_strlen.c delete mode 100644 libft/ft_strmapi.c delete mode 100644 libft/ft_strncmp.c delete mode 100644 libft/ft_strnstr.c delete mode 100644 libft/ft_strrchr.c delete mode 100644 libft/ft_strreplacejoin.c delete mode 100644 libft/ft_strtrim.c delete mode 100644 libft/ft_substr.c delete mode 100644 libft/ft_tolower.c delete mode 100644 libft/ft_toupper.c delete mode 100644 libft/libft.h diff --git a/libft/ft_atoi.c b/libft/ft_atoi.c deleted file mode 100644 index b1bad40..0000000 --- a/libft/ft_atoi.c +++ /dev/null @@ -1,38 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_atoi.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jteissie +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/03/22 19:28:31 by jteissie #+# #+# */ -/* Updated: 2024/03/23 16:31:12 by jteissie ### ########.fr */ -/* */ -/* ************************************************************************** */ - -int ft_atoi(const char *nptr) -{ - int i; - int result; - int minus; - - i = 0; - result = 0; - minus = 0; - while (nptr[i] == ' ' || (nptr[i] >= 9 && nptr[i] <= 13)) - i++; - if (nptr[i] == '-' || nptr[i] == '+') - { - if (nptr[i] == '-') - minus = 1; - i++; - } - while (nptr[i] >= '0' && nptr[i] <= '9') - { - result = result * 10 + (nptr[i] - '0'); - i++; - } - if (minus) - result *= -1; - return (result); -} diff --git a/libft/ft_bzero.c b/libft/ft_bzero.c deleted file mode 100644 index dbde44c..0000000 --- a/libft/ft_bzero.c +++ /dev/null @@ -1,27 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_bzero.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jteissie +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/03/23 16:41:46 by jteissie #+# #+# */ -/* Updated: 2024/05/15 15:00:35 by jteissie ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -void ft_bzero(void *s, size_t n) -{ - unsigned int i; - unsigned char *str; - - i = 0; - str = s; - while (i < n) - { - str[i] = '\0'; - i++; - } -} diff --git a/libft/ft_calloc.c b/libft/ft_calloc.c deleted file mode 100644 index 7732477..0000000 --- a/libft/ft_calloc.c +++ /dev/null @@ -1,28 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_calloc.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jteissie +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/03/23 17:05:28 by jteissie #+# #+# */ -/* Updated: 2024/05/22 15:40:09 by jteissie ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -void *ft_calloc(size_t nmemb, size_t size) -{ - void *ptr; - size_t total_size; - - total_size = size * nmemb; - if (total_size < size && total_size != 0) - return (NULL); - ptr = malloc(total_size); - if (!ptr) - return (NULL); - ft_memset(ptr, 0, total_size); - return (ptr); -} diff --git a/libft/ft_isalnum.c b/libft/ft_isalnum.c deleted file mode 100644 index 0bf36bf..0000000 --- a/libft/ft_isalnum.c +++ /dev/null @@ -1,20 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_isalnum.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jteissie +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/03/23 16:31:49 by jteissie #+# #+# */ -/* Updated: 2024/05/22 14:57:58 by jteissie ### ########.fr */ -/* */ -/* ************************************************************************** */ - -int ft_isalnum(int c) -{ - if ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z')) - return (1); - if (c >= '0' && c <= '9') - return (1); - return (0); -} diff --git a/libft/ft_isalpha.c b/libft/ft_isalpha.c deleted file mode 100644 index d8c9152..0000000 --- a/libft/ft_isalpha.c +++ /dev/null @@ -1,18 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_isalpha.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jteissie +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/03/23 16:42:26 by jteissie #+# #+# */ -/* Updated: 2024/05/22 14:58:03 by jteissie ### ########.fr */ -/* */ -/* ************************************************************************** */ - -int ft_isalpha(int c) -{ - if ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z')) - return (1); - return (0); -} diff --git a/libft/ft_isascii.c b/libft/ft_isascii.c deleted file mode 100644 index 6f95061..0000000 --- a/libft/ft_isascii.c +++ /dev/null @@ -1,18 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_isascii.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jteissie +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/03/23 17:06:25 by jteissie #+# #+# */ -/* Updated: 2024/05/22 14:58:10 by jteissie ### ########.fr */ -/* */ -/* ************************************************************************** */ - -int ft_isascii(int c) -{ - if (c > 127 || c < 0) - return (0); - return (1); -} diff --git a/libft/ft_isdigit.c b/libft/ft_isdigit.c deleted file mode 100644 index 427b606..0000000 --- a/libft/ft_isdigit.c +++ /dev/null @@ -1,18 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_isdigit.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jteissie +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/03/23 16:33:38 by jteissie #+# #+# */ -/* Updated: 2024/05/22 14:58:16 by jteissie ### ########.fr */ -/* */ -/* ************************************************************************** */ - -int ft_isdigit(int c) -{ - if (c >= '0' && c <= '9') - return (1); - return (0); -} diff --git a/libft/ft_isprint.c b/libft/ft_isprint.c deleted file mode 100644 index ace4dcd..0000000 --- a/libft/ft_isprint.c +++ /dev/null @@ -1,18 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_isprint.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jteissie +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/03/23 16:43:06 by jteissie #+# #+# */ -/* Updated: 2024/03/24 18:13:36 by jteissie ### ########.fr */ -/* */ -/* ************************************************************************** */ - -int ft_isprint(int c) -{ - if (c >= 32 && c <= 126) - return (c); - return (0); -} diff --git a/libft/ft_itoa.c b/libft/ft_itoa.c deleted file mode 100644 index 40ebafc..0000000 --- a/libft/ft_itoa.c +++ /dev/null @@ -1,63 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_itoa.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jteissie +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/03/23 17:10:20 by jteissie #+# #+# */ -/* Updated: 2024/05/19 11:34:35 by jteissie ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -void ft_putnbr_array(char *str, int nb, int *index) -{ - long int number; - - number = nb; - if (number < 0) - { - str[0] = '-'; - number *= -1; - *index = *index + 1; - } - if (number > 9) - { - ft_putnbr_array(str, number / 10, index); - str[*index] = number % 10 + '0'; - *index = *index + 1; - return ; - } - str[*index] = number + '0'; - *index = *index + 1; - return ; -} - -char *ft_itoa(int n) -{ - int digits; - char *string; - int digits_count; - int i; - - digits = n; - digits_count = 0; - i = 0; - if (n == 0) - digits_count = 1; - while (digits != 0) - { - digits /= 10; - digits_count++; - } - if (n < 0) - digits_count++; - string = malloc(sizeof(char) * (digits_count + 1)); - if (!string) - return (NULL); - ft_putnbr_array(string, n, &i); - string[i] = '\0'; - return (string); -} diff --git a/libft/ft_lstadd_back_bonus.c b/libft/ft_lstadd_back_bonus.c deleted file mode 100644 index dabea03..0000000 --- a/libft/ft_lstadd_back_bonus.c +++ /dev/null @@ -1,28 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_lstadd_back_bonus.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jteissie +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/18 14:45:13 by jteissie #+# #+# */ -/* Updated: 2024/05/20 14:08:42 by jteissie ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -void ft_lstadd_back(t_list **lst, t_list *new) -{ - t_list *last; - - if (lst == NULL || new == NULL) - return ; - if (*lst == NULL) - *lst = new; - else - { - last = ft_lstlast(*lst); - last->next = new; - } -} diff --git a/libft/ft_lstadd_front_bonus.c b/libft/ft_lstadd_front_bonus.c deleted file mode 100644 index 5bd9ec2..0000000 --- a/libft/ft_lstadd_front_bonus.c +++ /dev/null @@ -1,19 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_lstadd_front_bonus.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jteissie +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/17 16:46:06 by jteissie #+# #+# */ -/* Updated: 2024/05/20 16:40:39 by jteissie ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -void ft_lstadd_front(t_list **lst, t_list *new) -{ - new->next = *lst; - *lst = new; -} diff --git a/libft/ft_lstclear_bonus.c b/libft/ft_lstclear_bonus.c deleted file mode 100644 index 82ef5f5..0000000 --- a/libft/ft_lstclear_bonus.c +++ /dev/null @@ -1,27 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_lstclear_bonus.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: tsuchen +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/18 18:10:45 by jteissie #+# #+# */ -/* Updated: 2024/08/30 10:56:06 by tsuchen ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -void ft_lstclear(t_list **lst, void (*del)(void *)) -{ - t_list *temp; - - while (*lst != NULL) - { - temp = *lst; - *lst = (*lst)->next; - del(temp->content); - free(temp); - } - lst = NULL; -} diff --git a/libft/ft_lstdelone_bonus.c b/libft/ft_lstdelone_bonus.c deleted file mode 100644 index fe8207b..0000000 --- a/libft/ft_lstdelone_bonus.c +++ /dev/null @@ -1,19 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_lstdelone_bonus.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jteissie +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/18 15:18:30 by jteissie #+# #+# */ -/* Updated: 2024/05/20 15:32:18 by jteissie ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -void ft_lstdelone(t_list *lst, void (*del)(void *)) -{ - del(lst->content); - free(lst); -} diff --git a/libft/ft_lstiter_bonus.c b/libft/ft_lstiter_bonus.c deleted file mode 100644 index 97b4a4f..0000000 --- a/libft/ft_lstiter_bonus.c +++ /dev/null @@ -1,22 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_lstiter_bonus.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jteissie +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/18 19:08:59 by jteissie #+# #+# */ -/* Updated: 2024/05/20 15:32:26 by jteissie ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -void ft_lstiter(t_list *lst, void (*f)(void *)) -{ - while (lst) - { - f(lst->content); - lst = lst->next; - } -} diff --git a/libft/ft_lstlast_bonus.c b/libft/ft_lstlast_bonus.c deleted file mode 100644 index 05a9f93..0000000 --- a/libft/ft_lstlast_bonus.c +++ /dev/null @@ -1,29 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_lstlast_bonus.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jteissie +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/18 14:36:42 by jteissie #+# #+# */ -/* Updated: 2024/05/18 18:59:01 by jteissie ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -t_list *ft_lstlast(t_list *lst) -{ - t_list *temp; - t_list *last; - - if (lst == NULL) - return (NULL); - temp = lst; - while (temp != NULL) - { - last = temp; - temp = temp->next; - } - return (last); -} diff --git a/libft/ft_lstmap_bonus.c b/libft/ft_lstmap_bonus.c deleted file mode 100644 index efe918f..0000000 --- a/libft/ft_lstmap_bonus.c +++ /dev/null @@ -1,36 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_lstmap_bonus.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jteissie +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/18 19:13:05 by jteissie #+# #+# */ -/* Updated: 2024/05/21 19:10:37 by jteissie ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -t_list *ft_lstmap(t_list *lst, void *(*f)(void *), void (*del)(void *)) -{ - t_list *new_list; - t_list *new_node; - void *temp_content; - - new_list = NULL; - while (lst) - { - temp_content = f(lst->content); - new_node = ft_lstnew(temp_content); - if (!new_node) - { - del(temp_content); - ft_lstclear(&new_list, del); - return (NULL); - } - ft_lstadd_back(&new_list, new_node); - lst = lst->next; - } - return (new_list); -} diff --git a/libft/ft_lstnew_bonus.c b/libft/ft_lstnew_bonus.c deleted file mode 100644 index fdbdabf..0000000 --- a/libft/ft_lstnew_bonus.c +++ /dev/null @@ -1,25 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_lstnew_bonus.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jteissie +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/17 15:52:52 by jteissie #+# #+# */ -/* Updated: 2024/05/17 16:52:12 by jteissie ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -t_list *ft_lstnew(void *content) -{ - t_list *new_list; - - new_list = malloc(sizeof(t_list)); - if (!new_list) - return (NULL); - new_list->content = content; - new_list->next = NULL; - return (new_list); -} diff --git a/libft/ft_lstsize_bonus.c b/libft/ft_lstsize_bonus.c deleted file mode 100644 index 4fcb334..0000000 --- a/libft/ft_lstsize_bonus.c +++ /dev/null @@ -1,28 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_lstsize_bonus.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jteissie +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/05/18 14:25:01 by jteissie #+# #+# */ -/* Updated: 2024/05/18 14:35:30 by jteissie ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -int ft_lstsize(t_list *lst) -{ - t_list *temp; - int counter; - - counter = 0; - temp = lst; - while (temp != NULL) - { - temp = temp->next; - counter++; - } - return (counter); -} diff --git a/libft/ft_memchr.c b/libft/ft_memchr.c deleted file mode 100644 index 1f8e57e..0000000 --- a/libft/ft_memchr.c +++ /dev/null @@ -1,29 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_memchr.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jteissie +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/03/23 16:34:32 by jteissie #+# #+# */ -/* Updated: 2024/05/20 10:58:24 by jteissie ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -void *ft_memchr(const void *s, int c, size_t n) -{ - unsigned int i; - const unsigned char *str; - - i = 0; - str = s; - while (i < n) - { - if (str[i] == (unsigned char) c) - return ((void *)&str[i]); - i++; - } - return (NULL); -} diff --git a/libft/ft_memcmp.c b/libft/ft_memcmp.c deleted file mode 100644 index 7955734..0000000 --- a/libft/ft_memcmp.c +++ /dev/null @@ -1,31 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_memcmp.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jteissie +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/03/23 16:43:43 by jteissie #+# #+# */ -/* Updated: 2024/05/15 18:49:16 by jteissie ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -int ft_memcmp(const void *s1, const void *s2, size_t n) -{ - unsigned int i; - unsigned const char *str_1; - unsigned const char *str_2; - - i = 0; - str_1 = s1; - str_2 = s2; - while (i < n) - { - if (str_1[i] != str_2[i]) - return (str_1[i] - str_2[i]); - i++; - } - return (0); -} diff --git a/libft/ft_memcpy.c b/libft/ft_memcpy.c deleted file mode 100644 index 4d2bbf3..0000000 --- a/libft/ft_memcpy.c +++ /dev/null @@ -1,32 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_memcpy.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jteissie +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/03/23 17:12:25 by jteissie #+# #+# */ -/* Updated: 2024/05/18 16:13:24 by jteissie ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -void *ft_memcpy(void *dest, const void *src, size_t n) -{ - unsigned int i; - const char *src_str; - char *dest_str; - - i = 0; - if (dest == NULL && src == NULL) - return (NULL); - src_str = src; - dest_str = dest; - while (i < n) - { - dest_str[i] = src_str[i]; - i++; - } - return ((void *)dest_str); -} diff --git a/libft/ft_memmove.c b/libft/ft_memmove.c deleted file mode 100644 index 91079f1..0000000 --- a/libft/ft_memmove.c +++ /dev/null @@ -1,57 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_memmove.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jteissie +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/03/23 16:35:42 by jteissie #+# #+# */ -/* Updated: 2024/05/20 10:58:00 by jteissie ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -static char *backward_copy(char *to, const char *from, size_t index) -{ - while (index > 0) - { - to[index - 1] = from[index - 1]; - index--; - } - to[index] = from[index]; - return (to); -} - -static char *normal_copy(char *to, const char *from, size_t index, size_t n) -{ - while (index < n) - { - to[index] = from[index]; - index++; - } - return (to); -} - -void *ft_memmove(void *dest, const void *src, size_t n) -{ - size_t i; - const char *from; - char *to; - - if ((dest == NULL && src == NULL) || n == 0) - return (dest); - from = src; - to = dest; - if (to > from) - { - i = n; - to = backward_copy(to, from, i); - } - else - { - i = 0; - to = normal_copy(to, from, i, n); - } - return (dest); -} diff --git a/libft/ft_memset.c b/libft/ft_memset.c deleted file mode 100644 index 2d739a4..0000000 --- a/libft/ft_memset.c +++ /dev/null @@ -1,28 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_memset.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jteissie +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/03/23 16:44:33 by jteissie #+# #+# */ -/* Updated: 2024/05/20 10:57:36 by jteissie ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -void *ft_memset(void *s, int c, size_t n) -{ - size_t i; - unsigned char *str; - - i = 0; - str = s; - while (i < n) - { - str[i] = (unsigned char)c; - i++; - } - return (s); -} diff --git a/libft/ft_putchar_fd.c b/libft/ft_putchar_fd.c deleted file mode 100644 index 211f6f1..0000000 --- a/libft/ft_putchar_fd.c +++ /dev/null @@ -1,18 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_putchar_fd.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jteissie +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/03/23 17:48:56 by jteissie #+# #+# */ -/* Updated: 2024/05/15 15:04:12 by jteissie ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -void ft_putchar_fd(char c, int fd) -{ - write(fd, &c, 1); -} diff --git a/libft/ft_putendl_fd.c b/libft/ft_putendl_fd.c deleted file mode 100644 index 2878e04..0000000 --- a/libft/ft_putendl_fd.c +++ /dev/null @@ -1,19 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_putendl_fd.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jteissie +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/03/23 17:55:16 by jteissie #+# #+# */ -/* Updated: 2024/03/23 17:58:22 by jteissie ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -void ft_putendl_fd(char *s, int fd) -{ - ft_putstr_fd(s, fd); - ft_putchar_fd('\n', fd); -} diff --git a/libft/ft_putnbr_fd.c b/libft/ft_putnbr_fd.c deleted file mode 100644 index 1d1eccb..0000000 --- a/libft/ft_putnbr_fd.c +++ /dev/null @@ -1,33 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_putnbr_fd.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jteissie +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/03/23 17:59:07 by jteissie #+# #+# */ -/* Updated: 2024/05/17 14:46:54 by jteissie ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -void ft_putnbr_fd(int n, int fd) -{ - long int number; - - number = n; - if (number < 0) - { - ft_putchar_fd('-', fd); - number *= -1; - } - if (number > 9) - { - ft_putnbr_fd(number / 10, fd); - ft_putchar_fd(number % 10 + 48, fd); - return ; - } - ft_putchar_fd(number + 48, fd); - return ; -} diff --git a/libft/ft_putstr_fd.c b/libft/ft_putstr_fd.c deleted file mode 100644 index bd6a258..0000000 --- a/libft/ft_putstr_fd.c +++ /dev/null @@ -1,25 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_putstr_fd.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jteissie +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/03/23 17:52:53 by jteissie #+# #+# */ -/* Updated: 2024/05/15 15:05:54 by jteissie ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -void ft_putstr_fd(char *s, int fd) -{ - int i; - - i = 0; - while (s[i]) - { - ft_putchar_fd(s[i], fd); - i++; - } -} diff --git a/libft/ft_split.c b/libft/ft_split.c deleted file mode 100644 index fe98d92..0000000 --- a/libft/ft_split.c +++ /dev/null @@ -1,119 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_split.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jteissie +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/03/23 17:14:10 by jteissie #+# #+# */ -/* Updated: 2024/07/18 16:34:59 by jteissie ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -static int check_sep(char c, char sep) -{ - if (c == sep || c == '\0') - return (1); - return (0); -} - -static int count_words(char const *str, char sep) -{ - int i; - int words; - - i = 0; - words = 0; - if (!str || str[0] == '\0') - return (0); - if (check_sep(str[i], sep)) - i++; - while (str[i]) - { - if (check_sep(str[i], sep) - && !check_sep(str[i - 1], sep)) - words++; - i++; - } - if (check_sep(str[i], sep) && !check_sep(str[i - 1], sep)) - words++; - return (words); -} - -static char *build_str(char const *str, int index, int word_index) -{ - char *split_str; - int i; - - i = 0; - split_str = ft_calloc(word_index + 1, sizeof(char)); - if (!split_str) - return (NULL); - while (word_index > 0) - { - split_str[i] = str[index - word_index]; - i++; - word_index--; - } - split_str[i] = '\0'; - return (split_str); -} - -static char **assemble(char **split, char const *s, char c, int slots) -{ - int i; - int word_index; - int split_index; - - i = 0; - word_index = 0; - split_index = 0; - while (split_index < slots && s && s[i]) - { - while (!check_sep(s[i], c)) - { - word_index++; - i++; - } - if (check_sep(s[i], c) && !check_sep(s[i - 1], c)) - { - split[split_index] = build_str(s, i, word_index); - split_index++; - word_index = 0; - } - i++; - } - split[split_index] = NULL; - return (split); -} - -char **ft_split(char const *s, char c) -{ - char **split; - int words; - int safety_check; - - words = 0; - words = count_words(s, c); - split = ft_calloc(words + 1, sizeof(char *)); - if (!split) - return (NULL); - split = assemble(split, s, c, words); - safety_check = 0; - while (split[safety_check]) - safety_check++; - if (safety_check < words) - { - safety_check = 0; - while (safety_check <= words) - { - free(split[safety_check]); - safety_check++; - } - free(split); - return (NULL); - } - return (split); -} diff --git a/libft/ft_strarrjoin.c b/libft/ft_strarrjoin.c deleted file mode 100644 index 45c8ed6..0000000 --- a/libft/ft_strarrjoin.c +++ /dev/null @@ -1,51 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_strarrjoin.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bthomas +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/07/29 11:32:23 by bthomas #+# #+# */ -/* Updated: 2024/07/29 11:40:58 by bthomas ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -static size_t total_len(char **arr, size_t num_entries) -{ - size_t len; - size_t i; - - if (!arr || !*arr) - return (0); - len = 0; - i = 0; - while (i < num_entries && arr[i]) - { - len += ft_strlen(arr[i]); - i++; - } - return (len); -} - -char *ft_strarrjoin(char **arr, size_t num_entries) -{ - char *ret; - size_t ret_len; - size_t i; - - ret_len = total_len(arr, num_entries); - if (!ret_len) - return (NULL); - ret = (char *)ft_calloc(ret_len + 1, 1); - if (!ret) - return (NULL); - i = 0; - while (arr[i]) - { - ft_strlcat(ret, arr[i], ft_strlen(arr[i])); - i++; - } - return (ret); -} diff --git a/libft/ft_strchr.c b/libft/ft_strchr.c deleted file mode 100644 index 1feed62..0000000 --- a/libft/ft_strchr.c +++ /dev/null @@ -1,29 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_strchr.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jteissie +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/03/23 16:37:23 by jteissie #+# #+# */ -/* Updated: 2024/05/21 15:19:06 by jteissie ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -char *ft_strchr(char const *str, int c) -{ - int i; - - i = 0; - while (str[i]) - { - if (str[i] == (char)c) - return ((char *)&str[i]); - i++; - } - if (str[i] == (char)c) - return ((char *)&str[i]); - return (0); -} diff --git a/libft/ft_strcmp.c b/libft/ft_strcmp.c deleted file mode 100644 index 6f8c766..0000000 --- a/libft/ft_strcmp.c +++ /dev/null @@ -1,29 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_strcmp.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bthomas +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/07/13 16:35:10 by bthomas #+# #+# */ -/* Updated: 2024/07/14 13:25:51 by bthomas ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -int ft_strcmp(const char *s1, const char *s2) -{ - size_t s1len; - size_t s2len; - - if (!s1 && !s2) - return (0); - else if (!s1 || !s2) - return (1); - s1len = ft_strlen(s1); - s2len = ft_strlen(s2); - if (s1len != s2len) - return (1); - return (ft_strncmp(s1, s2, s1len)); -} diff --git a/libft/ft_strdup.c b/libft/ft_strdup.c deleted file mode 100644 index 7c93db6..0000000 --- a/libft/ft_strdup.c +++ /dev/null @@ -1,25 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_strdup.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bthomas +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/03/23 16:46:49 by jteissie #+# #+# */ -/* Updated: 2024/07/21 13:29:01 by bthomas ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -char *ft_strdup(const char *s) -{ - char *cpy; - size_t len; - - len = ft_strlen(s); - cpy = malloc(len + 1); - if (cpy != NULL) - ft_strlcpy(cpy, s, len + 1); - return (cpy); -} diff --git a/libft/ft_striteri.c b/libft/ft_striteri.c deleted file mode 100644 index b480f1f..0000000 --- a/libft/ft_striteri.c +++ /dev/null @@ -1,25 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_striteri.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jteissie +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/03/23 17:41:41 by jteissie #+# #+# */ -/* Updated: 2024/05/20 15:33:42 by jteissie ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -void ft_striteri(char *s, void (*f)(unsigned int, char*)) -{ - size_t i; - - i = 0; - while (s[i]) - { - (*f)(i, &s[i]); - i++; - } -} diff --git a/libft/ft_strjoin.c b/libft/ft_strjoin.c deleted file mode 100644 index b60c4a7..0000000 --- a/libft/ft_strjoin.c +++ /dev/null @@ -1,39 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_strjoin.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bthomas +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/03/23 17:35:02 by jteissie #+# #+# */ -/* Updated: 2024/07/18 11:04:26 by bthomas ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -char *ft_strjoin(char const *s1, char const *s2) -{ - char *joined; - int i; - int parse_index; - - i = 0; - parse_index = 0; - if (!s1 && !s2) - return (NULL); - if (!s1) - return (ft_strdup(s2)); - if (!s2) - return (ft_strdup(s1)); - joined = malloc (sizeof(char) * ft_strlen(s1) + ft_strlen(s2) + 1); - if (!joined) - return (NULL); - while (s1[parse_index]) - joined[i++] = s1[parse_index++]; - parse_index = 0; - while (s2[parse_index]) - joined[i++] = s2[parse_index++]; - joined[i] = '\0'; - return (joined); -} diff --git a/libft/ft_strjoin3.c b/libft/ft_strjoin3.c deleted file mode 100644 index 79fcae5..0000000 --- a/libft/ft_strjoin3.c +++ /dev/null @@ -1,30 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_strjoin3.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bthomas +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/07/19 10:31:28 by bthomas #+# #+# */ -/* Updated: 2024/07/26 14:14:56 by bthomas ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -char *ft_strjoin3(char *s1, char *s2, char *s3) -{ - char *result; - size_t len; - - len = ft_strlen(s1) + ft_strlen(s2) + ft_strlen(s3); - if (!len) - return (ft_strdup("")); - result = (char *)malloc(sizeof(char) * (len + 1)); - if (!result) - return (NULL); - ft_strlcpy(result, s1, len + 1); - ft_strlcat(result, s2, len + 1); - ft_strlcat(result, s3, len + 1); - return (result); -} diff --git a/libft/ft_strlcat.c b/libft/ft_strlcat.c deleted file mode 100644 index afdce27..0000000 --- a/libft/ft_strlcat.c +++ /dev/null @@ -1,35 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_strlcat.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jteissie +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/03/23 16:38:32 by jteissie #+# #+# */ -/* Updated: 2024/05/18 17:07:13 by jteissie ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -size_t ft_strlcat(char *dest, const char *src, size_t size) -{ - size_t i; - size_t dest_len; - size_t total_len; - - i = 0; - if ((!dest) && size == 0) - return (ft_strlen(src)); - dest_len = ft_strlen(dest); - total_len = ft_strlen(dest) + ft_strlen(src); - if (dest_len >= size || size == 0) - return (ft_strlen(src) + size); - while (i < size - dest_len - 1 && src[i]) - { - dest[dest_len + i] = src[i]; - i++; - } - dest[dest_len + i] = '\0'; - return (total_len); -} diff --git a/libft/ft_strlcpy.c b/libft/ft_strlcpy.c deleted file mode 100644 index 10c77b5..0000000 --- a/libft/ft_strlcpy.c +++ /dev/null @@ -1,34 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_strlcpy.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jteissie +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/03/23 16:47:51 by jteissie #+# #+# */ -/* Updated: 2024/05/17 11:51:14 by jteissie ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -size_t ft_strlcpy(char *dest, const char *src, size_t size) -{ - size_t i; - - i = 0; - if (size == 1) - { - dest[i] = '\0'; - return (ft_strlen(src)); - } - if (size == 0) - return (ft_strlen(src)); - while (i < size - 1 && src[i]) - { - dest[i] = src[i]; - i++; - } - dest[i] = '\0'; - return (ft_strlen(src)); -} diff --git a/libft/ft_strlen.c b/libft/ft_strlen.c deleted file mode 100644 index 16c26ff..0000000 --- a/libft/ft_strlen.c +++ /dev/null @@ -1,23 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_strlen.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bthomas +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/03/23 17:36:02 by jteissie #+# #+# */ -/* Updated: 2024/07/28 17:37:26 by bthomas ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -size_t ft_strlen(const char *str) -{ - int i; - - i = 0; - while (str && *str && str[i]) - i++; - return (i); -} diff --git a/libft/ft_strmapi.c b/libft/ft_strmapi.c deleted file mode 100644 index 487b704..0000000 --- a/libft/ft_strmapi.c +++ /dev/null @@ -1,31 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_strmapi.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jteissie +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/03/22 18:36:04 by jteissie #+# #+# */ -/* Updated: 2024/03/24 17:25:48 by jteissie ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -char *ft_strmapi(char const *s, char (*f) (unsigned int, char)) -{ - int i; - char *str; - - i = 0; - str = malloc(sizeof(char) * ft_strlen(s) + 1); - if (!str) - return (NULL); - while (s[i]) - { - str[i] = f(i, s[i]); - i++; - } - str[i] = 0; - return (str); -} diff --git a/libft/ft_strncmp.c b/libft/ft_strncmp.c deleted file mode 100644 index e907238..0000000 --- a/libft/ft_strncmp.c +++ /dev/null @@ -1,40 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_strncmp.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jteissie +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/03/23 16:48:57 by jteissie #+# #+# */ -/* Updated: 2024/05/18 16:35:31 by jteissie ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -int ft_strncmp(const char *s1, const char *s2, size_t n) -{ - size_t i; - - i = 0; - while (i < n && (s1[i] || s2[i])) - { - if (s1[i] != s2[i]) - return ((unsigned char)s1[i] - (unsigned char)s2[i]); - i++; - } - return (0); -} - -/* -int ft_strncmp(const char *s1, const char *s2, size_t n) -{ - size_t i; - - i = 0; - if (n == 0) - return (0); - while (s1[i] == s2[i] && s1[i] && s2[i] && i < n - 1) - i++; - return ((unsigned char)s1[i] - (unsigned char)s2[i]); -}*/ \ No newline at end of file diff --git a/libft/ft_strnstr.c b/libft/ft_strnstr.c deleted file mode 100644 index 4ce07b5..0000000 --- a/libft/ft_strnstr.c +++ /dev/null @@ -1,37 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_strnstr.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jteissie +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/03/23 17:36:54 by jteissie #+# #+# */ -/* Updated: 2024/05/22 11:10:33 by jteissie ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -char *ft_strnstr(const char *big, const char *little, size_t len) -{ - size_t i; - size_t little_i; - - i = 0; - if (little[0] == '\0') - return ((char *)big); - while (i < len && big[i]) - { - little_i = 0; - while (big[i + little_i] == little[little_i]) - { - if (i + little_i == len) - return (NULL); - little_i++; - if (little[little_i] == '\0') - return ((char *)&big[i]); - } - i++; - } - return (NULL); -} diff --git a/libft/ft_strrchr.c b/libft/ft_strrchr.c deleted file mode 100644 index d974f2a..0000000 --- a/libft/ft_strrchr.c +++ /dev/null @@ -1,27 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_strrchr.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jteissie +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/03/23 16:40:16 by jteissie #+# #+# */ -/* Updated: 2024/05/16 16:19:45 by jteissie ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -char *ft_strrchr(const char *s, int c) -{ - int i; - - i = ft_strlen(s); - while (i >= 0) - { - if (s[i] == (char) c) - return ((char *)&s[i]); - i--; - } - return (NULL); -} diff --git a/libft/ft_strreplacejoin.c b/libft/ft_strreplacejoin.c deleted file mode 100644 index d423b4c..0000000 --- a/libft/ft_strreplacejoin.c +++ /dev/null @@ -1,33 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_strreplacejoin.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bthomas +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/07/27 13:59:00 by bthomas #+# #+# */ -/* Updated: 2024/07/28 17:10:06 by bthomas ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -char *ft_strreplacejoin(char **s1, char **s2) -{ - char *result; - - result = ft_strjoin(*s1, *s2); - if (*s1) - { - free(*s1); - *s1 = NULL; - } - if (*s2) - { - free(*s2); - *s2 = NULL; - } - if (!result) - return (NULL); - return (result); -} diff --git a/libft/ft_strtrim.c b/libft/ft_strtrim.c deleted file mode 100644 index 8a2db75..0000000 --- a/libft/ft_strtrim.c +++ /dev/null @@ -1,50 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_strtrim.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jteissie +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/03/22 14:37:51 by jteissie #+# #+# */ -/* Updated: 2024/03/24 17:30:04 by jteissie ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -static int ft_isset(char c, char const *set) -{ - size_t i; - - i = 0; - while (set[i]) - { - if (set[i] == c) - return (1); - i++; - } - return (0); -} - -char *ft_strtrim(char const *s1, char const *set) -{ - size_t start; - size_t end; - size_t i; - char *str; - - start = 0; - end = ft_strlen(s1); - while (s1[start] && ft_isset(s1[start], set)) - start++; - while (end > start && ft_isset(s1[end - 1], set)) - end--; - str = malloc(sizeof(char) * (end - start) + 1); - if (!str) - return (NULL); - i = 0; - while (start < end) - str[i++] = s1[start++]; - str[i] = 0; - return (str); -} diff --git a/libft/ft_substr.c b/libft/ft_substr.c deleted file mode 100644 index 662744b..0000000 --- a/libft/ft_substr.c +++ /dev/null @@ -1,41 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_substr.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: bthomas +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/03/23 17:37:49 by jteissie #+# #+# */ -/* Updated: 2024/07/26 13:04:03 by bthomas ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -char *ft_substr(char const *s, unsigned int start, size_t len) -{ - char *sub_str; - unsigned int i; - - i = 0; - if (s && len > ft_strlen(s)) - len = ft_strlen(s); - if (s && start >= ft_strlen(s)) - len = 0; - if (s && start < ft_strlen(s) && len > ft_strlen(s) - start) - len = ft_strlen(s) - start; - sub_str = (char *)malloc(sizeof(char) * len + 1); - if (!sub_str) - return (NULL); - if (start < ft_strlen(s)) - { - while (s[start] && i < len) - { - sub_str[i] = s[start]; - start++; - i++; - } - } - sub_str[i] = '\0'; - return (sub_str); -} diff --git a/libft/ft_tolower.c b/libft/ft_tolower.c deleted file mode 100644 index 5f6b553..0000000 --- a/libft/ft_tolower.c +++ /dev/null @@ -1,20 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_tolower.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jteissie +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/03/23 16:41:04 by jteissie #+# #+# */ -/* Updated: 2024/03/23 16:41:22 by jteissie ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -int ft_tolower(int c) -{ - if (c >= 'A' && c <= 'Z') - c += 32; - return (c); -} diff --git a/libft/ft_toupper.c b/libft/ft_toupper.c deleted file mode 100644 index c76d959..0000000 --- a/libft/ft_toupper.c +++ /dev/null @@ -1,20 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_toupper.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jteissie +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/03/23 17:04:49 by jteissie #+# #+# */ -/* Updated: 2024/03/23 17:05:07 by jteissie ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -int ft_toupper(int c) -{ - if (c >= 'a' && c <= 'z') - c -= 32; - return (c); -} diff --git a/libft/libft.h b/libft/libft.h deleted file mode 100644 index 016bcb0..0000000 --- a/libft/libft.h +++ /dev/null @@ -1,88 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* libft.h :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: tsuchen +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2024/03/24 16:02:39 by jteissie #+# #+# */ -/* Updated: 2024/08/30 10:56:17 by tsuchen ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#ifndef LIBFT_H -# define LIBFT_H -# include -# include -# include - -int ft_isdigit(int c); -int ft_isalpha(int c); -int ft_isalnum(int c); -int ft_isascii(int c); -int ft_isprint(int c); -int ft_toupper(int c); -int ft_atoi(const char *nptr); -int ft_tolower(int c); -char *ft_strchr(const char *s, int c); -int ft_strncmp(const char *s1, const char *s2, size_t size); -int ft_strcmp(const char *s1, const char *s2); -char *ft_strdup(const char *s); -char *ft_itoa(int n); -void ft_bzero(void *s, size_t n); -void *ft_calloc(size_t nmemb, size_t t); -void *ft_memchr(const void *s, int c, size_t n); -int ft_memcmp(const void *s1, const void *s2, size_t n); -void *ft_memcpy(void *dest, const void *src, size_t n); -void *ft_memmove(void *dest, const void *src, size_t n); -void *ft_memset(void *s, int c, size_t n); -char **ft_split(char const *s, char c); -char *ft_strjoin(char const *s1, char const *s2); -size_t ft_strlen(const char *str); -size_t ft_strlcat(char *dest, const char *src, size_t size); -size_t ft_strlcpy(char *dest, const char *src, size_t size); -char *ft_strnstr(const char *big, const char *little, size_t n); -char *ft_strrchr(const char *s, int c); -char *ft_substr(char const *s, unsigned int start, size_t len); -char *ft_strtrim(char const *s1, char const *set); -char *ft_strmapi(char const *s, char (*f)(unsigned int, char)); -void ft_striteri(char *s, void (*f)(unsigned int, char*)); -void ft_putchar_fd(char c, int fd); -void ft_putendl_fd(char *s, int fd); -void ft_putnbr_fd(int n, int fd); -void ft_putstr_fd(char *s, int fd); - -char *ft_strjoin3(char *s1, char *s2, char *s3); -char *ft_strreplacejoin(char **s1, char **s2); -char *ft_strarrjoin(char **arr, size_t num_entries); - -typedef struct s_list -{ - void *content; - struct s_list *next; -} t_list; -t_list *ft_lstnew(void *content); -void ft_lstadd_front(t_list **lst, t_list *new); -int ft_lstsize(t_list *lst); -t_list *ft_lstlast(t_list *lst); -void ft_lstadd_back(t_list **lst, t_list *new); -void ft_lstdelone(t_list *lst, void (*del)(void *)); -void ft_lstclear(t_list **lst, void (*del)(void *)); -void ft_lstiter(t_list *lst, void (*f)(void *)); -t_list *ft_lstmap(t_list *lst, void *(*f)(void *), void (*del)(void *)); - -// ft_printf -int ft_printf(const char *fmt, ...) - __attribute__((format (printf, 1, 2))); -int triage_format(char format, va_list args); -int process_string(const char *str, va_list args); -int print_putchar_fd(char c, int fd); -int print_strlen(char const *s); -int print_putstr_fd(char *s, int fd); -void ft_putnbr_base(unsigned int n, char *base, int *print); -void print_unsigned(va_list args, int *count); -void print_ptr(va_list args, int *count); -void ft_putptr(unsigned long ptr, int *print); -void print_char(va_list args, int *count, char format); -void print_nbr(va_list args, int *count, char format); -#endif