libft rendu norm fixes and moulitest fixes are here

This commit is contained in:
Jack Halford 2016-11-03 17:57:17 +01:00
parent 26652ca579
commit 8b89d3cd49
53 changed files with 696 additions and 107 deletions

View file

@ -1,13 +1,22 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_isalnum.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/03 14:56:18 by jhalford #+# #+# */
/* Updated: 2016/11/03 15:31:33 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
int ft_isalnum(int c)
{
unsigned char a;
a = (unsigned char)c;
if ((a >= 'a' && a <= 'z')
|| (a >= 'A' && a <= 'Z')
|| (a >= '0' && a <= '9'))
return (a);
if ((c >= 'a' && c <= 'z')
|| (c >= 'A' && c <= 'Z')
|| (c >= '0' && c <= '9'))
return (c);
return (0);
}

View file

@ -1,11 +1,20 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_isalpha.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/03 14:56:24 by jhalford #+# #+# */
/* Updated: 2016/11/03 15:32:00 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
int ft_isalpha(int c)
{
unsigned char a;
a = (unsigned char)c;
if ((a >= 'a' && a <= 'z') || (a >= 'A' && a <= 'Z'))
return (a);
if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'))
return (c);
return (0);
}

View file

@ -1,11 +1,20 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_isascii.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/03 14:56:28 by jhalford #+# #+# */
/* Updated: 2016/11/03 15:35:42 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
int ft_isascii(int c)
{
unsigned char a;
a = (unsigned char)c;
if (a >= 0 && a <= 127)
return (a);
if (c >= 0 && c <= 127)
return (1);
return (0);
}

View file

@ -1,3 +1,15 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_isdigit.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/03 14:56:33 by jhalford #+# #+# */
/* Updated: 2016/11/03 14:56:34 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
int ft_isdigit(int c)

View file

@ -1,11 +1,20 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_isprint.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/03 14:56:38 by jhalford #+# #+# */
/* Updated: 2016/11/03 15:32:40 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
int ft_isprint(int c)
{
unsigned char a;
a = (unsigned char)c;
if (a >= 32 && a <= 126)
return (a);
if (c >= 32 && c <= 126)
return (c);
return (0);
}

View file

@ -1,11 +1,20 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_tolower.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/03 14:58:46 by jhalford #+# #+# */
/* Updated: 2016/11/03 15:24:09 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
int ft_toupper(int c)
int ft_tolower(int c)
{
unsigned char a;
a = (unsigned char)c;
if (a >= 'A' && a <= 'Z')
return (a + 32);
return (a);
if (c >= 'A' && c <= 'Z')
return (c + 32);
return (c);
}

View file

@ -1,11 +1,20 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_toupper.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/03 14:53:58 by jhalford #+# #+# */
/* Updated: 2016/11/03 15:24:40 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
int ft_toupper(int c)
{
unsigned char a;
a = (unsigned char)c;
if (a >= 'a' && a <= 'z')
return (a - 32);
return (a);
if (c >= 'a' && c <= 'z')
return (c - 32);
return (c);
}

22
libft/src/lst/ft_lstadd.c Normal file
View file

@ -0,0 +1,22 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_lstadd.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/03 14:57:13 by jhalford #+# #+# */
/* Updated: 2016/11/03 14:57:13 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void ft_lstadd(t_list **alst, t_list *new)
{
if (new)
{
new->next = *alst;
*alst = new;
}
}

20
libft/src/lst/ft_lstdel.c Normal file
View file

@ -0,0 +1,20 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_lstdel.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/03 15:18:57 by jhalford #+# #+# */
/* Updated: 2016/11/03 16:40:21 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void ft_lstdel(t_list **alst, void (*del)(void *, size_t))
{
if ((*alst)->next)
ft_lstdel(&(*alst)->next, del);
ft_lstdelone(&(*alst), del);
}

View file

@ -1,3 +1,15 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_lstdelone.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/03 14:57:15 by jhalford #+# #+# */
/* Updated: 2016/11/03 15:15:51 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void ft_lstdelone(t_list **alst, void (*del)(void *, size_t))

View file

@ -1,3 +1,15 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_lsteadd.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/03 14:57:17 by jhalford #+# #+# */
/* Updated: 2016/11/03 14:57:18 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void ft_lsteadd(t_list **alst, t_list *new)
@ -5,7 +17,6 @@ void ft_lsteadd(t_list **alst, t_list *new)
t_list *lst;
lst = *alst;
new->next = NULL;
if (lst)
{
while (lst->next)

View file

@ -1,3 +1,15 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_lstiter.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/03 14:57:19 by jhalford #+# #+# */
/* Updated: 2016/11/03 14:57:19 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void ft_lstiter(t_list *lst, void (*f)(t_list *elem))

View file

@ -1,5 +1,33 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_lstmap.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/03 14:57:21 by jhalford #+# #+# */
/* Updated: 2016/11/03 16:40:39 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
static void ft_lsteadd(t_list **alst, t_list *new)
{
t_list *lst;
lst = *alst;
new->next = NULL;
if (lst)
{
while (lst->next)
lst = lst->next;
lst->next = new;
}
else
*alst = new;
}
t_list *ft_lstmap(t_list *lst, t_list *(*f)(t_list *elem))
{
t_list *out;
@ -9,7 +37,6 @@ t_list *ft_lstmap(t_list *lst, t_list *(*f)(t_list *elem))
while (lst)
{
elem = (*f)(lst);
if (elem)
elem = ft_lstnew(elem->content, elem->content_size);
ft_lsteadd(&out, elem);
lst = lst->next;

View file

@ -1,3 +1,15 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_lstnew.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/03 14:57:24 by jhalford #+# #+# */
/* Updated: 2016/11/03 14:57:24 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
t_list *ft_lstnew(void const *content, size_t content_size)

View file

@ -1,5 +1,37 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_itoa.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/03 14:57:10 by jhalford #+# #+# */
/* Updated: 2016/11/03 15:27:16 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
static char *ft_strrev(char *str)
{
int len;
char tmp;
int i;
i = 0;
len = 0;
while (str[len] != '\0')
len++;
while (i < len / 2)
{
tmp = str[len - (i + 1)];
str[len - (i + 1)] = str[i];
str[i] = tmp;
i++;
}
return (str);
}
static size_t ft_size(int n)
{
size_t i;
@ -14,9 +46,11 @@ char *ft_itoa(int n)
{
int i;
char *str;
int neg;
i = 0;
str = ft_strnew(ft_size(n) + 1);
neg = FT_NEG(n) ? 1 : 0;
if (n == 0)
{
str[i++] = '0';
@ -28,7 +62,7 @@ char *ft_itoa(int n)
str[i++] = FT_ABS(n % 10) + '0';
n /= 10;
}
if (FT_NEG(n))
if (neg)
str[i++] = '-';
str[i] = '\0';
return (ft_strrev(str));

View file

@ -1,3 +1,15 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_bzero.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/03 14:56:08 by jhalford #+# #+# */
/* Updated: 2016/11/03 14:56:09 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void ft_bzero(void *s, size_t n)

View file

@ -1,3 +1,15 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memalloc.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/03 14:57:25 by jhalford #+# #+# */
/* Updated: 2016/11/03 14:57:25 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void *ft_memalloc(size_t size)

View file

@ -1,3 +1,15 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memccpy.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/03 14:57:26 by jhalford #+# #+# */
/* Updated: 2016/11/03 15:36:05 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void *ft_memccpy(void *dst, const void *src, int c, size_t n)
@ -8,7 +20,7 @@ void *ft_memccpy(void *dst, const void *src, int c, size_t n)
while (++i < n)
{
*(char *)dst++ = *(char *)src;
if (*(char *)src++ == (unsigned char)c)
if (*(char *)src++ == c)
return (dst);
}
return (NULL);

View file

@ -1,3 +1,15 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memchr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/03 14:57:28 by jhalford #+# #+# */
/* Updated: 2016/11/03 14:57:29 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void *ft_memchr(const void *s, int c, size_t n)

View file

@ -1,3 +1,15 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memcmp.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/03 14:57:30 by jhalford #+# #+# */
/* Updated: 2016/11/03 15:44:21 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
int ft_memcmp(const void *s1, const void *s2, size_t n)
@ -5,10 +17,10 @@ int ft_memcmp(const void *s1, const void *s2, size_t n)
size_t i;
int cmp;
i = 0;
i = -1;
while (++i < n)
{
cmp = ((unsigned char *)s1)[i] - ((unsigned char *)s2)[i];
cmp = *(unsigned char *)s1++ - *(unsigned char *)s2++;
if (cmp)
return (cmp);
}

View file

@ -1,3 +1,15 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memcpy.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/03 14:57:31 by jhalford #+# #+# */
/* Updated: 2016/11/03 14:57:32 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void *ft_memcpy(void *dst, const void *src, size_t n)

View file

@ -1,3 +1,15 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memdel.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/03 14:57:33 by jhalford #+# #+# */
/* Updated: 2016/11/03 14:57:33 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void ft_memdel(void **ap)

View file

@ -1,14 +1,31 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memmove.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/03 14:57:34 by jhalford #+# #+# */
/* Updated: 2016/11/03 15:53:48 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void *ft_memmove(void *dst, const void *src, size_t len)
{
char *srcc;
char *dstc;
size_t i;
i = 0;
while (i < len && (dst + i < src || dst + i > src + len))
{
((char *)dst)[i] = ((char *)src)[i];
i++;
}
i = -1;
srcc = (char *)src;
dstc = (char *)dst;
if (srcc < dstc)
while ((int)(--len) >= 0)
*(dstc + len) = *(srcc + len);
else
while (++i < len)
*(dstc + i) = *(srcc + i);
return (dst);
}

View file

@ -1,3 +1,15 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memset.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/03 14:57:36 by jhalford #+# #+# */
/* Updated: 2016/11/03 14:57:36 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void *ft_memset(void *b, int c, size_t len)

View file

@ -1,7 +1,18 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_putchar.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/03 14:57:37 by jhalford #+# #+# */
/* Updated: 2016/11/03 14:57:38 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
int ft_putchar(int c)
void ft_putchar(char c)
{
write(1, &c, 1);
return (0);
}

View file

@ -1,3 +1,15 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_putchar_fd.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/03 14:57:39 by jhalford #+# #+# */
/* Updated: 2016/11/03 14:57:39 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void ft_putchar_fd(char c, int fd)

View file

@ -1,3 +1,15 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_putendl.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/03 14:57:40 by jhalford #+# #+# */
/* Updated: 2016/11/03 14:57:41 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void ft_putendl(char const *s)

View file

@ -1,3 +1,15 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_putendl_fd.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/03 14:57:42 by jhalford #+# #+# */
/* Updated: 2016/11/03 14:57:42 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void ft_putendl_fd(char const *s, int fd)

View file

@ -1,3 +1,15 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_putstr_fd.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/03 14:57:48 by jhalford #+# #+# */
/* Updated: 2016/11/03 14:57:49 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void ft_putstr_fd(char const *s, int fd)

View file

@ -6,10 +6,12 @@
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/08/03 16:17:21 by jhalford #+# #+# */
/* Updated: 2016/08/07 18:10:10 by jhalford ### ########.fr */
/* Updated: 2016/11/03 15:13:04 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
static int ft_iswhitespace(char c)
{
if (c == ' ' || c == '\t' || c == '\n')

View file

@ -19,7 +19,7 @@ char *ft_strcat(char *s1, const char *s2)
size = ft_strlen(s1);
j = 0;
while (s2 && s2[j] != '\0')
while (s2[j] != '\0')
{
s1[size + j] = s2[j];
j++;

View file

@ -1,3 +1,15 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strchr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/03 14:57:53 by jhalford #+# #+# */
/* Updated: 2016/11/03 15:07:30 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strchr(const char *s, int c)

View file

@ -1,3 +1,15 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strclr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/03 14:57:54 by jhalford #+# #+# */
/* Updated: 2016/11/03 14:57:55 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void ft_strclr(char *s)

View file

@ -6,7 +6,7 @@
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/08/07 10:49:02 by jhalford #+# #+# */
/* Updated: 2016/08/25 17:06:34 by jhalford ### ########.fr */
/* Updated: 2016/11/03 16:08:51 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
@ -14,18 +14,10 @@
int ft_strcmp(const char *s1, const char *s2)
{
int cmp;
int i;
i = 0;
while (1)
{
cmp = (s1[i] - s2[i]);
if (s1[i] == '\0' && s2[i] == '\0')
return (cmp);
if (s1[i] == s2[i])
while (*(s1 + i) && *(s1 + i) == *(s2 + i))
i++;
else
return (cmp);
}
return (*((unsigned char*)s1 + i) - *((unsigned char*)s2 + i));
}

View file

@ -1,8 +1,19 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strdel.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/03 14:58:00 by jhalford #+# #+# */
/* Updated: 2016/11/03 14:58:00 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void ft_strdel(char **as)
{
if (as)
free(*as);
*as = NULL;
}

View file

@ -1,3 +1,15 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strdup.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/03 14:58:01 by jhalford #+# #+# */
/* Updated: 2016/11/03 14:58:02 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strdup(const char *s1)

View file

@ -1,6 +1,18 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strequ.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/03 14:58:04 by jhalford #+# #+# */
/* Updated: 2016/11/03 15:02:10 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
int ft_strequ(char const *s1, char const *s2)
{
return(ft_strcmp(s1, s2) == 0);
return (ft_strcmp(s1, s2) == 0);
}

View file

@ -1,3 +1,15 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_striter.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/03 14:58:13 by jhalford #+# #+# */
/* Updated: 2016/11/03 14:58:13 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void ft_striter(char *s, void (*f)(char *))

View file

@ -1,3 +1,15 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_striteri.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/03 14:58:15 by jhalford #+# #+# */
/* Updated: 2016/11/03 14:58:15 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void ft_striteri(char *s, void (*f)(unsigned int, char *))

View file

@ -1,3 +1,15 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strjoin.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/03 14:58:18 by jhalford #+# #+# */
/* Updated: 2016/11/03 14:58:18 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strjoin(char const *s1, char const *s2)

View file

@ -1,3 +1,15 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strlen.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/03 14:58:22 by jhalford #+# #+# */
/* Updated: 2016/11/03 14:58:23 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
size_t ft_strlen(const char *s)

View file

@ -1,3 +1,15 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strmap.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/03 14:58:24 by jhalford #+# #+# */
/* Updated: 2016/11/03 14:58:25 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strmap(char const *s, char (*f)(char))

View file

@ -1,3 +1,15 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strmapi.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/03 14:58:28 by jhalford #+# #+# */
/* Updated: 2016/11/03 14:58:29 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strmapi(char const *s, char (*f)(unsigned int, char))

View file

@ -6,7 +6,7 @@
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/08/07 10:57:07 by jhalford #+# #+# */
/* Updated: 2016/08/07 10:57:11 by jhalford ### ########.fr */
/* Updated: 2016/11/03 15:02:27 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
@ -14,7 +14,7 @@
char *ft_strncat(char *s1, const char *s2, size_t n)
{
size_t size;;
size_t size;
size_t j;
size = ft_strlen(s1);

View file

@ -6,7 +6,7 @@
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/08/07 10:49:12 by jhalford #+# #+# */
/* Updated: 2016/08/15 22:25:07 by jhalford ### ########.fr */
/* Updated: 2016/11/03 16:11:00 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
@ -14,20 +14,13 @@
int ft_strncmp(const char *s1, const char *s2, size_t n)
{
int cmp;
size_t i;
int i;
i = 0;
while (1)
{
cmp = (s1[i] - s2[i]);
if (i >= n - 1)
return (cmp);
if (s1[i] == '\0' && s2[i] == '\0')
return (cmp);
if (s1[i] == s2[i])
while (*(s1 + i) && *(s1 + i) == *(s2 + i) && i < (int)n)
i++;
if (i < (int)n)
return (*((unsigned char*)s1 + i) - *((unsigned char*)s2 + i));
else
return (cmp);
}
return (0);
}

View file

@ -1,6 +1,18 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strnequ.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/03 14:58:32 by jhalford #+# #+# */
/* Updated: 2016/11/03 15:02:36 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
int ft_strnequ(char const *s1, char const *s2, size_t n)
{
return(ft_strncmp(s1, s2, n) == 0);
return (ft_strncmp(s1, s2, n) == 0);
}

View file

@ -1,3 +1,15 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strnew.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/03 14:58:34 by jhalford #+# #+# */
/* Updated: 2016/11/03 14:58:35 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strnew(size_t size)

View file

@ -1,23 +1,34 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strnstr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/03 14:58:36 by jhalford #+# #+# */
/* Updated: 2016/11/03 16:34:42 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strnstr(const char *big, const char *little, size_t len)
{
size_t i;
size_t j;
char *a;
int j;
a = (char *)big;
i = 0;
while (a[i] != '\0' && i < len)
i = -1;
if (!*little)
return ((char *)big);
while (big[++i] && i < len)
{
j = 0;
while (a[i + j] == little[j])
while (big[i + j] == little[j] && i + j < len)
{
j++;
if (little[j] == '\0')
return (a + i);
if (!little[j])
return ((char *)big + i);
}
i++;
}
return (NULL);
}

View file

@ -1,3 +1,15 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strrchr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/03 14:58:38 by jhalford #+# #+# */
/* Updated: 2016/11/03 15:08:33 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strrchr(const char *s, int c)

View file

@ -1,3 +1,15 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strsplit.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/03 14:58:40 by jhalford #+# #+# */
/* Updated: 2016/11/03 15:00:19 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
static char **alloc_table(char **table, const char *str, char c)
@ -85,8 +97,6 @@ char **ft_strsplit(char const *s, char c)
{
char **table;
if (!s)
return (NULL);
table = 0;
table = alloc_table(table, s, c);
table = alloc_words(table, s, c);

View file

@ -6,7 +6,7 @@
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/08/07 10:48:35 by jhalford #+# #+# */
/* Updated: 2016/08/09 13:53:17 by jhalford ### ########.fr */
/* Updated: 2016/11/03 16:28:05 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
@ -14,22 +14,24 @@
char *ft_strstr(const char *big, const char *little)
{
size_t i;
size_t j;
int i;
int j;
char *a;
a = (char *)big;
i = 0;
while (a[i] != '\0')
if (!*little)
return (a);
while (a[i])
{
j = 0;
while (a[i + j] == little[j])
{
j++;
if (little[j] == '\0')
if (!little[j])
return (a + i);
}
i++;
}
return (0);
return (NULL);
}

View file

@ -1,3 +1,15 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strsub.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/03 14:58:43 by jhalford #+# #+# */
/* Updated: 2016/11/03 14:58:43 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strsub(char const *s, unsigned int start, size_t len)

View file

@ -1,3 +1,15 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strtrim.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/03 14:58:45 by jhalford #+# #+# */
/* Updated: 2016/11/03 14:58:45 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strtrim(char const *s)