aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/algo/ft_reverse.c27
-rw-r--r--src/ctype/ft_isblank.c16
-rw-r--r--src/str/ft_strnlen.c25
-rw-r--r--src/str/ft_strpbrk.c24
-rw-r--r--src/str/ft_strsep.c27
-rw-r--r--src/str/ft_strtoupper.c2
6 files changed, 120 insertions, 1 deletions
diff --git a/src/algo/ft_reverse.c b/src/algo/ft_reverse.c
new file mode 100644
index 0000000..0bc447f
--- /dev/null
+++ b/src/algo/ft_reverse.c
@@ -0,0 +1,27 @@
+/* ************************************************************************** */
+/* */
+/* ::: :::::::: */
+/* ft_reverse.c :+: :+: :+: */
+/* +:+ +:+ +:+ */
+/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */
+/* +#+#+#+#+#+ +#+ */
+/* Created: 2020/02/10 05:07:13 by cacharle #+# #+# */
+/* Updated: 2020/02/10 05:19:22 by cacharle ### ########.fr */
+/* */
+/* ************************************************************************** */
+
+#include "libft_algo.h"
+
+void ft_reverse(void *base, size_t nel, size_t width)
+{
+ size_t i;
+
+ i = 0;
+ nel--;
+ while (i < nel)
+ {
+ ft_memswap(base + i * width, base + nel * width, width);
+ i++;
+ nel--;
+ }
+}
diff --git a/src/ctype/ft_isblank.c b/src/ctype/ft_isblank.c
new file mode 100644
index 0000000..def106b
--- /dev/null
+++ b/src/ctype/ft_isblank.c
@@ -0,0 +1,16 @@
+/* ************************************************************************** */
+/* */
+/* ::: :::::::: */
+/* ft_isblank.c :+: :+: :+: */
+/* +:+ +:+ +:+ */
+/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */
+/* +#+#+#+#+#+ +#+ */
+/* Created: 2020/02/10 05:17:45 by cacharle #+# #+# */
+/* Updated: 2020/02/10 05:18:34 by cacharle ### ########.fr */
+/* */
+/* ************************************************************************** */
+
+int ft_isblank(int c)
+{
+ return (c == ' ' || c == '\t');
+}
diff --git a/src/str/ft_strnlen.c b/src/str/ft_strnlen.c
new file mode 100644
index 0000000..5e1569c
--- /dev/null
+++ b/src/str/ft_strnlen.c
@@ -0,0 +1,25 @@
+/* ************************************************************************** */
+/* */
+/* ::: :::::::: */
+/* ft_strnlen.c :+: :+: :+: */
+/* +:+ +:+ +:+ */
+/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */
+/* +#+#+#+#+#+ +#+ */
+/* Created: 2020/02/10 05:21:04 by cacharle #+# #+# */
+/* Updated: 2020/02/10 05:23:23 by cacharle ### ########.fr */
+/* */
+/* ************************************************************************** */
+
+#include "libft_str.h"
+
+/*
+** wrong implementation since it scans beyond maxlen
+*/
+
+size_t ft_strnlen(const char *s, size_t maxlen)
+{
+ size_t len;
+
+ len = ft_strlen(s);
+ return (len > maxlen ? maxlen : len);
+}
diff --git a/src/str/ft_strpbrk.c b/src/str/ft_strpbrk.c
new file mode 100644
index 0000000..753e4d9
--- /dev/null
+++ b/src/str/ft_strpbrk.c
@@ -0,0 +1,24 @@
+/* ************************************************************************** */
+/* */
+/* ::: :::::::: */
+/* ft_strpbrk.c :+: :+: :+: */
+/* +:+ +:+ +:+ */
+/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */
+/* +#+#+#+#+#+ +#+ */
+/* Created: 2020/02/10 04:39:29 by cacharle #+# #+# */
+/* Updated: 2020/02/10 04:54:13 by cacharle ### ########.fr */
+/* */
+/* ************************************************************************** */
+
+#include "libft_str.h"
+
+char *ft_strpbrk(const char *s, const char *charset)
+{
+ if (s == NULL || charset == NULL)
+ return (NULL);
+ while (*s && ft_strchr(charset, *s) == NULL)
+ s++;
+ if (*s == '\0')
+ return (NULL);
+ return ((char*)s);
+}
diff --git a/src/str/ft_strsep.c b/src/str/ft_strsep.c
new file mode 100644
index 0000000..2000706
--- /dev/null
+++ b/src/str/ft_strsep.c
@@ -0,0 +1,27 @@
+/* ************************************************************************** */
+/* */
+/* ::: :::::::: */
+/* ft_strsep.c :+: :+: :+: */
+/* +:+ +:+ +:+ */
+/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */
+/* +#+#+#+#+#+ +#+ */
+/* Created: 2020/02/10 04:44:11 by cacharle #+# #+# */
+/* Updated: 2020/02/10 04:51:15 by cacharle ### ########.fr */
+/* */
+/* ************************************************************************** */
+
+#include "libft_str.h"
+
+char *ft_strsep(char **stringp, const char *delim)
+{
+ char *tmp;
+
+ if (stringp == NULL || *stringp == NULL || delim == NULL)
+ return (NULL);
+ tmp = ft_strpbrk(*stringp, delim);
+ if (tmp == NULL)
+ return (NULL);
+ *tmp = '\0';
+ *stringp = tmp;
+ return (tmp);
+}
diff --git a/src/str/ft_strtoupper.c b/src/str/ft_strtoupper.c
index d4c49d5..07c19e5 100644
--- a/src/str/ft_strtoupper.c
+++ b/src/str/ft_strtoupper.c
@@ -6,7 +6,7 @@
/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/02/10 04:12:04 by cacharle #+# #+# */
-/* Updated: 2020/02/10 04:12:17 by cacharle ### ########.fr */
+/* Updated: 2020/02/10 05:05:38 by cacharle ### ########.fr */
/* */
/* ************************************************************************** */