From 18e88699a6906be236d815f026746a60fadca1bb Mon Sep 17 00:00:00 2001 From: Willem Haffmans Date: Sun, 3 Nov 2024 10:49:45 +0000 Subject: [PATCH] starting to create comments and an implemantation of a circular linked list --- inc/libft.h | 8 ++++++++ src/string/ft_isalnum.c | 8 ++++++++ src/string/ft_isalpha.c | 6 ++++++ src/string/ft_isascii.c | 7 +++++++ src/string/ft_isdigit.c | 6 ++++++ src/string/ft_isprint.c | 6 ++++++ src/string/ft_split.c | 7 +++++++ src/string/ft_strchr.c | 9 ++++++++- src/string/ft_strlcat.c | 8 ++++++++ src/string/ft_strlen.c | 7 ++++++- 10 files changed, 70 insertions(+), 2 deletions(-) diff --git a/inc/libft.h b/inc/libft.h index 70a72be..e859777 100644 --- a/inc/libft.h +++ b/inc/libft.h @@ -20,6 +20,14 @@ typedef struct s_list struct s_list *next; } t_list; +typedef struct s_clist +{ + void *content; + struct s_clist *next; + struct s_clist *prev; +} t_clist; + + int ft_isalpha(int c); int ft_isdigit(int c); int ft_isalnum(int c); diff --git a/src/string/ft_isalnum.c b/src/string/ft_isalnum.c index 7439e0e..531e125 100644 --- a/src/string/ft_isalnum.c +++ b/src/string/ft_isalnum.c @@ -12,6 +12,14 @@ #include "libft.h" +/** + * @brief ft_isalnum() checks if a character is a digit or an + * alphabetical character. + * + * @param c contains an integer of the character to be tested. + * @return int returns c if the int codes for an digit or an alphabetical + * character. + */ int ft_isalnum(int c) { return (ft_isdigit(c) || ft_isalpha(c)); diff --git a/src/string/ft_isalpha.c b/src/string/ft_isalpha.c index 1d35b48..0625061 100644 --- a/src/string/ft_isalpha.c +++ b/src/string/ft_isalpha.c @@ -12,6 +12,12 @@ #include "libft.h" +/** + * @brief ft_isalpha() checks if a character is an alphabetical character. + * + * @param c contains an integer of the character to be tested. + * @return int returns c if the int codes for an alphabetical character. + */ int ft_isalpha(int c) { return (('A' <= c && 'Z' >= c) || ('a' <= c && 'z' >= c)); diff --git a/src/string/ft_isascii.c b/src/string/ft_isascii.c index 25cc440..0edfc23 100644 --- a/src/string/ft_isascii.c +++ b/src/string/ft_isascii.c @@ -12,6 +12,13 @@ #include "libft.h" +/** + * @brief ft_isalnum() checks if a character is an ascii character + * + * @param c contains an integer of the character to be tested. + * @return int returns c if the int codes for an digit or an ascii + * character. + */ int ft_isascii(int c) { return (0 <= c && 127 >= c); diff --git a/src/string/ft_isdigit.c b/src/string/ft_isdigit.c index f1d4fb8..00a8c4d 100644 --- a/src/string/ft_isdigit.c +++ b/src/string/ft_isdigit.c @@ -12,6 +12,12 @@ #include "libft.h" +/** + * @brief ft_isdigit() checks if a character is a digit. + * + * @param c contains an integer of the character to be tested. + * @return int returns c if the int codes for an digit. + */ int ft_isdigit(int c) { return ('0' <= c && '9' >= c); diff --git a/src/string/ft_isprint.c b/src/string/ft_isprint.c index b7cc59f..954db8b 100644 --- a/src/string/ft_isprint.c +++ b/src/string/ft_isprint.c @@ -12,6 +12,12 @@ #include "libft.h" +/** + * @brief ft_isprint() checks if a character is a printable character. + * + * @param c contains an integer of the character to be tested. + * @return int returns c if the int codes for aprintable character. + */ int ft_isprint(int c) { return (32 <= c && 126 >= c); diff --git a/src/string/ft_split.c b/src/string/ft_split.c index 33cb5e9..b87c0b9 100644 --- a/src/string/ft_split.c +++ b/src/string/ft_split.c @@ -40,6 +40,13 @@ static void *free_arr(int n, char ***arr) return (NULL); } +/** + * @brief ft_split() splits an array based on a seperator. + * + * @param s is a string. + * @param c is the seperator. + * @return char** an array of string where the last element is NULL. + */ char **ft_split(char const *s, char c) { char **result; diff --git a/src/string/ft_strchr.c b/src/string/ft_strchr.c index b57b931..09e107c 100644 --- a/src/string/ft_strchr.c +++ b/src/string/ft_strchr.c @@ -11,7 +11,14 @@ /* ************************************************************************** */ #include "libft.h" - +/** + * @brief ft_strchr() return a pointer to the first char found in the string. + * + * @param s the string to be searched. + * @param c the character searched for. + * @return char* the pointer to the first char found in the string if + * nothing is foun ft_strchr() NULL. + */ char *ft_strchr(const char *s, int c) { while (*s) diff --git a/src/string/ft_strlcat.c b/src/string/ft_strlcat.c index a5b5cd1..9474189 100644 --- a/src/string/ft_strlcat.c +++ b/src/string/ft_strlcat.c @@ -12,6 +12,14 @@ #include "libft.h" +/** + * @brief ft_strlcat() concatenates size bytes from src into dst + * + * @param dst the destination string. + * @param src the source string. + * @param size the amount of bytes to be copied into dst + * @return size_t the amount of bytes that should havebeen copied. + */ size_t ft_strlcat(char *dst, const char *src, size_t size) { size_t src_len; diff --git a/src/string/ft_strlen.c b/src/string/ft_strlen.c index 01cfa5f..842dcd9 100644 --- a/src/string/ft_strlen.c +++ b/src/string/ft_strlen.c @@ -11,7 +11,12 @@ /* ************************************************************************** */ #include "libft.h" - +/** + * @brief ft_strlen() return the length of a null-terminated string. + * + * @param s the string. + * @return size_t the length of the string. + */ size_t ft_strlen(const char *s) { size_t length;