From f5bcbeac3cedfa862378e5aeb29821d36d0c1e26 Mon Sep 17 00:00:00 2001 From: Raphael Date: Thu, 31 Oct 2024 18:16:00 +0100 Subject: [PATCH] docs: Adding the doxygen on all my function --- Makefile | 10 +++++----- list/ft_lstadd_back.c | 8 +++++++- list/ft_lstadd_front.c | 8 +++++++- list/ft_lstclear.c | 8 +++++++- list/ft_lstdelone.c | 8 +++++++- list/ft_lstiter.c | 8 +++++++- list/ft_lstlast.c | 8 +++++++- list/ft_lstmap.c | 10 +++++++++- list/ft_lstnew.c | 8 +++++++- list/ft_lstsize.c | 8 +++++++- memory/ft_bzero.c | 8 +++++++- memory/ft_calloc.c | 8 +++++++- memory/ft_memchr.c | 12 +++++++++++- memory/ft_memcmp.c | 14 +++++++++++++- memory/ft_memcpy.c | 11 ++++++++++- memory/ft_memmove.c | 11 ++++++++++- memory/ft_memset.c | 11 ++++++++++- print/ft_printf.c | 15 ++++++++++++++- print/ft_putchar_fd.c | 8 +++++++- print/ft_putendl_fd.c | 8 +++++++- print/ft_putnbr_fd.c | 8 +++++++- print/ft_putstr_fd.c | 8 +++++++- str/ft_split.c | 11 ++++++++++- str/ft_strchr.c | 11 ++++++++++- str/ft_strcmp.c | 15 +++++++++++++-- str/ft_strcpy.c | 10 +++++++++- str/ft_strdup.c | 10 +++++++++- str/ft_striteri.c | 10 +++++++++- str/ft_strjoin.c | 11 ++++++++++- str/ft_strlcat.c | 11 ++++++++++- str/ft_strlcpy.c | 11 ++++++++++- str/ft_strlen.c | 9 ++++++++- str/ft_strmapi.c | 11 ++++++++++- str/ft_strncmp.c | 11 ++++++++++- str/ft_strnstr.c | 16 +++++++++++++++- str/ft_strrchr.c | 11 ++++++++++- str/ft_strtrim.c | 10 +++++++++- str/ft_substr.c | 11 ++++++++++- 38 files changed, 342 insertions(+), 43 deletions(-) diff --git a/Makefile b/Makefile index 34cc676..a97fdcf 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,7 @@ # By: rparodi +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2023/11/12 11:05:05 by rparodi #+# #+# # -# Updated: 2024/10/31 17:22:49 by rparodi ### ########.fr # +# Updated: 2024/10/31 17:26:05 by rparodi ### ########.fr # # # # **************************************************************************** # @@ -32,6 +32,10 @@ LDLIBS = -lft INCLUDES = ./includes/libft/ +# Objects +OBJDIRNAME = ./build +OBJ = $(addprefix $(OBJDIRNAME)/,$(SRC:.c=.o)) + SRC = char/ft_isdigit.c \ char/ft_isalnum.c \ char/ft_isalpha.c \ @@ -81,10 +85,6 @@ SRC = char/ft_isdigit.c \ str/ft_strtrim.c \ str/ft_substr.c -# Objects -OBJDIRNAME = ./build -OBJ = $(addprefix $(OBJDIRNAME)/,$(SRC:.c=.o)) - # Colors GREEN = \033[32m GREY = \033[0;90m diff --git a/list/ft_lstadd_back.c b/list/ft_lstadd_back.c index 3b7be38..344a851 100644 --- a/list/ft_lstadd_back.c +++ b/list/ft_lstadd_back.c @@ -6,12 +6,18 @@ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/11/12 11:39:56 by rparodi #+# #+# */ -/* Updated: 2023/11/12 17:11:53 by rparodi ### ########.fr */ +/* Updated: 2024/10/31 17:29:37 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ #include "libft.h" +/** + * @brief Add the list new to the back of chained list of lst + * + * @param lst first element of the list + * @param new The element to add at the end + */ void ft_lstadd_back(t_list **lst, t_list *new) { t_list *tempo; diff --git a/list/ft_lstadd_front.c b/list/ft_lstadd_front.c index 3e3794e..42dcf9a 100644 --- a/list/ft_lstadd_front.c +++ b/list/ft_lstadd_front.c @@ -6,12 +6,18 @@ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/11/12 11:40:16 by rparodi #+# #+# */ -/* Updated: 2023/11/12 17:14:33 by rparodi ### ########.fr */ +/* Updated: 2024/10/31 17:30:01 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ #include "libft.h" +/** + * @brief Add the list new to the front of chained list of lst + * + * @param lst first element of the list + * @param new The element to add at the start + */ void ft_lstadd_front(t_list **lst, t_list *new) { if (*lst == NULL) diff --git a/list/ft_lstclear.c b/list/ft_lstclear.c index 3cf5595..4a34087 100644 --- a/list/ft_lstclear.c +++ b/list/ft_lstclear.c @@ -6,12 +6,18 @@ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/11/12 11:40:37 by rparodi #+# #+# */ -/* Updated: 2023/11/12 19:34:19 by rparodi ### ########.fr */ +/* Updated: 2024/10/31 17:32:23 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ #include "libft.h" +/** + * @brief Clear the all list with the function + * + * @param lst the start of the chained list + * @param del the function to clear the list + */ void ft_lstclear(t_list **lst, void (*del)(void *)) { t_list *tempo; diff --git a/list/ft_lstdelone.c b/list/ft_lstdelone.c index bffd7cf..21cc2dd 100644 --- a/list/ft_lstdelone.c +++ b/list/ft_lstdelone.c @@ -6,12 +6,18 @@ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/11/12 11:42:11 by rparodi #+# #+# */ -/* Updated: 2023/11/12 18:10:40 by rparodi ### ########.fr */ +/* Updated: 2024/10/31 17:46:00 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ #include "libft.h" +/** + * @brief Clear the element of the list with the function + * + * @param lst the element of the list to be clear + * @param del the function to clear the list + */ void ft_lstdelone(t_list *lst, void (*del)(void *)) { del(lst->content); diff --git a/list/ft_lstiter.c b/list/ft_lstiter.c index 30547eb..717f8a5 100644 --- a/list/ft_lstiter.c +++ b/list/ft_lstiter.c @@ -6,12 +6,18 @@ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/11/12 11:42:24 by rparodi #+# #+# */ -/* Updated: 2023/11/12 18:07:02 by rparodi ### ########.fr */ +/* Updated: 2024/10/31 17:46:55 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ #include "libft.h" +/** + * @brief Apply the function given in arguments at all the element of the list + * + * @param lst the chained list + * @param f the pointer to function + */ void ft_lstiter(t_list *lst, void (*f)(void *)) { while (lst != NULL) diff --git a/list/ft_lstlast.c b/list/ft_lstlast.c index d0b6b53..4d64a7b 100644 --- a/list/ft_lstlast.c +++ b/list/ft_lstlast.c @@ -6,12 +6,18 @@ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/11/12 11:42:54 by rparodi #+# #+# */ -/* Updated: 2023/11/12 17:25:48 by rparodi ### ########.fr */ +/* Updated: 2024/10/31 17:48:08 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ #include "libft.h" +/** + * @brief Found the last element of the chained list + * + * @param lst the chained list + * @return the last element of the chained list + */ t_list *ft_lstlast(t_list *lst) { if (lst == NULL) diff --git a/list/ft_lstmap.c b/list/ft_lstmap.c index 6282a67..d1c505c 100644 --- a/list/ft_lstmap.c +++ b/list/ft_lstmap.c @@ -6,12 +6,20 @@ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/11/12 11:43:28 by rparodi #+# #+# */ -/* Updated: 2023/11/12 19:28:02 by rparodi ### ########.fr */ +/* Updated: 2024/10/31 17:51:38 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ #include "libft.h" +/** + * @brief Create an other list from an old one with a function on all element + * + * @param lst the chained list + * @param f the function to function to iterate + * @param del The function to delete the old list + * @return + */ t_list *ft_lstmap(t_list *lst, void *(*f)(void *), void (*del)(void *)) { t_list *tempo; diff --git a/list/ft_lstnew.c b/list/ft_lstnew.c index 6d2a4fc..816fea4 100644 --- a/list/ft_lstnew.c +++ b/list/ft_lstnew.c @@ -6,12 +6,18 @@ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/11/12 11:44:02 by rparodi #+# #+# */ -/* Updated: 2023/11/12 14:25:12 by rparodi ### ########.fr */ +/* Updated: 2024/10/31 17:52:24 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ #include "libft.h" +/** + * @brief Allocate a new list with the first element + * + * @param content the element to give on first element + * @return the new list + */ t_list *ft_lstnew(void *content) { t_list *to_return; diff --git a/list/ft_lstsize.c b/list/ft_lstsize.c index 99d1d45..fffaf49 100644 --- a/list/ft_lstsize.c +++ b/list/ft_lstsize.c @@ -6,12 +6,18 @@ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/11/12 11:44:24 by rparodi #+# #+# */ -/* Updated: 2023/11/13 12:22:02 by rparodi ### ########.fr */ +/* Updated: 2024/10/31 17:53:11 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ #include "libft.h" +/** + * @brief Give the size of the chained list + * + * @param lst the chained list + * @return the size of the list + */ int ft_lstsize(t_list *lst) { int count; diff --git a/memory/ft_bzero.c b/memory/ft_bzero.c index 5b8fb1e..2492e03 100644 --- a/memory/ft_bzero.c +++ b/memory/ft_bzero.c @@ -6,12 +6,18 @@ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/11/07 16:43:13 by rparodi #+# #+# */ -/* Updated: 2023/11/07 17:25:28 by rparodi ### ########.fr */ +/* Updated: 2024/10/31 17:54:25 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ #include "libft.h" +/** + * @brief Sets a block of memory to zero + * + * @param s Pointer to the memory area to be set at zero + * @param n Number of bytes to set to zero + */ void ft_bzero(void *s, size_t n) { ft_memset(s, 0, n); diff --git a/memory/ft_calloc.c b/memory/ft_calloc.c index a057429..db1e5d0 100644 --- a/memory/ft_calloc.c +++ b/memory/ft_calloc.c @@ -6,12 +6,18 @@ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/11/07 16:47:17 by rparodi #+# #+# */ -/* Updated: 2023/11/13 14:47:17 by rparodi ### ########.fr */ +/* Updated: 2024/10/31 17:55:30 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ #include "libft.h" +/** + * @brief Allocates and zeroes memory for an array + * + * @param nmemb Number of elements to allocate + * @param size Size of each element in bytes + */ void *ft_calloc(size_t nmemb, size_t size) { size_t total; diff --git a/memory/ft_memchr.c b/memory/ft_memchr.c index ec3f19c..6dd568d 100644 --- a/memory/ft_memchr.c +++ b/memory/ft_memchr.c @@ -6,12 +6,22 @@ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/11/07 16:48:30 by rparodi #+# #+# */ -/* Updated: 2023/11/07 18:45:57 by rparodi ### ########.fr */ +/* Updated: 2024/10/31 17:59:07 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ #include "libft.h" +/** + * @brief Scans memory for a byte + * + * @param s Pointer to the memory area to scan + * @param c Byte value to search for + * @param n Number of bytes to scan in s + * + * @return A pointer to the matching byte in memory, or NULL if the byte +is not found within the first n bytes + */ void *ft_memchr(const void *s, int c, size_t n) { size_t i; diff --git a/memory/ft_memcmp.c b/memory/ft_memcmp.c index d1a3ba5..3b88c68 100644 --- a/memory/ft_memcmp.c +++ b/memory/ft_memcmp.c @@ -6,12 +6,24 @@ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/11/07 16:49:04 by rparodi #+# #+# */ -/* Updated: 2023/11/07 18:46:15 by rparodi ### ########.fr */ +/* Updated: 2024/10/31 17:59:48 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ #include "libft.h" +/** + * @brief Compares two memory blocks + * + * @param s1 Pointer to the first memory area + * @param s2 Pointer to the second memory area + * @param n Number of bytes to compare + * + * @return An integer indicating the relationship between the two memory areas: + * - `< 0` if `s1` is less than `s2` + * - `0` if `s1` equals `s2` + * - `> 0` if `s1` is greater than `s2` + */ int ft_memcmp(const void *s1, const void *s2, size_t n) { size_t i; diff --git a/memory/ft_memcpy.c b/memory/ft_memcpy.c index 2715322..4da7a37 100644 --- a/memory/ft_memcpy.c +++ b/memory/ft_memcpy.c @@ -6,12 +6,21 @@ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/11/07 16:49:46 by rparodi #+# #+# */ -/* Updated: 2023/11/13 19:14:23 by rparodi ### ########.fr */ +/* Updated: 2024/10/31 17:57:31 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ #include "libft.h" +/** + * @brief Copies memory from source to destination + * + * @param dest Pointer to the destination memory area + * @param src Pointer to the source memory area + * @param n Number of bytes to copy from src to dest + * + * @return A pointer to the destination memory area dest + */ void *ft_memcpy(void *dest, const void *src, size_t n) { char *d; diff --git a/memory/ft_memmove.c b/memory/ft_memmove.c index 986a36f..96037b0 100644 --- a/memory/ft_memmove.c +++ b/memory/ft_memmove.c @@ -6,7 +6,7 @@ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/11/07 16:51:35 by rparodi #+# #+# */ -/* Updated: 2023/11/13 19:55:40 by rparodi ### ########.fr */ +/* Updated: 2024/10/31 18:15:19 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ @@ -37,6 +37,15 @@ char *ft_checks(char *s, char *d, size_t n) return (d); } +/** + * @brief Copies memory with overlap handling + * + * @param dest Pointer to the destination memory area + * @param src Pointer to the source memory area + * @param n Number of bytes to copy from src to dest + * + * @return A pointer to the destination memory area dest + */ void *ft_memmove(void *dest, const void *src, size_t n) { char *d; diff --git a/memory/ft_memset.c b/memory/ft_memset.c index 1a68559..f88525f 100644 --- a/memory/ft_memset.c +++ b/memory/ft_memset.c @@ -6,12 +6,21 @@ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/11/07 16:50:29 by rparodi #+# #+# */ -/* Updated: 2023/11/07 18:58:02 by rparodi ### ########.fr */ +/* Updated: 2024/10/31 17:56:59 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ #include "libft.h" +/** + * @brief Fills a block of memory with a specified byte + * + * @param s Pointer to the memory area to fill + * @param c Byte value to be set in the memory + * @param n Number of bytes to be set to the value c + * + * @return A pointer to the memory area s + */ void *ft_memset(void *s, int c, size_t n) { char *str; diff --git a/print/ft_printf.c b/print/ft_printf.c index ffeee23..fa158ed 100644 --- a/print/ft_printf.c +++ b/print/ft_printf.c @@ -6,7 +6,7 @@ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/11/14 17:27:44 by rparodi #+# #+# */ -/* Updated: 2024/10/31 16:12:37 by rparodi ### ########.fr */ +/* Updated: 2024/10/31 18:01:28 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ @@ -43,6 +43,13 @@ int _check_args(int fd, char c, va_list args, int *ret_value) return (1); } +/** + * @brief Print on a file descriptor + * + * @param fd the file descriptor + * @param s the string + * @return the number of character printable + */ int ft_dprintf(int fd, const char *s, ...) { size_t i; @@ -69,6 +76,12 @@ int ft_dprintf(int fd, const char *s, ...) return (ret_value); } +/** + * @brief Print on the standard output + * + * @param s the string + * @return the number of character printable + */ int ft_printf(const char *s, ...) { size_t i; diff --git a/print/ft_putchar_fd.c b/print/ft_putchar_fd.c index 5b4613f..592a3a6 100644 --- a/print/ft_putchar_fd.c +++ b/print/ft_putchar_fd.c @@ -6,12 +6,18 @@ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/11/09 13:58:22 by rparodi #+# #+# */ -/* Updated: 2023/11/10 15:31:57 by rparodi ### ########.fr */ +/* Updated: 2024/10/31 18:02:37 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ #include "libft.h" +/** + * @brief print an character on a file descriptor + * + * @param c the character to print + * @param fd the file descriptor + */ void ft_putchar_fd(char c, int fd) { write(fd, &c, 1); diff --git a/print/ft_putendl_fd.c b/print/ft_putendl_fd.c index 8c43b1c..8d53376 100644 --- a/print/ft_putendl_fd.c +++ b/print/ft_putendl_fd.c @@ -6,12 +6,18 @@ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/11/09 13:59:01 by rparodi #+# #+# */ -/* Updated: 2023/11/10 15:57:53 by rparodi ### ########.fr */ +/* Updated: 2024/10/31 18:03:47 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ #include "libft.h" +/** + * @brief Print a string follow by a new line on a file descriptor + * + * @param s the string to print + * @param fd the file descriptor + */ void ft_putendl_fd(char *s, int fd) { ft_putstr_fd(s, fd); diff --git a/print/ft_putnbr_fd.c b/print/ft_putnbr_fd.c index d596c3a..17aeedf 100644 --- a/print/ft_putnbr_fd.c +++ b/print/ft_putnbr_fd.c @@ -6,7 +6,7 @@ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/11/09 13:59:18 by rparodi #+# #+# */ -/* Updated: 2023/11/13 20:13:20 by rparodi ### ########.fr */ +/* Updated: 2024/10/31 18:04:17 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ @@ -39,6 +39,12 @@ static int ft_check_sign(int n, char *str, size_t *i, int fd) return (n); } +/** + * @brief Print a number on a file descriptor + * + * @param n the number to print + * @param fd the file descriptor + */ void ft_putnbr_fd(int n, int fd) { size_t i; diff --git a/print/ft_putstr_fd.c b/print/ft_putstr_fd.c index 3f5f4e0..70a3bc9 100644 --- a/print/ft_putstr_fd.c +++ b/print/ft_putstr_fd.c @@ -6,12 +6,18 @@ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/11/09 13:58:46 by rparodi #+# #+# */ -/* Updated: 2023/11/10 15:57:46 by rparodi ### ########.fr */ +/* Updated: 2024/10/31 18:05:11 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ #include "libft.h" +/** + * @brief print a string on a file descriptor + * + * @param s the string to print + * @param fd the file descriptor + */ void ft_putstr_fd(char *s, int fd) { write(fd, s, ft_strlen(s)); diff --git a/str/ft_split.c b/str/ft_split.c index 32a5d2d..95f71df 100644 --- a/str/ft_split.c +++ b/str/ft_split.c @@ -6,7 +6,7 @@ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/11/09 13:56:02 by rparodi #+# #+# */ -/* Updated: 2023/11/13 12:14:57 by rparodi ### ########.fr */ +/* Updated: 2024/10/31 18:13:39 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ @@ -74,6 +74,15 @@ static char **ext_w(char **words_array, const char *str, char sep, int size) return (words_array); } +/** + * @brief Splits a string into an array of substrings based on a delimiter. + * + * @param s The string to split. + * @param c The delimiter character. + * + * @return A NULL-terminated array of substrings, + * or NULL if memory allocation fails. + */ char **ft_split(char const *s, char c) { int size; diff --git a/str/ft_strchr.c b/str/ft_strchr.c index f29c896..82ee8bd 100644 --- a/str/ft_strchr.c +++ b/str/ft_strchr.c @@ -6,12 +6,21 @@ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/11/07 16:32:19 by rparodi #+# #+# */ -/* Updated: 2023/11/09 12:08:01 by rparodi ### ########.fr */ +/* Updated: 2024/10/31 18:13:01 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ #include "libft.h" +/** + * @brief Locates the first occurrence of a character in a string. + * + * @param s The string to search. + * @param c The character to locate. + * + * @return A pointer to the matched character, + * or NULL if it does not appear in `s`. + */ char *ft_strchr(const char *s, int c) { unsigned int i; diff --git a/str/ft_strcmp.c b/str/ft_strcmp.c index e2da6f7..08ad900 100644 --- a/str/ft_strcmp.c +++ b/str/ft_strcmp.c @@ -1,17 +1,28 @@ /* ************************************************************************** */ /* */ /* ::: :::::::: */ -/* strcmp.c :+: :+: :+: */ +/* ft_strcmp.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/11/07 16:56:56 by rparodi #+# #+# */ -/* Updated: 2024/10/31 17:05:03 by rparodi ### ########.fr */ +/* Updated: 2024/10/31 18:07:20 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ #include "libft.h" +/** + * @brief Compares two strings lexicographically. + * + * @param s1 The first string to compare. + * @param s2 The second string to compare. + * + * @return An integer indicating the relationship between the two strings: + * - `< 0` if `s1` is less than `s2`. + * - `0` if `s1` equals `s2`. + * - `> 0` if `s1` is greater than `s2`. + */ int ft_strcmp(const char *s1, const char *s2) { size_t i; diff --git a/str/ft_strcpy.c b/str/ft_strcpy.c index 6ad4595..756166a 100644 --- a/str/ft_strcpy.c +++ b/str/ft_strcpy.c @@ -6,12 +6,20 @@ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/10/31 16:14:10 by rparodi #+# #+# */ -/* Updated: 2024/10/31 16:15:46 by rparodi ### ########.fr */ +/* Updated: 2024/10/31 18:14:03 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ #include "libft.h" +/** + * @brief Copies a string. + * + * @param dst The destination buffer. + * @param src The source string. + * + * @return A pointer to `dst`. + */ char *ft_strcpy(char *dst, const char *src) { size_t i; diff --git a/str/ft_strdup.c b/str/ft_strdup.c index 38a98fc..15a229a 100644 --- a/str/ft_strdup.c +++ b/str/ft_strdup.c @@ -6,12 +6,20 @@ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/11/07 16:53:59 by rparodi #+# #+# */ -/* Updated: 2023/11/13 20:02:09 by rparodi ### ########.fr */ +/* Updated: 2024/10/31 18:14:44 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ #include "libft.h" +/** + * @brief Duplicates a string. + * + * @param s1 The string to duplicate. + * + * @return A pointer to the duplicated string, + * or NULL if memory allocation fails. + */ char *ft_strdup(const char *s) { size_t len; diff --git a/str/ft_striteri.c b/str/ft_striteri.c index bf9869a..581d59a 100644 --- a/str/ft_striteri.c +++ b/str/ft_striteri.c @@ -6,12 +6,20 @@ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/11/09 13:57:34 by rparodi #+# #+# */ -/* Updated: 2023/11/11 17:26:00 by rparodi ### ########.fr */ +/* Updated: 2024/10/31 18:11:04 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ #include "libft.h" +/** + * @brief Applies a function to each character of a string. + * + * @param s The string to modify. + * @param f The function to apply to each character. + * + * @return void + */ void ft_striteri(char *s, void (*f)(unsigned int, char*)) { size_t i; diff --git a/str/ft_strjoin.c b/str/ft_strjoin.c index 18844b3..8b353b0 100644 --- a/str/ft_strjoin.c +++ b/str/ft_strjoin.c @@ -6,12 +6,21 @@ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/11/09 13:55:15 by rparodi #+# #+# */ -/* Updated: 2023/11/09 17:47:46 by rparodi ### ########.fr */ +/* Updated: 2024/10/31 18:13:21 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ #include "libft.h" +/** + * @brief Joins two strings into a new string. + * + * @param s1 The first string. + * @param s2 The second string. + * + * @return A pointer to the new concatenated string, + * or NULL if memory allocation fails. + */ char *ft_strjoin(char const *s1, char const *s2) { size_t i; diff --git a/str/ft_strlcat.c b/str/ft_strlcat.c index 5ef6701..2dde695 100644 --- a/str/ft_strlcat.c +++ b/str/ft_strlcat.c @@ -6,7 +6,7 @@ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/11/08 22:28:26 by rparodi #+# #+# */ -/* Updated: 2023/11/12 11:45:52 by rparodi ### ########.fr */ +/* Updated: 2024/10/31 18:10:19 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ @@ -22,6 +22,15 @@ static size_t ft_strnlen(char *dest, size_t size) return (i); } +/** + * @brief Appends a string with size limit. + * + * @param dst The destination buffer. + * @param src The source string. + * @param size The size of the destination buffer. + * + * @return The total length of the string it tried to create. + */ size_t ft_strlcat(char *dest, const char *src, size_t size) { size_t i; diff --git a/str/ft_strlcpy.c b/str/ft_strlcpy.c index bfd75e5..1d089fa 100644 --- a/str/ft_strlcpy.c +++ b/str/ft_strlcpy.c @@ -6,12 +6,21 @@ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/11/07 16:55:25 by rparodi #+# #+# */ -/* Updated: 2023/11/13 19:16:30 by rparodi ### ########.fr */ +/* Updated: 2024/10/31 18:12:13 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ #include "libft.h" +/** + * @brief Copies a string with size limit. + * + * @param dst The destination buffer. + * @param src The source string. + * @param size The maximum number of characters to copy. + * + * @return The total length of `src`. + */ size_t ft_strlcpy(char *dst, const char *src, size_t size) { size_t i; diff --git a/str/ft_strlen.c b/str/ft_strlen.c index ea2a01e..4c0e9a7 100644 --- a/str/ft_strlen.c +++ b/str/ft_strlen.c @@ -6,12 +6,19 @@ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/11/07 16:56:24 by rparodi #+# #+# */ -/* Updated: 2023/11/08 12:37:09 by rparodi ### ########.fr */ +/* Updated: 2024/10/31 18:12:19 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ #include "libft.h" +/** + * @brief Computes the length of a string. + * + * @param s The input string. + * + * @return The number of characters in the string `s`. + */ size_t ft_strlen(const char *s) { size_t i; diff --git a/str/ft_strmapi.c b/str/ft_strmapi.c index 163c12f..691df40 100644 --- a/str/ft_strmapi.c +++ b/str/ft_strmapi.c @@ -6,12 +6,21 @@ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/11/09 13:56:57 by rparodi #+# #+# */ -/* Updated: 2023/11/13 19:49:30 by rparodi ### ########.fr */ +/* Updated: 2024/10/31 18:14:29 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ #include "libft.h" +/** + * @brief Applies a function to each character of a string. + * + * @param s The input string. + * @param f The function to apply to each character. + * + * @return A pointer to the newly created string, + * or NULL if memory allocation fails. + */ char *ft_strmapi(char const *s, char (*f)(unsigned int, char)) { size_t i; diff --git a/str/ft_strncmp.c b/str/ft_strncmp.c index 9afff02..714b572 100644 --- a/str/ft_strncmp.c +++ b/str/ft_strncmp.c @@ -6,12 +6,21 @@ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/11/07 16:56:56 by rparodi #+# #+# */ -/* Updated: 2023/11/09 13:16:39 by rparodi ### ########.fr */ +/* Updated: 2024/10/31 18:13:58 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ #include "libft.h" +/** + * @brief Compares two strings up to a specified number of characters. + * + * @param s1 The first string to compare. + * @param s2 The second string to compare. + * @param n The maximum number of characters to compare. + * + * @return An integer indicating the relationship between the two strings. + */ int ft_strncmp(const char *s1, const char *s2, size_t n) { size_t i; diff --git a/str/ft_strnstr.c b/str/ft_strnstr.c index 6c20844..b5061fa 100644 --- a/str/ft_strnstr.c +++ b/str/ft_strnstr.c @@ -6,12 +6,26 @@ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/11/07 16:57:44 by rparodi #+# #+# */ -/* Updated: 2023/11/13 19:17:49 by rparodi ### ########.fr */ +/* Updated: 2024/10/31 18:12:05 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ #include "libft.h" +/** + * @brief Locates a substring within a string, up to a specified length. + * + * The `ft_strnstr` function locates the first occurrence of the null-terminated + * string `needle` within the string `haystack`, + * searching only up to `len` characters. + * + * @param big The string to search. + * @param little The substring to locate. + * @param len The maximum number of characters to search. + * + * @return A pointer to the beginning of the located substring, + * or NULL if `needle` is not found. + */ char *ft_strnstr(const char *big, const char *little, size_t len) { size_t i; diff --git a/str/ft_strrchr.c b/str/ft_strrchr.c index 3f7177a..5d06ac9 100644 --- a/str/ft_strrchr.c +++ b/str/ft_strrchr.c @@ -6,12 +6,21 @@ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/11/07 16:58:22 by rparodi #+# #+# */ -/* Updated: 2023/11/11 18:46:54 by rparodi ### ########.fr */ +/* Updated: 2024/10/31 18:13:53 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ #include "libft.h" +/** + * @brief Locates the last occurrence of a character in a string. + * + * @param s The string to search. + * @param c The character to locate. + * + * @return A pointer to the matched character, + * or NULL if it does not appear in `s`. + */ char *ft_strrchr(const char *s, int c) { size_t i; diff --git a/str/ft_strtrim.c b/str/ft_strtrim.c index 2d3e105..8a1b364 100644 --- a/str/ft_strtrim.c +++ b/str/ft_strtrim.c @@ -6,12 +6,20 @@ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/11/09 13:55:44 by rparodi #+# #+# */ -/* Updated: 2023/11/13 20:08:51 by rparodi ### ########.fr */ +/* Updated: 2024/10/31 18:09:25 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ #include "libft.h" +/** + * @brief Trims specified characters from the start and end of a string. + * + * @param s1 The string to trim. + * @param set The set of characters to remove. + * + * @return A pointer to the trimmed string, or NULL if memory allocation fails. + */ char *ft_strtrim(char const *s1, char const *set) { size_t i; diff --git a/str/ft_substr.c b/str/ft_substr.c index fd634f4..7129bdf 100644 --- a/str/ft_substr.c +++ b/str/ft_substr.c @@ -6,12 +6,21 @@ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/11/09 13:54:42 by rparodi #+# #+# */ -/* Updated: 2023/11/13 20:08:02 by rparodi ### ########.fr */ +/* Updated: 2024/10/31 18:10:59 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ #include "libft.h" +/** + * @brief Extracts a substring from a string. + * + * @param s The source string. + * @param start The starting index of the substring. + * @param len The maximum length of the substring. + * + * @return A pointer to the substring, or NULL if memory allocation fails. + */ char *ft_substr(char const *s, unsigned int start, size_t len) { char *str;