diff --git a/ft_atoi.o b/ft_atoi.o new file mode 100644 index 0000000..afb0010 Binary files /dev/null and b/ft_atoi.o differ diff --git a/ft_bzero.o b/ft_bzero.o new file mode 100644 index 0000000..62d7f17 Binary files /dev/null and b/ft_bzero.o differ diff --git a/ft_calloc.o b/ft_calloc.o new file mode 100644 index 0000000..060138b Binary files /dev/null and b/ft_calloc.o differ diff --git a/ft_isalnum.o b/ft_isalnum.o new file mode 100644 index 0000000..aecf709 Binary files /dev/null and b/ft_isalnum.o differ diff --git a/ft_isalpha.o b/ft_isalpha.o new file mode 100644 index 0000000..0bd62e8 Binary files /dev/null and b/ft_isalpha.o differ diff --git a/ft_isascii.o b/ft_isascii.o new file mode 100644 index 0000000..11cdcbf Binary files /dev/null and b/ft_isascii.o differ diff --git a/ft_isdigit.o b/ft_isdigit.o new file mode 100644 index 0000000..9473b5f Binary files /dev/null and b/ft_isdigit.o differ diff --git a/ft_isprint.o b/ft_isprint.o new file mode 100644 index 0000000..fa1d564 Binary files /dev/null and b/ft_isprint.o differ diff --git a/ft_itoa.o b/ft_itoa.o new file mode 100644 index 0000000..9d54483 Binary files /dev/null and b/ft_itoa.o differ diff --git a/ft_memchr.c b/ft_memchr.c index c6c91ff..188a661 100644 --- a/ft_memchr.c +++ b/ft_memchr.c @@ -6,26 +6,22 @@ /* By: adjoly +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/11/05 14:52:53 by adjoly #+# #+# */ -/* Updated: 2023/11/08 14:52:06 by adjoly ### ########.fr */ +/* Updated: 2023/11/09 14:27:32 by adjoly ### ########.fr */ /* */ /* ************************************************************************** */ #include "libft.h" -#define BUFFER_SIZE 10 - void *ft_memchr(const void *s, int c, size_t n) { size_t i; i = 0; - while (((char *)s)[i] && i < n) + while (i < n) { - if (((char *)s)[i] == (char)c) - return (((char *)s + i)); + if (((unsigned char *)s)[i] == (unsigned char)c) + return (((void *)s + i)); i++; } - if (c == 0) - return (((char *)s) + i); return (NULL); } diff --git a/ft_memchr.o b/ft_memchr.o new file mode 100644 index 0000000..be0211d Binary files /dev/null and b/ft_memchr.o differ diff --git a/ft_memcmp.c b/ft_memcmp.c index 5484b9e..9da23a1 100644 --- a/ft_memcmp.c +++ b/ft_memcmp.c @@ -6,7 +6,7 @@ /* By: adjoly +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/11/08 12:04:48 by adjoly #+# #+# */ -/* Updated: 2023/11/08 12:16:47 by adjoly ### ########.fr */ +/* Updated: 2023/11/09 14:06:17 by adjoly ### ########.fr */ /* */ /* ************************************************************************** */ @@ -18,6 +18,8 @@ int ft_memcmp(const void *s1, const void *s2, size_t n) size_t i; i = 0; + if (n == 0) + return (0); while (((unsigned char *)s1)[i] == ((unsigned char *)s2)[i] && i < n - 1) i++; return (((unsigned char *)s1)[i] - ((unsigned char *)s2)[i]); diff --git a/ft_memcmp.o b/ft_memcmp.o new file mode 100644 index 0000000..f6e2703 Binary files /dev/null and b/ft_memcmp.o differ diff --git a/ft_memcpy.o b/ft_memcpy.o new file mode 100644 index 0000000..6fec394 Binary files /dev/null and b/ft_memcpy.o differ diff --git a/ft_memmove.o b/ft_memmove.o new file mode 100644 index 0000000..02381d8 Binary files /dev/null and b/ft_memmove.o differ diff --git a/ft_memset.o b/ft_memset.o new file mode 100644 index 0000000..936618d Binary files /dev/null and b/ft_memset.o differ diff --git a/ft_putchar_fd.o b/ft_putchar_fd.o new file mode 100644 index 0000000..786101f Binary files /dev/null and b/ft_putchar_fd.o differ diff --git a/ft_putnbr_fd.o b/ft_putnbr_fd.o new file mode 100644 index 0000000..82110de Binary files /dev/null and b/ft_putnbr_fd.o differ diff --git a/ft_putstr_fd.o b/ft_putstr_fd.o new file mode 100644 index 0000000..ed9d76c Binary files /dev/null and b/ft_putstr_fd.o differ diff --git a/ft_strchr.c b/ft_strchr.c index 2a967e2..2016b39 100644 --- a/ft_strchr.c +++ b/ft_strchr.c @@ -6,7 +6,7 @@ /* By: adjoly +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/11/01 15:45:18 by adjoly #+# #+# */ -/* Updated: 2023/11/08 14:31:21 by adjoly ### ########.fr */ +/* Updated: 2023/11/09 14:31:55 by adjoly ### ########.fr */ /* */ /* ************************************************************************** */ @@ -19,5 +19,7 @@ char *ft_strchr(const char *s, int c) len_s = ft_strlen(s); result = ft_memchr(s, c, len_s); + if (c == 0) + return ((char *)s + len_s); return (result); } diff --git a/ft_strchr.o b/ft_strchr.o new file mode 100644 index 0000000..c5583ff Binary files /dev/null and b/ft_strchr.o differ diff --git a/ft_strdup.o b/ft_strdup.o new file mode 100644 index 0000000..5c511ad Binary files /dev/null and b/ft_strdup.o differ diff --git a/ft_strjoin.o b/ft_strjoin.o new file mode 100644 index 0000000..84cbaa5 Binary files /dev/null and b/ft_strjoin.o differ diff --git a/ft_strlcat.o b/ft_strlcat.o new file mode 100644 index 0000000..fffbf92 Binary files /dev/null and b/ft_strlcat.o differ diff --git a/ft_strlcpy.o b/ft_strlcpy.o new file mode 100644 index 0000000..e25b437 Binary files /dev/null and b/ft_strlcpy.o differ diff --git a/ft_strlen.o b/ft_strlen.o new file mode 100644 index 0000000..0bbb64d Binary files /dev/null and b/ft_strlen.o differ diff --git a/ft_strncmp.o b/ft_strncmp.o new file mode 100644 index 0000000..1f797d9 Binary files /dev/null and b/ft_strncmp.o differ diff --git a/ft_strnstr.c b/ft_strnstr.c new file mode 100644 index 0000000..3a385bc --- /dev/null +++ b/ft_strnstr.c @@ -0,0 +1,36 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_strnstr.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: adjoly +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2023/11/08 16:02:17 by adjoly #+# #+# */ +/* Updated: 2023/11/09 13:58:30 by adjoly ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "libft.h" + +char *ft_strnstr(const char *big, const char *little, size_t len) +{ + size_t i; + size_t j; + + i = 0; + j = 0; + if (!little || big == little) + return ((char *)big); + if (len <= 0) + return (0); + while (i < len && big[i]) + { + j = 0; + while (i + j < len && big[i + j] == little[j]) + j++; + if (little[j] == 0) + return ((char *)big + i); + i++; + } + return (NULL); +} diff --git a/ft_strnstr.o b/ft_strnstr.o new file mode 100644 index 0000000..c975132 Binary files /dev/null and b/ft_strnstr.o differ diff --git a/ft_strrchr.c b/ft_strrchr.c new file mode 100644 index 0000000..d77e573 --- /dev/null +++ b/ft_strrchr.c @@ -0,0 +1,33 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_strrchr.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: adjoly +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2023/11/08 14:44:26 by adjoly #+# #+# */ +/* Updated: 2023/11/08 15:21:28 by adjoly ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "libft.h" + +char *ft_strrchr(const char *s, int c) +{ + size_t i; + size_t len_s; + + len_s = ft_strlen(s); + i = len_s; + if (c == 0) + return (&((char *)s)[len_s]); + while (i > 0) + { + if (s[i] == (char)c) + return (&((char *)s)[i]); + i--; + } + if (s[0] == (char)c) + return (&((char *)s)[0]); + return (NULL); +} diff --git a/ft_strrchr.o b/ft_strrchr.o new file mode 100644 index 0000000..aa9ce75 Binary files /dev/null and b/ft_strrchr.o differ diff --git a/ft_substr.c b/ft_substr.c index 7b02b8e..c6d5b1d 100644 --- a/ft_substr.c +++ b/ft_substr.c @@ -6,7 +6,7 @@ /* By: adjoly +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/11/02 17:59:58 by adjoly #+# #+# */ -/* Updated: 2023/11/05 12:14:35 by adjoly ### ########.fr */ +/* Updated: 2023/11/09 15:02:46 by adjoly ### ########.fr */ /* */ /* ************************************************************************** */ @@ -18,15 +18,14 @@ char *ft_substr(char const *s, unsigned int start, size_t len) char *result; i = 0; - if (s == NULL || len == 0) + if (s == NULL) return (NULL); - if (start >= ft_strlen(s)) + if (start > ft_strlen(s)) { - result = malloc(1); - result[0] = '\0'; + result = calloc(1, 1); return (result); } - result = malloc((len + 1) * sizeof(char)); + result = malloc(((ft_strlen(s) - len) + 1) * sizeof(char)); if (result == NULL) return (NULL); while (i < len && s[start + i]) diff --git a/ft_substr.o b/ft_substr.o new file mode 100644 index 0000000..f8e0888 Binary files /dev/null and b/ft_substr.o differ diff --git a/ft_tolower.o b/ft_tolower.o new file mode 100644 index 0000000..9fde8fe Binary files /dev/null and b/ft_tolower.o differ diff --git a/ft_toupper.o b/ft_toupper.o new file mode 100644 index 0000000..374dad9 Binary files /dev/null and b/ft_toupper.o differ diff --git a/libft.a b/libft.a new file mode 100644 index 0000000..0b6b1d7 Binary files /dev/null and b/libft.a differ