Patch the issues of previous commit.
authorLukas Jiriste <ljiriste@student.42prague.com>
Sat, 13 Jan 2024 14:00:45 +0000 (15:00 +0100)
committerLukas Jiriste <ljiriste@student.42prague.com>
Sat, 13 Jan 2024 14:00:45 +0000 (15:00 +0100)
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.

Makefile
ft_str/ft_strcmp.c
inc/ft_str.h

index b66e514c9b4175cfac2ae29376412dbcd613e4f9..77db79ffb47b915d6ea08ddb81d369465ad186b1 100644 (file)
--- 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                             \
index 279108c6ab64730f6498de1ad4d4ec4c9e99b1e1..e20ddb587250538bcf1fb48ec9e8f36f59715d84 100644 (file)
@@ -6,7 +6,7 @@
 /*   By: ljiriste <ljiriste@student.42prague.com>   +#+  +:+       +#+        */
 /*                                                +#+#+#+#+#+   +#+           */
 /*   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]);
 }
index 6cd16e45780e62b5e6ac17e81ee699766891d332..c3c13ab7b4285dc0979dc8a036eca13f67e0c020 100644 (file)
@@ -6,7 +6,7 @@
 /*   By: ljiriste <ljiriste@student.42prague.com>   +#+  +:+       +#+        */
 /*                                                +#+#+#+#+#+   +#+           */
 /*   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);