diff options
| author | nass1pro <nass1pro@gmail.com> | 2020-06-12 13:52:58 +0200 |
|---|---|---|
| committer | nass1pro <nass1pro@gmail.com> | 2020-06-13 11:45:50 +0200 |
| commit | d971bd8d16608f316396aba7a579d0b1f1af5aeb (patch) | |
| tree | 98ec558582ed20a120e13b4a376fd206fb620da0 /test_mini/libft/src/str | |
| parent | 3136f59540a8dd29e2f096be5a8943e2ddd28431 (diff) | |
| download | minishell-d971bd8d16608f316396aba7a579d0b1f1af5aeb.tar.gz minishell-d971bd8d16608f316396aba7a579d0b1f1af5aeb.tar.bz2 minishell-d971bd8d16608f316396aba7a579d0b1f1af5aeb.zip | |
Added e_token enum
Diffstat (limited to 'test_mini/libft/src/str')
44 files changed, 0 insertions, 1251 deletions
diff --git a/test_mini/libft/src/str/ft_atoi.c b/test_mini/libft/src/str/ft_atoi.c deleted file mode 100644 index d6fa5bb..0000000 --- a/test_mini/libft/src/str/ft_atoi.c +++ /dev/null @@ -1,22 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_atoi.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2019/10/07 09:46:16 by cacharle #+# #+# */ -/* Updated: 2020/01/15 10:56:06 by cacharle ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -/* -** Convert a string to an int -*/ - -int ft_atoi(const char *str) -{ - return ((int)ft_strtol(str, (char**)NULL, 10)); -} diff --git a/test_mini/libft/src/str/ft_atoi_strict.c b/test_mini/libft/src/str/ft_atoi_strict.c deleted file mode 100644 index 8be4c4b..0000000 --- a/test_mini/libft/src/str/ft_atoi_strict.c +++ /dev/null @@ -1,38 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_strict_atoi.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2020/01/15 10:06:29 by cacharle #+# #+# */ -/* Updated: 2020/02/14 02:46:43 by cacharle ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -int ft_atoi_strict(const char *s) -{ - char *end; - long ret; - - if (*s != '-' && !ft_isdigit(*s)) - { - errno = EINVAL; - return (0); - } - errno = 0; - ret = ft_strtol(s, &end, 10); - if (errno == ERANGE || ret > INT_MAX || ret < INT_MIN) - { - errno = ERANGE; - return (0); - } - if (*end != '\0') - { - errno = EINVAL; - return (0); - } - return (ret); -} diff --git a/test_mini/libft/src/str/ft_itoa.c b/test_mini/libft/src/str/ft_itoa.c deleted file mode 100644 index 39b6e12..0000000 --- a/test_mini/libft/src/str/ft_itoa.c +++ /dev/null @@ -1,40 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_itoa.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2019/10/07 10:19:56 by cacharle #+# #+# */ -/* Updated: 2020/02/14 03:39:11 by cacharle ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -char *ft_itoa(int n) -{ - char *str; - int len; - unsigned int u_nbr; - - len = n < 0 || n == 0 ? 1 : 0; - u_nbr = n < 0 ? -n : n; - while (u_nbr > 0) - { - u_nbr /= 10; - len++; - } - if ((str = (char*)malloc(sizeof(char) * (len + 1))) == NULL) - return (NULL); - str[len] = '\0'; - u_nbr = n < 0 ? -n : n; - if (n < 0) - str[0] = '-'; - while (--len >= (n < 0 ? 1 : 0)) - { - str[len] = (u_nbr % 10) | 0x30; - u_nbr /= 10; - } - return (str); -} diff --git a/test_mini/libft/src/str/ft_split.c b/test_mini/libft/src/str/ft_split.c deleted file mode 100644 index 6fb5964..0000000 --- a/test_mini/libft/src/str/ft_split.c +++ /dev/null @@ -1,73 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_split.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2019/10/17 08:29:02 by cacharle #+# #+# */ -/* Updated: 2019/11/20 04:08:27 by cacharle ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -static size_t count_segment(char const *s, char c) -{ - size_t counter; - int i; - - counter = 0; - i = 0; - while (s[i]) - { - if (s[i] == c) - { - i++; - continue ; - } - counter++; - while (s[i] && s[i] != c) - i++; - } - return (counter); -} - -static void *destroy_strs(char **strs) -{ - if (strs == NULL) - return (NULL); - while (*strs != NULL) - free(*strs++); - free(strs); - return (NULL); -} - -char **ft_split(char const *s, char c) -{ - char **strs; - size_t tab_counter; - size_t i; - size_t j; - - if (s == NULL) - return (NULL); - tab_counter = count_segment(s, c); - if ((strs = (char**)malloc(sizeof(char*) * (tab_counter + 1))) == NULL) - return (NULL); - tab_counter = 0; - j = -1; - while (s[++j]) - { - if (s[j] == c) - continue ; - i = 0; - while (s[j + i] && s[j + i] != c) - i++; - if ((strs[tab_counter++] = ft_strndup(&s[j], i)) == NULL) - return (destroy_strs(strs)); - j += i - 1; - } - strs[tab_counter] = NULL; - return (strs); -} diff --git a/test_mini/libft/src/str/ft_strcasecmp.c b/test_mini/libft/src/str/ft_strcasecmp.c deleted file mode 100644 index 044e6de..0000000 --- a/test_mini/libft/src/str/ft_strcasecmp.c +++ /dev/null @@ -1,24 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_strcasecmp.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2020/02/10 04:08:38 by cacharle #+# #+# */ -/* Updated: 2020/02/10 04:31:33 by cacharle ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft_str.h" -#include "libft_types.h" - -int ft_strcasecmp(const char *s1, const char *s2) -{ - while (*s1 && *s2 && ft_tolower(*s1) == ft_tolower(*s2)) - { - s1++; - s2++; - } - return ((t_ftuchar)ft_tolower(*s1) - (t_ftuchar)ft_tolower(*s2)); -} diff --git a/test_mini/libft/src/str/ft_strcat.c b/test_mini/libft/src/str/ft_strcat.c deleted file mode 100644 index d5bc7e0..0000000 --- a/test_mini/libft/src/str/ft_strcat.c +++ /dev/null @@ -1,19 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_strcat.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2019/10/07 10:09:41 by cacharle #+# #+# */ -/* Updated: 2019/11/21 01:03:38 by cacharle ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -char *ft_strcat(char *dest, const char *src) -{ - ft_memcpy(dest + ft_strlen(dest), src, ft_strlen(src) + 1); - return (dest); -} diff --git a/test_mini/libft/src/str/ft_strchr.c b/test_mini/libft/src/str/ft_strchr.c deleted file mode 100644 index 50bfc0a..0000000 --- a/test_mini/libft/src/str/ft_strchr.c +++ /dev/null @@ -1,18 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_strchr.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2019/10/07 10:14:47 by cacharle #+# #+# */ -/* Updated: 2019/11/21 01:04:52 by cacharle ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -char *ft_strchr(const char *s, int c) -{ - return (ft_memchr(s, c, ft_strlen(s) + 1)); -} diff --git a/test_mini/libft/src/str/ft_strclr.c b/test_mini/libft/src/str/ft_strclr.c deleted file mode 100644 index 7e412fe..0000000 --- a/test_mini/libft/src/str/ft_strclr.c +++ /dev/null @@ -1,20 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_strclr.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2019/10/07 10:15:18 by cacharle #+# #+# */ -/* Updated: 2019/11/21 01:11:51 by cacharle ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -void ft_strclr(char *s) -{ - if (s == NULL) - return ; - ft_bzero(s, ft_strlen(s)); -} diff --git a/test_mini/libft/src/str/ft_strcmp.c b/test_mini/libft/src/str/ft_strcmp.c deleted file mode 100644 index aced711..0000000 --- a/test_mini/libft/src/str/ft_strcmp.c +++ /dev/null @@ -1,23 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_strcmp.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2019/10/07 10:16:07 by cacharle #+# #+# */ -/* Updated: 2020/02/10 04:18:11 by cacharle ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -int ft_strcmp(const char *s1, const char *s2) -{ - while (*s1 && *s2 && *s1 == *s2) - { - s1++; - s2++; - } - return (*s1 - *s2); -} diff --git a/test_mini/libft/src/str/ft_strcount.c b/test_mini/libft/src/str/ft_strcount.c deleted file mode 100644 index 87e756d..0000000 --- a/test_mini/libft/src/str/ft_strcount.c +++ /dev/null @@ -1,24 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_strcount.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2019/11/15 09:17:48 by cacharle #+# #+# */ -/* Updated: 2019/11/15 09:19:36 by cacharle ### ########.fr */ -/* */ -/* ************************************************************************** */ - -int ft_strcount(char *str, char c) -{ - int counter; - - if (c == '\0') - return (1); - counter = 0; - while (*str) - if (*str++ == c) - counter++; - return (counter); -} diff --git a/test_mini/libft/src/str/ft_strcpy.c b/test_mini/libft/src/str/ft_strcpy.c deleted file mode 100644 index ee6ff0d..0000000 --- a/test_mini/libft/src/str/ft_strcpy.c +++ /dev/null @@ -1,18 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_strcpy.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2019/10/07 10:38:36 by cacharle #+# #+# */ -/* Updated: 2020/01/17 11:36:19 by cacharle ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -char *ft_strcpy(char *dest, const char *src) -{ - return (ft_memcpy(dest, src, ft_strlen(src) + 1)); -} diff --git a/test_mini/libft/src/str/ft_strcspn.c b/test_mini/libft/src/str/ft_strcspn.c deleted file mode 100644 index 7cc06a5..0000000 --- a/test_mini/libft/src/str/ft_strcspn.c +++ /dev/null @@ -1,23 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* 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/test_mini/libft/src/str/ft_strdel.c b/test_mini/libft/src/str/ft_strdel.c deleted file mode 100644 index 05cf064..0000000 --- a/test_mini/libft/src/str/ft_strdel.c +++ /dev/null @@ -1,18 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_strdel.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2019/10/07 10:39:14 by cacharle #+# #+# */ -/* Updated: 2019/11/20 01:58:27 by cacharle ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -void ft_strdel(char **as) -{ - ft_memdel((void*)as); -} diff --git a/test_mini/libft/src/str/ft_strdup.c b/test_mini/libft/src/str/ft_strdup.c deleted file mode 100644 index b248272..0000000 --- a/test_mini/libft/src/str/ft_strdup.c +++ /dev/null @@ -1,22 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_strdup.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2019/10/07 10:18:07 by cacharle #+# #+# */ -/* Updated: 2020/02/14 03:39:56 by cacharle ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -char *ft_strdup(const char *s) -{ - char *clone; - - if ((clone = (char*)malloc(sizeof(char) * (ft_strlen(s) + 1))) == NULL) - return (NULL); - return (ft_strcpy(clone, s)); -} diff --git a/test_mini/libft/src/str/ft_strequ.c b/test_mini/libft/src/str/ft_strequ.c deleted file mode 100644 index 75ccb81..0000000 --- a/test_mini/libft/src/str/ft_strequ.c +++ /dev/null @@ -1,20 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_strequ.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2019/10/07 10:18:34 by cacharle #+# #+# */ -/* Updated: 2019/11/20 02:00:22 by cacharle ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -int ft_strequ(char const *s1, char const *s2) -{ - if (s1 == NULL || s2 == NULL) - return (0); - return (ft_strcmp(s1, s2) == 0); -} diff --git a/test_mini/libft/src/str/ft_striter.c b/test_mini/libft/src/str/ft_striter.c deleted file mode 100644 index f410d24..0000000 --- a/test_mini/libft/src/str/ft_striter.c +++ /dev/null @@ -1,21 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_striter.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2019/10/07 10:38:16 by cacharle #+# #+# */ -/* Updated: 2019/11/20 02:01:32 by cacharle ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -void ft_striter(char *s, void (*f)(char *)) -{ - if (s == NULL || f == NULL) - return ; - while (*s) - (*f)(s++); -} diff --git a/test_mini/libft/src/str/ft_striteri.c b/test_mini/libft/src/str/ft_striteri.c deleted file mode 100644 index 05f15d4..0000000 --- a/test_mini/libft/src/str/ft_striteri.c +++ /dev/null @@ -1,27 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_striteri.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2019/10/07 10:33:09 by cacharle #+# #+# */ -/* Updated: 2019/11/20 02:01:41 by cacharle ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -void ft_striteri(char *s, void (*f)(unsigned int, char *)) -{ - unsigned int i; - - if (s == NULL || f == NULL) - return ; - i = 0; - while (s[i]) - { - (*f)(i, &s[i]); - i++; - } -} diff --git a/test_mini/libft/src/str/ft_strjoin.c b/test_mini/libft/src/str/ft_strjoin.c deleted file mode 100644 index b65eaa2..0000000 --- a/test_mini/libft/src/str/ft_strjoin.c +++ /dev/null @@ -1,25 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_strjoin.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2019/10/07 10:35:26 by cacharle #+# #+# */ -/* Updated: 2020/02/14 03:40:39 by cacharle ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -char *ft_strjoin(char const *s1, char const *s2) -{ - char *joined; - - if (s1 == NULL || s2 == NULL) - return (NULL); - if ((joined = (char*)malloc(sizeof(char) - * (ft_strlen(s1) + ft_strlen(s2) + 1))) == NULL) - return (NULL); - return (ft_strcat(ft_strcpy(joined, s1), s2)); -} diff --git a/test_mini/libft/src/str/ft_strjoin3.c b/test_mini/libft/src/str/ft_strjoin3.c deleted file mode 100644 index e5e5530..0000000 --- a/test_mini/libft/src/str/ft_strjoin3.c +++ /dev/null @@ -1,36 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_strjoin3.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2020/04/01 18:00:49 by charles #+# #+# */ -/* Updated: 2020/04/01 18:01:43 by charles ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -/* -** \brief Join 3 strings in a new malloc'd one -** \param s1 String 1 -** \param s2 String 2 -** \param s3 String 3 -** \return The joined string -*/ - -char *ft_strjoin3(char const *s1, char const *s2, char const *s3) -{ - char *joined; - - if (s1 == NULL || s2 == NULL || s3 == NULL) - return (NULL); - if ((joined = (char*)malloc(sizeof(char) - * (ft_strlen(s1) + ft_strlen(s2) + ft_strlen(s3) + 1))) == NULL) - return (NULL); - ft_strcpy(joined, s1); - ft_strcat(joined, s2); - ft_strcat(joined, s3); - return (joined); -} diff --git a/test_mini/libft/src/str/ft_strjoinf.c b/test_mini/libft/src/str/ft_strjoinf.c deleted file mode 100644 index 228a963..0000000 --- a/test_mini/libft/src/str/ft_strjoinf.c +++ /dev/null @@ -1,35 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_strjoinf.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2020/02/14 03:41:07 by cacharle #+# #+# */ -/* Updated: 2020/02/14 03:41:25 by cacharle ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include <stdlib.h> -#include "libft.h" -#include "libft_str.h" - -char *ft_strjoinf(char const *s1, char const *s2, t_ftstrjoinf_tag tag) -{ - char *joined; - - if (s1 == NULL || s2 == NULL) - return (NULL); - if ((joined = ft_strjoin(s1, s2)) == NULL) - return (NULL); - if (tag == FT_STRJOINF_FST) - free((void*)s1); - else if (tag == FT_STRJOINF_SND) - free((void*)s2); - else if (tag == FT_STRJOINF_ALL) - { - free((void*)s1); - free((void*)s2); - } - return (joined); -} diff --git a/test_mini/libft/src/str/ft_strlcat.c b/test_mini/libft/src/str/ft_strlcat.c deleted file mode 100644 index ce7fa0b..0000000 --- a/test_mini/libft/src/str/ft_strlcat.c +++ /dev/null @@ -1,32 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_strlcat.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2019/10/07 10:31:37 by cacharle #+# #+# */ -/* Updated: 2019/11/20 03:31:08 by cacharle ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -size_t ft_strlcat(char *dst, const char *src, size_t size) -{ - size_t i; - size_t j; - size_t dst_len; - size_t src_len; - - dst_len = ft_strlen(dst); - src_len = ft_strlen(src); - if (size <= dst_len) - return (src_len + size); - i = 0; - j = dst_len; - while (src[i] && j < size - 1) - dst[j++] = src[i++]; - dst[j] = '\0'; - return (dst_len + src_len); -} diff --git a/test_mini/libft/src/str/ft_strlcpy.c b/test_mini/libft/src/str/ft_strlcpy.c deleted file mode 100644 index 6afb8f5..0000000 --- a/test_mini/libft/src/str/ft_strlcpy.c +++ /dev/null @@ -1,28 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_strlcpy.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2019/10/07 12:28:47 by cacharle #+# #+# */ -/* Updated: 2019/11/20 03:31:16 by cacharle ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -size_t ft_strlcpy(char *dst, const char *src, size_t size) -{ - unsigned int i; - - if (dst == NULL || src == NULL) - return (0); - if (size == 0) - return (ft_strlen(src)); - i = -1; - while (++i < size - 1 && src[i] != '\0') - dst[i] = src[i]; - dst[i] = '\0'; - return (ft_strlen(src)); -} diff --git a/test_mini/libft/src/str/ft_strlen.c b/test_mini/libft/src/str/ft_strlen.c deleted file mode 100644 index 0d593e1..0000000 --- a/test_mini/libft/src/str/ft_strlen.c +++ /dev/null @@ -1,41 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_strlen.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2019/10/07 10:32:48 by cacharle #+# #+# */ -/* Updated: 2020/01/17 11:13:43 by cacharle ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -size_t ft_strlen(const char *s) -{ - unsigned long int *ptr; - const char *cpy; - - ptr = (unsigned long int*)s; - while (TRUE) - { - cpy = (const char*)ptr++; - if (cpy[0] == '\0') - return (cpy - s); - if (cpy[1] == '\0') - return (cpy + 1 - s); - if (cpy[2] == '\0') - return (cpy + 2 - s); - if (cpy[3] == '\0') - return (cpy + 3 - s); - if (cpy[4] == '\0') - return (cpy + 4 - s); - if (cpy[5] == '\0') - return (cpy + 5 - s); - if (cpy[6] == '\0') - return (cpy + 6 - s); - if (cpy[7] == '\0') - return (cpy + 7 - s); - } -} diff --git a/test_mini/libft/src/str/ft_strmap.c b/test_mini/libft/src/str/ft_strmap.c deleted file mode 100644 index 61d16f1..0000000 --- a/test_mini/libft/src/str/ft_strmap.c +++ /dev/null @@ -1,34 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_strmap.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2019/10/07 10:29:52 by cacharle #+# #+# */ -/* Updated: 2019/11/20 04:02:11 by cacharle ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -char *ft_strmap(char const *s, char (*f)(char)) -{ - size_t i; - size_t len; - char *mapped; - - if (s == NULL || f == NULL) - return (NULL); - len = ft_strlen(s); - if ((mapped = (char*)malloc(sizeof(char) * (len + 1))) == NULL) - return (NULL); - i = 0; - while (i < len) - { - mapped[i] = (*f)(s[i]); - i++; - } - mapped[i] = '\0'; - return (mapped); -} diff --git a/test_mini/libft/src/str/ft_strmapi.c b/test_mini/libft/src/str/ft_strmapi.c deleted file mode 100644 index 71d77e4..0000000 --- a/test_mini/libft/src/str/ft_strmapi.c +++ /dev/null @@ -1,34 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_strmapi.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2019/10/07 10:29:32 by cacharle #+# #+# */ -/* Updated: 2019/11/20 04:02:15 by cacharle ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -char *ft_strmapi(char *s, char (*f)(unsigned int, char)) -{ - size_t i; - size_t len; - char *mapped; - - if (s == NULL || f == NULL) - return (NULL); - len = ft_strlen(s); - if ((mapped = (char*)malloc(sizeof(char) * (len + 1))) == NULL) - return (NULL); - i = 0; - while (i < len) - { - mapped[i] = (*f)((unsigned int)i, s[i]); - i++; - } - mapped[i] = '\0'; - return (mapped); -} diff --git a/test_mini/libft/src/str/ft_strncasecmp.c b/test_mini/libft/src/str/ft_strncasecmp.c deleted file mode 100644 index aafdc8c..0000000 --- a/test_mini/libft/src/str/ft_strncasecmp.c +++ /dev/null @@ -1,26 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_strncasecmp.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2020/02/10 04:18:36 by cacharle #+# #+# */ -/* Updated: 2020/02/10 04:31:38 by cacharle ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" -#include "libft_types.h" - -int ft_strncasecmp(const char *s1, const char *s2, size_t n) -{ - size_t i; - - if (n == 0) - return (0); - i = 0; - while (i + 1 < n && s1[i] && ft_tolower(s1[i]) == ft_tolower(s2[i])) - i++; - return ((t_ftuchar)ft_tolower(s1[i]) - (t_ftuchar)ft_tolower(s2[i])); -} diff --git a/test_mini/libft/src/str/ft_strncat.c b/test_mini/libft/src/str/ft_strncat.c deleted file mode 100644 index d68db0a..0000000 --- a/test_mini/libft/src/str/ft_strncat.c +++ /dev/null @@ -1,29 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_strncat.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2019/10/07 10:28:37 by cacharle #+# #+# */ -/* Updated: 2019/11/20 03:33:22 by cacharle ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -char *ft_strncat(char *dest, const char *src, size_t n) -{ - size_t i; - size_t j; - - i = ft_strlen(dest); - j = 0; - while (j < n && src[j]) - { - dest[i + j] = src[j]; - j++; - } - dest[i + j] = '\0'; - return (dest); -} diff --git a/test_mini/libft/src/str/ft_strncmp.c b/test_mini/libft/src/str/ft_strncmp.c deleted file mode 100644 index caa052b..0000000 --- a/test_mini/libft/src/str/ft_strncmp.c +++ /dev/null @@ -1,26 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_strncmp.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2019/10/07 10:27:34 by cacharle #+# #+# */ -/* Updated: 2020/02/10 04:17:50 by cacharle ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" -#include "libft_types.h" - -int ft_strncmp(const char *s1, const char *s2, size_t n) -{ - size_t i; - - if (n == 0) - return (0); - i = 0; - while (i + 1 < n && s1[i] == s2[i] && s1[i]) - i++; - return ((t_ftuchar)s1[i] - (t_ftuchar)s2[i]); -} diff --git a/test_mini/libft/src/str/ft_strncpy.c b/test_mini/libft/src/str/ft_strncpy.c deleted file mode 100644 index 07a4927..0000000 --- a/test_mini/libft/src/str/ft_strncpy.c +++ /dev/null @@ -1,24 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_strncpy.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2019/10/07 10:26:59 by cacharle #+# #+# */ -/* Updated: 2020/01/17 10:40:21 by cacharle ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -char *ft_strncpy(char *dest, const char *src, size_t n) -{ - size_t len; - - len = ft_strlen(src); - ft_memcpy(dest, src, n < len ? n : len); - if (len < n) - ft_bzero(dest + len, n - len); - return (dest); -} diff --git a/test_mini/libft/src/str/ft_strndup.c b/test_mini/libft/src/str/ft_strndup.c deleted file mode 100644 index 894ea4e..0000000 --- a/test_mini/libft/src/str/ft_strndup.c +++ /dev/null @@ -1,23 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_strndup.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2019/10/25 03:28:52 by cacharle #+# #+# */ -/* Updated: 2020/02/14 03:43:55 by cacharle ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -char *ft_strndup(const char *s1, size_t n) -{ - char *clone; - - if ((clone = (char*)malloc(sizeof(char) * (n + 1))) == NULL) - return (NULL); - clone[n] = '\0'; - return (ft_strncpy(clone, s1, n)); -} diff --git a/test_mini/libft/src/str/ft_strnequ.c b/test_mini/libft/src/str/ft_strnequ.c deleted file mode 100644 index e242ee7..0000000 --- a/test_mini/libft/src/str/ft_strnequ.c +++ /dev/null @@ -1,20 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_strnequ.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2019/10/07 10:30:27 by cacharle #+# #+# */ -/* Updated: 2019/11/20 02:00:42 by cacharle ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -int ft_strnequ(char const *s1, char const *s2, size_t n) -{ - if (s1 == NULL || s2 == NULL) - return (0); - return (ft_strncmp(s1, s2, n) == 0); -} diff --git a/test_mini/libft/src/str/ft_strnew.c b/test_mini/libft/src/str/ft_strnew.c deleted file mode 100644 index 1bca6d5..0000000 --- a/test_mini/libft/src/str/ft_strnew.c +++ /dev/null @@ -1,18 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_strnew.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2019/10/07 10:17:34 by cacharle #+# #+# */ -/* Updated: 2019/11/20 03:16:14 by cacharle ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -char *ft_strnew(size_t size) -{ - return ((char*)ft_calloc(size + 1, sizeof(char))); -} diff --git a/test_mini/libft/src/str/ft_strnlen.c b/test_mini/libft/src/str/ft_strnlen.c deleted file mode 100644 index 5e1569c..0000000 --- a/test_mini/libft/src/str/ft_strnlen.c +++ /dev/null @@ -1,25 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* 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/test_mini/libft/src/str/ft_strnstr.c b/test_mini/libft/src/str/ft_strnstr.c deleted file mode 100644 index 4995637..0000000 --- a/test_mini/libft/src/str/ft_strnstr.c +++ /dev/null @@ -1,29 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_strnstr.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2019/10/07 10:25:13 by cacharle #+# #+# */ -/* Updated: 2019/11/20 03:58:42 by cacharle ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -char *ft_strnstr(const char *haystack, const char *needle, size_t len) -{ - size_t needle_len; - - needle_len = ft_strlen(needle); - if (needle_len == 0) - return ((char*)haystack); - while (*haystack && len-- >= needle_len) - { - if (ft_strnequ(haystack, needle, needle_len)) - return ((char*)haystack); - haystack++; - } - return (NULL); -} diff --git a/test_mini/libft/src/str/ft_strpbrk.c b/test_mini/libft/src/str/ft_strpbrk.c deleted file mode 100644 index 753e4d9..0000000 --- a/test_mini/libft/src/str/ft_strpbrk.c +++ /dev/null @@ -1,24 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* 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/test_mini/libft/src/str/ft_strrchr.c b/test_mini/libft/src/str/ft_strrchr.c deleted file mode 100644 index 4cedb76..0000000 --- a/test_mini/libft/src/str/ft_strrchr.c +++ /dev/null @@ -1,24 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_strrchr.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2019/10/07 10:26:24 by cacharle #+# #+# */ -/* Updated: 2019/11/21 18:46:27 by cacharle ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -char *ft_strrchr(const char *s, int c) -{ - size_t i; - - i = ft_strlen(s) + 1; - while (s[--i] != (char)c) - if (i == 0) - return (NULL); - return ((char*)s + i); -} diff --git a/test_mini/libft/src/str/ft_strsep.c b/test_mini/libft/src/str/ft_strsep.c deleted file mode 100644 index 2000706..0000000 --- a/test_mini/libft/src/str/ft_strsep.c +++ /dev/null @@ -1,27 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* 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/test_mini/libft/src/str/ft_strspn.c b/test_mini/libft/src/str/ft_strspn.c deleted file mode 100644 index 81814e5..0000000 --- a/test_mini/libft/src/str/ft_strspn.c +++ /dev/null @@ -1,23 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* 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); -} diff --git a/test_mini/libft/src/str/ft_strstr.c b/test_mini/libft/src/str/ft_strstr.c deleted file mode 100644 index 4d4d403..0000000 --- a/test_mini/libft/src/str/ft_strstr.c +++ /dev/null @@ -1,29 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_strstr.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2019/10/07 10:15:29 by cacharle #+# #+# */ -/* Updated: 2019/11/20 03:58:32 by cacharle ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -char *ft_strstr(const char *haystack, const char *needle) -{ - size_t needle_len; - - needle_len = ft_strlen(needle); - if (needle_len == 0) - return ((char*)haystack); - while (*haystack) - { - if (ft_strnequ(haystack, needle, needle_len)) - return ((char*)haystack); - haystack++; - } - return (NULL); -} diff --git a/test_mini/libft/src/str/ft_strtol.c b/test_mini/libft/src/str/ft_strtol.c deleted file mode 100644 index 82276d8..0000000 --- a/test_mini/libft/src/str/ft_strtol.c +++ /dev/null @@ -1,80 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_strtol.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2020/01/15 10:26:45 by cacharle #+# #+# */ -/* Updated: 2020/02/10 02:21:16 by cacharle ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -#define STRTOL_STD_BASE "0123456789abcdefghijklmnopqrstuvwxyz" - -static int st_strtol_handle_base(int base, const char **str) -{ - if (base > 36) - return (-1); - if (base != 16 && base != 0) - return (base); - if (base == 16 && **str == '0' && (*str)[1] == 'x') - { - *str += 2; - return (base); - } - if (**str == '0') - { - (*str)++; - if (**str == 'x') - { - (*str)++; - return (16); - } - else - return (8); - } - return (10); -} - -static long st_errno_return(int err) -{ - errno = err; - return (0); -} - -/* -** If there is no digits doesn't put str in endptr like the original, -** instead it puts the address of the char after spaces and sign. -** Too much lines and annoyance, I can't be bothered. -*/ - -long ft_strtol(const char *str, char **endptr, int base) -{ - t_ftbool is_negative; - long long nb; - char base_str[37]; - - while (ft_isspace(*str)) - str++; - is_negative = *str == '-' ? TRUE : FALSE; - if (*str == '-' || *str == '+') - str++; - if ((base = st_strtol_handle_base(base, &str)) == -1) - return (st_errno_return(EINVAL)); - ft_strncpy(base_str, STRTOL_STD_BASE, base); - base_str[base] = '\0'; - nb = 0; - while (*str != '\0' && ft_strchr(base_str, *str) != NULL) - { - nb *= base; - nb += ft_strchr(base_str, ft_tolower(*str++)) - base_str; - if (((long)nb ^ (long)(nb / base)) < 0) - errno = ERANGE; - } - if (endptr != NULL) - *endptr = (char*)str; - return (is_negative ? -nb : nb); -} diff --git a/test_mini/libft/src/str/ft_strtolower.c b/test_mini/libft/src/str/ft_strtolower.c deleted file mode 100644 index 2eb34c2..0000000 --- a/test_mini/libft/src/str/ft_strtolower.c +++ /dev/null @@ -1,26 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_strtolower.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2020/02/10 04:10:01 by cacharle #+# #+# */ -/* Updated: 2020/02/10 04:12:21 by cacharle ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft_str.h" -#include "libft_ctype.h" - -char *ft_strtolower(char *s) -{ - int i; - - if (s == NULL) - return (NULL); - i = -1; - while (s[i]) - s[i] = ft_tolower(s[i]); - return (s); -} diff --git a/test_mini/libft/src/str/ft_strtoupper.c b/test_mini/libft/src/str/ft_strtoupper.c deleted file mode 100644 index 4a751d3..0000000 --- a/test_mini/libft/src/str/ft_strtoupper.c +++ /dev/null @@ -1,26 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_strtoupper.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2020/02/10 04:12:04 by cacharle #+# #+# */ -/* Updated: 2020/02/14 02:49:35 by cacharle ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft_str.h" -#include "libft_ctype.h" - -char *ft_strtoupper(char *s) -{ - int i; - - if (s == NULL) - return (NULL); - i = -1; - while (s[i]) - s[i] = ft_toupper(s[i]); - return (s); -} diff --git a/test_mini/libft/src/str/ft_strtrim.c b/test_mini/libft/src/str/ft_strtrim.c deleted file mode 100644 index aa48826..0000000 --- a/test_mini/libft/src/str/ft_strtrim.c +++ /dev/null @@ -1,31 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_strtrim.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2019/10/07 10:24:16 by cacharle #+# #+# */ -/* Updated: 2019/11/20 03:52:58 by cacharle ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -char *ft_strtrim(char const *s1, char const *set) -{ - size_t start; - size_t len; - - if (s1 == NULL || set == NULL) - return (NULL); - start = 0; - while (s1[start] && ft_strchr(set, s1[start]) != NULL) - start++; - len = ft_strlen(&s1[start]); - if (len != 0) - while (s1[start + len - 1] - && ft_strchr(set, s1[start + len - 1]) != NULL) - len--; - return (ft_substr(s1, start, len)); -} diff --git a/test_mini/libft/src/str/ft_substr.c b/test_mini/libft/src/str/ft_substr.c deleted file mode 100644 index ad9c706..0000000 --- a/test_mini/libft/src/str/ft_substr.c +++ /dev/null @@ -1,26 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_substr.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2019/10/17 08:28:49 by cacharle #+# #+# */ -/* Updated: 2020/02/14 03:44:42 by cacharle ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "libft.h" - -char *ft_substr(char const *s, unsigned int start, size_t len) -{ - char *sub; - - if (s == NULL) - return (NULL); - if ((sub = (char*)malloc(sizeof(char) * (len + 1))) == NULL) - return (NULL); - if (start > ft_strlen(s)) - return (sub); - return (ft_strncpy(sub, s + start, len)); -} |
