aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCharles <sircharlesaze@gmail.com>2020-02-10 04:33:35 +0100
committerCharles <sircharlesaze@gmail.com>2020-02-10 04:33:35 +0100
commit8e3c9342ce7e4932c4a59c0823af63d19ade8046 (patch)
tree79ec970d0e794fc4d1bde5c0c87909627dd455c7
parentfc457992114e71989e5cdeab452bc054a400a397 (diff)
downloadlibft-8e3c9342ce7e4932c4a59c0823af63d19ade8046.tar.gz
libft-8e3c9342ce7e4932c4a59c0823af63d19ade8046.tar.bz2
libft-8e3c9342ce7e4932c4a59c0823af63d19ade8046.zip
Added ft_strspn, ft_strcspn
-rw-r--r--include/libft_str.h8
-rw-r--r--src/str/ft_strcasecmp.c4
-rw-r--r--src/str/ft_strcspn.c23
-rw-r--r--src/str/ft_strncasecmp.c4
-rw-r--r--src/str/ft_strspn.c23
5 files changed, 55 insertions, 7 deletions
diff --git a/include/libft_str.h b/include/libft_str.h
index ba0b203..80fb09f 100644
--- a/include/libft_str.h
+++ b/include/libft_str.h
@@ -6,7 +6,7 @@
/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/01/31 10:39:22 by cacharle #+# #+# */
-/* Updated: 2020/02/10 04:23:06 by cacharle ### ########.fr */
+/* Updated: 2020/02/10 04:32:44 by cacharle ### ########.fr */
/* */
/* ************************************************************************** */
@@ -53,8 +53,10 @@ int ft_strcount(char *str, char c);
char *ft_itoa(int n);
int ft_strict_atoi(const char *s);
long ft_strtol(const char *s, char **endptr, int base);
-int strcasecmp(const char *s1, const char *s2);
-int strncasecmp(const char *s1, const char *s2, size_t n);
+int ft_strcasecmp(const char *s1, const char *s2);
+int ft_strncasecmp(const char *s1, const char *s2, size_t n);
+size_t ft_strspn(const char *s, const char *charset);
+size_t ft_strcspn(const char *s, const char *charset);
/*
** bloat ?
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 <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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 <marvin@42.fr> +#+ +:+ +#+ */
+/* +#+#+#+#+#+ +#+ */
+/* 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 <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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 <marvin@42.fr> +#+ +:+ +#+ */
+/* +#+#+#+#+#+ +#+ */
+/* 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);
+}