makefile fix and other fixes

This commit is contained in:
David Gailleton
2025-11-12 16:45:04 +01:00
parent 3433a95ddd
commit 187e68e1aa
26 changed files with 88 additions and 61 deletions

View File

@@ -2,7 +2,7 @@ CC= cc
AR= ar AR= ar
ARFLAGS= rc ARFLAGS= rcs
HEADER= libft.h HEADER= libft.h
@@ -65,25 +65,21 @@ DEP= $(SRC:.c=.d)
BONUS_DEP= $(BONUS_SRC:.c=.d) BONUS_DEP= $(BONUS_SRC:.c=.d)
ALL_SRC= $(SRC) $(BONUS_SRC)
ALL_OBJ= $(OBJ) $(BONUS_OBJ) ALL_OBJ= $(OBJ) $(BONUS_OBJ)
ALL_DEP= $(DEP) $(BONUS_DEP) ALL_DEP= $(DEP) $(BONUS_DEP)
%.o: %.c %.o: %.c
$(CC) -MMD -MP -o $@ -c $< $(CFLAGS) -I$(HEADER) $(CC) -MMD -MP -o $@ -c $< $(CFLAGS) -I$(HEADER)
all: $(NAME)
$(NAME): $(OBJ) $(NAME): $(OBJ)
$(AR) $(ARFLAGS) $(NAME) $(OBJ) $(AR) $(ARFLAGS) $(NAME) $(OBJ)
ranlib $(NAME)
all: $(NAME) bonus:
$(MAKE) $(NAME) SRC="$(SRC) $(BONUS_SRC)"
bonus: $(ALL_OBJ)
$(AR) $(ARFLAGS) $(NAME) $(ALL_OBJ)
ranlib $(NAME)
clean: clean:
rm -f $(ALL_OBJ) $(ALL_DEP) rm -f $(ALL_OBJ) $(ALL_DEP)
@@ -93,6 +89,6 @@ fclean: clean
re: fclean all re: fclean all
-include $(ALL_DEP) -include $(DEP)
.PHONY: all clean fclean re bonus .PHONY: all clean fclean re bonus

View File

