From 8e3c9342ce7e4932c4a59c0823af63d19ade8046 Mon Sep 17 00:00:00 2001 From: Charles Date: Mon, 10 Feb 2020 04:33:35 +0100 Subject: Added ft_strspn, ft_strcspn --- src/str/ft_strcasecmp.c | 4 ++-- src/str/ft_strcspn.c | 23 +++++++++++++++++++++++ src/str/ft_strncasecmp.c | 4 ++-- src/str/ft_strspn.c | 23 +++++++++++++++++++++++ 4 files changed, 50 insertions(+), 4 deletions(-) create mode 100644 src/str/ft_strcspn.c create mode 100644 src/str/ft_strspn.c (limited to 'src/str') diff --git a/src/str/ft_strcasecmp.c b/src/str/ft_strcasecmp.c index 45ba592..044e6de 100644 --- a/src/str/ft_strcasecmp.c +++ b/src/str/ft_strcasecmp.c @@ -6,14 +6,14 @@ /* By: cacharle +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/02/10 04:08:38 by cacharle #+# #+# */ -/* Updated: 2020/02/10 04:22:56 by cacharle ### ########.fr */ +/* Updated: 2020/02/10 04:31:33 by cacharle ### ########.fr */ /* */ /* ************************************************************************** */ #include "libft_str.h" #include "libft_types.h" -int strcasecmp(const char *s1, const char *s2) +int ft_strcasecmp(const char *s1, const char *s2) { while (*s1 && *s2 && ft_tolower(*s1) == ft_tolower(*s2)) { diff --git a/src/str/ft_strcspn.c b/src/str/ft_strcspn.c new file mode 100644 index 0000000..7cc06a5 --- /dev/null +++ b/src/str/ft_strcspn.c @@ -0,0 +1,23 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_strcspn.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: cacharle +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/02/10 04:30:59 by cacharle #+# #+# */ +/* Updated: 2020/02/10 04:32:15 by cacharle ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "libft_str.h" + +size_t ft_strcspn(const char *s, const char *charset) +{ + int i; + + i = 0; + while (ft_strchr(charset, s[i]) == NULL) + i++; + return (i); +} diff --git a/src/str/ft_strncasecmp.c b/src/str/ft_strncasecmp.c index 1b6308d..aafdc8c 100644 --- a/src/str/ft_strncasecmp.c +++ b/src/str/ft_strncasecmp.c @@ -6,14 +6,14 @@ /* By: cacharle +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/02/10 04:18:36 by cacharle #+# #+# */ -/* Updated: 2020/02/10 04:21:10 by cacharle ### ########.fr */ +/* Updated: 2020/02/10 04:31:38 by cacharle ### ########.fr */ /* */ /* ************************************************************************** */ #include "libft.h" #include "libft_types.h" -int strncasecmp(const char *s1, const char *s2, size_t n) +int ft_strncasecmp(const char *s1, const char *s2, size_t n) { size_t i; diff --git a/src/str/ft_strspn.c b/src/str/ft_strspn.c new file mode 100644 index 0000000..81814e5 --- /dev/null +++ b/src/str/ft_strspn.c @@ -0,0 +1,23 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_strspn.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: cacharle +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/02/10 04:29:13 by cacharle #+# #+# */ +/* Updated: 2020/02/10 04:33:11 by cacharle ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "libft_str.h" + +size_t ft_strspn(const char *s, const char *charset) +{ + int i; + + i = 0; + while (ft_strchr(charset, s[i]) != NULL) + i++; + return (i); +} -- cgit