Trying to trace the source of the segfault

I will breakdown the parser for a slight moment then relink it.
This commit is contained in:
Mthandazo Ndhlovu
2019-04-22 16:00:16 +02:00
parent a8b2e31701
commit c35deace58
15 changed files with 93 additions and 209 deletions

View File

@@ -6,12 +6,12 @@
# By: tmaze <tmaze@student.42.fr> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2018/04/07 12:47:06 by tmaze #+# #+# #
# Updated: 2019/04/18 09:18:00 by tmaze ### ########.fr #
# Updated: 2019/04/22 12:11:07 by mndhlovu ### ########.fr #
# #
#******************************************************************************#
CC = gcc
CCFLAGS = -Wall -Werror -Wextra
CCFLAGS = -Wall -Werror -Wextra -g
CCSTD =
NAME = libft.a

28
libft/ft_strcmp.c Normal file
View File

@@ -0,0 +1,28 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strcmp.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: tmaze <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2018/04/03 15:38:27 by tmaze #+# #+# */
/* Updated: 2019/04/22 10:46:05 by mndhlovu ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
int ft_strcmp(const char *s1, const char *s2)
{
int i;
int diff;
i = 1;
diff = (unsigned char)s1[0] - (unsigned char)s2[0];
while (diff == 0 && s1[i - 1] && s2[i - 1])
{
diff = (unsigned char)s1[i] - (unsigned char)s2[i];
i++;
}
return (diff);
}

View File

@@ -3,26 +3,22 @@
/* ::: :::::::: */
/* ft_strcmp.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: tmaze <marvin@42.fr> +#+ +:+ +#+ */
/* By: mndhlovu <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2018/04/03 15:38:27 by tmaze #+# #+# */
/* Updated: 2018/04/08 15:30:24 by tmaze ### ########.fr */
/* Created: 2018/11/07 17:33:42 by mndhlovu #+# #+# */
/* Updated: 2018/11/09 17:56:30 by mndhlovu ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
#include <string.h>
int ft_strcmp(const char *s1, const char *s2)
int ft_strcmp(const char *s1, const char *s2)
{
int i;
int diff;
size_t len;
i = 1;
diff = (unsigned char)s1[0] - (unsigned char)s2[0];
while (diff == 0 && s1[i - 1] && s2[i - 1])
{
diff = (unsigned char)s1[i] - (unsigned char)s2[i];
i++;
}
return (diff);
len = 0;
while (s1[len] && s2[len] && s1[len] == s2[len])
len++;
return ((unsigned char)s1[len] - (unsigned char)s2[len]);
}