@@ -6,16 +6,33 @@
/* By: dgaillet <dgaillet@student.42.fr> +#+ +:+ +#+ */ /* By: dgaillet <dgaillet@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2025/11/05 19:07:51 by dgaillet #+# #+# */ /* Created: 2025/11/05 19:07:51 by dgaillet #+# #+# */
/* Updated: 2025/11/11 13:48:35 by dgaillet ### ########lyon.fr */ /* Updated: 2025/11/12 14:17:18 by dgaillet ### ########lyon.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
#include "libft.h" #include "libft.h"
int ft_atoi(const char *nptr) static long long int str_to_ll(const char *nptr)
{ {
int i; int i;
int res; long long int res;
i = 0;
res = 0;
while (ft_isdigit(nptr[i]))
{
if (res * 10 < res && res > 0)
return (-1);
res = (10 * res) + nptr[i] - 48;
i++;
}
return (res);
}
static long long int ft_atoll(const char *nptr)
{
int i;
long long int res;
i = 0; i = 0;
res = 0; res = 0;
@@ -24,13 +41,22 @@ int ft_atoi(const char *nptr)
while ((nptr[i] >= 9 && nptr[i] <= 13) || nptr[i] == ' ') while ((nptr[i] >= 9 && nptr[i] <= 13) || nptr[i] == ' ')
i++; i++;
if (nptr[i] == '-' && ft_isdigit(nptr[i + 1])) if (nptr[i] == '-' && ft_isdigit(nptr[i + 1]))
return (-1 * ft_atoi(&nptr[i] + 1)); {
res = -1 * ft_atoll(&nptr[i] + 1);
if ((nptr[i + 1] != '1' && res == 1)
|| (nptr[i + 1] == '1' && ft_isdigit(nptr[i + 2]) && res == 1))
return (0);
return (res);
}
else if (nptr[i] == '+' && ft_isdigit(nptr[i + 1])) else if (nptr[i] == '+' && ft_isdigit(nptr[i + 1]))
i++; i++;
while (ft_isdigit(nptr[i])) return (str_to_ll(&nptr[i]));
{ }
res = (10 * res) + nptr[i] - 48;
i++; int ft_atoi(const char *nptr)
} {
int res;
res = (int) ft_atoll(nptr);
return (res); return (res);
} }

View File

@@ -6,7 +6,7 @@
/* By: dgaillet <dgaillet@student.42.fr> +#+ +:+ +#+ */ /* By: dgaillet <dgaillet@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2025/11/05 11:41:08 by dgaillet #+# #+# */ /* Created: 2025/11/05 11:41:08 by dgaillet #+# #+# */
/* Updated: 2025/11/11 11:41:35 by dgaillet ### ########lyon.fr */ /* Updated: 2025/11/12 13:54:13 by dgaillet ### ########lyon.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

View File

@@ -6,7 +6,7 @@
/* By: dgaillet <dgaillet@student.42.fr> +#+ +:+ +#+ */ /* By: dgaillet <dgaillet@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2025/11/05 19:26:10 by dgaillet #+# #+# */ /* Created: 2025/11/05 19:26:10 by dgaillet #+# #+# */
/* Updated: 2025/11/05 21:18:14 by dgaillet ### ########lyon.fr */ /* Updated: 2025/11/12 15:51:55 by dgaillet ### ########lyon.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@@ -16,6 +16,9 @@ void *ft_calloc(size_t nmemb, size_t size)
{ {
void *all_mem; void *all_mem;
if ((nmemb * size < nmemb || nmemb * size < size)
&& size > 0 && nmemb > 0)
return (NULL);
all_mem = malloc(size * nmemb); all_mem = malloc(size * nmemb);
if (!all_mem) if (!all_mem)
return (NULL); return (NULL);

View File

@@ -6,7 +6,7 @@
/* By: dgaillet <dgaillet@student.42.fr> +#+ +:+ +#+ */ /* By: dgaillet <dgaillet@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2025/11/07 13:06:35 by dgaillet #+# #+# */ /* Created: 2025/11/07 13:06:35 by dgaillet #+# #+# */
/* Updated: 2025/11/11 13:48:49 by dgaillet ### ########lyon.fr */ /* Updated: 2025/11/12 14:20:16 by dgaillet ### ########lyon.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

View File

@@ -6,7 +6,7 @@
/* By: dgaillet <dgaillet@student.42.fr> +#+ +:+ +#+ */ /* By: dgaillet <dgaillet@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2025/11/09 15:06:49 by dgaillet #+# #+# */ /* Created: 2025/11/09 15:06:49 by dgaillet #+# #+# */
/* Updated: 2025/11/11 15:20:02 by dgaillet ### ########lyon.fr */ /* Updated: 2025/11/12 13:11:12 by dgaillet ### ########lyon.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@@ -16,6 +16,8 @@ void ft_lstadd_back(t_list **lst, t_list *new)
{ {
t_list *temp; t_list *temp;
if (!lst)
return ;
if (!(*lst)) if (!(*lst))
{ {
*lst = new; *lst = new;

View File

@@ -6,7 +6,7 @@
/* By: dgaillet <dgaillet@student.42.fr> +#+ +:+ +#+ */ /* By: dgaillet <dgaillet@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2025/11/09 14:36:17 by dgaillet #+# #+# */ /* Created: 2025/11/09 14:36:17 by dgaillet #+# #+# */
/* Updated: 2025/11/11 15:26:21 by dgaillet ### ########lyon.fr */ /* Updated: 2025/11/12 13:14:35 by dgaillet ### ########lyon.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@@ -19,14 +19,3 @@ void ft_lstadd_front(t_list **lst, t_list *new)
new->next = *lst; new->next = *lst;
*lst = new; *lst = new;
} }
int main(void)
{
t_list *ptr;
t_list *lst[1];
ptr = ft_lstnew(NULL);
lst[0] = NULL;
ft_lstadd_front(lst, ptr);
free(ptr);
}

View File

@@ -6,7 +6,7 @@
/* By: dgaillet <dgaillet@student.42.fr> +#+ +:+ +#+ */ /* By: dgaillet <dgaillet@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2025/11/09 15:31:17 by dgaillet #+# #+# */ /* Created: 2025/11/09 15:31:17 by dgaillet #+# #+# */
/* Updated: 2025/11/10 18:18:56 by dgaillet ### ########lyon.fr */ /* Updated: 2025/11/12 13:15:37 by dgaillet ### ########lyon.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@@ -17,7 +17,7 @@ void ft_lstclear(t_list **lst, void (*del)(void *))
t_list *temp; t_list *temp;
t_list *next; t_list *next;
if (!*lst) if (!lst ||!*lst)
return ; return ;
temp = *lst; temp = *lst;
next = temp->next; next = temp->next;

View File

@@ -6,7 +6,7 @@
/* By: dgaillet <dgaillet@student.42.fr> +#+ +:+ +#+ */ /* By: dgaillet <dgaillet@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2025/11/09 15:51:31 by dgaillet #+# #+# */ /* Created: 2025/11/09 15:51:31 by dgaillet #+# #+# */
/* Updated: 2025/11/10 18:19:08 by dgaillet ### ########lyon.fr */ /* Updated: 2025/11/12 15:54:18 by dgaillet ### ########lyon.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@@ -14,6 +14,8 @@
void ft_lstiter(t_list *lst, void (*f)(void *)) void ft_lstiter(t_list *lst, void (*f)(void *))
{ {
if (!f)
return ;
while (lst) while (lst)
{ {
f(lst->content); f(lst->content);

View File

@@ -6,7 +6,7 @@
/* By: dgaillet <dgaillet@student.42.fr> +#+ +:+ +#+ */ /* By: dgaillet <dgaillet@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2025/11/05 17:54:17 by dgaillet #+# #+# */ /* Created: 2025/11/05 17:54:17 by dgaillet #+# #+# */
/* Updated: 2025/11/11 11:53:16 by dgaillet ### ########lyon.fr */ /* Updated: 2025/11/12 13:56:15 by dgaillet ### ########lyon.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

View File

@@ -6,7 +6,7 @@
/* By: dgaillet <dgaillet@student.42.fr> +#+ +:+ +#+ */ /* By: dgaillet <dgaillet@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2025/11/05 18:00:38 by dgaillet #+# #+# */ /* Created: 2025/11/05 18:00:38 by dgaillet #+# #+# */
/* Updated: 2025/11/11 11:59:58 by dgaillet ### ########lyon.fr */ /* Updated: 2025/11/12 13:54:27 by dgaillet ### ########lyon.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

View File

@@ -6,7 +6,7 @@
/* By: dgaillet <dgaillet@student.42.fr> +#+ +:+ +#+ */ /* By: dgaillet <dgaillet@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2025/11/05 11:46:16 by dgaillet #+# #+# */ /* Created: 2025/11/05 11:46:16 by dgaillet #+# #+# */
/* Updated: 2025/11/09 20:00:45 by dgaillet ### ########lyon.fr */ /* Updated: 2025/11/12 14:24:38 by dgaillet ### ########lyon.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

View File

@@ -6,7 +6,7 @@
/* By: dgaillet <dgaillet@student.42.fr> +#+ +:+ +#+ */ /* By: dgaillet <dgaillet@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2025/11/05 11:20:47 by dgaillet #+# #+# */ /* Created: 2025/11/05 11:20:47 by dgaillet #+# #+# */
/* Updated: 2025/11/09 19:08:42 by dgaillet ### ########lyon.fr */ /* Updated: 2025/11/12 13:54:07 by dgaillet ### ########lyon.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

View File

@@ -6,7 +6,7 @@
/* By: dgaillet <dgaillet@student.42.fr> +#+ +:+ +#+ */ /* By: dgaillet <dgaillet@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2025/11/06 17:02:58 by dgaillet #+# #+# */ /* Created: 2025/11/06 17:02:58 by dgaillet #+# #+# */
/* Updated: 2025/11/11 13:49:21 by dgaillet ### ########lyon.fr */ /* Updated: 2025/11/12 13:30:49 by dgaillet ### ########lyon.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@@ -57,6 +57,8 @@ char **ft_split(char const *s, char c)
int i; int i;
int j; int j;
if (!s)
return (NULL);
strs = ft_calloc(sizeof(char *), strs_size(s, c) + 1); strs = ft_calloc(sizeof(char *), strs_size(s, c) + 1);
if (!strs) if (!strs)
return (NULL); return (NULL);
@@ -67,12 +69,11 @@ char **ft_split(char const *s, char c)
if ((s[j] != c && j == 0) || (s[j] != c && s[j - 1] == c)) if ((s[j] != c && j == 0) || (s[j] != c && s[j - 1] == c))
{ {
strs[i] = ft_substr(&s[j], 0, next_match((char *) &s[j], c)); strs[i] = ft_substr(&s[j], 0, next_match((char *) &s[j], c));
if (!strs[i]) if (!strs[i++])
{ {
clear_strs(strs); clear_strs(strs);
return (NULL); return (NULL);
} }
i++;
} }
j++; j++;
} }

View File

@@ -6,7 +6,7 @@
/* By: dgaillet <dgaillet@student.42.fr> +#+ +:+ +#+ */ /* By: dgaillet <dgaillet@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2025/11/05 17:24:37 by dgaillet #+# #+# */ /* Created: 2025/11/05 17:24:37 by dgaillet #+# #+# */
/* Updated: 2025/11/11 12:36:25 by dgaillet ### ########lyon.fr */ /* Updated: 2025/11/12 13:54:20 by dgaillet ### ########lyon.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

View File

@@ -6,7 +6,7 @@
/* By: dgaillet <dgaillet@student.42.fr> +#+ +:+ +#+ */ /* By: dgaillet <dgaillet@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2025/11/05 19:31:29 by dgaillet #+# #+# */ /* Created: 2025/11/05 19:31:29 by dgaillet #+# #+# */
/* Updated: 2025/11/06 10:07:22 by dgaillet ### ########lyon.fr */ /* Updated: 2025/11/12 13:54:36 by dgaillet ### ########lyon.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

View File

@@ -6,7 +6,7 @@
/* By: dgaillet <dgaillet@student.42.fr> +#+ +:+ +#+ */ /* By: dgaillet <dgaillet@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2025/11/08 17:36:38 by dgaillet #+# #+# */ /* Created: 2025/11/08 17:36:38 by dgaillet #+# #+# */
/* Updated: 2025/11/08 17:40:42 by dgaillet ### ########lyon.fr */ /* Updated: 2025/11/12 13:32:30 by dgaillet ### ########lyon.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@@ -14,6 +14,8 @@ void ft_striteri(char *s, void (*f)(unsigned int, char*))
{ {
unsigned int i; unsigned int i;
if (!s)
return ;
i = 0; i = 0;
while (s[i]) while (s[i])
{ {

View File

@@ -6,7 +6,7 @@
/* By: dgaillet <dgaillet@student.42.fr> +#+ +:+ +#+ */ /* By: dgaillet <dgaillet@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2025/11/06 13:52:21 by dgaillet #+# #+# */ /* Created: 2025/11/06 13:52:21 by dgaillet #+# #+# */
/* Updated: 2025/11/11 12:39:10 by dgaillet ### ########lyon.fr */ /* Updated: 2025/11/12 13:36:32 by dgaillet ### ########lyon.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

View File

@@ -6,7 +6,7 @@
/* By: dgaillet <dgaillet@student.42.fr> +#+ +:+ +#+ */ /* By: dgaillet <dgaillet@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2025/11/05 17:11:43 by dgaillet #+# #+# */ /* Created: 2025/11/05 17:11:43 by dgaillet #+# #+# */
/* Updated: 2025/11/06 12:26:04 by dgaillet ### ########lyon.fr */ /* Updated: 2025/11/12 13:38:24 by dgaillet ### ########lyon.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

View File

@@ -6,7 +6,7 @@
/* By: dgaillet <dgaillet@student.42.fr> +#+ +:+ +#+ */ /* By: dgaillet <dgaillet@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2025/11/05 11:17:31 by dgaillet #+# #+# */ /* Created: 2025/11/05 11:17:31 by dgaillet #+# #+# */
/* Updated: 2025/11/11 13:29:00 by dgaillet ### ########lyon.fr */ /* Updated: 2025/11/12 13:36:18 by dgaillet ### ########lyon.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

View File

@@ -6,7 +6,7 @@
/* By: dgaillet <dgaillet@student.42.fr> +#+ +:+ +#+ */ /* By: dgaillet <dgaillet@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2025/11/08 17:30:25 by dgaillet #+# #+# */ /* Created: 2025/11/08 17:30:25 by dgaillet #+# #+# */
/* Updated: 2025/11/08 17:34:12 by dgaillet ### ########lyon.fr */ /* Updated: 2025/11/12 13:39:16 by dgaillet ### ########lyon.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@@ -17,6 +17,8 @@ char *ft_strmapi(char const *s, char (*f)(unsigned int, char))
char *str; char *str;
unsigned int i; unsigned int i;
if (!s)
return (NULL);
i = 0; i = 0;
str = malloc(sizeof(char) * (ft_strlen(s) + 1)); str = malloc(sizeof(char) * (ft_strlen(s) + 1));
if (!str) if (!str)

View File

@@ -6,7 +6,7 @@
/* By: dgaillet <dgaillet@student.42.fr> +#+ +:+ +#+ */ /* By: dgaillet <dgaillet@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2025/11/05 17:34:15 by dgaillet #+# #+# */ /* Created: 2025/11/05 17:34:15 by dgaillet #+# #+# */
/* Updated: 2025/11/11 13:47:04 by dgaillet ### ########lyon.fr */ /* Updated: 2025/11/12 13:41:15 by dgaillet ### ########lyon.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

View File

@@ -6,7 +6,7 @@
/* By: dgaillet <dgaillet@student.42.fr> +#+ +:+ +#+ */ /* By: dgaillet <dgaillet@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2025/11/05 18:05:52 by dgaillet #+# #+# */ /* Created: 2025/11/05 18:05:52 by dgaillet #+# #+# */
/* Updated: 2025/11/11 13:47:25 by dgaillet ### ########lyon.fr */ /* Updated: 2025/11/12 13:42:42 by dgaillet ### ########lyon.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

View File

@@ -6,7 +6,7 @@
/* By: dgaillet <dgaillet@student.42.fr> +#+ +:+ +#+ */ /* By: dgaillet <dgaillet@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2025/11/05 17:28:39 by dgaillet #+# #+# */ /* Created: 2025/11/05 17:28:39 by dgaillet #+# #+# */
/* Updated: 2025/11/11 13:47:40 by dgaillet ### ########lyon.fr */ /* Updated: 2025/11/12 13:43:49 by dgaillet ### ########lyon.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

View File

@@ -6,7 +6,7 @@
/* By: dgaillet <dgaillet@student.42.fr> +#+ +:+ +#+ */ /* By: dgaillet <dgaillet@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2025/11/06 16:31:38 by dgaillet #+# #+# */ /* Created: 2025/11/06 16:31:38 by dgaillet #+# #+# */
/* Updated: 2025/11/11 13:48:05 by dgaillet ### ########lyon.fr */ /* Updated: 2025/11/12 13:50:53 by dgaillet ### ########lyon.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@@ -67,6 +67,8 @@ char *ft_strtrim(char const *s1, char const *set)
size_t i; size_t i;
char *str; char *str;
if (!s1 || !set)
return (NULL);
i = 0; i = 0;
if (is_empty(s1, set)) if (is_empty(s1, set))
return (ft_calloc(1, sizeof(char))); return (ft_calloc(1, sizeof(char)));

View File

@@ -6,7 +6,7 @@
/* By: dgaillet <dgaillet@student.42.fr> +#+ +:+ +#+ */ /* By: dgaillet <dgaillet@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2025/11/06 13:20:55 by dgaillet #+# #+# */ /* Created: 2025/11/06 13:20:55 by dgaillet #+# #+# */
/* Updated: 2025/11/06 13:58:18 by dgaillet ### ########lyon.fr */ /* Updated: 2025/11/12 13:51:23 by dgaillet ### ########lyon.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@@ -18,6 +18,8 @@ char *ft_substr(char const *s, unsigned int start, size_t len)
char *sub_str; char *sub_str;
size_t s_len; size_t s_len;
if (!s)
return (NULL);
s_len = ft_strlen(s); s_len = ft_strlen(s);
if (start > s_len) if (start > s_len)
len = 0; len = 0;