diff --git a/libft/LICENSE b/libft/LICENSE deleted file mode 100644 index d0e4b83..0000000 --- a/libft/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2018 Kilian - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/libft/Makefile b/libft/Makefile deleted file mode 100644 index 7e73c6e..0000000 --- a/libft/Makefile +++ /dev/null @@ -1,132 +0,0 @@ -# **************************************************************************** # -# # -# ::: :::::::: # -# Makefile :+: :+: :+: # -# +:+ +:+ +:+ # -# By: kibotrel +#+ +:+ +#+ # -# +#+#+#+#+#+ +#+ # -# Created: 2018/11/07 14:35:03 by kibotrel #+# #+# # -# Updated: 2019/02/21 16:51:15 by kibotrel ### ########.fr # -# # -# **************************************************************************** # - -# Executable's name (Can be changed) - -NAME = libft.a - -# All the directories needed to know where files should be (Can be changed) - -OBJDIR = objs/ -SRCDIR = srcs/ -INCDIR = ./incs/ - -# Source files (Can be changed) - -SRC = ft_putchar.c ft_putchar_fd.c \ - ft_putstr.c ft_putstr_fd.c \ - ft_putnbr.c ft_putnbr_fd.c \ - ft_putendl.c ft_putendl_fd.c \ - ft_print_error.c \ - \ - ft_memset.c ft_memdel.c \ - ft_memcmp.c ft_memchr.c \ - ft_memcpy.c ft_memccpy.c \ - ft_memmove.c \ - \ - ft_atoi.c ft_itoa.c \ - ft_strdup.c ft_strlen.c \ - ft_strnew.c ft_strdel.c \ - ft_strclr.c ft_strsplit.c \ - ft_bzero.c ft_strtrim.c \ - ft_strlcat.c ft_memalloc.c \ - ft_create_elem.c ft_itoa_base.c \ - \ - ft_strstr.c ft_strnstr.c \ - ft_strcmp.c ft_strncmp.c \ - ft_strcpy.c ft_strncpy.c \ - ft_strequ.c ft_strnequ.c \ - ft_strcat.c ft_strncat.c \ - ft_striter.c ft_striteri.c \ - ft_strmap.c ft_strmapi.c \ - ft_strchr.c ft_strrchr.c \ - ft_strjoin.c ft_strsub.c \ - ft_strrev.c ft_numlen.c \ - ft_word_count.c ft_word_length.c \ - \ - ft_str_is_uppercase.c ft_str_is_lowercase.c \ - ft_strupcase.c ft_strlowcase.c \ - ft_toupper.c ft_tolower.c \ - ft_isalpha.c ft_isdigit.c \ - ft_isalnum.c ft_isascii.c \ - ft_isprint.c ft_isspace.c \ - \ - ft_count_if.c ft_foreach.c \ - ft_is_sort.c ft_foreach.c \ - \ - ft_lstnew.c ft_lstadd.c \ - ft_lstdel.c ft_lstdelone.c \ - ft_lstmap.c ft_lstiter.c \ - \ - ft_list_at.c ft_list_size.c \ - ft_list_foreach.c ft_list_foreach_if.c \ - ft_list_push_back.c ft_list_push_front.c \ - ft_list_last.c ft_list_remove_if.c \ - ft_list_reverse.c \ - \ - ft_match.c ft_nmatch.c \ - ft_power.c ft_fibonacci.c \ - ft_is_prime.c ft_find_next_prime.c \ - ft_is_negative.c ft_sort_int_tab.c \ - \ - ft_btree_create_node.c ft_btree_search_item.c \ - ft_btree_apply_infix.c ft_btree_apply_suffix.c \ - ft_btree_apply_prefix.c \ - \ - ft_get_next_line.c - -# Some tricks in order to get the makefile doing his job the way I want (Can't be changed) - -CSRC = $(addprefix $(SRCDIR), $(SRC)) -COBJ = $(addprefix $(OBJDIR), $(OBJ)) -CHECKDIR = $(shell if [ ! -d "$(OBJDIR)" ]; then mkdir $(OBJDIR); fi) - -# How files should be compiled with set flags (Can be changed) - -OBJ = $(SRC:.c=.o) -CFLAGS = -I$(INCDIR) -Wall -Wextra -Werror -CC = gcc - -# Build the library when all .c files are compiled into .o files and then indexing it - -$(NAME): $(CHECKDIR) $(COBJ) - @echo "\033[33m\n - Building \033[0m$(NAME) \033[33m...\n\033[0m" - @ar rc $(NAME) $(COBJ) - @echo "\033[33m - Indexing \033[0m$(NAME) \033[33m...\n\033[0m" - @ranlib $(NAME) - @echo "\033[32m*** Project $(NAME) successfully compiled ***\n\033[0m" - -all: $(NAME) - -# Redefinition of implicit compilation rule to prompt some colors and file names during the said compilation - -$(OBJDIR)%.o: $(SRCDIR)%.c - @echo "\033[33m - Compiling :\033[0m" $< - @$(CC) $(CFLAGS) -c $< -o $@ - -# Deleting all .o files and then the directory where they were located - -clean: - @echo "\033[32m*** Deleting all object files from $(NAME) ... ***\n\033[0m" - @rm -rf $(COBJ) - -# Deleting the library after cleaning up all .o files - -fclean: clean - @echo "\033[32m*** Deleting executable file from $(NAME) ... ***\n\033[0m" - @rm -rf $(NAME) - -# Delete all .o files then the library and rebuild the whole thing again - -re: fclean all - -.PHONY: all clean fclean re diff --git a/libft/README.md b/libft/README.md deleted file mode 100644 index eb949e8..0000000 --- a/libft/README.md +++ /dev/null @@ -1,4 +0,0 @@ -# Libft -The very first school project at 42. This repository contains everything to validate the project **libft** and all the function that I thought useful at some point in the cursus. - -Every function is documented in the wiki, check it out for more information ! diff --git a/libft/incs/libft.h b/libft/incs/libft.h deleted file mode 100644 index b32f9ec..0000000 --- a/libft/incs/libft.h +++ /dev/null @@ -1,170 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* libft.h :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: kibotrel +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2018/11/07 14:59:01 by kibotrel #+# #+# */ -/* Updated: 2019/02/20 20:16:29 by kibotrel ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#ifndef LIBFT_H -# define LIBFT_H - -# include - -/* -** Libc Functions -*/ - -# define LLMAX 9223372036854775807ull - -size_t ft_strlen(const char *s); -size_t ft_strlcat(char *dst, const char *src, size_t size); -void ft_bzero(void *s, size_t n); -void *ft_memset(void *b, int c, size_t len); -void *ft_memchr(const void *s, int c, size_t n); -void *ft_memcpy(void *dst, const void *src, size_t n); -void *ft_memmove(void *dst, const void *src, size_t len); -void *ft_memccpy(void *dst, const void *src, int c, size_t n); -char *ft_strdup(const char *s1); -char *ft_strchr(const char *s, int c); -char *ft_strrchr(const char *s, int c); -char *ft_strcat(char *s1, const char *s2); -char *ft_strcpy(char *dst, const char *src); -char *ft_strncat(char *s1, const char *s2, size_t n); -char *ft_strncpy(char *dst, const char *src, size_t len); -char *ft_strstr(const char *haystack, const char *needle); -char *ft_strnstr(const char *haystack, const char *needle, - size_t len); -int ft_isalpha(int c); -int ft_isdigit(int c); -int ft_isalnum(int c); -int ft_isascii(int c); -int ft_isprint(int c); -int ft_toupper(int c); -int ft_tolower(int c); -int ft_atoi(const char *str); -int ft_strcmp(const char *s1, const char *s2); -int ft_memcmp(const void *s1, const void *s2, size_t n); -int ft_strncmp(const char *s1, const char *s2, size_t n); - -/* -** Complementary Functions -*/ - -void ft_putnbr(int nb); -void ft_strclr(char *s); -void ft_putchar(char c); -void ft_memdel(void **ap); -void ft_strdel(char **as); -void ft_putstr(char const *s); -void *ft_memalloc(size_t size); -void ft_putendl(char const *s); -void ft_putnbr_fd(int n, int fd); -void ft_putchar_fd(char c, int fd); -void ft_putstr_fd(char const *s, int fd); -void ft_putendl_fd(char const *s, int fd); -void ft_striter(char *s, void (*f)(char *)); -void ft_striteri(char *s, void (*f)(unsigned int, char *)); -char *ft_itoa(int n); -char *ft_strnew(size_t size); -char *ft_strtrim(char const *s); -char **ft_strsplit(char const *s, char c); -char *ft_strmap(char const *s, char (*f)(char)); -char *ft_strjoin(char const *s1, char const *s2); -char *ft_strmapi(char const *s, char (*f)(unsigned int, char)); -char *ft_strsub(char const *s, unsigned int start, size_t len); -int ft_strequ(char const *s1, char const *s2); -int ft_strnequ(char const *s1, char const *s2, size_t n); - -/* -** Bonus Functions -*/ - -typedef struct s_list -{ - void *content; - size_t content_size; - struct s_list *next; -} t_list; - -t_list *ft_lstmap(t_list *lst, t_list *(*f)(t_list *elem)); -t_list *ft_lstnew(void const *content, size_t content_size); -void ft_lstadd(t_list **alst, t_list *new); -void ft_lstiter(t_list *lst, void (*f)(t_list *elem)); -void ft_lstdel(t_list **alst, void (*del)(void *, size_t)); -void ft_lstdelone(t_list **alst, void (*del)(void *, size_t)); - -/* -** Extra Functions -*/ - -# define BUFF_SIZE 4096 - -typedef struct s_gnlist -{ - struct s_gnlist *next; - struct s_gnlist *prev; - int fd; - char *save; -} t_gnlist; - -typedef struct s_chain -{ - void *data; - struct s_chain *next; -} t_chain; - -typedef struct s_btree -{ - struct s_btree *left; - struct s_btree *right; - void *item; -} t_btree; - -unsigned int ft_numlen(int nb); -t_btree *ft_btree_create_node(void *item); -t_chain *ft_create_elem(void *data); -t_chain *ft_list_last(t_chain *begin_list); -t_chain *ft_list_at(t_chain *begin_list, unsigned int nbr); -void ft_list_reverse(t_chain **begin_list); -void ft_print_error(char *desc, int error); -void ft_sort_int_tab(int *tab, unsigned int size); -void ft_foreach(int *tab, int length, void (*f)(int)); -void ft_list_push_back(t_chain **begin_list, void *data); -void ft_list_push_front(t_chain **begin_list, void *data); -void ft_list_foreach(t_chain *begin_list, void (*f)(void *)); -void ft_btree_apply_infix(t_btree *src, void (applyf)(void *)); -void ft_btree_apply_suffix(t_btree *src, void (*applyf)(void *)); -void ft_btree_apply_prefix(t_btree *src, void (*applyf)(void *)); -void ft_list_remove_if(t_chain **begin_list, void *data_ref, - int (*cmp)()); -void *ft_btree_search_item(t_btree *root, void *dataref, - int (*cmpf)(void *, void *)); -void ft_foreach_if(t_chain *begin_list, void (*f)(void *), - void *data_ref, int (*cmp)()); -char *ft_strrev(char *str); -char *ft_strupcase(char *str); -char *ft_strlowcase(char *str); -char *ft_itoa_base(int value, int base); -int ft_isspace(int c); -int ft_is_prime(int nb); -int ft_is_negative(int n); -int ft_fibonacci(int index); -int ft_find_next_prime(int nb); -int ft_power(int nb, int power); -int ft_match(char *s1, char *s2); -int ft_nmatch(char *s1, char *s2); -int ft_str_is_lowercase(char *str); -int ft_str_is_uppercase(char *str); -int ft_list_size(t_chain *begin_list); -int ft_word_count(char const *s, char c); -int ft_count_if(char **tab, int (*f)(char*)); -int ft_get_next_line(const int fd, char **line); -int ft_word_length(char const *s, int i, char c); -int ft_is_sort(int *tab, int length, int (*f)(int, int)); - -#endif diff --git a/libft/srcs/ft_atoi.c b/libft/srcs/ft_atoi.c deleted file mode 100644 index 706f27e..0000000 --- a/libft/srcs/ft_atoi.c +++ /dev/null @@ -1,46 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_atoi.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: kibotrel +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2018/11/07 17:32:03 by kibotrel #+# #+# */ -/* Updated: 2018/11/25 16:58:29 by kibotrel ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -static int lim(unsigned long long n, int sign) -{ - if (n >= LLMAX && sign == 0) - return (-1); - if (n >= LLMAX + 1 && sign == 1) - return (0); - return (42); -} - -int ft_atoi(const char *str) -{ - int i; - int negative; - unsigned long long result; - - i = 0; - negative = 0; - result = 0; - while (ft_isspace(str[i])) - i++; - if (str[i] == '+' || str[i] == '-') - { - if (str[i] == '-') - negative = 1; - i++; - } - while (ft_isdigit((int)str[i])) - result = result * 10 + ((int)str[i++] - '0'); - if (lim(result, negative) == 0 || lim(result, negative) == -1) - return (lim(result, negative)); - return ((negative == 1) ? -result : result); -} diff --git a/libft/srcs/ft_btree_apply_infix.c b/libft/srcs/ft_btree_apply_infix.c deleted file mode 100755 index e49cc49..0000000 --- a/libft/srcs/ft_btree_apply_infix.c +++ /dev/null @@ -1,23 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_btree_apply_infix.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: kibotrel +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2018/07/26 17:37:37 by kibotrel #+# #+# */ -/* Updated: 2019/01/15 23:28:38 by kibotrel ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -void ft_btree_apply_infix(t_btree *src, void (*applyf)(void *)) -{ - if (src) - { - ft_btree_apply_infix(src->left, applyf); - (*applyf)(src->item); - ft_btree_apply_infix(src->right, applyf); - } -} diff --git a/libft/srcs/ft_btree_apply_prefix.c b/libft/srcs/ft_btree_apply_prefix.c deleted file mode 100755 index 65ffce4..0000000 --- a/libft/srcs/ft_btree_apply_prefix.c +++ /dev/null @@ -1,23 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_btree_apply_prefix.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: kibotrel +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2018/07/26 16:56:20 by kibotrel #+# #+# */ -/* Updated: 2019/01/15 23:29:03 by kibotrel ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -void ft_btree_apply_prefix(t_btree *src, void (*applyf)(void *)) -{ - if (src) - { - (*applyf)(src->item); - ft_btree_apply_prefix(src->left, applyf); - ft_btree_apply_prefix(src->right, applyf); - } -} diff --git a/libft/srcs/ft_btree_apply_suffix.c b/libft/srcs/ft_btree_apply_suffix.c deleted file mode 100755 index 27ddadd..0000000 --- a/libft/srcs/ft_btree_apply_suffix.c +++ /dev/null @@ -1,23 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_btree_apply_suffix.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: kibotrel +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2018/07/26 18:20:13 by kibotrel #+# #+# */ -/* Updated: 2019/01/15 23:29:16 by kibotrel ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -void ft_btree_apply_suffix(t_btree *src, void (*applyf)(void *)) -{ - if (src) - { - ft_btree_apply_suffix(src->left, applyf); - ft_btree_apply_suffix(src->right, applyf); - (*applyf)(src->item); - } -} diff --git a/libft/srcs/ft_btree_create_node.c b/libft/srcs/ft_btree_create_node.c deleted file mode 100755 index 1cb9f6a..0000000 --- a/libft/srcs/ft_btree_create_node.c +++ /dev/null @@ -1,26 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_btree_create_node.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: kibotrel +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2018/07/26 14:51:17 by kibotrel #+# #+# */ -/* Updated: 2019/01/15 23:29:56 by kibotrel ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include -#include "libft.h" - -t_btree *ft_btree_create_node(void *item) -{ - t_btree *elem; - - if (!(elem = malloc(sizeof(*elem)))) - return (NULL); - elem->item = item; - elem->left = NULL; - elem->right = NULL; - return (elem); -} diff --git a/libft/srcs/ft_btree_search_item.c b/libft/srcs/ft_btree_search_item.c deleted file mode 100755 index 1e374e5..0000000 --- a/libft/srcs/ft_btree_search_item.c +++ /dev/null @@ -1,30 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_btree_search_item.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: kibotrel +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2018/07/26 20:46:29 by kibotrel #+# #+# */ -/* Updated: 2019/01/16 01:37:13 by kibotrel ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -void *ft_btree_search_item(t_btree *root, void *data_ref, - int (*cmpf)(void *, void *)) -{ - void *value; - - value = NULL; - if (!root) - return (NULL); - if (root->left) - value = ft_btree_search_item(root->left, data_ref, cmpf); - if ((cmpf(root->item, data_ref)) == 0) - return (root->item); - if (root->right != NULL && value != NULL) - value = ft_btree_search_item(root->right, data_ref, cmpf); - return (value); -} diff --git a/libft/srcs/ft_bzero.c b/libft/srcs/ft_bzero.c deleted file mode 100644 index e41f554..0000000 --- a/libft/srcs/ft_bzero.c +++ /dev/null @@ -1,24 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_bzero.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: kibotrel +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2018/11/08 14:31:02 by kibotrel #+# #+# */ -/* Updated: 2019/01/15 23:31:37 by kibotrel ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -void ft_bzero(void *s, size_t n) -{ - char *str; - size_t i; - - str = (char*)s; - i = -1; - while (s && n && ++i < n) - str[i] = 0; -} diff --git a/libft/srcs/ft_count_if.c b/libft/srcs/ft_count_if.c deleted file mode 100755 index e8dc03f..0000000 --- a/libft/srcs/ft_count_if.c +++ /dev/null @@ -1,26 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_count_if.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: kibotrel +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2018/07/17 22:37:15 by kibotrel #+# #+# */ -/* Updated: 2019/01/15 23:38:05 by kibotrel ### ########.fr */ -/* */ -/* ************************************************************************** */ - -int ft_count_if(char **tab, int (*f)(char*)) -{ - int i; - int count; - - i = -1; - count = 0; - while (tab[++i] != 0) - { - if (f(tab[i]) == 1) - count++; - } - return (count); -} diff --git a/libft/srcs/ft_create_elem.c b/libft/srcs/ft_create_elem.c deleted file mode 100644 index fcc1fc8..0000000 --- a/libft/srcs/ft_create_elem.c +++ /dev/null @@ -1,28 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_create_elem.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: kibotrel +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2018/11/15 17:44:53 by kibotrel #+# #+# */ -/* Updated: 2019/01/15 23:38:25 by kibotrel ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include -#include "libft.h" - -t_chain *ft_create_elem(void *data) -{ - t_chain *new; - - if (!(new = (t_chain*)malloc(sizeof(*new)))) - return (0); - if (data) - { - new->data = data; - new->next = NULL; - } - return (new); -} diff --git a/libft/srcs/ft_fibonacci.c b/libft/srcs/ft_fibonacci.c deleted file mode 100755 index fd4ada2..0000000 --- a/libft/srcs/ft_fibonacci.c +++ /dev/null @@ -1,22 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_fibonacci.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: kibotrel +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2018/07/07 17:10:26 by kibotrel #+# #+# */ -/* Updated: 2019/01/15 23:39:08 by kibotrel ### ########.fr */ -/* */ -/* ************************************************************************** */ - -int ft_fibonacci(int index) -{ - if (index < 0) - return (-1); - else if (index == 0) - return (0); - else if (index == 1 || index == 2) - return (1); - return (ft_fibonacci(index - 2) + ft_fibonacci(index - 1)); -} diff --git a/libft/srcs/ft_find_next_prime.c b/libft/srcs/ft_find_next_prime.c deleted file mode 100755 index 9853d6a..0000000 --- a/libft/srcs/ft_find_next_prime.c +++ /dev/null @@ -1,29 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_find_next_prime.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: kibotrel +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2018/07/05 22:24:54 by kibotrel #+# #+# */ -/* Updated: 2018/11/15 18:45:01 by kibotrel ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -int ft_find_next_prime(int nb) -{ - int x; - - x = nb; - if (nb <= 2) - return (2); - while (x < 2 * nb) - { - if (ft_is_prime(x) == 1) - return (x); - x++; - } - return (0); -} diff --git a/libft/srcs/ft_foreach.c b/libft/srcs/ft_foreach.c deleted file mode 100755 index 854363f..0000000 --- a/libft/srcs/ft_foreach.c +++ /dev/null @@ -1,20 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_foreach.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: kibotrel +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2018/07/17 18:36:53 by kibotrel #+# #+# */ -/* Updated: 2019/01/15 23:40:05 by kibotrel ### ########.fr */ -/* */ -/* ************************************************************************** */ - -void ft_foreach(int *tab, int length, void (*f)(int)) -{ - int i; - - i = -1; - while (++i < length) - f(tab[i]); -} diff --git a/libft/srcs/ft_get_next_line.c b/libft/srcs/ft_get_next_line.c deleted file mode 100644 index aa17762..0000000 --- a/libft/srcs/ft_get_next_line.c +++ /dev/null @@ -1,109 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_get_next_line.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: kibotrel +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2018/11/18 16:49:40 by kibotrel #+# #+# */ -/* Updated: 2019/01/15 23:21:11 by kibotrel ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include -#include -#include "libft.h" - -static int ft_index(const char *str, char c) -{ - int i; - - i = 0; - while (str && str[i] && str[i] != c) - i++; - return (i); -} - -static int ft_process_line(char **save, char **line, int length, int n) -{ - char *tmp; - - tmp = *save; - if ((tmp != NULL || n < 0) && (!(*line = ft_strsub(*save, 0, length)))) - return (-1); - if (tmp && tmp[length] == '\n') - length++; - if (tmp && tmp[length]) - *save = ft_strdup(tmp + length); - else - *save = NULL; - n = (tmp != NULL || n > 0); - free(tmp); - return (n); -} - -static int ft_fd_line(const int fd, char **line, char **save) -{ - char str[BUFF_SIZE + 1]; - char *tmp; - int n; - int length; - - while ((length = ft_index(*save, '\n')) == ft_index(*save, '\0')) - { - if ((n = read(fd, str, BUFF_SIZE)) < 0) - return (-1); - if (n == 0) - break ; - str[n] = '\0'; - if (!(tmp = ft_strjoin(*save ? *save : "", str))) - return (-1); - free(*save); - *save = tmp; - } - return (ft_process_line(save, line, length, n)); -} - -static void ft_gnlist_del(t_gnlist **cyclehit) -{ - t_gnlist *tmp; - - tmp = *cyclehit; - *cyclehit = tmp->next; - if (*cyclehit == tmp) - *cyclehit = NULL; - else - { - tmp->prev->next = tmp->next; - tmp->next->prev = tmp->prev; - } - free(tmp); -} - -int ft_get_next_line(const int fd, char **line) -{ - static t_gnlist *cyclehit = NULL; - t_gnlist *current; - int n; - - n = 0; - current = cyclehit; - while (cyclehit && (!n || current != cyclehit) && cyclehit->fd != fd - && (n = 1)) - cyclehit = cyclehit->next; - if (!cyclehit || cyclehit->fd != fd) - { - if (!(current = (t_gnlist*)malloc(sizeof(*current)))) - return (-1); - current->next = (cyclehit ? cyclehit->next : current); - current->prev = (cyclehit ? cyclehit : current); - current->next->prev = current; - current->prev->next = current; - current->save = NULL; - cyclehit = current; - cyclehit->fd = fd; - } - if ((n = ft_fd_line(cyclehit->fd, line, &cyclehit->save)) == 0) - ft_gnlist_del(&cyclehit); - return (n); -} diff --git a/libft/srcs/ft_is_negative.c b/libft/srcs/ft_is_negative.c deleted file mode 100755 index 485f82e..0000000 --- a/libft/srcs/ft_is_negative.c +++ /dev/null @@ -1,19 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_is_negative.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: kibotrel +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2018/07/03 19:31:57 by kibotrel #+# #+# */ -/* Updated: 2019/01/15 23:41:42 by kibotrel ### ########.fr */ -/* */ -/* ************************************************************************** */ - -int ft_is_negative(int n) -{ - if (n < 0) - return (-1); - else - return (1); -} diff --git a/libft/srcs/ft_is_prime.c b/libft/srcs/ft_is_prime.c deleted file mode 100755 index e0b239e..0000000 --- a/libft/srcs/ft_is_prime.c +++ /dev/null @@ -1,33 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_is_prime.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: kibotrel +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2018/07/05 20:03:40 by kibotrel #+# #+# */ -/* Updated: 2018/11/15 18:43:59 by kibotrel ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -int ft_is_prime(int nb) -{ - int x; - - if (nb < 0 || nb == 0 || nb == 1) - return (0); - if (nb == 2 || nb == 3 || nb == 5) - return (1); - if (nb % 2 == 0 || nb % 3 == 0 || nb % 5 == 0) - return (0); - x = 7; - while (x < nb) - { - if (nb % x == 0) - return (0); - x += 2; - } - return (1); -} diff --git a/libft/srcs/ft_is_sort.c b/libft/srcs/ft_is_sort.c deleted file mode 100755 index 4077c47..0000000 --- a/libft/srcs/ft_is_sort.c +++ /dev/null @@ -1,40 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_is_sort.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: kibotrel +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2018/07/17 23:27:32 by kibotrel #+# #+# */ -/* Updated: 2018/11/16 12:29:01 by kibotrel ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -int ft_is_sort(int *tab, int length, int (*f)(int, int)) -{ - int i; - - i = -1; - while (++i < length - 2) - { - if (f(tab[i], tab[i + 1]) > 0) - { - while (++i < length - 1) - { - if (f(tab[i], tab[i + 1]) < 0) - return (0); - } - } - else if (f(tab[i], tab[i + 1]) < 0) - { - while (++i < length - 1) - { - if (f(tab[i], tab[i + 1]) > 0) - return (0); - } - } - } - return (1); -} diff --git a/libft/srcs/ft_isalnum.c b/libft/srcs/ft_isalnum.c deleted file mode 100644 index e97105d..0000000 --- a/libft/srcs/ft_isalnum.c +++ /dev/null @@ -1,18 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_isalnum.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: kibotrel +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2018/11/08 13:24:04 by kibotrel #+# #+# */ -/* Updated: 2018/11/25 14:22:29 by kibotrel ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -int ft_isalnum(int c) -{ - return ((ft_isalpha(c) == 1 || ft_isdigit(c) == 1) ? 1 : 0); -} diff --git a/libft/srcs/ft_isalpha.c b/libft/srcs/ft_isalpha.c deleted file mode 100644 index 948ff2e..0000000 --- a/libft/srcs/ft_isalpha.c +++ /dev/null @@ -1,16 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_isalpha.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: kibotrel +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2018/11/08 12:49:03 by kibotrel #+# #+# */ -/* Updated: 2018/11/25 14:35:02 by kibotrel ### ########.fr */ -/* */ -/* ************************************************************************** */ - -int ft_isalpha(int c) -{ - return (((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z')) ? 1 : 0); -} diff --git a/libft/srcs/ft_isascii.c b/libft/srcs/ft_isascii.c deleted file mode 100644 index 57ed8a1..0000000 --- a/libft/srcs/ft_isascii.c +++ /dev/null @@ -1,16 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_isascii.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: kibotrel +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2018/11/08 13:31:58 by kibotrel #+# #+# */ -/* Updated: 2018/11/25 16:14:17 by kibotrel ### ########.fr */ -/* */ -/* ************************************************************************** */ - -int ft_isascii(int c) -{ - return ((c >= 0 && c <= 127) ? 1 : 0); -} diff --git a/libft/srcs/ft_isdigit.c b/libft/srcs/ft_isdigit.c deleted file mode 100644 index 97f73f5..0000000 --- a/libft/srcs/ft_isdigit.c +++ /dev/null @@ -1,16 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_isdigit.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: kibotrel +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2018/11/08 13:11:29 by kibotrel #+# #+# */ -/* Updated: 2018/11/25 16:14:54 by kibotrel ### ########.fr */ -/* */ -/* ************************************************************************** */ - -int ft_isdigit(int c) -{ - return ((c >= '0' && c <= '9') ? 1 : 0); -} diff --git a/libft/srcs/ft_isprint.c b/libft/srcs/ft_isprint.c deleted file mode 100644 index fb5637c..0000000 --- a/libft/srcs/ft_isprint.c +++ /dev/null @@ -1,16 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_isprint.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: kibotrel +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2018/11/08 13:45:59 by kibotrel #+# #+# */ -/* Updated: 2018/11/25 16:15:57 by kibotrel ### ########.fr */ -/* */ -/* ************************************************************************** */ - -int ft_isprint(int c) -{ - return ((c >= ' ' && c <= '~') ? 1 : 0); -} diff --git a/libft/srcs/ft_isspace.c b/libft/srcs/ft_isspace.c deleted file mode 100644 index c8d9043..0000000 --- a/libft/srcs/ft_isspace.c +++ /dev/null @@ -1,17 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_isspace.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: kibotrel +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2018/11/25 16:49:18 by kibotrel #+# #+# */ -/* Updated: 2018/11/25 17:00:47 by kibotrel ### ########.fr */ -/* */ -/* ************************************************************************** */ - -int ft_isspace(int c) -{ - return ((c == '\t' || c == '\n' || c == '\r' || c == '\v' || c == '\f' - || c == ' ') ? 1 : 0); -} diff --git a/libft/srcs/ft_itoa.c b/libft/srcs/ft_itoa.c deleted file mode 100644 index 422ef9c..0000000 --- a/libft/srcs/ft_itoa.c +++ /dev/null @@ -1,36 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_itoa.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: kibotrel +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2018/11/13 16:56:21 by kibotrel #+# #+# */ -/* Updated: 2018/11/25 16:26:11 by kibotrel ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" -#include - -char *ft_itoa(int n) -{ - char *str; - int length; - long nb; - - length = ft_numlen(n); - nb = n; - if (!(str = (char*)malloc(sizeof(*str) * (length + 1)))) - return (0); - str[length--] = '\0'; - str[0] = (n == 0 ? '0' : '-'); - if (n < 0) - nb = -nb; - while (nb > 0) - { - str[length--] = (nb % 10) + '0'; - nb /= 10; - } - return (str); -} diff --git a/libft/srcs/ft_itoa_base.c b/libft/srcs/ft_itoa_base.c deleted file mode 100644 index fb6213f..0000000 --- a/libft/srcs/ft_itoa_base.c +++ /dev/null @@ -1,54 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_itoa_base.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: kibotrel +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2019/01/22 13:52:52 by kibotrel #+# #+# */ -/* Updated: 2019/03/30 16:18:36 by kibotrel ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include - -int numlen(int value, int base) -{ - int size; - - size = 1; - if (value < 0) - size++; - while (value / base) - { - size++; - value /= base; - } - return (size); -} - -char *ft_itoa_base(int value, int base) -{ - int size; - char *result; - char *ref_base; - long nbr; - - nbr = value; - ref_base = "0123456789ABCDEF"; - if (base < 2 || base > 16) - return (NULL); - size = ((base != 10 && value < 0) ? numlen(-nbr, base) : numlen(nbr, base)); - if (!(result = (char*)malloc(sizeof(*result) * (size + 1)))) - return (NULL); - result[size--] = '\0'; - result[0] = (value < 0 ? '-' : '0'); - if (value < 0) - nbr = -nbr; - while (nbr > 0) - { - result[size--] = ref_base[nbr % base]; - nbr /= base; - } - return (result); -} diff --git a/libft/srcs/ft_list_at.c b/libft/srcs/ft_list_at.c deleted file mode 100755 index 3e88209..0000000 --- a/libft/srcs/ft_list_at.c +++ /dev/null @@ -1,26 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_list_at.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: kibotrel +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2018/07/19 21:18:45 by kibotrel #+# #+# */ -/* Updated: 2018/11/15 18:53:42 by kibotrel ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -t_chain *ft_list_at(t_chain *begin_list, unsigned int nbr) -{ - if (begin_list == NULL) - return (0); - while (nbr-- > 0) - { - if (begin_list == NULL) - return (NULL); - begin_list = begin_list->next; - } - return (begin_list); -} diff --git a/libft/srcs/ft_list_foreach.c b/libft/srcs/ft_list_foreach.c deleted file mode 100755 index 23d8a7e..0000000 --- a/libft/srcs/ft_list_foreach.c +++ /dev/null @@ -1,22 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_list_foreach.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: kibotrel +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2018/07/24 16:07:04 by kibotrel #+# #+# */ -/* Updated: 2018/11/15 19:57:03 by kibotrel ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -void ft_list_foreach(t_chain *begin_list, void (*f)(void *)) -{ - while (begin_list) - { - (*f)(begin_list->data); - begin_list = begin_list->next; - } -} diff --git a/libft/srcs/ft_list_foreach_if.c b/libft/srcs/ft_list_foreach_if.c deleted file mode 100755 index ec8e44d..0000000 --- a/libft/srcs/ft_list_foreach_if.c +++ /dev/null @@ -1,27 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_list_foreach_if.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: kibotrel +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2018/07/24 16:45:15 by kibotrel #+# #+# */ -/* Updated: 2018/11/15 20:00:49 by kibotrel ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -void ft_list_foreach_if(t_chain *begin_list, void (*f)(void *), - void *data_ref, int (*cmp)()) -{ - t_chain *position; - - position = begin_list; - while (position) - { - if ((*cmp)(position->data, data_ref) == 0) - (*f)(position->data); - position = position->next; - } -} diff --git a/libft/srcs/ft_list_last.c b/libft/srcs/ft_list_last.c deleted file mode 100755 index 49eab37..0000000 --- a/libft/srcs/ft_list_last.c +++ /dev/null @@ -1,22 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_list_last.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: kibotrel +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2018/07/19 10:55:21 by kibotrel #+# #+# */ -/* Updated: 2018/11/15 20:06:48 by kibotrel ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -t_chain *ft_list_last(t_chain *begin_list) -{ - if (begin_list == 0) - return (0); - while (begin_list->next != 0) - begin_list = begin_list->next; - return (begin_list); -} diff --git a/libft/srcs/ft_list_push_back.c b/libft/srcs/ft_list_push_back.c deleted file mode 100755 index 9e0d8f1..0000000 --- a/libft/srcs/ft_list_push_back.c +++ /dev/null @@ -1,28 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_list_push_back.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: kibotrel +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2018/07/19 09:46:07 by kibotrel #+# #+# */ -/* Updated: 2018/11/15 20:03:22 by kibotrel ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -void ft_list_push_back(t_chain **begin_list, void *data) -{ - t_chain *head; - - head = *begin_list; - if (head) - { - while (head->next) - head = head->next; - head->next = ft_create_elem(data); - } - else - *begin_list = ft_create_elem(data); -} diff --git a/libft/srcs/ft_list_push_front.c b/libft/srcs/ft_list_push_front.c deleted file mode 100755 index a538c4b..0000000 --- a/libft/srcs/ft_list_push_front.c +++ /dev/null @@ -1,22 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_list_push_front.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: kibotrel +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2018/07/19 10:25:24 by kibotrel #+# #+# */ -/* Updated: 2018/11/15 19:05:58 by kibotrel ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -void ft_list_push_front(t_chain **begin_list, void *data) -{ - t_chain *first_elem; - - first_elem = ft_create_elem(data); - first_elem->next = *begin_list; - *begin_list = first_elem; -} diff --git a/libft/srcs/ft_list_remove_if.c b/libft/srcs/ft_list_remove_if.c deleted file mode 100755 index 3f0dad5..0000000 --- a/libft/srcs/ft_list_remove_if.c +++ /dev/null @@ -1,43 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_list_remove_if.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: kibotrel +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2018/07/24 18:11:52 by kibotrel #+# #+# */ -/* Updated: 2018/11/16 14:52:56 by kibotrel ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" -#include - -void ft_list_remove_if(t_chain **begin_list, void *data_ref, int (*cmp)()) -{ - t_chain *position; - t_chain *previous; - t_chain *tmp; - - if (!begin_list) - return ; - position = *begin_list; - previous = NULL; - while (position) - { - if ((*cmp)(position->data, data_ref) == 0) - { - if (position == *begin_list) - *begin_list = position->next; - (previous) ? previous->next = position->next : 0; - tmp = position; - position = position->next; - free(tmp); - } - else - { - previous = position; - position = position->next; - } - } -} diff --git a/libft/srcs/ft_list_reverse.c b/libft/srcs/ft_list_reverse.c deleted file mode 100755 index 470aade..0000000 --- a/libft/srcs/ft_list_reverse.c +++ /dev/null @@ -1,35 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_list_reverse.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: kibotrel +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2018/07/24 10:18:31 by kibotrel #+# #+# */ -/* Updated: 2018/11/15 19:12:24 by kibotrel ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -void ft_list_reverse(t_chain **begin_list) -{ - t_chain *list1; - t_chain *list2; - t_chain *list3; - - list1 = *begin_list; - list2 = 0; - list3 = 0; - if (*begin_list) - { - while (list1) - { - list3 = list2; - list2 = list1; - list1 = list1->next; - list2->next = list3; - } - *begin_list = list2; - } -} diff --git a/libft/srcs/ft_list_size.c b/libft/srcs/ft_list_size.c deleted file mode 100755 index aaa674d..0000000 --- a/libft/srcs/ft_list_size.c +++ /dev/null @@ -1,28 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_list_size.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: kibotrel +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2018/07/19 10:36:08 by kibotrel #+# #+# */ -/* Updated: 2018/11/15 19:13:38 by kibotrel ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -int ft_list_size(t_chain *begin_list) -{ - int count; - - count = 0; - if (begin_list == 0) - return (0); - while (begin_list != 0) - { - begin_list = begin_list->next; - count++; - } - return (count); -} diff --git a/libft/srcs/ft_lstadd.c b/libft/srcs/ft_lstadd.c deleted file mode 100644 index 88daa8c..0000000 --- a/libft/srcs/ft_lstadd.c +++ /dev/null @@ -1,19 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_lstadd.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: kibotrel +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2018/11/14 18:01:54 by kibotrel #+# #+# */ -/* Updated: 2018/11/14 18:20:11 by kibotrel ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -void ft_lstadd(t_list **alst, t_list *new) -{ - new->next = *alst; - *alst = new; -} diff --git a/libft/srcs/ft_lstdel.c b/libft/srcs/ft_lstdel.c deleted file mode 100644 index 8db08db..0000000 --- a/libft/srcs/ft_lstdel.c +++ /dev/null @@ -1,40 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_lstdel.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: kibotrel +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2018/11/15 16:01:06 by kibotrel #+# #+# */ -/* Updated: 2018/11/15 17:12:36 by kibotrel ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" -#include - -void ft_lstdel(t_list **alst, void (*del)(void *, size_t)) -{ - t_list *position; - t_list *previous; - t_list *tmp; - - if (alst) - { - position = *alst; - previous = NULL; - while (position) - { - if (position && del) - { - if (position == *alst) - *alst = position->next; - (previous) ? previous->next = position->next : 0; - tmp = position; - position = position->next; - del(tmp->content, tmp->content_size); - free(tmp); - } - } - } -} diff --git a/libft/srcs/ft_lstdelone.c b/libft/srcs/ft_lstdelone.c deleted file mode 100644 index 5588a96..0000000 --- a/libft/srcs/ft_lstdelone.c +++ /dev/null @@ -1,24 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_lstdelone.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: kibotrel +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2018/11/15 14:19:25 by kibotrel #+# #+# */ -/* Updated: 2018/11/20 12:53:22 by kibotrel ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" -#include - -void ft_lstdelone(t_list **alst, void (*del)(void *, size_t)) -{ - if (alst && del) - { - del((*alst)->content, (*alst)->content_size); - free(*alst); - *alst = NULL; - } -} diff --git a/libft/srcs/ft_lstiter.c b/libft/srcs/ft_lstiter.c deleted file mode 100644 index 1fdfb22..0000000 --- a/libft/srcs/ft_lstiter.c +++ /dev/null @@ -1,22 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_lsttiter.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: kibotrel +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2018/11/14 17:45:27 by kibotrel #+# #+# */ -/* Updated: 2018/11/14 17:54:28 by kibotrel ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -void ft_lstiter(t_list *lst, void (*f)(t_list *elem)) -{ - while (lst && f) - { - f(lst); - lst = lst->next; - } -} diff --git a/libft/srcs/ft_lstmap.c b/libft/srcs/ft_lstmap.c deleted file mode 100644 index 2bf054a..0000000 --- a/libft/srcs/ft_lstmap.c +++ /dev/null @@ -1,45 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_lstmap.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: kibotrel +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2018/11/15 15:59:08 by kibotrel #+# #+# */ -/* Updated: 2018/11/15 17:12:25 by kibotrel ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" -#include - -static void ft_push_back(t_list **begin_list, t_list *data) -{ - t_list *head; - - head = *begin_list; - if (head) - { - while (head->next) - head = head->next; - head->next = data; - } - else - *begin_list = data; -} - -t_list *ft_lstmap(t_list *lst, t_list *(f)(t_list *elem)) -{ - t_list *map; - t_list *new; - - map = NULL; - while (lst) - { - if (!(new = f(lst))) - return (0); - ft_push_back(&map, new); - lst = lst->next; - } - return (map); -} diff --git a/libft/srcs/ft_lstnew.c b/libft/srcs/ft_lstnew.c deleted file mode 100644 index 8d3d00c..0000000 --- a/libft/srcs/ft_lstnew.c +++ /dev/null @@ -1,36 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_listnew.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: kibotrel +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2018/11/14 17:15:34 by kibotrel #+# #+# */ -/* Updated: 2018/11/14 17:57:32 by kibotrel ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" -#include - -t_list *ft_lstnew(void const *content, size_t content_size) -{ - t_list *new; - - if (!(new = (t_list*)malloc(sizeof(*new)))) - return (0); - if (!content) - { - new->content = NULL; - new->content_size = 0; - } - else - { - if (!(new->content = malloc(sizeof(char) * content_size))) - return (0); - ft_memcpy(new->content, content, content_size); - new->content_size = content_size; - } - new->next = NULL; - return (new); -} diff --git a/libft/srcs/ft_match.c b/libft/srcs/ft_match.c deleted file mode 100755 index 42d103e..0000000 --- a/libft/srcs/ft_match.c +++ /dev/null @@ -1,26 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_match.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: kibotrel +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2018/07/15 16:28:54 by kibotrel #+# #+# */ -/* Updated: 2018/11/16 14:24:07 by kibotrel ### ########.fr */ -/* */ -/* ************************************************************************** */ - -int ft_match(char *s1, char *s2) -{ - if (!s1 || !s2) - return (0); - if (s1[0] == '\0' && s2[0] == '\0') - return (1); - if (s1[0] != '\0' && s2[0] == '*') - return (ft_match(s1 + 1, s2) || ft_match(s1, s2 + 1)); - if (s1[0] == '\0' && s2[0] == '*') - return (ft_match(s1, s2 + 1)); - if (s1[0] == s2[0]) - return (ft_match(s1 + 1, s2 + 1)); - return (0); -} diff --git a/libft/srcs/ft_memalloc.c b/libft/srcs/ft_memalloc.c deleted file mode 100644 index 724e0ec..0000000 --- a/libft/srcs/ft_memalloc.c +++ /dev/null @@ -1,24 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_memalloc.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: kibotrel +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2018/11/09 18:23:34 by kibotrel #+# #+# */ -/* Updated: 2018/11/25 16:33:42 by kibotrel ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" -#include - -void *ft_memalloc(size_t size) -{ - char *alloc; - - if (!(alloc = (char*)malloc(size))) - return (0); - ft_bzero((void *)alloc, size); - return ((void *)alloc); -} diff --git a/libft/srcs/ft_memccpy.c b/libft/srcs/ft_memccpy.c deleted file mode 100644 index 5d300f7..0000000 --- a/libft/srcs/ft_memccpy.c +++ /dev/null @@ -1,31 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_memccpy.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: kibotrel +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2018/11/13 11:32:13 by kibotrel #+# #+# */ -/* Updated: 2018/11/25 17:36:02 by kibotrel ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -void *ft_memccpy(void *dst, const void *src, int c, size_t n) -{ - char *dest; - const unsigned char *source; - size_t i; - - dest = (char*)dst; - source = (const unsigned char*)src; - i = -1; - while (dst && src && ++i < n) - { - dest[i] = source[i]; - if (source[i] == (unsigned char)c) - return ((void*)dest + (i + 1)); - } - return (NULL); -} diff --git a/libft/srcs/ft_memchr.c b/libft/srcs/ft_memchr.c deleted file mode 100644 index f81141d..0000000 --- a/libft/srcs/ft_memchr.c +++ /dev/null @@ -1,27 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_memchr.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: kibotrel +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2018/11/11 13:27:08 by kibotrel #+# #+# */ -/* Updated: 2018/11/25 17:16:21 by kibotrel ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -void *ft_memchr(const void *s, int c, size_t n) -{ - unsigned char *mem; - - mem = (unsigned char*)s; - while (s && --n > 0) - { - if (*mem == (unsigned char)c) - return (mem); - mem++; - } - return (NULL); -} diff --git a/libft/srcs/ft_memcmp.c b/libft/srcs/ft_memcmp.c deleted file mode 100644 index 625e00b..0000000 --- a/libft/srcs/ft_memcmp.c +++ /dev/null @@ -1,28 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_memcmp.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: kibotrel +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2018/11/08 14:54:14 by kibotrel #+# #+# */ -/* Updated: 2018/11/25 17:34:41 by kibotrel ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -int ft_memcmp(const void *s1, const void *s2, size_t n) -{ - unsigned const char *str1; - unsigned const char *str2; - size_t i; - - i = -1; - str1 = (unsigned const char*)s1; - str2 = (unsigned const char*)s2; - while (s1 && s2 && ++i < n) - if (str1[i] != str2[i]) - return (str1[i] - str2[i]); - return (0); -} diff --git a/libft/srcs/ft_memcpy.c b/libft/srcs/ft_memcpy.c deleted file mode 100644 index f73a514..0000000 --- a/libft/srcs/ft_memcpy.c +++ /dev/null @@ -1,31 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_memcpy.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: kibotrel +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2018/11/11 13:03:09 by kibotrel #+# #+# */ -/* Updated: 2018/11/25 17:32:32 by kibotrel ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -void *ft_memcpy(void *dst, const void *src, size_t n) -{ - const char *s1; - char *s2; - size_t i; - - s1 = src; - s2 = dst; - i = -1; - if (dst == src) - return (dst); - if (n == 0) - return (dst); - while (dst && src && ++i < n) - s2[i] = s1[i]; - return (dst); -} diff --git a/libft/srcs/ft_memdel.c b/libft/srcs/ft_memdel.c deleted file mode 100644 index f476956..0000000 --- a/libft/srcs/ft_memdel.c +++ /dev/null @@ -1,22 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_memdel.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: kibotrel +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2018/11/09 18:33:49 by kibotrel #+# #+# */ -/* Updated: 2018/11/09 18:39:13 by kibotrel ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include - -void ft_memdel(void **ap) -{ - if (ap != NULL) - { - free(*ap); - *ap = NULL; - } -} diff --git a/libft/srcs/ft_memmove.c b/libft/srcs/ft_memmove.c deleted file mode 100644 index a1976b8..0000000 --- a/libft/srcs/ft_memmove.c +++ /dev/null @@ -1,31 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_memmove.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: kibotrel +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2018/11/12 14:27:04 by kibotrel #+# #+# */ -/* Updated: 2018/11/25 17:49:23 by kibotrel ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -void *ft_memmove(void *dst, const void *src, size_t len) -{ - unsigned const char *source; - unsigned char *dest; - size_t i; - - source = (unsigned const char*)src; - dest = (unsigned char*)dst; - i = -1; - if (dst && src && dst > src) - while (len--) - dest[len] = source[len]; - else if (dst && src) - while (++i < len) - dest[i] = source[i]; - return (dst); -} diff --git a/libft/srcs/ft_memset.c b/libft/srcs/ft_memset.c deleted file mode 100644 index afc7448..0000000 --- a/libft/srcs/ft_memset.c +++ /dev/null @@ -1,25 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_memset.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: kibotrel +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2018/11/12 13:19:42 by kibotrel #+# #+# */ -/* Updated: 2018/11/25 17:37:52 by kibotrel ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -void *ft_memset(void *b, int c, size_t len) -{ - char *set; - size_t i; - - i = -1; - set = (char *)b; - while (b && len && ++i < len) - set[i] = (unsigned char)c; - return (b); -} diff --git a/libft/srcs/ft_nmatch.c b/libft/srcs/ft_nmatch.c deleted file mode 100755 index f29c963..0000000 --- a/libft/srcs/ft_nmatch.c +++ /dev/null @@ -1,26 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_nnmatch.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: kibotrel +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2018/07/15 17:19:53 by kibotrel #+# #+# */ -/* Updated: 2018/12/18 20:31:09 by kibotrel ### ########.fr */ -/* */ -/* ************************************************************************** */ - -int ft_nmatch(char *s1, char *s2) -{ - if (!s1 || !s2) - return (0); - if (s1[0] == '\0' && s2[0] == '\0') - return (1); - if (s1[0] != '\0' && s2[0] == '*') - return (ft_nmatch(s1 + 1, s2) + ft_nmatch(s1, s2 + 1)); - if (s1[0] == '\0' && s2[0] == '*') - return (ft_nmatch(s1, s2 + 1)); - if (s1[0] == s2[0]) - return (ft_nmatch(s1 + 1, s2 + 1)); - return (0); -} diff --git a/libft/srcs/ft_numlen.c b/libft/srcs/ft_numlen.c deleted file mode 100644 index 2a1cd2c..0000000 --- a/libft/srcs/ft_numlen.c +++ /dev/null @@ -1,26 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_numlen.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: kibotrel +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2018/11/25 16:24:36 by kibotrel #+# #+# */ -/* Updated: 2018/11/25 19:21:38 by kibotrel ### ########.fr */ -/* */ -/* ************************************************************************** */ - -unsigned int ft_numlen(int nb) -{ - unsigned int size; - - size = 1; - if (nb < 0) - size++; - while (nb / 10) - { - nb /= 10; - size++; - } - return (size); -} diff --git a/libft/srcs/ft_power.c b/libft/srcs/ft_power.c deleted file mode 100755 index 5a0b7b2..0000000 --- a/libft/srcs/ft_power.c +++ /dev/null @@ -1,22 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_power.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: kibotrel +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2018/07/05 12:17:24 by kibotrel #+# #+# */ -/* Updated: 2018/11/16 15:01:14 by kibotrel ### ########.fr */ -/* */ -/* ************************************************************************** */ - -int ft_power(int nb, int power) -{ - if (nb == 0 && power == 0) - return (1); - if (nb == 0 || power < 0) - return (0); - else if (nb == 1 || power == 0) - return (1); - return (nb * ft_power(nb, power - 1)); -} diff --git a/libft/srcs/ft_print_error.c b/libft/srcs/ft_print_error.c deleted file mode 100644 index ff6b1de..0000000 --- a/libft/srcs/ft_print_error.c +++ /dev/null @@ -1,20 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_print_error.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: kibotrel +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2019/02/20 19:34:43 by kibotrel #+# #+# */ -/* Updated: 2019/02/20 19:37:11 by kibotrel ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include -#include "libft.h" - -void ft_print_error(char *desc, int error) -{ - ft_putendl(desc); - exit(error); -} diff --git a/libft/srcs/ft_putchar.c b/libft/srcs/ft_putchar.c deleted file mode 100644 index 6bb2717..0000000 --- a/libft/srcs/ft_putchar.c +++ /dev/null @@ -1,18 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_putchar.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: kibotrel +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2018/11/07 16:26:41 by kibotrel #+# #+# */ -/* Updated: 2018/11/07 16:57:43 by kibotrel ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include - -void ft_putchar(char c) -{ - write(1, &c, 1); -} diff --git a/libft/srcs/ft_putchar_fd.c b/libft/srcs/ft_putchar_fd.c deleted file mode 100644 index f336d61..0000000 --- a/libft/srcs/ft_putchar_fd.c +++ /dev/null @@ -1,18 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_putchar_fd.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: kibotrel +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2018/11/09 18:56:40 by kibotrel #+# #+# */ -/* Updated: 2018/11/09 18:57:47 by kibotrel ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include - -void ft_putchar_fd(char c, int fd) -{ - write(fd, &c, 1); -} diff --git a/libft/srcs/ft_putendl.c b/libft/srcs/ft_putendl.c deleted file mode 100644 index 85d80f6..0000000 --- a/libft/srcs/ft_putendl.c +++ /dev/null @@ -1,20 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_putendl.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: kibotrel +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2018/11/08 17:51:13 by kibotrel #+# #+# */ -/* Updated: 2018/11/08 18:00:06 by kibotrel ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -void ft_putendl(char const *s) -{ - if (s) - ft_putstr(s); - ft_putchar('\n'); -} diff --git a/libft/srcs/ft_putendl_fd.c b/libft/srcs/ft_putendl_fd.c deleted file mode 100644 index c073cb6..0000000 --- a/libft/srcs/ft_putendl_fd.c +++ /dev/null @@ -1,19 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_putendl_fd.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: kibotrel +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2018/11/09 19:07:07 by kibotrel #+# #+# */ -/* Updated: 2018/11/09 20:41:27 by kibotrel ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -void ft_putendl_fd(char const *s, int fd) -{ - ft_putstr_fd(s, fd); - ft_putchar_fd('\n', fd); -} diff --git a/libft/srcs/ft_putnbr.c b/libft/srcs/ft_putnbr.c deleted file mode 100644 index 45f9a1b..0000000 --- a/libft/srcs/ft_putnbr.c +++ /dev/null @@ -1,35 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_putnbr.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: kibotrel +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2018/11/07 17:20:13 by kibotrel #+# #+# */ -/* Updated: 2018/11/25 19:40:13 by kibotrel ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" -#include - -void ft_putnbr(int nb) -{ - if (nb < 0) - { - ft_putchar('-'); - if (nb == INT_MIN) - { - ft_putchar('2'); - nb = INT_MIN + 2000000000; - } - nb = -nb; - } - if (nb >= 10) - { - ft_putnbr(nb / 10); - ft_putnbr(nb % 10); - } - else - ft_putchar('0' + nb); -} diff --git a/libft/srcs/ft_putnbr_fd.c b/libft/srcs/ft_putnbr_fd.c deleted file mode 100644 index 261f1a6..0000000 --- a/libft/srcs/ft_putnbr_fd.c +++ /dev/null @@ -1,35 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_putnbr_fd.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: kibotrel +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2018/11/09 19:34:22 by kibotrel #+# #+# */ -/* Updated: 2018/11/25 19:42:54 by kibotrel ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" -#include - -void ft_putnbr_fd(int n, int fd) -{ - if (n < 0) - { - ft_putchar_fd('-', fd); - if (n == INT_MIN) - { - ft_putchar_fd('2', fd); - n = INT_MIN + 2000000000; - } - n = -n; - } - if (n >= 10) - { - ft_putnbr_fd(n / 10, fd); - ft_putnbr_fd(n % 10, fd); - } - else - ft_putchar_fd(n + '0', fd); -} diff --git a/libft/srcs/ft_putstr.c b/libft/srcs/ft_putstr.c deleted file mode 100644 index 1512bdc..0000000 --- a/libft/srcs/ft_putstr.c +++ /dev/null @@ -1,19 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_putstr.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: kibotrel +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2018/11/07 17:02:55 by kibotrel #+# #+# */ -/* Updated: 2018/11/25 19:29:55 by kibotrel ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" -#include - -void ft_putstr(char const *s) -{ - write(1, s, ft_strlen(s)); -} diff --git a/libft/srcs/ft_putstr_fd.c b/libft/srcs/ft_putstr_fd.c deleted file mode 100644 index 54f509e..0000000 --- a/libft/srcs/ft_putstr_fd.c +++ /dev/null @@ -1,19 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_putstr_fd.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: kibotrel +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2018/11/09 19:02:24 by kibotrel #+# #+# */ -/* Updated: 2018/11/25 19:40:56 by kibotrel ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" -#include - -void ft_putstr_fd(char const *s, int fd) -{ - (write(fd, s, ft_strlen(s))); -} diff --git a/libft/srcs/ft_sort_int_tab.c b/libft/srcs/ft_sort_int_tab.c deleted file mode 100644 index f1a3c1f..0000000 --- a/libft/srcs/ft_sort_int_tab.c +++ /dev/null @@ -1,31 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_sort_int_tab.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: exam +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2019/01/15 10:03:41 by exam #+# #+# */ -/* Updated: 2019/01/23 19:35:05 by kibotrel ### ########.fr */ -/* */ -/* ************************************************************************** */ - -void ft_sort_int_tab(int *tab, unsigned int size) -{ - unsigned int i; - int tmp; - - i = 0; - while (i < size - 1) - { - if (tab[i] > tab[i + 1]) - { - tmp = tab[i]; - tab[i] = tab[i + 1]; - tab[i + 1] = tmp; - i = 0; - } - else - i++; - } -} diff --git a/libft/srcs/ft_str_is_lowercase.c b/libft/srcs/ft_str_is_lowercase.c deleted file mode 100755 index 0af01e6..0000000 --- a/libft/srcs/ft_str_is_lowercase.c +++ /dev/null @@ -1,25 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_str_is_lowercase.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: kibotrel +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2018/07/08 17:58:46 by kibotrel #+# #+# */ -/* Updated: 2018/11/15 19:32:04 by kibotrel ### ########.fr */ -/* */ -/* ************************************************************************** */ - -int ft_str_is_lowercase(char *str) -{ - int i; - - i = 0; - while (str[i]) - { - if (!(str[i] >= 'a' && str[i] <= 'z')) - return (0); - i++; - } - return (1); -} diff --git a/libft/srcs/ft_str_is_uppercase.c b/libft/srcs/ft_str_is_uppercase.c deleted file mode 100755 index 23c61c7..0000000 --- a/libft/srcs/ft_str_is_uppercase.c +++ /dev/null @@ -1,25 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_is_uppercase.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: kibotrel +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2018/07/08 19:11:34 by kibotrel #+# #+# */ -/* Updated: 2018/11/15 19:32:54 by kibotrel ### ########.fr */ -/* */ -/* ************************************************************************** */ - -int ft_str_is_uppercase(char *str) -{ - int i; - - i = 0; - while (str[i]) - { - if (!(str[i] >= 'A' && str[i] <= 'Z')) - return (0); - i++; - } - return (1); -} diff --git a/libft/srcs/ft_strcat.c b/libft/srcs/ft_strcat.c deleted file mode 100644 index 98ca606..0000000 --- a/libft/srcs/ft_strcat.c +++ /dev/null @@ -1,26 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_strcat.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: kibotrel +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2018/11/07 21:20:01 by kibotrel #+# #+# */ -/* Updated: 2018/11/25 17:56:32 by kibotrel ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -char *ft_strcat(char *s1, const char *s2) -{ - int i; - int j; - - i = ft_strlen(s1); - j = -1; - while (s2 && s2[++j]) - s1[i + j] = s2[j]; - s1[i + j] = '\0'; - return (s1); -} diff --git a/libft/srcs/ft_strchr.c b/libft/srcs/ft_strchr.c deleted file mode 100644 index ea48a16..0000000 --- a/libft/srcs/ft_strchr.c +++ /dev/null @@ -1,29 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_strchr.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: kibotrel +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2018/11/08 18:09:11 by kibotrel #+# #+# */ -/* Updated: 2018/11/25 18:00:17 by kibotrel ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -char *ft_strchr(const char *s, int c) -{ - int i; - - i = 0; - if (c == 0) - return ((char*)s + ft_strlen(s)); - while (s && s[i]) - { - if (s[i] == c) - return ((char*)s + i); - i++; - } - return (NULL); -} diff --git a/libft/srcs/ft_strclr.c b/libft/srcs/ft_strclr.c deleted file mode 100644 index b963ce4..0000000 --- a/libft/srcs/ft_strclr.c +++ /dev/null @@ -1,18 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_strclr.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: kibotrel +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2018/11/09 13:51:47 by kibotrel #+# #+# */ -/* Updated: 2018/11/25 18:45:27 by kibotrel ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -void ft_strclr(char *s) -{ - ft_bzero((void *)s, ft_strlen(s)); -} diff --git a/libft/srcs/ft_strcmp.c b/libft/srcs/ft_strcmp.c deleted file mode 100755 index 0f58446..0000000 --- a/libft/srcs/ft_strcmp.c +++ /dev/null @@ -1,21 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_strcmp.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: kibotrel +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2018/11/06 13:23:44 by kibotrel #+# #+# */ -/* Updated: 2018/11/11 14:50:51 by kibotrel ### ########.fr */ -/* */ -/* ************************************************************************** */ - -int ft_strcmp(const char *s1, const char *s2) -{ - int i; - - i = 0; - while (s1[i] == s2[i] && s1[i] != '\0') - i++; - return ((unsigned char)s1[i] - (unsigned char)s2[i]); -} diff --git a/libft/srcs/ft_strcpy.c b/libft/srcs/ft_strcpy.c deleted file mode 100644 index 03613dc..0000000 --- a/libft/srcs/ft_strcpy.c +++ /dev/null @@ -1,22 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_strcpy.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: kibotrel +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2018/11/08 19:46:11 by kibotrel #+# #+# */ -/* Updated: 2018/11/25 17:50:43 by kibotrel ### ########.fr */ -/* */ -/* ************************************************************************** */ - -char *ft_strcpy(char *dst, const char *src) -{ - int i; - - i = -1; - while (src && src[++i]) - dst[i] = src[i]; - dst[i] = '\0'; - return (dst); -} diff --git a/libft/srcs/ft_strdel.c b/libft/srcs/ft_strdel.c deleted file mode 100755 index 219072d..0000000 --- a/libft/srcs/ft_strdel.c +++ /dev/null @@ -1,22 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_strdel.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: kibotrel +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2018/11/09 13:16:49 by kibotrel #+# #+# */ -/* Updated: 2018/11/09 13:47:02 by kibotrel ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include - -void ft_strdel(char **as) -{ - if (as != NULL && *as != NULL) - { - free(*as); - *as = NULL; - } -} diff --git a/libft/srcs/ft_strdup.c b/libft/srcs/ft_strdup.c deleted file mode 100755 index c1fe988..0000000 --- a/libft/srcs/ft_strdup.c +++ /dev/null @@ -1,28 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_strdup.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: kibotrel +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2018/11/05 18:43:58 by kibotrel #+# #+# */ -/* Updated: 2018/11/25 17:52:43 by kibotrel ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" -#include - -char *ft_strdup(const char *s1) -{ - int i; - char *dup; - - i = -1; - if (!s1 || !(dup = (char*)malloc(sizeof(*dup) * (ft_strlen(s1) + 1)))) - return (NULL); - while (s1[++i]) - dup[i] = s1[i]; - dup[i] = '\0'; - return (dup); -} diff --git a/libft/srcs/ft_strequ.c b/libft/srcs/ft_strequ.c deleted file mode 100644 index 7557802..0000000 --- a/libft/srcs/ft_strequ.c +++ /dev/null @@ -1,21 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_strequ.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: kibotrel +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2018/11/09 14:44:41 by kibotrel #+# #+# */ -/* Updated: 2018/11/25 19:04:38 by kibotrel ### ########.fr */ -/* */ -/* ************************************************************************** */ - -int ft_strequ(char const *s1, char const *s2) -{ - int i; - - i = 0; - while (s1 && s2 && s1[i] == s2[i] && s1[i]) - i++; - return ((s1 && s2 && s1[i] == s2[i]) ? 1 : 0); -} diff --git a/libft/srcs/ft_striter.c b/libft/srcs/ft_striter.c deleted file mode 100644 index 5913a48..0000000 --- a/libft/srcs/ft_striter.c +++ /dev/null @@ -1,21 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_striter.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: kibotrel +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2018/11/09 14:01:51 by kibotrel #+# #+# */ -/* Updated: 2018/11/25 19:02:12 by kibotrel ### ########.fr */ -/* */ -/* ************************************************************************** */ - -void ft_striter(char *s, void (*f)(char *)) -{ - int i; - - i = 0; - if (f != 0) - while (s && s[i]) - f(&s[i++]); -} diff --git a/libft/srcs/ft_striteri.c b/libft/srcs/ft_striteri.c deleted file mode 100644 index 6b74d9e..0000000 --- a/libft/srcs/ft_striteri.c +++ /dev/null @@ -1,24 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_striteri.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: kibotrel +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2018/11/09 14:15:34 by kibotrel #+# #+# */ -/* Updated: 2018/11/25 19:01:03 by kibotrel ### ########.fr */ -/* */ -/* ************************************************************************** */ - -void ft_striteri(char *s, void (*f)(unsigned int, char *)) -{ - unsigned int i; - - i = 0; - if (f != 0) - while (s && s[i]) - { - f(i, &s[i]); - i++; - } -} diff --git a/libft/srcs/ft_strjoin.c b/libft/srcs/ft_strjoin.c deleted file mode 100644 index de2bdad..0000000 --- a/libft/srcs/ft_strjoin.c +++ /dev/null @@ -1,25 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_strjoin.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: kibotrel +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2018/11/09 17:50:24 by kibotrel #+# #+# */ -/* Updated: 2018/11/25 19:19:51 by kibotrel ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" -#include - -char *ft_strjoin(char const *s1, char const *s2) -{ - size_t size; - char *join; - - size = ft_strlen(s1) + ft_strlen(s2); - if (!(join = (char*)malloc(sizeof(*join) * (size + 1)))) - return (0); - return (ft_strcat(ft_strcpy(join, s1), s2)); -} diff --git a/libft/srcs/ft_strlcat.c b/libft/srcs/ft_strlcat.c deleted file mode 100755 index d442637..0000000 --- a/libft/srcs/ft_strlcat.c +++ /dev/null @@ -1,41 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_strlcat.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: kibotrel +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2018/11/12 15:49:09 by kibotrel #+# #+# */ -/* Updated: 2018/11/25 17:59:28 by kibotrel ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -size_t ft_strlcat(char *dst, const char *src, size_t size) -{ - size_t i; - size_t j; - size_t dest_size; - - i = ft_strlen(dst); - dest_size = i; - j = 0; - if (size == 0) - { - dst[i] = '\0'; - return (ft_strlen(src)); - } - else if (size <= i) - return (ft_strlen(src) + size); - else - { - while (src && src[j] && i + j < size - 1) - { - dst[i + j] = src[j]; - j++; - } - dst[i + j] = '\0'; - } - return (ft_strlen(src) + dest_size); -} diff --git a/libft/srcs/ft_strlen.c b/libft/srcs/ft_strlen.c deleted file mode 100644 index 7ff075f..0000000 --- a/libft/srcs/ft_strlen.c +++ /dev/null @@ -1,23 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_strlen.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: kibotrel +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2018/11/07 19:24:42 by kibotrel #+# #+# */ -/* Updated: 2018/11/25 17:50:57 by kibotrel ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -size_t ft_strlen(const char *s) -{ - size_t i; - - i = 0; - while (s && s[i]) - i++; - return (i); -} diff --git a/libft/srcs/ft_strlowcase.c b/libft/srcs/ft_strlowcase.c deleted file mode 100644 index 0487ee2..0000000 --- a/libft/srcs/ft_strlowcase.c +++ /dev/null @@ -1,24 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_strlowcase.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: kibotrel +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2019/02/20 19:58:17 by kibotrel #+# #+# */ -/* Updated: 2019/02/20 20:20:42 by kibotrel ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -char *ft_strlowcase(char *str) -{ - int i; - - i = -1; - while (str[++i]) - if (str[i] >= 'A' && str[i] <= 'Z') - str[i] = ft_tolower(str[i]); - return (str); -} diff --git a/libft/srcs/ft_strmap.c b/libft/srcs/ft_strmap.c deleted file mode 100644 index 8d17a02..0000000 --- a/libft/srcs/ft_strmap.c +++ /dev/null @@ -1,28 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_strmap.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: kibotrel +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2018/11/09 16:09:20 by kibotrel #+# #+# */ -/* Updated: 2018/11/11 16:14:53 by kibotrel ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" -#include - -char *ft_strmap(char const *s, char (*f)(char)) -{ - char *map; - int i; - - i = -1; - if (!s || !(map = (char*)malloc(sizeof(*map) * (ft_strlen(s) + 1)))) - return (0); - while (s[++i]) - map[i] = f(s[i]); - map[i] = '\0'; - return (map); -} diff --git a/libft/srcs/ft_strmapi.c b/libft/srcs/ft_strmapi.c deleted file mode 100644 index f0e397b..0000000 --- a/libft/srcs/ft_strmapi.c +++ /dev/null @@ -1,28 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_strmapi.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: kibotrel +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2018/11/09 16:32:36 by kibotrel #+# #+# */ -/* Updated: 2018/11/25 19:02:03 by kibotrel ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" -#include "stdlib.h" - -char *ft_strmapi(char const *s, char (*f)(unsigned int, char)) -{ - unsigned int i; - char *map; - - i = -1; - if (!s || !(map = (char*)malloc(sizeof(*map) * (ft_strlen(s) + 1)))) - return (0); - while (s[++i]) - map[i] = f(i, s[i]); - map[i] = '\0'; - return (map); -} diff --git a/libft/srcs/ft_strncat.c b/libft/srcs/ft_strncat.c deleted file mode 100644 index 9d23ab7..0000000 --- a/libft/srcs/ft_strncat.c +++ /dev/null @@ -1,26 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_strncat.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: kibotrel +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2018/11/09 20:26:18 by kibotrel #+# #+# */ -/* Updated: 2018/11/25 17:57:51 by kibotrel ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -char *ft_strncat(char *s1, const char *s2, size_t n) -{ - size_t size; - size_t i; - - i = 0; - size = ft_strlen(s1); - while (s2 && s2[i] && i < n) - s1[size++] = s2[i++]; - s1[size] = '\0'; - return (s1); -} diff --git a/libft/srcs/ft_strncmp.c b/libft/srcs/ft_strncmp.c deleted file mode 100644 index a0f3f4d..0000000 --- a/libft/srcs/ft_strncmp.c +++ /dev/null @@ -1,29 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_strncmp.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: kibotrel +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2018/11/08 17:05:11 by kibotrel #+# #+# */ -/* Updated: 2018/11/15 17:29:23 by kibotrel ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -int ft_strncmp(const char *s1, const char *s2, size_t n) -{ - size_t i; - - i = 0; - while (s1[i] && i < n) - { - if (s1[i] != s2[i]) - return ((unsigned char)s1[i] - (unsigned char)s2[i]); - i++; - } - if (i < n && s1[i] == '\0') - return ((unsigned char)s1[i] - (unsigned char)s2[i]); - return (0); -} diff --git a/libft/srcs/ft_strncpy.c b/libft/srcs/ft_strncpy.c deleted file mode 100644 index 9a18d29..0000000 --- a/libft/srcs/ft_strncpy.c +++ /dev/null @@ -1,29 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_strncpy.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: kibotrel +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2018/11/08 20:36:54 by kibotrel #+# #+# */ -/* Updated: 2018/11/25 17:56:12 by kibotrel ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -char *ft_strncpy(char *dst, const char *src, size_t len) -{ - size_t i; - - i = 0; - while (src && len && src[i] && i < len) - { - dst[i] = src[i]; - i++; - } - if (src && len && ft_strlen(src) < len) - while (i++ < len) - dst[i - 1] = '\0'; - return (dst); -} diff --git a/libft/srcs/ft_strnequ.c b/libft/srcs/ft_strnequ.c deleted file mode 100644 index 0897f9d..0000000 --- a/libft/srcs/ft_strnequ.c +++ /dev/null @@ -1,25 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_strnequ.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: kibotrel +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2018/11/09 15:24:36 by kibotrel #+# #+# */ -/* Updated: 2018/11/25 19:05:13 by kibotrel ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -int ft_strnequ(char const *s1, char const *s2, size_t n) -{ - size_t i; - - i = 0; - if (n == 0) - return (1); - while (s1 && s2 && s1[i] && s1[i] == s2[i] && i < n - 1) - i++; - return ((s1 && s2 && s1[i] == s2[i]) ? 1 : 0); -} diff --git a/libft/srcs/ft_strnew.c b/libft/srcs/ft_strnew.c deleted file mode 100644 index c00607a..0000000 --- a/libft/srcs/ft_strnew.c +++ /dev/null @@ -1,26 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_strnew.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: kibotrel +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2018/11/08 21:25:05 by kibotrel #+# #+# */ -/* Updated: 2018/11/11 15:09:46 by kibotrel ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include - -char *ft_strnew(size_t size) -{ - char *new; - size_t i; - - i = 0; - if (!(new = (char*)malloc(sizeof(*new) * size + 1))) - return (0); - while (i <= size) - new[i++] = '\0'; - return (new); -} diff --git a/libft/srcs/ft_strnstr.c b/libft/srcs/ft_strnstr.c deleted file mode 100644 index 3dbf46f..0000000 --- a/libft/srcs/ft_strnstr.c +++ /dev/null @@ -1,35 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_strnstr.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: kibotrel +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2018/11/08 16:24:00 by kibotrel #+# #+# */ -/* Updated: 2018/11/25 18:06:18 by kibotrel ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -char *ft_strnstr(const char *haystack, const char *needle, size_t n) -{ - size_t i; - size_t j; - size_t size; - - i = -1; - if (!(size = ft_strlen(needle))) - return ((char*)haystack); - while (haystack[++i] && i < n) - { - j = 0; - while ((needle[j] == haystack[i + j]) && (i + j < n)) - { - if (j == size - 1) - return ((char*)(haystack + i)); - j++; - } - } - return (NULL); -} diff --git a/libft/srcs/ft_strrchr.c b/libft/srcs/ft_strrchr.c deleted file mode 100644 index beba5d8..0000000 --- a/libft/srcs/ft_strrchr.c +++ /dev/null @@ -1,26 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_strrchr.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: kibotrel +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2018/11/08 19:09:51 by kibotrel #+# #+# */ -/* Updated: 2018/11/25 18:02:04 by kibotrel ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -char *ft_strrchr(const char *s, int c) -{ - int i; - - i = ft_strlen(s); - if (c == 0) - return ((char*)s + i); - while (s && --i >= 0) - if (s[i] == c) - return ((char*)s + i); - return (NULL); -} diff --git a/libft/srcs/ft_strrev.c b/libft/srcs/ft_strrev.c deleted file mode 100755 index 40c3bb0..0000000 --- a/libft/srcs/ft_strrev.c +++ /dev/null @@ -1,33 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_strrev.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: kibotrel +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2018/07/05 00:32:33 by kibotrel #+# #+# */ -/* Updated: 2018/11/15 19:39:09 by kibotrel ### ########.fr */ -/* */ -/* ************************************************************************** */ - -char *ft_strrev(char *str) -{ - int i; - int size; - char tmp; - - i = 0; - size = 0; - while (str[size]) - size++; - size--; - while (i < size) - { - tmp = str[i]; - str[i] = str[size]; - str[size] = tmp; - i++; - size--; - } - return (str); -} diff --git a/libft/srcs/ft_strsplit.c b/libft/srcs/ft_strsplit.c deleted file mode 100644 index 49ec3f4..0000000 --- a/libft/srcs/ft_strsplit.c +++ /dev/null @@ -1,38 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_strsplit.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: kibotrel +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2018/11/14 12:14:34 by kibotrel #+# #+# */ -/* Updated: 2019/01/16 01:59:20 by kibotrel ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" -#include - -char **ft_strsplit(char const *s, char c) -{ - char **tab; - int i; - int j; - - i = 0; - if (!s || !(tab = (char**)malloc(sizeof(*tab) * (ft_word_count(s, c) + 1)))) - return (0); - j = 0; - while (s[i] != '\0') - { - while (s[i] && s[i] == c) - i++; - if (s[i] != '\0') - { - tab[j++] = ft_strsub(s, i, ft_word_length(s, i, c)); - i += ft_word_length(s, i, c); - } - } - tab[j] = 0; - return (tab); -} diff --git a/libft/srcs/ft_strstr.c b/libft/srcs/ft_strstr.c deleted file mode 100644 index c9ae370..0000000 --- a/libft/srcs/ft_strstr.c +++ /dev/null @@ -1,35 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_strstr.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: kibotrel +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2018/11/07 20:16:37 by kibotrel #+# #+# */ -/* Updated: 2018/11/25 18:05:04 by kibotrel ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -char *ft_strstr(const char *haystack, const char *needle) -{ - int i; - int j; - int size; - - i = -1; - if (!(size = ft_strlen(needle))) - return ((char*)haystack); - while (haystack[++i]) - { - j = 0; - while (needle[j] == haystack[i + j]) - { - if (j == size - 1) - return ((char*)(haystack + i)); - j++; - } - } - return (NULL); -} diff --git a/libft/srcs/ft_strsub.c b/libft/srcs/ft_strsub.c deleted file mode 100644 index f3922c3..0000000 --- a/libft/srcs/ft_strsub.c +++ /dev/null @@ -1,28 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_strsub.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: kibotrel +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2018/11/09 16:59:39 by kibotrel #+# #+# */ -/* Updated: 2018/11/19 14:00:38 by kibotrel ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" -#include - -char *ft_strsub(char const *s, unsigned int start, size_t len) -{ - char *sub; - unsigned int i; - - i = 0; - if (!s || !(sub = (char*)malloc(sizeof(*sub) * (len + 1)))) - return (0); - while (len-- > 0) - sub[i++] = s[start++]; - sub[i] = '\0'; - return (sub); -} diff --git a/libft/srcs/ft_strtrim.c b/libft/srcs/ft_strtrim.c deleted file mode 100644 index b07ed80..0000000 --- a/libft/srcs/ft_strtrim.c +++ /dev/null @@ -1,61 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_strtrim.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: kibotrel +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2018/11/09 17:22:57 by kibotrel #+# #+# */ -/* Updated: 2018/11/25 19:25:35 by kibotrel ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" -#include - -static size_t precheck(char const *s) -{ - size_t i; - - i = -1; - while (s && s[++i]) - if (s[i] != '\0' && s[i] != ' ' && s[i] != '\t' && s[i] != '\n') - return (1); - return (0); -} - -static char *blank(void) -{ - char *empty; - - if (!(empty = (char*)malloc(sizeof(*empty * 1)))) - return (0); - *empty = '\0'; - return (empty); -} - -char *ft_strtrim(char const *s) -{ - char *trim; - size_t end; - size_t start; - size_t i; - - end = 0; - start = 0; - i = 0; - if (!precheck(s)) - return (blank()); - while (s[end]) - end++; - while (s[end] == '\0' || s[end] == ' ' || s[end] == '\n' || s[end] == '\t') - end--; - while (s[start] == ' ' || s[start] == '\n' || s[start] == '\t') - start++; - if (!s || !(trim = (char*)malloc(sizeof(*trim) * (end - start + 2)))) - return (0); - while (start <= end) - trim[i++] = s[start++]; - trim[i] = '\0'; - return (trim); -} diff --git a/libft/srcs/ft_strupcase.c b/libft/srcs/ft_strupcase.c deleted file mode 100644 index b125b98..0000000 --- a/libft/srcs/ft_strupcase.c +++ /dev/null @@ -1,24 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_strupcase.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: kibotrel +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2019/02/20 20:02:23 by kibotrel #+# #+# */ -/* Updated: 2019/02/20 20:18:50 by kibotrel ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -char *ft_strupcase(char *str) -{ - int i; - - i = -1; - while (str[++i]) - if (str[i] >= 'a' && str[i] <= 'z') - str[i] = ft_toupper(str[i]); - return (str); -} diff --git a/libft/srcs/ft_tolower.c b/libft/srcs/ft_tolower.c deleted file mode 100644 index aebc22f..0000000 --- a/libft/srcs/ft_tolower.c +++ /dev/null @@ -1,16 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_tolower.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: kibotrel +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2018/11/08 14:17:53 by kibotrel #+# #+# */ -/* Updated: 2018/11/25 18:11:43 by kibotrel ### ########.fr */ -/* */ -/* ************************************************************************** */ - -int ft_tolower(int c) -{ - return ((c >= 'A' && c <= 'Z') ? c + 32 : c); -} diff --git a/libft/srcs/ft_toupper.c b/libft/srcs/ft_toupper.c deleted file mode 100644 index bd735c3..0000000 --- a/libft/srcs/ft_toupper.c +++ /dev/null @@ -1,16 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_toupper.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: kibotrel +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2018/11/08 14:09:32 by kibotrel #+# #+# */ -/* Updated: 2018/11/25 18:12:28 by kibotrel ### ########.fr */ -/* */ -/* ************************************************************************** */ - -int ft_toupper(int c) -{ - return ((c >= 'a' && c <= 'z') ? c - 32 : c); -} diff --git a/libft/srcs/ft_word_count.c b/libft/srcs/ft_word_count.c deleted file mode 100644 index e7b7015..0000000 --- a/libft/srcs/ft_word_count.c +++ /dev/null @@ -1,24 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_word_count.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: kibotrel +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2019/01/16 01:43:57 by kibotrel #+# #+# */ -/* Updated: 2019/01/16 01:55:55 by kibotrel ### ########.fr */ -/* */ -/* ************************************************************************** */ - -int ft_word_count(char const *s, char c) -{ - int i; - int count; - - i = -1; - count = 0; - while (s && s[++i]) - if (s[i] != c && (s[i + 1] == c || s[i + 1] == '\0')) - count++; - return (count); -} diff --git a/libft/srcs/ft_word_length.c b/libft/srcs/ft_word_length.c deleted file mode 100644 index 34c3f1b..0000000 --- a/libft/srcs/ft_word_length.c +++ /dev/null @@ -1,24 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_word_length.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: kibotrel +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2019/01/16 01:49:34 by kibotrel #+# #+# */ -/* Updated: 2019/01/16 01:56:17 by kibotrel ### ########.fr */ -/* */ -/* ************************************************************************** */ - -int ft_word_length(char const *s, int i, char c) -{ - int length; - - length = 0; - while (s[i] && s[i] != c) - { - length++; - i++; - } - return (length); -}