This commit is contained in:
Camille Chauvet
2023-01-04 20:07:13 +01:00
parent b2dfb505bd
commit 909bb442b6
81 changed files with 500 additions and 77 deletions

39
libftx/extra/Makefile Normal file
View File

@ -0,0 +1,39 @@
:# **************************************************************************** #
# #
# ::: :::::::: #
# Makefile :+: :+: :+: #
# +:+ +:+ +:+ #
# By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2022/09/27 08:39:27 by cchauvet #+# #+# #
# Updated: 2023/01/04 20:00:03 by cchauvet ### ########.fr #
# #
# **************************************************************************** #
CC = clang
SRCS = ft_strcmp.c ft_strfjoin.c ft_strmerger.c
OBJS = $(SRCS:.c=.o)
NAME = extra.a
CFLAGS = -Wall -Werror -Wextra
%.o: %.c extra.h
$(CC) $(CFLAGS) -c -o $@ $<
all: $(NAME)
$(NAME): $(OBJS)
ar -rc $(NAME) $(OBJS)
clean:
rm -f $(OBJS) $(BOBJS)
fclean: clean
rm -f $(NAME)
re: fclean all
.PHONY: all bonus clean fclean re

BIN
libftx/extra/extra.a Normal file

Binary file not shown.

22
libftx/extra/extra.h Normal file
View File

@ -0,0 +1,22 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* extra.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/01/04 14:03:10 by cchauvet #+# #+# */
/* Updated: 2023/01/04 19:59:10 by cchauvet ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef EXTRA_H
# define EXTRA_H
# include <stdarg.h>
# include <stdlib.h>
# include "../libft/libft.h"
char *ft_strfjoin(char *s1, char *s2);
char *ft_strmerger(size_t arg_len, ...);
int ft_strcmp(char *s1, char *s2);
#endif

20
libftx/extra/ft_strcmp.c Normal file
View File

@ -0,0 +1,20 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strcmp.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/01/04 19:20:47 by cchauvet #+# #+# */
/* Updated: 2023/01/04 19:22:20 by cchauvet ### ########.fr */
/* */
/* ************************************************************************** */
#include "extra.h"
int ft_strcmp(char *s1, char *s2)
{
while (*s1 == *s2 && *s1 != '\0')
s1++;
return (*s1 - *s2);
}

BIN
libftx/extra/ft_strcmp.o Normal file

Binary file not shown.

View File

@ -0,0 +1,36 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strfjoin.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/01/04 14:06:04 by cchauvet #+# #+# */
/* Updated: 2023/01/04 14:17:40 by cchauvet ### ########.fr */
/* */
/* ************************************************************************** */
#include "extra.h"
char *ft_strfjoin(char *s1, char *s2)
{
size_t i;
size_t y;
char *out;
out = malloc((ft_strlen(s1) + ft_strlen(s2) + 1) * sizeof(char));
if (out == NULL)
return (NULL);
i = -1;
if (s1 != NULL)
while (s1[++i] != '\0')
out[i] = s1[i];
free(s1);
y = -1;
if (s2 != NULL)
while (s2[++y] != '\0')
out[i + y] = s2[y];
free(s2);
out[i + y] = '\0';
return (out);
}

BIN
libftx/extra/ft_strfjoin.o Normal file

Binary file not shown.

View File

@ -0,0 +1,33 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strmerger.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/01/04 15:09:15 by cchauvet #+# #+# */
/* Updated: 2023/01/04 15:24:17 by cchauvet ### ########.fr */
/* */
/* ************************************************************************** */
#include "extra.h"
char *ft_strmerger(size_t arg_len, ...)
{
va_list va;
char *out;
char *temp;
va_start(va, arg_len);
out = ft_strjoin(va_arg(va, char *), va_arg(va, char *));
while (arg_len > 2)
{
temp = ft_strjoin(out, va_arg(va, char *));
free(out);
if (temp == NULL)
return (NULL);
out = temp;
arg_len--;
}
return (out);
}

BIN
libftx/extra/ft_strmerger.o Normal file

Binary file not shown.