From: Lukas Jiriste Date: Sat, 13 Jan 2024 14:00:45 +0000 (+0100) Subject: Patch the issues of previous commit. X-Git-Url: https://git.ljiriste.work/?a=commitdiff_plain;h=b5558acce95c98a9cf0a4e19b46d8e52c6016333;p=Libft.git Patch the issues of previous commit. Patch ft_strcmp.c so that it actually compiles... Add ft_strcmp to header file and the Makefile so that it is usable and compiles to libft.a. --- diff --git a/Makefile b/Makefile index b66e514..77db79f 100644 --- a/Makefile +++ b/Makefile @@ -14,6 +14,7 @@ SRCgen := ft_swap.c \ SRCmath := ft_abs.c \ SRCstr := ft_strncat_alloc.c \ + ft_strcmp.c \ ft_strncmp.c \ ft_strndup.c \ ft_strchr.c \ diff --git a/ft_str/ft_strcmp.c b/ft_str/ft_strcmp.c index 279108c..e20ddb5 100644 --- a/ft_str/ft_strcmp.c +++ b/ft_str/ft_strcmp.c @@ -6,7 +6,7 @@ /* By: ljiriste +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/01/13 14:11:31 by ljiriste #+# #+# */ -/* Updated: 2024/01/13 14:48:37 by ljiriste ### ########.fr */ +/* Updated: 2024/01/13 15:00:17 by ljiriste ### ########.fr */ /* */ /* ************************************************************************** */ @@ -20,8 +20,5 @@ int ft_strcmp(const char *s1, const char *s2) i = 0; while (s1[i] == s2[i] && s1[i] && s2[i]) ++i; - if (n > 0) - return ((unsigned char)s1[i] - (unsigned char)s2[i]); - else - return (0); + return ((unsigned char)s1[i] - (unsigned char)s2[i]); } diff --git a/inc/ft_str.h b/inc/ft_str.h index 6cd16e4..c3c13ab 100644 --- a/inc/ft_str.h +++ b/inc/ft_str.h @@ -6,7 +6,7 @@ /* By: ljiriste +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/12/09 11:50:15 by ljiriste #+# #+# */ -/* Updated: 2023/12/09 15:13:41 by ljiriste ### ########.fr */ +/* Updated: 2024/01/13 14:59:16 by ljiriste ### ########.fr */ /* */ /* ************************************************************************** */ @@ -19,6 +19,7 @@ size_t ft_strlen(const char *s); size_t ft_strlcpy(char *dst, const char *src, size_t size); size_t ft_strlcat(char *dst, const char *src, size_t size); char *ft_strncat_alloc(char **dest, const char *src, size_t n); +int ft_strcmp(const char *s1, const char *s2); int ft_strncmp(const char *s1, const char *s2, size_t n); char *ft_strchr(const char *s, int c); char *ft_strrchr(const char *s, int c);