From 70e3b4133b89e4e77a67139ccaa37322e2507e49 Mon Sep 17 00:00:00 2001 From: JozanLeClerc Date: Tue, 1 Sep 2020 18:28:12 +0200 Subject: Added quotes multiline --- libft/src/ft_isspace.c | 1 - libft/src/ft_iswhitespace.c | 25 +++++++++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 libft/src/ft_iswhitespace.c (limited to 'libft/src') diff --git a/libft/src/ft_isspace.c b/libft/src/ft_isspace.c index b9b653f..8454c7c 100644 --- a/libft/src/ft_isspace.c +++ b/libft/src/ft_isspace.c @@ -11,7 +11,6 @@ /* ************************************************************************** */ #include -#include t_bool ft_isspace(int c) diff --git a/libft/src/ft_iswhitespace.c b/libft/src/ft_iswhitespace.c new file mode 100644 index 0000000..3bb5868 --- /dev/null +++ b/libft/src/ft_iswhitespace.c @@ -0,0 +1,25 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_iswhitespace.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: rbousset +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/02/14 17:06:40 by rbousset #+# #+# */ +/* Updated: 2020/02/14 17:06:40 by rbousset ### ########lyon.fr */ +/* */ +/* ************************************************************************** */ + +#include + +t_bool + ft_iswhitespace(int c) +{ + if (c == '\t' || + c == '\v' || + c == '\f' || + c == '\r' || + c == ' ') + return (TRUE); + return (FALSE); +} -- cgit v1.2.3 From f165808b1cb551cd86655268b8dfa4fb7dcd5eb7 Mon Sep 17 00:00:00 2001 From: JozanLeClerc Date: Thu, 10 Sep 2020 18:13:47 +0200 Subject: FIX --- libft/src/ft_nrealloc.c | 4 ++-- libft/src/ft_strsubst.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'libft/src') diff --git a/libft/src/ft_nrealloc.c b/libft/src/ft_nrealloc.c index 82975d1..6b42380 100644 --- a/libft/src/ft_nrealloc.c +++ b/libft/src/ft_nrealloc.c @@ -21,7 +21,7 @@ void if (!ptr) { - if (!(ptr = malloc(newsize))) + if ((ptr = malloc(newsize)) == NULL) return (NULL); return (ptr); } @@ -30,7 +30,7 @@ void ft_memdel((void*)&ptr); return (NULL); } - if (!(nptr = malloc(newsize))) + if ((nptr = malloc(newsize)) == NULL) return (ptr); ft_memcpy(nptr, ptr, oldsize); ft_memdel((void*)&ptr); diff --git a/libft/src/ft_strsubst.c b/libft/src/ft_strsubst.c index 57e0ac8..3c5c643 100644 --- a/libft/src/ft_strsubst.c +++ b/libft/src/ft_strsubst.c @@ -20,10 +20,10 @@ char char *nstr; char *ptr; - if (!(ptr = ft_strnstr(str, pattern, ft_strlen(str)))) + if ((ptr = ft_strnstr(str, pattern, ft_strlen(str))) == NULL) return (NULL); nlen = ft_strlen(str) - ft_strlen(pattern) + ft_strlen(subst); - if (!(nstr = (char*)malloc((nlen + 1) * sizeof(char)))) + if ((nstr = (char*)malloc((nlen + 1) * sizeof(char))) == NULL) return (NULL); ft_memcpy(nstr, str, ptr - str); ft_memcpy(nstr + (ptr - str), subst, ft_strlen(subst)); -- cgit v1.2.3 From 89c27ba72e11665823cba7023f694a8639891ccb Mon Sep 17 00:00:00 2001 From: JozanLeClerc Date: Thu, 10 Sep 2020 19:53:00 +0200 Subject: New libft func, cool stuff --- libft/src/ft_strsubst_s.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 libft/src/ft_strsubst_s.c (limited to 'libft/src') diff --git a/libft/src/ft_strsubst_s.c b/libft/src/ft_strsubst_s.c new file mode 100644 index 0000000..ea61610 --- /dev/null +++ b/libft/src/ft_strsubst_s.c @@ -0,0 +1,31 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_strsubst_s.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: rbousset +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/02/14 17:19:27 by rbousset #+# #+# */ +/* Updated: 2020/02/14 17:19:29 by rbousset ### ########lyon.fr */ +/* */ +/* ************************************************************************** */ + +#include +#include +#include + +int8_t + ft_strsubst_s(char *str, const char *pattern, const char *subst) +{ + char *ptr; + + if ((ptr = ft_strnstr(str, pattern, ft_strlen(str))) == NULL) + return (1); + (void)ft_memmove(str + ((ptr - str) + ft_strlen(subst)), + str + ((ptr - str) + ft_strlen(pattern)), + ft_strlen(str + ((ptr - str) + ft_strlen(pattern))) + 1); + (void)ft_memmove(str + (ptr - str), + subst, + ft_strlen(subst)); + return (0); +} -- cgit v1.2.3 From b41111c07a40ee405fb8e8b6c178a315272db7ae Mon Sep 17 00:00:00 2001 From: JozanLeClerc Date: Sat, 12 Sep 2020 19:16:21 +0200 Subject: Sorted alias --- libft/src/ft_strlcpy.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'libft/src') diff --git a/libft/src/ft_strlcpy.c b/libft/src/ft_strlcpy.c index ed4d924..5076a69 100644 --- a/libft/src/ft_strlcpy.c +++ b/libft/src/ft_strlcpy.c @@ -16,9 +16,9 @@ size_t ft_strlcpy(char *dst, const char *src, size_t size) { - size_t src_len; + size_t src_len; - if (!dst || !src) + if (dst == NULL || src == NULL) return (0); src_len = ft_strlen(src); if (src_len + 1 < size) -- cgit v1.2.3