From 63c1dea7a2994f3a15cb8ccce0aa6eb625245a7f Mon Sep 17 00:00:00 2001 From: Raphael Date: Fri, 5 Sep 2025 16:28:33 +0200 Subject: [PATCH 1/8] docs(char): moving the actual documentation on the header - The documentation on the header allow u to see on the files where the header is inclued --- char/ft_isalnum.c | 8 +------- char/ft_isalpha.c | 8 +------- char/ft_isascii.c | 8 +------- char/ft_isdigit.c | 8 +------- char/ft_isprint.c | 8 +------- char/ft_tolower.c | 8 +------- char/ft_toupper.c | 8 +------- includes/char.h | 50 ++++++++++++++++++++++++++++++++++++++++++++++- 8 files changed, 56 insertions(+), 50 deletions(-) diff --git a/char/ft_isalnum.c b/char/ft_isalnum.c index 189f919..f36023a 100644 --- a/char/ft_isalnum.c +++ b/char/ft_isalnum.c @@ -6,18 +6,12 @@ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/11/06 12:47:28 by rparodi #+# #+# */ -/* Updated: 2025/09/04 18:12:52 by rparodi ### ########.fr */ +/* Updated: 2025/09/05 16:01:38 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ #include "char.h" -/** - * @brief Check if the character is alpha-numeric - * - * @param c the character - * @return the character if alphanumeric or 0 if not - */ int ft_isalnum(int c) { if (ft_isalpha(c) || ft_isdigit(c)) diff --git a/char/ft_isalpha.c b/char/ft_isalpha.c index a543c4c..be64e5a 100644 --- a/char/ft_isalpha.c +++ b/char/ft_isalpha.c @@ -6,16 +6,10 @@ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/11/06 11:58:37 by rparodi #+# #+# */ -/* Updated: 2025/09/04 18:13:06 by rparodi ### ########.fr */ +/* Updated: 2025/09/05 16:03:14 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ -/** - * @brief Check if the character is alpha - * - * @param c the character - * @return the character if alpha or 0 if not - */ int ft_isalpha(int c) { if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')) diff --git a/char/ft_isascii.c b/char/ft_isascii.c index 8ed7e6d..c36b984 100644 --- a/char/ft_isascii.c +++ b/char/ft_isascii.c @@ -6,16 +6,10 @@ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/11/06 14:04:26 by rparodi #+# #+# */ -/* Updated: 2025/09/05 10:40:03 by rparodi ### ########.fr */ +/* Updated: 2025/09/05 16:01:13 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ -/** - * @brief Check if the character is in the ascii table - * - * @param c the character - * @return the character if in the ascii table or 0 if not - */ int ft_isascii(int c) { if (c == 0) diff --git a/char/ft_isdigit.c b/char/ft_isdigit.c index 379f867..fd464ad 100644 --- a/char/ft_isdigit.c +++ b/char/ft_isdigit.c @@ -6,16 +6,10 @@ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/11/06 12:44:28 by rparodi #+# #+# */ -/* Updated: 2025/09/04 18:13:17 by rparodi ### ########.fr */ +/* Updated: 2025/09/05 16:00:16 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ -/** - * @brief Check if the character is alpha numeric - * - * @param c the character - * @return the character if numeric or 0 if not - */ int ft_isdigit(int c) { if (c >= '0' && c <= '9') diff --git a/char/ft_isprint.c b/char/ft_isprint.c index c4c38c4..7bdd052 100644 --- a/char/ft_isprint.c +++ b/char/ft_isprint.c @@ -6,16 +6,10 @@ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/11/06 14:06:53 by rparodi #+# #+# */ -/* Updated: 2025/09/05 10:44:13 by rparodi ### ########.fr */ +/* Updated: 2025/09/05 16:03:14 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ -/** - * @brief Check if the character is printable - * - * @param c the character - * @return the character if can be print or 0 if not - */ int ft_isprint(int c) { if (c >= 32 && c <= 126) diff --git a/char/ft_tolower.c b/char/ft_tolower.c index 525223a..d5e7d1c 100644 --- a/char/ft_tolower.c +++ b/char/ft_tolower.c @@ -6,16 +6,10 @@ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/11/07 10:38:54 by rparodi #+# #+# */ -/* Updated: 2025/09/04 11:42:13 by rparodi ### ########.fr */ +/* Updated: 2025/09/05 16:00:45 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ -/** - * @brief convert the upper case to lower case - * - * @param c the character - * @return the character to lower case if is on upper - */ int ft_tolower(int c) { if (c >= 'A' && c <= 'Z') diff --git a/char/ft_toupper.c b/char/ft_toupper.c index fed811d..921cca5 100644 --- a/char/ft_toupper.c +++ b/char/ft_toupper.c @@ -6,16 +6,10 @@ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/11/07 10:44:26 by rparodi #+# #+# */ -/* Updated: 2025/09/04 11:41:57 by rparodi ### ########.fr */ +/* Updated: 2025/09/05 16:00:45 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ -/** - * @brief convert the lower case to upper case - * - * @param c the character - * @return the character to upper case if is on lower - */ int ft_toupper(int c) { if (c >= 'a' && c <= 'z') diff --git a/includes/char.h b/includes/char.h index ac26e90..394e408 100644 --- a/includes/char.h +++ b/includes/char.h @@ -6,19 +6,67 @@ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/10/31 14:54:04 by rparodi #+# #+# */ -/* Updated: 2025/09/01 18:26:44 by rparodi ### ########.fr */ +/* Updated: 2025/09/05 16:06:07 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ #ifndef CHAR_H # define CHAR_H +/** + * @brief Check if the character is alpha-numeric + * + * @param c the character + * @return 1 if the char is alpha-numeric overwise 0 + */ int ft_isalnum(int c); + +/** + * @brief Check if the character is alpha + * + * @param c the character + * @return 1 if the char is alphabetic overwise 0 + */ int ft_isalpha(int c); + +/** + * @brief Check if the character is in the ascii table + * + * @param c the character + * @return 1 if the char is ascii overwise 0 + */ int ft_isascii(int c); + +/** + * @brief Check if the character is numeric + * + * @param c the character + * @return 1 if the char is numeric overwise 0 + */ int ft_isdigit(int c); + +/** + * @brief Check if the character is printable + * + * @param c the character + * @return 1 if the char is printable 0 + */ int ft_isprint(int c); + +/** + * @brief convert the upper case to lower case + * + * @param c the character + * @return the character to lower case if is on upper + */ int ft_tolower(int c); + +/** + * @brief convert the lower case to upper case + * + * @param c the character + * @return the character to upper case if is on lower + */ int ft_toupper(int c); #endif From 52b85d2dc6658d9010ceb2a3f6800f308fc4400e Mon Sep 17 00:00:00 2001 From: Raphael Date: Fri, 5 Sep 2025 16:29:16 +0200 Subject: [PATCH 2/8] docs(convert): moving the actual documentation on the header - The documentation on the header allow u to see on the files where the header is inclued --- convert/ft_atoi.c | 8 +------- convert/ft_atoll.c | 8 +------- convert/ft_itoa.c | 8 +------- includes/convert.h | 22 +++++++++++++++++++++- 4 files changed, 24 insertions(+), 22 deletions(-) diff --git a/convert/ft_atoi.c b/convert/ft_atoi.c index ba63e8d..6475e7c 100644 --- a/convert/ft_atoi.c +++ b/convert/ft_atoi.c @@ -6,7 +6,7 @@ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/11/08 17:22:41 by rparodi #+# #+# */ -/* Updated: 2025/09/05 14:34:51 by rparodi ### ########.fr */ +/* Updated: 2025/09/05 16:08:14 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ @@ -31,12 +31,6 @@ static int ft_check_sign(const char *nptr, int *i) return (1); } -/** - * @brief Converts string to integer - * - * @param nptr the string that will be converted - * @return The integer on the string - */ int ft_atoi(const char *nptr) { int i; diff --git a/convert/ft_atoll.c b/convert/ft_atoll.c index bce4af4..43ba49a 100644 --- a/convert/ft_atoll.c +++ b/convert/ft_atoll.c @@ -6,7 +6,7 @@ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/10/31 15:12:07 by rparodi #+# #+# */ -/* Updated: 2025/09/05 14:54:50 by rparodi ### ########.fr */ +/* Updated: 2025/09/05 16:08:14 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ @@ -33,12 +33,6 @@ static int ft_check_sign(const char *nptr, size_t *i) return (1); } -/** - * @brief Converts string to long long integer - * - * @param nptr the string that will be converted - * @return The long long int on the string - */ long long int ft_atoll(const char *nptr) { size_t i; diff --git a/convert/ft_itoa.c b/convert/ft_itoa.c index f25351a..e267dab 100644 --- a/convert/ft_itoa.c +++ b/convert/ft_itoa.c @@ -6,7 +6,7 @@ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/11/09 13:56:30 by rparodi #+# #+# */ -/* Updated: 2025/09/01 16:30:01 by rparodi ### ########.fr */ +/* Updated: 2025/09/05 16:08:14 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ @@ -26,12 +26,6 @@ static size_t ft_check_sign(char *str, long *nb) return (0); } -/** - * @brief Converts integer to string - * - * @param n the integer that will be converted - * @return The string with this integer - */ char *ft_itoa(int n) { size_t i; diff --git a/includes/convert.h b/includes/convert.h index 2674ae8..f3dcd96 100644 --- a/includes/convert.h +++ b/includes/convert.h @@ -6,15 +6,35 @@ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/10/31 14:57:24 by rparodi #+# #+# */ -/* Updated: 2025/09/01 17:55:58 by rparodi ### ########.fr */ +/* Updated: 2025/09/05 16:07:54 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ #ifndef CONVERT_H # define CONVERT_H +/** + * @brief Converts integer to string + * + * @param n the integer that will be converted + * @return The string with this integer + */ char *ft_itoa(int n); + +/** + * @brief Converts string to integer + * + * @param nptr the string that will be converted + * @return The integer on the string + */ int ft_atoi(const char *nptr); + +/** + * @brief Converts string to long long integer + * + * @param nptr the string that will be converted + * @return The long long int on the string + */ long long int ft_atoll(const char *nptr); #endif From 3cadabea0a7fc637286c2ae94e00247caf66c450 Mon Sep 17 00:00:00 2001 From: Raphael Date: Fri, 5 Sep 2025 16:29:29 +0200 Subject: [PATCH 3/8] docs(list): moving the actual documentation on the header - The documentation on the header allow u to see on the files where the header is inclued --- includes/list.h | 66 +++++++++++++++++++++++++++++++++++++++++- 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 +---- 10 files changed, 74 insertions(+), 66 deletions(-) diff --git a/includes/list.h b/includes/list.h index 88aee8c..6b831c4 100644 --- a/includes/list.h +++ b/includes/list.h @@ -6,7 +6,7 @@ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/10/31 15:00:12 by rparodi #+# #+# */ -/* Updated: 2025/09/01 16:34:41 by rparodi ### ########.fr */ +/* Updated: 2025/09/05 16:24:23 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ @@ -19,14 +19,78 @@ typedef struct s_list struct s_list *next; } t_list; +/** + * @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); + +/** + * @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); + +/** + * @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 The list edited by the function given by f + */ t_list *ft_lstmap(t_list *lst, void *(*f)(void *), void (*del)(void *)); + +/** + * @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); + +/** + * @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); + +/** + * @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); + +/** + * @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 *)); + +/** + * @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 *)); + +/** + * @brief Apply the fstunction 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 *)); #endif diff --git a/list/ft_lstadd_back.c b/list/ft_lstadd_back.c index 03da61e..3e99f37 100644 --- a/list/ft_lstadd_back.c +++ b/list/ft_lstadd_back.c @@ -6,19 +6,13 @@ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/11/12 11:39:56 by rparodi #+# #+# */ -/* Updated: 2025/09/01 16:35:17 by rparodi ### ########.fr */ +/* Updated: 2025/09/05 16:14:04 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ #include "list.h" #include -/** - * @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 aad3a53..89cfab6 100644 --- a/list/ft_lstadd_front.c +++ b/list/ft_lstadd_front.c @@ -6,19 +6,13 @@ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/11/12 11:40:16 by rparodi #+# #+# */ -/* Updated: 2025/09/01 16:35:45 by rparodi ### ########.fr */ +/* Updated: 2025/09/05 16:14:05 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ #include "list.h" #include -/** - * @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 77e0359..b9d571a 100644 --- a/list/ft_lstclear.c +++ b/list/ft_lstclear.c @@ -6,18 +6,12 @@ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/11/12 11:40:37 by rparodi #+# #+# */ -/* Updated: 2025/09/01 16:33:31 by rparodi ### ########.fr */ +/* Updated: 2025/09/05 16:14:05 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ #include "list.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 7948114..fe42293 100644 --- a/list/ft_lstdelone.c +++ b/list/ft_lstdelone.c @@ -6,19 +6,13 @@ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/11/12 11:42:11 by rparodi #+# #+# */ -/* Updated: 2025/09/01 16:36:07 by rparodi ### ########.fr */ +/* Updated: 2025/09/05 16:14:05 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ #include "list.h" #include -/** - * @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 0fb98c5..270fb79 100644 --- a/list/ft_lstiter.c +++ b/list/ft_lstiter.c @@ -6,19 +6,13 @@ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/11/12 11:42:24 by rparodi #+# #+# */ -/* Updated: 2025/09/01 16:35:17 by rparodi ### ########.fr */ +/* Updated: 2025/09/05 16:14:05 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ #include "list.h" #include -/** - * @brief Apply the fstunction 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 b6e6a56..dfb3fa7 100644 --- a/list/ft_lstlast.c +++ b/list/ft_lstlast.c @@ -6,19 +6,13 @@ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/11/12 11:42:54 by rparodi #+# #+# */ -/* Updated: 2025/09/01 16:36:47 by rparodi ### ########.fr */ +/* Updated: 2025/09/05 16:14:04 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ #include "list.h" #include -/** - * @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 0299b5d..f9bef32 100644 --- a/list/ft_lstmap.c +++ b/list/ft_lstmap.c @@ -6,21 +6,13 @@ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/11/12 11:43:28 by rparodi #+# #+# */ -/* Updated: 2025/09/01 16:37:46 by rparodi ### ########.fr */ +/* Updated: 2025/09/05 16:14:05 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ #include "list.h" #include -/** - * @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 bdef868..b9babff 100644 --- a/list/ft_lstnew.c +++ b/list/ft_lstnew.c @@ -6,19 +6,13 @@ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/11/12 11:44:02 by rparodi #+# #+# */ -/* Updated: 2025/09/01 16:39:00 by rparodi ### ########.fr */ +/* Updated: 2025/09/05 16:14:05 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ #include "list.h" #include -/** - * @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 e58fe3f..ae06474 100644 --- a/list/ft_lstsize.c +++ b/list/ft_lstsize.c @@ -6,19 +6,13 @@ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/11/12 11:44:24 by rparodi #+# #+# */ -/* Updated: 2025/09/01 16:39:28 by rparodi ### ########.fr */ +/* Updated: 2025/09/05 16:14:04 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ #include "list.h" #include -/** - * @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; From ed64bd73d6a414d57f487ea0219329fab2917594 Mon Sep 17 00:00:00 2001 From: Raphael Date: Fri, 5 Sep 2025 16:29:40 +0200 Subject: [PATCH 4/8] docs(memory): moving the actual documentation on the header - The documentation on the header allow u to see on the files where the header is inclued --- includes/memory.h | 69 ++++++++++++++++++++++++++++++++++++++++++++- 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 +------- 8 files changed, 75 insertions(+), 69 deletions(-) diff --git a/includes/memory.h b/includes/memory.h index 8ed4031..a410e96 100644 --- a/includes/memory.h +++ b/includes/memory.h @@ -6,7 +6,7 @@ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/10/31 15:18:17 by rparodi #+# #+# */ -/* Updated: 2025/09/04 11:51:05 by rparodi ### ########.fr */ +/* Updated: 2025/09/05 16:26:36 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ @@ -15,12 +15,79 @@ # include +/** + * @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); + +/** + * @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); + +/** + * @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); + +/** + * @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); + +/** + * @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); + +/** + * @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); + +/** + * @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); #endif diff --git a/memory/ft_bzero.c b/memory/ft_bzero.c index 732ea50..2316d16 100644 --- a/memory/ft_bzero.c +++ b/memory/ft_bzero.c @@ -6,19 +6,13 @@ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/11/07 16:43:13 by rparodi #+# #+# */ -/* Updated: 2025/09/01 16:39:50 by rparodi ### ########.fr */ +/* Updated: 2025/09/05 16:26:53 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ #include "memory.h" #include -/** - * @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 3f7583f..decbc8f 100644 --- a/memory/ft_calloc.c +++ b/memory/ft_calloc.c @@ -6,19 +6,13 @@ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/11/07 16:47:17 by rparodi #+# #+# */ -/* Updated: 2025/09/01 18:28:34 by rparodi ### ########.fr */ +/* Updated: 2025/09/05 16:25:35 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ #include "memory.h" #include -/** - * @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 1d8bb75..e1457ff 100644 --- a/memory/ft_memchr.c +++ b/memory/ft_memchr.c @@ -6,23 +6,13 @@ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/11/07 16:48:30 by rparodi #+# #+# */ -/* Updated: 2025/09/01 16:40:36 by rparodi ### ########.fr */ +/* Updated: 2025/09/05 16:26:04 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ #include "memory.h" #include -/** - * @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 7c3d955..be12fcb 100644 --- a/memory/ft_memcmp.c +++ b/memory/ft_memcmp.c @@ -6,24 +6,12 @@ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/11/07 16:49:04 by rparodi #+# #+# */ -/* Updated: 2025/09/01 16:40:58 by rparodi ### ########.fr */ +/* Updated: 2025/09/05 16:26:04 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ #include -/** - * @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 4c35af1..442c6b9 100644 --- a/memory/ft_memcpy.c +++ b/memory/ft_memcpy.c @@ -6,21 +6,12 @@ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/11/07 16:49:46 by rparodi #+# #+# */ -/* Updated: 2025/09/01 16:41:32 by rparodi ### ########.fr */ +/* Updated: 2025/09/05 16:26:04 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ #include -/** - * @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 6d63e80..010d283 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: 2025/09/04 11:56:02 by rparodi ### ########.fr */ +/* Updated: 2025/09/05 16:26:53 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ @@ -37,15 +37,6 @@ static 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 e4825d6..dd0cde5 100644 --- a/memory/ft_memset.c +++ b/memory/ft_memset.c @@ -6,21 +6,12 @@ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/11/07 16:50:29 by rparodi #+# #+# */ -/* Updated: 2025/09/01 16:42:01 by rparodi ### ########.fr */ +/* Updated: 2025/09/05 16:26:53 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ #include -/** - * @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; From 701ce57f84346ac28c0367e1a0357b70f8802ff1 Mon Sep 17 00:00:00 2001 From: Raphael Date: Fri, 5 Sep 2025 16:29:51 +0200 Subject: [PATCH 5/8] docs(print): moving the actual documentation on the header - The documentation on the header allow u to see on the files where the header is inclued --- includes/print.h | 44 ++++++++++++++++++++++++++++++++++++++++++- 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 +------- 6 files changed, 48 insertions(+), 43 deletions(-) diff --git a/includes/print.h b/includes/print.h index 690852d..7766698 100644 --- a/includes/print.h +++ b/includes/print.h @@ -6,18 +6,60 @@ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/10/31 15:07:30 by rparodi #+# #+# */ -/* Updated: 2025/09/01 17:36:18 by rparodi ### ########.fr */ +/* Updated: 2025/09/05 16:23:42 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ #ifndef PRINT_H # define PRINT_H +/** + * @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, ...); + +/** + * @brief Print on the standard output + * + * @param s the string + * @return the number of character printable + */ int ft_printf(const char *s, ...); + +/** + * @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); + +/** + * @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); + +/** + * @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); + +/** + * @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); #endif diff --git a/print/ft_printf.c b/print/ft_printf.c index 4fec8bb..06583a5 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: 2025/09/04 11:56:27 by rparodi ### ########.fr */ +/* Updated: 2025/09/05 16:23:43 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ @@ -44,13 +44,6 @@ static int _check_args(int fd, char c, va_list args, int *ret) 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; @@ -77,12 +70,6 @@ int ft_dprintf(int fd, const char *s, ...) return (ret); } -/** - * @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 0bb8f44..c94d46c 100644 --- a/print/ft_putchar_fd.c +++ b/print/ft_putchar_fd.c @@ -6,18 +6,12 @@ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/11/09 13:58:22 by rparodi #+# #+# */ -/* Updated: 2025/09/01 17:46:44 by rparodi ### ########.fr */ +/* Updated: 2025/09/05 16:23:43 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ #include -/** - * @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 734c2b1..833c3ec 100644 --- a/print/ft_putendl_fd.c +++ b/print/ft_putendl_fd.c @@ -6,18 +6,12 @@ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/11/09 13:59:01 by rparodi #+# #+# */ -/* Updated: 2025/09/01 17:46:30 by rparodi ### ########.fr */ +/* Updated: 2025/09/05 16:23:43 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ #include "print.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 220824f..dc81f28 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: 2025/09/01 17:47:41 by rparodi ### ########.fr */ +/* Updated: 2025/09/05 16:23:43 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ @@ -41,12 +41,6 @@ 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 3a0782f..a935180 100644 --- a/print/ft_putstr_fd.c +++ b/print/ft_putstr_fd.c @@ -6,19 +6,13 @@ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/11/09 13:58:46 by rparodi #+# #+# */ -/* Updated: 2025/09/01 17:48:07 by rparodi ### ########.fr */ +/* Updated: 2025/09/05 16:23:43 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ #include "str.h" #include -/** - * @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)); From 2cf0714dc772c4449947f5d8f1d2921d80a79d7c Mon Sep 17 00:00:00 2001 From: Raphael Date: Fri, 5 Sep 2025 16:30:00 +0200 Subject: [PATCH 6/8] docs(str): moving the actual documentation on the header - The documentation on the header allow u to see on the files where the header is inclued --- includes/str.h | 173 +++++++++++++++++++++++++++++++++++++++++++++- str/ft_split.c | 11 +-- str/ft_strchr.c | 11 +-- str/ft_strcmp.c | 13 +--- 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_strncpy.c | 11 +-- str/ft_strnstr.c | 16 +---- str/ft_strrchr.c | 11 +-- str/ft_strtrim.c | 10 +-- str/ft_substr.c | 11 +-- 18 files changed, 189 insertions(+), 172 deletions(-) diff --git a/includes/str.h b/includes/str.h index 84da184..8857667 100644 --- a/includes/str.h +++ b/includes/str.h @@ -6,7 +6,7 @@ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/10/31 15:04:59 by rparodi #+# #+# */ -/* Updated: 2025/09/04 11:53:11 by rparodi ### ########.fr */ +/* Updated: 2025/09/05 16:19:06 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ @@ -15,21 +15,192 @@ # include +/** + * @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); + +/** + * @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); + +/** + * @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); + +/** + * @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); + +/** + * @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); + +/** + * @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)); + +/** + * @brief Copies a string. + * + * @param dst The destination buffer. + * @param src The source string. + * @param size The size to copy + * + * @return A pointer to `dst`. + */ char *ft_strncpy(char *dst, const char *src, size_t size); + +/** + * @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); + +/** + * @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); + +/** + * @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); + +/** + * @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); + +/** + * @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); + +/** + * @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); + +/** + * @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 *dst, const char *src, size_t size); + +/** + * @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); + +/** + * @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); + +/** + * @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*)); #endif diff --git a/str/ft_split.c b/str/ft_split.c index ad124d3..04e40d2 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: 2025/09/01 17:49:19 by rparodi ### ########.fr */ +/* Updated: 2025/09/05 16:17:50 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ @@ -74,15 +74,6 @@ 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 472841e..432ae21 100644 --- a/str/ft_strchr.c +++ b/str/ft_strchr.c @@ -6,22 +6,13 @@ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/11/07 16:32:19 by rparodi #+# #+# */ -/* Updated: 2025/09/01 17:49:27 by rparodi ### ########.fr */ +/* Updated: 2025/09/05 16:17:50 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ #include "str.h" #include -/** - * @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 6ef1976..d382fba 100644 --- a/str/ft_strcmp.c +++ b/str/ft_strcmp.c @@ -6,23 +6,12 @@ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/11/07 16:56:56 by rparodi #+# #+# */ -/* Updated: 2025/09/01 17:50:06 by rparodi ### ########.fr */ +/* Updated: 2025/09/05 16:21:46 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ #include -/** - * @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 36eae2a..2077e55 100644 --- a/str/ft_strcpy.c +++ b/str/ft_strcpy.c @@ -6,20 +6,12 @@ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/10/31 16:14:10 by rparodi #+# #+# */ -/* Updated: 2025/09/01 17:36:18 by rparodi ### ########.fr */ +/* Updated: 2025/09/05 16:17:50 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ #include -/** - * @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 0a1a8c6..3f32edd 100644 --- a/str/ft_strdup.c +++ b/str/ft_strdup.c @@ -6,21 +6,13 @@ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/11/07 16:53:59 by rparodi #+# #+# */ -/* Updated: 2025/09/01 17:58:58 by rparodi ### ########.fr */ +/* Updated: 2025/09/05 16:17:50 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ #include "str.h" #include -/** - * @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 3a88652..3b844ae 100644 --- a/str/ft_striteri.c +++ b/str/ft_striteri.c @@ -6,20 +6,12 @@ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/11/09 13:57:34 by rparodi #+# #+# */ -/* Updated: 2025/09/01 17:50:26 by rparodi ### ########.fr */ +/* Updated: 2025/09/05 16:17:50 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ #include -/** - * @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 ca95a58..42ce3ca 100644 --- a/str/ft_strjoin.c +++ b/str/ft_strjoin.c @@ -6,22 +6,13 @@ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/11/09 13:55:15 by rparodi #+# #+# */ -/* Updated: 2025/09/01 17:58:58 by rparodi ### ########.fr */ +/* Updated: 2025/09/05 16:17:50 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ #include "str.h" #include -/** - * @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 f8bbf79..351b81d 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: 2025/09/01 17:52:29 by rparodi ### ########.fr */ +/* Updated: 2025/09/05 16:17:50 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ @@ -23,15 +23,6 @@ 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 86bd60a..cffe355 100644 --- a/str/ft_strlcpy.c +++ b/str/ft_strlcpy.c @@ -6,22 +6,13 @@ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/11/07 16:55:25 by rparodi #+# #+# */ -/* Updated: 2025/09/01 17:52:00 by rparodi ### ########.fr */ +/* Updated: 2025/09/05 16:17:50 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ #include "str.h" #include -/** - * @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 a6db9cf..b69f10a 100644 --- a/str/ft_strlen.c +++ b/str/ft_strlen.c @@ -6,19 +6,12 @@ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/11/07 16:56:24 by rparodi #+# #+# */ -/* Updated: 2025/09/01 18:34:21 by rparodi ### ########.fr */ +/* Updated: 2025/09/05 16:17:50 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ #include -/** - * @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 4a2c463..56ebc3e 100644 --- a/str/ft_strmapi.c +++ b/str/ft_strmapi.c @@ -6,7 +6,7 @@ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/11/09 13:56:57 by rparodi #+# #+# */ -/* Updated: 2025/09/01 18:28:51 by rparodi ### ########.fr */ +/* Updated: 2025/09/05 16:17:50 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ @@ -14,15 +14,6 @@ #include "str.h" #include -/** - * @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 78933d5..1caeeae 100644 --- a/str/ft_strncmp.c +++ b/str/ft_strncmp.c @@ -6,21 +6,12 @@ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/11/07 16:56:56 by rparodi #+# #+# */ -/* Updated: 2025/09/01 17:54:01 by rparodi ### ########.fr */ +/* Updated: 2025/09/05 16:17:50 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ #include -/** - * @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_strncpy.c b/str/ft_strncpy.c index d8db173..932677e 100644 --- a/str/ft_strncpy.c +++ b/str/ft_strncpy.c @@ -6,21 +6,12 @@ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/10/31 16:14:10 by rparodi #+# #+# */ -/* Updated: 2025/09/01 18:46:55 by rparodi ### ########.fr */ +/* Updated: 2025/09/05 16:17:50 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ #include -/** - * @brief Copies a string. - * - * @param dst The destination buffer. - * @param src The source string. - * @param size The size to copy - * - * @return A pointer to `dst`. - */ char *ft_strcpy(char *dst, const char *src, size_t size) { size_t i; diff --git a/str/ft_strnstr.c b/str/ft_strnstr.c index 8949913..d227b60 100644 --- a/str/ft_strnstr.c +++ b/str/ft_strnstr.c @@ -6,26 +6,12 @@ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/11/07 16:57:44 by rparodi #+# #+# */ -/* Updated: 2025/09/01 17:54:58 by rparodi ### ########.fr */ +/* Updated: 2025/09/05 16:17:50 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ #include -/** - * @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 b53358e..e75d8d6 100644 --- a/str/ft_strrchr.c +++ b/str/ft_strrchr.c @@ -6,22 +6,13 @@ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/11/07 16:58:22 by rparodi #+# #+# */ -/* Updated: 2025/09/01 17:49:39 by rparodi ### ########.fr */ +/* Updated: 2025/09/05 16:17:50 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ #include "str.h" #include -/** - * @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 b5ccf5e..89df743 100644 --- a/str/ft_strtrim.c +++ b/str/ft_strtrim.c @@ -6,21 +6,13 @@ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/11/09 13:55:44 by rparodi #+# #+# */ -/* Updated: 2025/09/01 18:26:20 by rparodi ### ########.fr */ +/* Updated: 2025/09/05 16:16:46 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ #include "str.h" #include -/** - * @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 8c1aecc..66b3480 100644 --- a/str/ft_substr.c +++ b/str/ft_substr.c @@ -6,22 +6,13 @@ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/11/09 13:54:42 by rparodi #+# #+# */ -/* Updated: 2025/09/01 18:26:29 by rparodi ### ########.fr */ +/* Updated: 2025/09/05 16:17:50 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ #include "str.h" #include -/** - * @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; From 7e80beedb850cb33c813cd34cd954f0ab1defdbc Mon Sep 17 00:00:00 2001 From: Raphael Date: Fri, 5 Sep 2025 16:30:55 +0200 Subject: [PATCH 7/8] build(str/strncpy): adding strncpy to the makefile - The file was here but not on the makefile so now it's patched --- Makefile | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 4aae38c..cb9d296 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,7 @@ # By: rparodi +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2023/11/12 11:05:05 by rparodi #+# #+# # -# Updated: 2025/09/05 15:10:23 by rparodi ### ########.fr # +# Updated: 2025/09/05 16:21:13 by rparodi ### ########.fr # # # # **************************************************************************** # @@ -30,10 +30,10 @@ CPPFLAGS = $(addprefix -I, $(INC_DIR)) -MMD -MP OBJDIRNAME = ./build OBJ = $(addprefix $(OBJDIRNAME)/,$(SRC:.c=.o)) -SRC = char/ft_isdigit.c \ - char/ft_isalnum.c \ +SRC = char/ft_isalnum.c \ char/ft_isalpha.c \ char/ft_isascii.c \ + char/ft_isdigit.c \ char/ft_isprint.c \ char/ft_tolower.c \ char/ft_toupper.c \ @@ -74,6 +74,7 @@ SRC = char/ft_isdigit.c \ str/ft_strlen.c \ str/ft_strmapi.c \ str/ft_strncmp.c \ + str/ft_strncpy.c \ str/ft_strnstr.c \ str/ft_strrchr.c \ str/ft_strtrim.c \ From 0bb6d77dbbcc9b48147da7472abefbd6fa7f37b4 Mon Sep 17 00:00:00 2001 From: Raphael Date: Fri, 5 Sep 2025 16:31:19 +0200 Subject: [PATCH 8/8] style(test/convert): normed the itoa tabs --- test/convert/test_itoa.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/convert/test_itoa.c b/test/convert/test_itoa.c index 8b1190c..fb273fe 100644 --- a/test/convert/test_itoa.c +++ b/test/convert/test_itoa.c @@ -6,7 +6,7 @@ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/09/04 16:54:42 by rparodi #+# #+# */ -/* Updated: 2025/09/05 15:08:52 by rparodi ### ########.fr */ +/* Updated: 2025/09/05 16:10:48 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ @@ -19,7 +19,7 @@ int main(void) { - const int integer[] = {0, 42, -42, +-42, -2147483648, 2147483647}; + const int integer[] = {0, 42, -42, + -42, -2147483648, 2147483647}; char result[1024]; size_t i;