libupdate
This commit is contained in:
parent
90add1c1ec
commit
8e82c0edbe
8
getnextline/.gitignore
vendored
Normal file
8
getnextline/.gitignore
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
*.pdf
|
||||
*.o
|
||||
*.a
|
||||
LICENSE
|
||||
obj
|
||||
tests/tmp
|
||||
.git
|
||||
.ccls-cache
|
@ -1,12 +1,12 @@
|
||||
# **************************************************************************** #
|
||||
# #
|
||||
# .--. _ #
|
||||
# Makefile :+: :+: :+: #
|
||||
# Makefile |o_o || | #
|
||||
# |:_/ || |_ _ ___ __ #
|
||||
# By: djonker <djonker@student.codam.nl> // \ \ __| | | \ \/ / #
|
||||
# (| | )|_| |_| |> < #
|
||||
# Created: 2021/05/27 01:24:02 by djonker /'\_ _/`\__|\__,_/_/\_\ #
|
||||
# Updated: 2023/02/16 17:21:38 by houtworm ### ########.fr #
|
||||
# Updated: 2023/02/20 20:37:06 by houtworm \___)=(___/ #
|
||||
# #
|
||||
# **************************************************************************** #
|
||||
|
||||
@ -16,18 +16,13 @@ FC = -Wall -Werror -Wextra
|
||||
RM =rm -f
|
||||
SRC =src/get_next_line.c\
|
||||
src/get_next_line_utils.c
|
||||
BSRC = src/get_next_line_bonus.c\
|
||||
src/get_next_line_utils_bonus.c
|
||||
OBJ =$(SRC:src/%.c=obj/%.o)
|
||||
BOBJ =$(BSRC:src/%.c=obj/%.o)
|
||||
FAR =ar -crs
|
||||
B1 = -D BUFFER_SIZE=1
|
||||
B2 = -D BUFFER_SIZE=8
|
||||
B3 = -D BUFFER_SIZE=500
|
||||
B4 = -D BUFFER_SIZE=1000000
|
||||
|
||||
all: $(NAME)
|
||||
|
||||
bonus: $(NAME)
|
||||
|
||||
clean:
|
||||
@$(RM) -r obj
|
||||
@printf "\e[1;35mCleaned Object Files\n\e[0;00m"
|
||||
@ -39,7 +34,7 @@ fclean: clean
|
||||
re: fclean all
|
||||
|
||||
$(OBJ): $(SRC)
|
||||
@mkdir -p obj
|
||||
@mkdir -p $(dir $@)
|
||||
@printf "\e[1;34mBuilding $@\n\e[0;00m"
|
||||
@$(CC) $(CFLAGS) -c $(@:obj/%.o=src/%.c) -o $@
|
||||
|
||||
@ -47,14 +42,3 @@ $(NAME): $(OBJ)
|
||||
@printf "\e[1;36mCompiling get next line\e[0;00m\n"
|
||||
@$(FAR) $(NAME) $^ > /dev/null 2>&1
|
||||
@printf "\e[1;32mDone\e[0;00m\n"
|
||||
|
||||
$(BOBJ): $(BSRC)
|
||||
@mkdir -p obj
|
||||
@printf "\e[1;34mBuilding $@\n\e[0;00m"
|
||||
@$(CC) $(CFLAGS) -c $(@:obj/%.o=src/%.c) -o $@
|
||||
|
||||
bonus: $(BOBJ)
|
||||
@printf "\e[1;36mCompiling get next line\e[0;00m\n"
|
||||
@$(FAR) $(NAME) $^ > /dev/null 2>&1
|
||||
@printf "\e[1;32mDone\e[0;00m\n"
|
||||
|
||||
|
@ -1,12 +1,12 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* :::::::: */
|
||||
/* get_next_line.h :+: :+: :+: */
|
||||
/* get_next_line.h |o_o || | */
|
||||
/* +:+ */
|
||||
/* By: djonker <marvin@codam.nl> +#+ */
|
||||
/* +#+ */
|
||||
/* Created: 2020/12/19 06:09:11 by djonker #+# #+# */
|
||||
/* Updated: 2023/02/16 17:30:41 by houtworm ### ########.fr */
|
||||
/* Updated: 2021/05/27 03:41:54 by djonker \___)=(___/ */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -35,7 +35,7 @@ int blimit(int l, struct s_gnl *strct, char **line, char *t);;
|
||||
int nonewline(int l, struct s_gnl *strct, char **line);
|
||||
char *gnl_substr(char const *s, unsigned int start, size_t len);
|
||||
void *gnl_memcpy(void *dst, const void *src, size_t n);
|
||||
size_t gnl_strlen(const char *str);
|
||||
size_t gnl_strlen(char *str);
|
||||
void gnl_bzero(void *s, size_t n);
|
||||
char *gnl_strjoin(char const *s1, char const *s2);
|
||||
|
||||
|
@ -1,38 +0,0 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* :::::::: */
|
||||
/* get_next_line_bonus.h :+: :+: :+: */
|
||||
/* +:+ */
|
||||
/* By: djonker <marvin@codam.nl> +#+ */
|
||||
/* +#+ */
|
||||
/* Created: 2020/12/19 06:09:11 by djonker #+# #+# */
|
||||
/* Updated: 2023/02/16 17:28:49 by houtworm ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef GET_NEXT_LINE_BONUS_H
|
||||
# define GET_NEXT_LINE_BONUS_H
|
||||
|
||||
# include "get_next_line_bonus.h"
|
||||
# include <unistd.h>
|
||||
# include <stdlib.h>
|
||||
# include <fcntl.h>
|
||||
|
||||
# ifndef BUFFER_SIZE
|
||||
# define BUFFER_SIZE 300
|
||||
# endif
|
||||
|
||||
struct s_gnl
|
||||
{
|
||||
char b[BUFFER_SIZE + 1];
|
||||
int fd;
|
||||
};
|
||||
|
||||
int get_next_line(int fd, char **line);
|
||||
char *gnl_substr(char const *s, unsigned int start, size_t len);
|
||||
void *gnl_memcpy(void *dst, const void *src, size_t n);
|
||||
size_t gnl_strlen(char *str);
|
||||
void gnl_bzero(void *s, size_t n);
|
||||
char *gnl_strjoin(char const *s1, char const *s2);
|
||||
|
||||
#endif
|
@ -1,12 +1,12 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* :::::::: */
|
||||
/* get_next_line.c :+: :+: :+: */
|
||||
/* get_next_line.c |o_o || | */
|
||||
/* +:+ */
|
||||
/* By: djonker <marvin@codam.nl> +#+ */
|
||||
/* +#+ */
|
||||
/* Created: 2021/03/15 22:51:05 by djonker #+# #+# */
|
||||
/* Updated: 2023/02/16 17:30:09 by houtworm ### ########.fr */
|
||||
/* Updated: 2023/02/20 20:32:05 by houtworm \___)=(___/ */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
@ -1,114 +0,0 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* :::::::: */
|
||||
/* get_next_line_bonus.c :+: :+: :+: */
|
||||
/* +:+ */
|
||||
/* By: djonker <marvin@codam.nl> +#+ */
|
||||
/* +#+ */
|
||||
/* Created: 2021/03/15 22:51:05 by djonker #+# #+# */
|
||||
/* Updated: 2023/02/16 17:29:48 by houtworm ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "../get_next_line_bonus.h"
|
||||
|
||||
int findnewline(struct s_gnl *strct)
|
||||
{
|
||||
int l;
|
||||
|
||||
l = 0;
|
||||
while (strct->b[l] != '\0')
|
||||
{
|
||||
if (strct->b[l] == '\n')
|
||||
return (l + 1);
|
||||
l++;
|
||||
}
|
||||
return (-1);
|
||||
}
|
||||
|
||||
int newline(struct s_gnl *strct, char **line)
|
||||
{
|
||||
int l;
|
||||
char *t;
|
||||
|
||||
l = findnewline(strct);
|
||||
line[0] = gnl_substr((const char *)strct->b, 0, l - 1);
|
||||
if (line[0] == NULL)
|
||||
return (-1);
|
||||
t = gnl_substr((const char *)strct->b, l, BUFFER_SIZE - l);
|
||||
if (t == NULL)
|
||||
{
|
||||
free(line[0]);
|
||||
return (-1);
|
||||
}
|
||||
gnl_memcpy(strct->b, t, gnl_strlen(t));
|
||||
gnl_bzero(&strct->b[gnl_strlen(t)], BUFFER_SIZE - gnl_strlen(t));
|
||||
free(t);
|
||||
return (1);
|
||||
}
|
||||
|
||||
int blimit(int l, struct s_gnl *strct, char **line, char *t)
|
||||
{
|
||||
char *f;
|
||||
|
||||
l = get_next_line(strct->fd, line);
|
||||
if (l == 1 || l == 0)
|
||||
{
|
||||
f = line[0];
|
||||
line[0] = gnl_strjoin(t, line[0]);
|
||||
free (f);
|
||||
}
|
||||
free(t);
|
||||
if (line[0] == NULL)
|
||||
return (-1);
|
||||
return (l);
|
||||
}
|
||||
|
||||
int nonewline(int l, struct s_gnl *strct, char **line)
|
||||
{
|
||||
char *t;
|
||||
|
||||
t = gnl_substr((const char *)strct->b, 0, gnl_strlen(strct->b));
|
||||
gnl_bzero(&strct->b[0], BUFFER_SIZE);
|
||||
l = read(strct->fd, strct->b, BUFFER_SIZE);
|
||||
if (l == -1 || t == NULL)
|
||||
{
|
||||
line[0] = NULL;
|
||||
return (-1);
|
||||
}
|
||||
if (l == BUFFER_SIZE || findnewline(strct) > -1)
|
||||
return (blimit(l, strct, line, t));
|
||||
line[0] = gnl_strjoin(t, strct->b);
|
||||
gnl_bzero(&strct->b, BUFFER_SIZE);
|
||||
free(t);
|
||||
if (line[0] == NULL)
|
||||
return (-1);
|
||||
return (0);
|
||||
}
|
||||
|
||||
int get_next_line(int fd, char **line)
|
||||
{
|
||||
static struct s_gnl strct[256];
|
||||
int l;
|
||||
|
||||
l = 0;
|
||||
if (!line)
|
||||
return (-1);
|
||||
if (fd < 0 || BUFFER_SIZE <= 0)
|
||||
{
|
||||
line[0] = NULL;
|
||||
return (-1);
|
||||
}
|
||||
strct[fd].b[BUFFER_SIZE] = '\0';
|
||||
strct[fd].fd = fd;
|
||||
if (strct[fd].b[0] == '\0')
|
||||
l = read(strct[fd].fd, strct[fd].b, BUFFER_SIZE);
|
||||
if (l == -1)
|
||||
{
|
||||
line[0] = NULL;
|
||||
return (-1);
|
||||
}
|
||||
if (findnewline(&strct[fd]) > -1)
|
||||
return (newline(&strct[fd], line));
|
||||
return (nonewline(l, &strct[fd], line));
|
||||
}
|
@ -6,13 +6,13 @@
|
||||
/* By: djonker <marvin@codam.nl> +#+ */
|
||||
/* +#+ */
|
||||
/* Created: 2021/04/05 07:45:24 by djonker #+# #+# */
|
||||
/* Updated: 2023/02/16 17:30:28 by houtworm ### ########.fr */
|
||||
/* Updated: 2023/02/07 00:54:10 by houtworm ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "../get_next_line.h"
|
||||
|
||||
size_t gnl_strlen(const char *str)
|
||||
size_t gnl_strlen(char *str)
|
||||
{
|
||||
size_t a;
|
||||
|
||||
|
@ -1,103 +0,0 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* :::::::: */
|
||||
/* get_next_line_utils_bonus.c :+: :+: :+: */
|
||||
/* +:+ */
|
||||
/* By: djonker <marvin@codam.nl> +#+ */
|
||||
/* +#+ */
|
||||
/* Created: 2021/04/05 07:45:24 by djonker #+# #+# */
|
||||
/* Updated: 2023/02/16 17:30:18 by houtworm ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "../get_next_line_bonus.h"
|
||||
|
||||
size_t gnl_strlen(char *str)
|
||||
{
|
||||
size_t a;
|
||||
|
||||
a = 0;
|
||||
while (*str)
|
||||
{
|
||||
a++;
|
||||
str++;
|
||||
}
|
||||
return (a);
|
||||
}
|
||||
|
||||
void gnl_bzero(void *s, size_t n)
|
||||
{
|
||||
char *p;
|
||||
|
||||
p = s;
|
||||
while (n)
|
||||
{
|
||||
*p = '\0';
|
||||
p++;
|
||||
n--;
|
||||
}
|
||||
}
|
||||
|
||||
void *gnl_memcpy(void *dst, const void *src, size_t n)
|
||||
{
|
||||
char *d;
|
||||
const char *s;
|
||||
long unsigned int i;
|
||||
|
||||
i = 0;
|
||||
d = dst;
|
||||
s = src;
|
||||
while (n > i)
|
||||
{
|
||||
d[i] = s[i];
|
||||
i++;
|
||||
}
|
||||
return (dst);
|
||||
}
|
||||
|
||||
char *gnl_strjoin(char const *s1, char const *s2)
|
||||
{
|
||||
int c1;
|
||||
int c2;
|
||||
int l1;
|
||||
int l2;
|
||||
char *r;
|
||||
|
||||
c1 = 0;
|
||||
c2 = 0;
|
||||
l1 = gnl_strlen((char *)s1);
|
||||
l2 = gnl_strlen((char *)s2);
|
||||
r = malloc(l1 + l2 + 1);
|
||||
if (r == NULL)
|
||||
return (r);
|
||||
while (c1 < l1)
|
||||
{
|
||||
r[c1] = s1[c1];
|
||||
c1++;
|
||||
}
|
||||
while (c2 < l2)
|
||||
{
|
||||
r[c1 + c2] = s2[c2];
|
||||
c2++;
|
||||
}
|
||||
r[c1 + c2] = '\0';
|
||||
return (r);
|
||||
}
|
||||
|
||||
char *gnl_substr(char const *s, unsigned int start, size_t len)
|
||||
{
|
||||
char *r;
|
||||
long unsigned int i;
|
||||
|
||||
i = 0;
|
||||
r = malloc(len + 1);
|
||||
if (r == NULL)
|
||||
return (NULL);
|
||||
while (len > i)
|
||||
{
|
||||
r[i] = s[i + start];
|
||||
i++;
|
||||
}
|
||||
r[i] = '\0';
|
||||
return (r);
|
||||
}
|
398
getnextline/test.sh
Executable file
398
getnextline/test.sh
Executable file
@ -0,0 +1,398 @@
|
||||
# **************************************************************************** #
|
||||
# #
|
||||
# .--. _ #
|
||||
# test.sh |o_o || | #
|
||||
# |:_/ || |_ _ ___ __ #
|
||||
# By: houtworm <codam@houtworm.net> // \ \ __| | | \ \/ / #
|
||||
# (| | )|_| |_| |> < #
|
||||
# Created: 2023/02/20 12:46:46 by houtworm /'\_ _/`\__|\__,_/_/\_\ #
|
||||
# Updated: 2023/03/06 09:04:17 by houtworm \___)=(___/ #
|
||||
# #
|
||||
# **************************************************************************** #
|
||||
|
||||
#!/bin/bash
|
||||
|
||||
# Vars and Init
|
||||
|
||||
PNAME=get_next_line.a
|
||||
SLEEP=1
|
||||
FAULTS=0
|
||||
VALGRIND=0
|
||||
which valgrind > /dev/null
|
||||
if [ $? -eq 0 ]
|
||||
then
|
||||
VALGRIND=1
|
||||
else
|
||||
printf "\n\e[1;31mInstall Valgrind for extra Memory Checking\e[0;00m\n"
|
||||
fi
|
||||
HEADLOC=$(find ./ -name '*line.h' | grep -v tests)
|
||||
mkdir -p tests/tmp
|
||||
cp $HEADLOC tests/tmp/get_next_line.h
|
||||
if [ $1 == "old" ]
|
||||
then
|
||||
SRCPATH="tests/src/old/"
|
||||
FILPATH="tests/files/old/"
|
||||
elif [ $1 == "new" ]
|
||||
then
|
||||
SRCPATH="tests/src/new/"
|
||||
FILPATH="tests/files/new/"
|
||||
else
|
||||
printf "\e[1;31mPlease run the tester as follows\n./test.sh [VERSION] [SLEEPTIME]\nold returns an int while new returns the line\nexamples:\n./test.sh old\n./test.sh new\n./test.sh old 5\e[0;00m\n"
|
||||
rm -rf tests/tmp
|
||||
exit 1
|
||||
fi
|
||||
if [ $2 ]
|
||||
then
|
||||
SLEEP=$2
|
||||
fi
|
||||
|
||||
# Functions
|
||||
|
||||
getnextline()
|
||||
{
|
||||
gcc -D BUFFER_SIZE=$1 -o tests/tmp/binary ${SRCPATH}$2 get_next_line.a
|
||||
./tests/tmp/binary > tests/tmp/output
|
||||
diff ${FILPATH}$3 tests/tmp/output > /dev/null
|
||||
if [ $? -eq 0 ]
|
||||
then
|
||||
printf "\e[1;32mOutput OK\e[0;00m\n"
|
||||
else
|
||||
printf "\e[1;31mOutput is wrong\e[0;00m\n"
|
||||
FAULTS=$(($FAULTS+1))
|
||||
fi
|
||||
gcc -g -fsanitize=address -D BUFFER_SIZE=$1 -o tests/tmp/binary ${SRCPATH}$2 get_next_line.a
|
||||
./tests/tmp/binary > tests/tmp/output 2>tests/tmp/memorycheck
|
||||
diff ${FILPATH}$3 tests/tmp/output > /dev/null
|
||||
if [ $? -eq 0 ]
|
||||
then
|
||||
cat tests/tmp/memorycheck | grep "leaked" > /dev/null
|
||||
if [ $? -eq 1 ]
|
||||
then
|
||||
printf "\e[1;32mNo Leaks Fsanitize\e[0;00m\n"
|
||||
else
|
||||
printf "\n\e[1;31mKO found Leaks \e[0;00m\n"
|
||||
cat tests/tmp/memorycheck
|
||||
FAULTS=$(($FAULTS+1))
|
||||
fi
|
||||
else
|
||||
printf "\e[1;31mKO with fsanitize\e[0;00m\n"
|
||||
cat tests/tmp/memorycheck
|
||||
FAULTS=$(($FAULTS+1))
|
||||
fi
|
||||
if [ $VALGRIND -eq 1 ]
|
||||
then
|
||||
gcc -o tests/tmp/binary ${SRCPATH}$2 get_next_line.a 2> /dev/null
|
||||
valgrind --leak-check=full ./tests/tmp/binary 2> tests/tmp/memorycheck > /dev/null
|
||||
cat tests/tmp/memorycheck | grep indirectly | grep "[123456789] bytes" > /dev/null
|
||||
if [ $? -eq 0 ]
|
||||
then
|
||||
printf "\n\e[1;31mLeaks Valgrind $1 $2\e[0;00m\n"
|
||||
cat tests/tmp/memorycheck
|
||||
FAULTS=$(($FAULTS+1))
|
||||
CURFUNERR=1
|
||||
else
|
||||
printf "\e[1;32mNo Leaks Valgrind\e[0;00m\n"
|
||||
fi
|
||||
cat tests/tmp/memorycheck | grep definitely | grep "[123456789] bytes" > /dev/null
|
||||
if [ $? -eq 0 ]
|
||||
then
|
||||
printf "\n\e[1;31mLeaks Valgrind $1 $2\e[0;00m\n"
|
||||
cat tests/tmp/memorycheck
|
||||
FAULTS=$(($FAULTS+1))
|
||||
CURFUNERR=1
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
checkfile()
|
||||
{
|
||||
ls $1 2> /dev/null | grep $1 > /dev/null
|
||||
if [ $? -ne $2 ]
|
||||
then
|
||||
printf "\e[1;31mMakefile does not create $1\e[0;00m\n"
|
||||
rm -rf tests/tmp
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
searchobj()
|
||||
{
|
||||
FILES=$(find ./ -name '*.o' | wc -l)
|
||||
if [ $1 -eq 0 ]
|
||||
then
|
||||
if [ $FILES -ne 0 ]
|
||||
then
|
||||
printf "\e[1;31mObject files found after clean\e[0;00m\n"
|
||||
FAULTS=$(($FAULTS+1))
|
||||
fi
|
||||
fi
|
||||
if [ $1 -eq 1 ]
|
||||
then
|
||||
if [ $FILES -eq 0 ]
|
||||
then
|
||||
printf "\e[1;31mObject files not found after make\e[0;00m\n"
|
||||
FAULTS=$(($FAULTS+1))
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
checkrule()
|
||||
{
|
||||
make $1 > /dev/null 2>&1
|
||||
if [ $? -eq 2 ]
|
||||
then
|
||||
printf "\e[1;31mMissing rule $1\e[0;00m\n"
|
||||
FAULTS=$(($FAULTS+1))
|
||||
fi
|
||||
}
|
||||
|
||||
relinkcheck()
|
||||
{
|
||||
make $1 2>&1 | grep -v Nothing > tests/tmp/relink && cat tests/tmp/relink | grep -v directory > /dev/null
|
||||
if [ $? -eq 0 ]
|
||||
then
|
||||
printf "\n\e[1;31mMakefile relinks\e\n[0;00m"
|
||||
cat tests/tmp/relink
|
||||
FAULTS=$(($FAULTS+1))
|
||||
else
|
||||
printf "\e[1;32mMakefile OK\n\e[0;00m"
|
||||
fi
|
||||
}
|
||||
|
||||
# Tests
|
||||
|
||||
# Test 1
|
||||
printf "\e[1;36mTest 1 Checking all source with Norminette\e[0;00m\n"
|
||||
norminette $(find ./ -name '*.[ch]' | grep -v ./tests/) > tests/tmp/norm
|
||||
if [ $? -eq 1 ]
|
||||
then
|
||||
printf "\e[1;31mYour shit is not norm!\e[0;00m\n"
|
||||
cat tests/tmp/norm
|
||||
FAULTS=$(($FAULTS+1))
|
||||
else
|
||||
printf "\e[1;32mNorminette OK\e[0;00m\n"
|
||||
fi
|
||||
sleep $SLEEP
|
||||
|
||||
# Test 2
|
||||
printf "\e[1;36mTest 2 Checking all mandatory rules Makefile\e[0;00m\n"
|
||||
checkrule all
|
||||
checkfile $PNAME 0
|
||||
searchobj 1
|
||||
checkrule clean
|
||||
searchobj 0
|
||||
checkfile $PNAME 0
|
||||
checkrule $PNAME
|
||||
searchobj 1
|
||||
checkfile $PNAME 0
|
||||
checkrule fclean
|
||||
searchobj 0
|
||||
checkfile $PNAME 1
|
||||
checkrule re
|
||||
searchobj 1
|
||||
checkfile $PNAME 0
|
||||
if [ $FAULTS -eq 0 ]
|
||||
then
|
||||
printf "\e[1;32mMakefile rules OK\e[0;00m\n"
|
||||
fi
|
||||
sleep $SLEEP
|
||||
|
||||
# Test 3
|
||||
printf "\e[1;36mTest 3 Checking if Makefile relinks\e[0;00m\n"
|
||||
relinkcheck
|
||||
sleep $SLEEP
|
||||
|
||||
# Test 4
|
||||
printf "\e[1;36mTest 4 Basic test with Buffer size 0\e[0;00m\n"
|
||||
getnextline 0 maina.c basic
|
||||
sleep $SLEEP
|
||||
|
||||
# Test 5
|
||||
printf "\e[1;36mTest 5 Basic test with Buffer size 1\e[0;00m\n"
|
||||
getnextline 1 maina.c basic
|
||||
sleep $SLEEP
|
||||
|
||||
# Test 6
|
||||
printf "\e[1;36mTest 6 Basic test with Buffer size 2\e[0;00m\n"
|
||||
getnextline 2 maina.c basic
|
||||
sleep $SLEEP
|
||||
|
||||
# Test 7
|
||||
printf "\e[1;36mTest 7 Basic test with Buffer size 3\e[0;00m\n"
|
||||
getnextline 3 maina.c basic
|
||||
sleep $SLEEP
|
||||
|
||||
# Test 8
|
||||
printf "\e[1;36mTest 8 Basic test with Buffer size 4\e[0;00m\n"
|
||||
getnextline 4 maina.c basic
|
||||
sleep $SLEEP
|
||||
|
||||
# Test 9
|
||||
printf "\e[1;36mTest 9 Basic test with Buffer size 5\e[0;00m\n"
|
||||
getnextline 5 maina.c basic
|
||||
sleep $SLEEP
|
||||
|
||||
# Test 10
|
||||
printf "\e[1;36mTest 10 Basic test with Buffer size 6\e[0;00m\n"
|
||||
getnextline 6 maina.c basic
|
||||
sleep $SLEEP
|
||||
|
||||
# Test 11
|
||||
printf "\e[1;36mTest 11 Basic test with Buffer size 7\e[0;00m\n"
|
||||
getnextline 7 maina.c basic
|
||||
sleep $SLEEP
|
||||
|
||||
# Test 12
|
||||
printf "\e[1;36mTest 12 Basic test with Buffer size 8\e[0;00m\n"
|
||||
getnextline 8 maina.c basic
|
||||
sleep $SLEEP
|
||||
|
||||
# Test 13
|
||||
printf "\e[1;36mTest 13 Basic test with Buffer size 9\e[0;00m\n"
|
||||
getnextline 9 maina.c basic
|
||||
sleep $SLEEP
|
||||
|
||||
# Test 14
|
||||
printf "\e[1;36mTest 14 Basic test with Buffer size 10\e[0;00m\n"
|
||||
getnextline 10 maina.c basic
|
||||
sleep $SLEEP
|
||||
|
||||
# Test 15
|
||||
printf "\e[1;36mTest 15 Basic test with Buffer size 100\e[0;00m\n"
|
||||
getnextline 100 maina.c basic
|
||||
sleep $SLEEP
|
||||
|
||||
# Test 16
|
||||
printf "\e[1;36mTest 16 Basic test with Buffer size 1000\e[0;00m\n"
|
||||
getnextline 1000 maina.c basic
|
||||
sleep $SLEEP
|
||||
|
||||
# Test 17
|
||||
printf "\e[1;36mTest 17 Basic test with Buffer size 10000\e[0;00m\n"
|
||||
getnextline 10000 maina.c basic
|
||||
sleep $SLEEP
|
||||
|
||||
# Test 18
|
||||
printf "\e[1;36mTest 18 Basic test with Buffer size 100000\e[0;00m\n"
|
||||
getnextline 100000 maina.c basic
|
||||
sleep $SLEEP
|
||||
|
||||
# Test 19
|
||||
printf "\e[1;36mTest 19 Basic test with Buffer size 1000000\e[0;00m\n"
|
||||
getnextline 1000000 maina.c basic
|
||||
sleep $SLEEP
|
||||
|
||||
# Test 20
|
||||
printf "\e[1;36mTest 20 Basic test with Buffer size 10000000\e[0;00m\n"
|
||||
getnextline 10000000 maina.c basic
|
||||
sleep $SLEEP
|
||||
|
||||
# Test 21
|
||||
printf "\e[1;36mTest 21 300.000 character line with buffer size 1\e[0;00m\n"
|
||||
getnextline 1 mainb.c extreme1
|
||||
sleep $SLEEP
|
||||
|
||||
# Test 22
|
||||
printf "\e[1;36mTest 22 300.000 character line with buffer size 100.000\e[0;00m\n"
|
||||
getnextline 100000 mainb.c extreme1
|
||||
sleep $SLEEP
|
||||
|
||||
# Test 23
|
||||
printf "\e[1;36mTest 23 300.000 empty lines with buffer size 1\e[0;00m\n"
|
||||
getnextline 1 mainc.c extreme2
|
||||
sleep $SLEEP
|
||||
|
||||
# Test 24
|
||||
printf "\e[1;36mTest 24 300.000 empty lines with buffer size 100.000\e[0;00m\n"
|
||||
getnextline 100000 mainc.c extreme2
|
||||
sleep $SLEEP
|
||||
|
||||
# Test 25
|
||||
printf "\e[1;36mTest 25 All unicode characters with buffer size 1\e[0;00m\n"
|
||||
getnextline 1 maine.c unicode
|
||||
sleep $SLEEP
|
||||
|
||||
# Test 26
|
||||
printf "\e[1;36mTest 26 All unicode characters with buffer size 100.000\e[0;00m\n"
|
||||
getnextline 100000 maine.c unicode
|
||||
sleep $SLEEP
|
||||
|
||||
# Test 27
|
||||
printf "\e[1;36mTest 27 Reading from stdin buffer size 1\e[0;00m\n"
|
||||
printf "Please type Hello, Press Enter and hit CTRL+D with every empty line\n"
|
||||
getnextline 1 mainf.c hello
|
||||
sleep $SLEEP
|
||||
|
||||
# Test 28
|
||||
printf "\e[1;36mTest 28 Reading from stdin buffer size 100.000\e[0;00m\n"
|
||||
printf "Please type Hello, Press Enter and hit CTRL+D with every empty line\n"
|
||||
getnextline 100000 mainf.c hello
|
||||
sleep $SLEEP
|
||||
|
||||
# Test 29
|
||||
find ./ -name '*bonus.h' | grep bonus > /dev/null
|
||||
if [ $? -eq 0 ]
|
||||
then
|
||||
HEADLOC=$(find ./ -name '*bonus.h')
|
||||
cp $HEADLOC tests/tmp/get_next_line.h
|
||||
fi
|
||||
printf "\e[1;36mTest 29 Checking if Makefile bonus rule exists\e[0;00m\n"
|
||||
make fclean > /dev/null
|
||||
make bonus >/dev/null 2>&1
|
||||
if [ $? -eq 2 ]
|
||||
then
|
||||
printf "\e[1;31mNo bonus? I am a little dissapointed...\e[0;00m\n"
|
||||
if [ $FAULTS -eq 0 ]
|
||||
then
|
||||
printf "\e[1;35mBut we got no errors, Congratulations\e[0;00m\n"
|
||||
make fclean > /dev/null
|
||||
rm -rf tests/tmp
|
||||
exit 0
|
||||
else
|
||||
printf "\e[1;31mAnd we got $FAULTS errors\nSo that's a bummer\e[0;00m\n"
|
||||
make fclean > /dev/null
|
||||
rm -rf tests/tmp
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
printf "\e[1;32mbonus rule OK\e[0;00m\n"
|
||||
sleep $SLEEP
|
||||
|
||||
# Test 30
|
||||
printf "\e[1;36mTest 30 Checking if Makefile relinks for bonus\e[0;00m\n"
|
||||
relinkcheck bonus
|
||||
sleep $SLEEP
|
||||
|
||||
# Test 31
|
||||
printf "\e[1;36mTest 31 Reading from 2 files at once buffer size 1\e[0;00m\n"
|
||||
getnextline 1 maind.c resd
|
||||
sleep $SLEEP
|
||||
|
||||
# Test 32
|
||||
printf "\e[1;36mTest 32 Reading from 2 files at once buffer size 100.000\e[0;00m\n"
|
||||
getnextline 100000 maind.c resd
|
||||
sleep $SLEEP
|
||||
|
||||
# Test 33
|
||||
printf "\e[1;36mTest 33 Reading from 5 files at once buffer size 1\e[0;00m\n"
|
||||
getnextline 1 maing.c resg
|
||||
sleep $SLEEP
|
||||
|
||||
# Test 34
|
||||
printf "\e[1;36mTest 34 Reading from 5 files at once buffer size 100.000\e[0;00m\n"
|
||||
getnextline 100000 maing.c resg
|
||||
sleep $SLEEP
|
||||
|
||||
# Conclusion
|
||||
if [ $FAULTS -eq 0 ]
|
||||
then
|
||||
printf "\e[1;35mwe got no errors, Congratulations\e[0;00m\n"
|
||||
else
|
||||
printf "\e[1;31mwe got $FAULTS errors\nSo that's a bummer\e[0;00m\n"
|
||||
make fclean > /dev/null
|
||||
rm -rf tests/tmp
|
||||
exit 1
|
||||
fi
|
||||
make fclean > /dev/null
|
||||
rm -rf tests/tmp
|
||||
exit 0
|
9
getnextline/tests/files/new/basic
Normal file
9
getnextline/tests/files/new/basic
Normal file
@ -0,0 +1,9 @@
|
||||
1 character on a line
|
||||
1
|
||||
1
|
||||
empty line
|
||||
|
||||
|
||||
3000 characters on a line
|
||||
123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890
|
||||
123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890
|
10
getnextline/tests/files/new/compare1
Normal file
10
getnextline/tests/files/new/compare1
Normal file
@ -0,0 +1,10 @@
|
||||
line 1
|
||||
line 3
|
||||
line 5
|
||||
line 7
|
||||
line 9
|
||||
line 11
|
||||
line 13
|
||||
line 15
|
||||
line 17
|
||||
line 19
|
10
getnextline/tests/files/new/compare2
Normal file
10
getnextline/tests/files/new/compare2
Normal file
@ -0,0 +1,10 @@
|
||||
line 2
|
||||
line 4
|
||||
line 6
|
||||
line 8
|
||||
line 10
|
||||
line 12
|
||||
line 14
|
||||
line 16
|
||||
line 18
|
||||
line 20
|
1
getnextline/tests/files/new/extreme1
Normal file
1
getnextline/tests/files/new/extreme1
Normal file
File diff suppressed because one or more lines are too long
306000
getnextline/tests/files/new/extreme2
Normal file
306000
getnextline/tests/files/new/extreme2
Normal file
File diff suppressed because it is too large
Load Diff
1
getnextline/tests/files/new/hello
Normal file
1
getnextline/tests/files/new/hello
Normal file
@ -0,0 +1 @@
|
||||
Hello
|
20
getnextline/tests/files/new/resd
Normal file
20
getnextline/tests/files/new/resd
Normal file
@ -0,0 +1,20 @@
|
||||
line 1
|
||||
line 2
|
||||
line 3
|
||||
line 4
|
||||
line 5
|
||||
line 6
|
||||
line 7
|
||||
line 8
|
||||
line 9
|
||||
line 10
|
||||
line 11
|
||||
line 12
|
||||
line 13
|
||||
line 14
|
||||
line 15
|
||||
line 16
|
||||
line 17
|
||||
line 18
|
||||
line 19
|
||||
line 20
|
306035
getnextline/tests/files/new/resg
Normal file
306035
getnextline/tests/files/new/resg
Normal file
File diff suppressed because one or more lines are too long
1
getnextline/tests/files/new/unicode
Normal file
1
getnextline/tests/files/new/unicode
Normal file
File diff suppressed because one or more lines are too long
10
getnextline/tests/files/old/basic
Normal file
10
getnextline/tests/files/old/basic
Normal file
@ -0,0 +1,10 @@
|
||||
<<1>>1 character on a line
|
||||
<<1>>1
|
||||
<<1>>1
|
||||
<<1>>empty line
|
||||
<<1>>
|
||||
<<1>>
|
||||
<<1>>3000 characters on a line
|
||||
<<1>>123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890
|
||||
<<1>>123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890
|
||||
<<0>>
|
2
getnextline/tests/files/old/extreme1
Normal file
2
getnextline/tests/files/old/extreme1
Normal file
File diff suppressed because one or more lines are too long
306001
getnextline/tests/files/old/extreme2
Normal file
306001
getnextline/tests/files/old/extreme2
Normal file
File diff suppressed because it is too large
Load Diff
2
getnextline/tests/files/old/hello
Normal file
2
getnextline/tests/files/old/hello
Normal file
@ -0,0 +1,2 @@
|
||||
<<1>>Hello
|
||||
<<0>>
|
22
getnextline/tests/files/old/resd
Normal file
22
getnextline/tests/files/old/resd
Normal file
@ -0,0 +1,22 @@
|
||||
<<1>>line 1
|
||||
<<1>>line 2
|
||||
<<1>>line 3
|
||||
<<1>>line 4
|
||||
<<1>>line 5
|
||||
<<1>>line 6
|
||||
<<1>>line 7
|
||||
<<1>>line 8
|
||||
<<1>>line 9
|
||||
<<1>>line 10
|
||||
<<1>>line 11
|
||||
<<1>>line 12
|
||||
<<1>>line 13
|
||||
<<1>>line 14
|
||||
<<1>>line 15
|
||||
<<1>>line 16
|
||||
<<1>>line 17
|
||||
<<1>>line 18
|
||||
<<1>>line 19
|
||||
<<1>>line 20
|
||||
<<0>>
|
||||
<<0>>
|
306035
getnextline/tests/files/old/resg
Normal file
306035
getnextline/tests/files/old/resg
Normal file
File diff suppressed because one or more lines are too long
2
getnextline/tests/files/old/unicode
Normal file
2
getnextline/tests/files/old/unicode
Normal file
File diff suppressed because one or more lines are too long
30
getnextline/tests/src/new/maina.c
Normal file
30
getnextline/tests/src/new/maina.c
Normal file
@ -0,0 +1,30 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* :::::::: */
|
||||
/* maina.c |o_o || | */
|
||||
/* +:+ */
|
||||
/* By: djonker <marvin@codam.nl> +#+ */
|
||||
/* +#+ */
|
||||
/* Created: 2021/02/15 03:43:05 by djonker #+# #+# */
|
||||
/* Updated: 2023/02/21 00:36:49 by houtworm \___)=(___/ */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "../../tmp/get_next_line.h"
|
||||
#include <stdio.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
int fd1;
|
||||
char *line;
|
||||
|
||||
line = "\n";
|
||||
fd1 = open("tests/files/new/basic", O_RDONLY);
|
||||
while (line)
|
||||
{
|
||||
line = get_next_line(fd1);
|
||||
printf("%s\n", line);
|
||||
free (line);
|
||||
}
|
||||
return (0);
|
||||
}
|
30
getnextline/tests/src/new/mainb.c
Normal file
30
getnextline/tests/src/new/mainb.c
Normal file
@ -0,0 +1,30 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* :::::::: */
|
||||
/* mainb.c |o_o || | */
|
||||
/* +:+ */
|
||||
/* By: djonker <marvin@codam.nl> +#+ */
|
||||
/* +#+ */
|
||||
/* Created: 2021/02/15 03:43:05 by djonker #+# #+# */
|
||||
/* Updated: 2023/02/21 00:36:03 by houtworm \___)=(___/ */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "../../tmp/get_next_line.h"
|
||||
#include <stdio.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
int fd1;
|
||||
char *line;
|
||||
|
||||
line = "\n";
|
||||
fd1 = open("tests/files/new/extreme1", O_RDONLY);
|
||||
while (line)
|
||||
{
|
||||
line = get_next_line(fd1);
|
||||
printf("%s\n", line);
|
||||
free(line);
|
||||
}
|
||||
return (0);
|
||||
}
|
30
getnextline/tests/src/new/mainc.c
Normal file
30
getnextline/tests/src/new/mainc.c
Normal file
@ -0,0 +1,30 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* :::::::: */
|
||||
/* mainc.c |o_o || | */
|
||||
/* +:+ */
|
||||
/* By: djonker <marvin@codam.nl> +#+ */
|
||||
/* +#+ */
|
||||
/* Created: 2021/02/15 03:43:05 by djonker #+# #+# */
|
||||
/* Updated: 2023/02/21 00:35:58 by houtworm \___)=(___/ */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "../../tmp/get_next_line.h"
|
||||
#include <stdio.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
int fd1;
|
||||
char *line;
|
||||
|
||||
line = "\n";
|
||||
fd1 = open("tests/files/new/extreme2", O_RDONLY);
|
||||
while (line)
|
||||
{
|
||||
line = get_next_line(fd1);
|
||||
printf("%s\n", line);
|
||||
free(line);
|
||||
}
|
||||
return (0);
|
||||
}
|
43
getnextline/tests/src/new/maind.c
Normal file
43
getnextline/tests/src/new/maind.c
Normal file
@ -0,0 +1,43 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* :::::::: */
|
||||
/* maind.c |o_o || | */
|
||||
/* +:+ */
|
||||
/* By: djonker <marvin@codam.nl> +#+ */
|
||||
/* +#+ */
|
||||
/* Created: 2021/02/15 03:43:05 by djonker #+# #+# */
|
||||
/* Updated: 2023/02/21 00:35:54 by houtworm \___)=(___/ */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "../../tmp/get_next_line.h"
|
||||
#include <stdio.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
int fd1;
|
||||
int fd2;
|
||||
char *line1;
|
||||
char *line2;
|
||||
|
||||
line1 = "\n";
|
||||
line2 = "\n";
|
||||
fd1 = open("tests/files/new/compare1", O_RDONLY);
|
||||
fd2 = open("tests/files/new/compare2", O_RDONLY);
|
||||
while (line1 || line2)
|
||||
{
|
||||
if (line1)
|
||||
{
|
||||
line1 = get_next_line(fd1);
|
||||
printf("%s\n", line1);
|
||||
free(line1);
|
||||
}
|
||||
if (line2)
|
||||
{
|
||||
line2 = get_next_line(fd2);
|
||||
printf("%s\n", line2);
|
||||
free(line2);
|
||||
}
|
||||
}
|
||||
return (0);
|
||||
}
|
30
getnextline/tests/src/new/maine.c
Normal file
30
getnextline/tests/src/new/maine.c
Normal file
@ -0,0 +1,30 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* :::::::: */
|
||||
/* maine.c |o_o || | */
|
||||
/* +:+ */
|
||||
/* By: djonker <marvin@codam.nl> +#+ */
|
||||
/* +#+ */
|
||||
/* Created: 2021/02/15 03:43:05 by djonker #+# #+# */
|
||||
/* Updated: 2023/02/23 15:00:31 by houtworm \___)=(___/ */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "../../tmp/get_next_line.h"
|
||||
#include <stdio.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
int fd1;
|
||||
char *line;
|
||||
|
||||
line = "\n";
|
||||
fd1 = open("tests/files/new/unicode", O_RDONLY);
|
||||
while (line)
|
||||
{
|
||||
line = get_next_line(fd1);
|
||||
printf("%s\n", line);
|
||||
free (line);
|
||||
}
|
||||
return (0);
|
||||
}
|
30
getnextline/tests/src/new/mainf.c
Normal file
30
getnextline/tests/src/new/mainf.c
Normal file
@ -0,0 +1,30 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* :::::::: */
|
||||
/* mainf.c |o_o || | */
|
||||
/* +:+ */
|
||||
/* By: djonker <marvin@codam.nl> +#+ */
|
||||
/* +#+ */
|
||||
/* Created: 2021/02/15 03:43:05 by djonker #+# #+# */
|
||||
/* Updated: 2023/02/21 00:35:34 by houtworm \___)=(___/ */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "../get_next_line.h"
|
||||
#include <stdio.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
int fd1;
|
||||
char *line;
|
||||
|
||||
line = "\n";
|
||||
fd1 = 0;
|
||||
while (line)
|
||||
{
|
||||
line = get_next_line(fd1);
|
||||
printf("%s\n", line);
|
||||
free(line);
|
||||
}
|
||||
return (0);
|
||||
}
|
50
getnextline/tests/src/new/maing.c
Normal file
50
getnextline/tests/src/new/maing.c
Normal file
@ -0,0 +1,50 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* :::::::: */
|
||||
/* maing.c |o_o || | */
|
||||
/* +:+ */
|
||||
/* By: djonker <marvin@codam.nl> +#+ */
|
||||
/* +#+ */
|
||||
/* Created: 2021/02/15 03:43:05 by djonker #+# #+# */
|
||||
/* Updated: 2023/03/01 01:41:42 by houtworm \___)=(___/ */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "../../tmp/get_next_line.h"
|
||||
#include <stdio.h>
|
||||
|
||||
char *printline(char *line, int fd)
|
||||
{
|
||||
line = get_next_line(fd);
|
||||
printf("%s\n", line);
|
||||
free(line);
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
int *fd[6];
|
||||
char *line[5];
|
||||
|
||||
fd[5] = 5;
|
||||
while (--fd[5] >= 0)
|
||||
*line[fd5] = "\n";
|
||||
fd[0] = open("tests/files/new/compare1", O_RDONLY);
|
||||
fd[1] = open("tests/files/new/basic", O_RDONLY);
|
||||
fd[2] = open("tests/files/new/extreme1", O_RDONLY);
|
||||
fd[3] = open("tests/files/new/compare2", O_RDONLY);
|
||||
fd[4] = open("tests/files/new/extreme2", O_RDONLY);
|
||||
while (line[0] || line[1] || line[2] || line[3] || line[4])
|
||||
{
|
||||
if (line[0])
|
||||
line[0] = printline(line[0], fd[0]);
|
||||
if (line[1])
|
||||
line[1] = printline(line[1], fd[1]);
|
||||
if (line[2])
|
||||
line[2] = printline(line[2], fd[2]);
|
||||
if (line[3])
|
||||
line[3] = printline(line[3], fd[3]);
|
||||
if (line[4])
|
||||
line[4] = printline(line[4], fd[4]);
|
||||
}
|
||||
return (0);
|
||||
}
|
31
getnextline/tests/src/old/maina.c
Normal file
31
getnextline/tests/src/old/maina.c
Normal file
@ -0,0 +1,31 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* :::::::: */
|
||||
/* maina.c |o_o || | */
|
||||
/* +:+ */
|
||||
/* By: djonker <marvin@codam.nl> +#+ */
|
||||
/* +#+ */
|
||||
/* Created: 2021/02/15 03:43:05 by djonker #+# #+# */
|
||||
/* Updated: 2023/02/21 00:42:59 by houtworm \___)=(___/ */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "../../tmp/get_next_line.h"
|
||||
#include <stdio.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
int fd1;
|
||||
int r1;
|
||||
char *line;
|
||||
|
||||
r1 = 1;
|
||||
fd1 = open("tests/files/new/basic", O_RDONLY);
|
||||
while (r1 > 0)
|
||||
{
|
||||
r1 = get_next_line(fd1, &line);
|
||||
printf("<<%d>>%s\n", r1, line);
|
||||
free(line);
|
||||
}
|
||||
return (0);
|
||||
}
|
31
getnextline/tests/src/old/mainb.c
Normal file
31
getnextline/tests/src/old/mainb.c
Normal file
@ -0,0 +1,31 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* :::::::: */
|
||||
/* mainb.c |o_o || | */
|
||||
/* +:+ */
|
||||
/* By: djonker <marvin@codam.nl> +#+ */
|
||||
/* +#+ */
|
||||
/* Created: 2021/02/15 03:43:05 by djonker #+# #+# */
|
||||
/* Updated: 2023/02/21 00:43:10 by houtworm \___)=(___/ */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "../../tmp/get_next_line.h"
|
||||
#include <stdio.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
int fd1;
|
||||
int r1;
|
||||
char *line;
|
||||
|
||||
r1 = 1;
|
||||
fd1 = open("tests/files/new/extreme1", O_RDONLY);
|
||||
while (r1 > 0)
|
||||
{
|
||||
r1 = get_next_line(fd1, &line);
|
||||
printf("<<%d>>%s\n", r1, line);
|
||||
free(line);
|
||||
}
|
||||
return (0);
|
||||
}
|
31
getnextline/tests/src/old/mainc.c
Normal file
31
getnextline/tests/src/old/mainc.c
Normal file
@ -0,0 +1,31 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* :::::::: */
|
||||
/* mainc.c |o_o || | */
|
||||
/* +:+ */
|
||||
/* By: djonker <marvin@codam.nl> +#+ */
|
||||
/* +#+ */
|
||||
/* Created: 2021/02/15 03:43:05 by djonker #+# #+# */
|
||||
/* Updated: 2023/02/21 00:43:21 by houtworm \___)=(___/ */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "../../tmp/get_next_line.h"
|
||||
#include <stdio.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
int fd1;
|
||||
int r1;
|
||||
char *line;
|
||||
|
||||
r1 = 1;
|
||||
fd1 = open("tests/files/new/extreme2", O_RDONLY);
|
||||
while (r1 > 0)
|
||||
{
|
||||
r1 = get_next_line(fd1, &line);
|
||||
printf("<<%d>>%s\n", r1, line);
|
||||
free(line);
|
||||
}
|
||||
return (0);
|
||||
}
|
42
getnextline/tests/src/old/maind.c
Normal file
42
getnextline/tests/src/old/maind.c
Normal file
@ -0,0 +1,42 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* :::::::: */
|
||||
/* maind.c |o_o || | */
|
||||
/* +:+ */
|
||||
/* By: djonker <marvin@codam.nl> +#+ */
|
||||
/* +#+ */
|
||||
/* Created: 2021/02/15 03:43:05 by djonker #+# #+# */
|
||||
/* Updated: 2023/03/01 01:24:29 by houtworm \___)=(___/ */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "../../tmp/get_next_line.h"
|
||||
#include <stdio.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
int fd[2];
|
||||
int r[2];
|
||||
char *line;
|
||||
|
||||
r[0] = 1;
|
||||
r[1] = 1;
|
||||
fd[0] = open("tests/files/new/compare1", O_RDONLY);
|
||||
fd[1] = open("tests/files/new/compare2", O_RDONLY);
|
||||
while (r[0] > 0 || r[1] > 0)
|
||||
{
|
||||
if (r[0] > 0)
|
||||
{
|
||||
r[0] = get_next_line(fd[0], &line);
|
||||
printf("<<%d>>%s\n", r[0], line);
|
||||
free(line);
|
||||
}
|
||||
if (r[1] > 0)
|
||||
{
|
||||
r[1] = get_next_line(fd[1], &line);
|
||||
printf("<<%d>>%s\n", r[1], line);
|
||||
free(line);
|
||||
}
|
||||
}
|
||||
return (0);
|
||||
}
|
31
getnextline/tests/src/old/maine.c
Normal file
31
getnextline/tests/src/old/maine.c
Normal file
@ -0,0 +1,31 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* :::::::: */
|
||||
/* maine.c |o_o || | */
|
||||
/* +:+ */
|
||||
/* By: djonker <marvin@codam.nl> +#+ */
|
||||
/* +#+ */
|
||||
/* Created: 2021/02/15 03:43:05 by djonker #+# #+# */
|
||||
/* Updated: 2023/02/23 15:00:34 by houtworm \___)=(___/ */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "../../tmp/get_next_line.h"
|
||||
#include <stdio.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
int fd1;
|
||||
int r1;
|
||||
char *line;
|
||||
|
||||
r1 = 1;
|
||||
fd1 = open("tests/files/new/unicode", O_RDONLY);
|
||||
while (r1 > 0)
|
||||
{
|
||||
r1 = get_next_line(fd1, &line);
|
||||
printf("<<%d>>%s\n", r1, line);
|
||||
free(line);
|
||||
}
|
||||
return (0);
|
||||
}
|
31
getnextline/tests/src/old/mainf.c
Normal file
31
getnextline/tests/src/old/mainf.c
Normal file
@ -0,0 +1,31 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* :::::::: */
|
||||
/* mainf.c |o_o || | */
|
||||
/* +:+ */
|
||||
/* By: djonker <marvin@codam.nl> +#+ */
|
||||
/* +#+ */
|
||||
/* Created: 2021/02/15 03:43:05 by djonker #+# #+# */
|
||||
/* Updated: 2023/02/21 00:44:00 by houtworm \___)=(___/ */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "../../tmp/get_next_line.h"
|
||||
#include <stdio.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
int fd1;
|
||||
int r1;
|
||||
char *line;
|
||||
|
||||
r1 = 1;
|
||||
fd1 = 0;
|
||||
while (r1 > 0)
|
||||
{
|
||||
r1 = get_next_line(fd1, &line);
|
||||
printf("<<%d>>%s\n", r1, line);
|
||||
free(line);
|
||||
}
|
||||
return (0);
|
||||
}
|
51
getnextline/tests/src/old/maing.c
Normal file
51
getnextline/tests/src/old/maing.c
Normal file
@ -0,0 +1,51 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* :::::::: */
|
||||
/* maing.c |o_o || | */
|
||||
/* +:+ */
|
||||
/* By: djonker <marvin@codam.nl> +#+ */
|
||||
/* +#+ */
|
||||
/* Created: 2021/02/15 03:43:05 by djonker #+# #+# */
|
||||
/* Updated: 2023/03/01 01:39:22 by houtworm \___)=(___/ */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "../../tmp/get_next_line.h"
|
||||
#include <stdio.h>
|
||||
|
||||
int printline(int fd, char *line)
|
||||
{
|
||||
int r;
|
||||
|
||||
r = get_next_line(fd, &line);
|
||||
printf("<<%d>>%s\n", r, line);
|
||||
free(line);
|
||||
return (r);
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
int fd[6];
|
||||
int r[5];
|
||||
char *line;
|
||||
|
||||
fd[5] = 5;
|
||||
while (--fd[5] >= 0)
|
||||
r[fd[5]] = 2;
|
||||
fd[0] = open("tests/files/new/compare1", O_RDONLY);
|
||||
fd[1] = open("tests/files/new/basic", O_RDONLY);
|
||||
fd[2] = open("tests/files/new/extreme1", O_RDONLY);
|
||||
fd[3] = open("tests/files/new/compare2", O_RDONLY);
|
||||
fd[4] = open("tests/files/new/extreme2", O_RDONLY);
|
||||
while (r[0] > 0 || r[1] > 0 || r[2] > 0 || r[3] > 0 || r[4] > 0)
|
||||
{
|
||||
fd[5] = 0;
|
||||
while (fd[5] < 5)
|
||||
{
|
||||
if (r[fd[5]] > 0)
|
||||
r[fd[5]] = printline(fd[fd[5]], line);
|
||||
fd[5]++;
|
||||
}
|
||||
}
|
||||
return (0);
|
||||
}
|
8
libft/.gitignore
vendored
Normal file
8
libft/.gitignore
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
*.pdf
|
||||
*.o
|
||||
*.a
|
||||
LICENSE
|
||||
obj
|
||||
tests/tmp
|
||||
.git
|
||||
.ccls-cache
|
@ -6,13 +6,13 @@
|
||||
# By: djonker <marvin@codam.nl> +#+ #
|
||||
# +#+ #
|
||||
# Created: 2020/10/27 15:02:02 by djonker #+# #+# #
|
||||
# Updated: 2023/02/17 02:39:13 by houtworm \___)=(___/ #
|
||||
# Updated: 2023/02/23 15:40:38 by houtworm \___)=(___/ #
|
||||
# #
|
||||
# **************************************************************************** #
|
||||
|
||||
NAME =libft.a
|
||||
CC =gcc
|
||||
FC =-Wall -Werror -Wextra# -fsanitize=address
|
||||
FC =-Wall -Werror -Wextra -fsanitize=address
|
||||
FAR =ar -rs
|
||||
RM =rm -f
|
||||
SRC =src/ft_atoi.c \
|
||||
@ -172,7 +172,7 @@ fclean: clean
|
||||
re: fclean all
|
||||
|
||||
$(COBJ): $(CSRC)
|
||||
@mkdir -p obj
|
||||
@mkdir -p $(dir $@)
|
||||
@printf "\e[1;34mBuilding $@\n\e[0;00m"
|
||||
@$(CC) $(CFLAGS) -c $(@:obj/%.o=src/%.c) -o $@
|
||||
|
||||
|
10
libft/Readme.md
Normal file
10
libft/Readme.md
Normal file
@ -0,0 +1,10 @@
|
||||
# Functions
|
||||
## striteri
|
||||
void ft_striteri(char *s, void (*f)(unsigned int, char*));
|
||||
|
||||
# Tester
|
||||
## general
|
||||
check for -Wall -Werror -Wextra
|
||||
Think of more edge cases for all functions
|
||||
## add tests extra
|
||||
check if function exists in .h and run the tests for that fucntion
|
@ -6,13 +6,13 @@
|
||||
/* By: djonker <marvin@codam.nl> +#+ */
|
||||
/* +#+ */
|
||||
/* Created: 2020/11/11 16:02:53 by djonker #+# #+# */
|
||||
/* Updated: 2023/02/17 02:56:08 by houtworm \___)=(___/ */
|
||||
/* Updated: 2023/03/05 20:30:31 by houtworm \___)=(___/ */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef LIBFT_H
|
||||
# define LIBFT_H
|
||||
# include <stdio.h>
|
||||
|
||||
# include <unistd.h>
|
||||
# include <stdlib.h>
|
||||
# include <stdarg.h>
|
||||
@ -47,7 +47,6 @@ int ft_toupper(int c);
|
||||
int ft_tolower(int c);
|
||||
void *ft_calloc(size_t count, size_t size);
|
||||
char *ft_strdup(const char *s);
|
||||
|
||||
char *ft_substr(char const *s, unsigned int start, size_t len);
|
||||
char *ft_strjoin(char const *s1, char const *s2);
|
||||
char *ft_strtrim(char const *s1, char const *set);
|
||||
@ -114,8 +113,6 @@ long long ft_atol(char *str);
|
||||
unsigned long long ft_atou(char *str);
|
||||
double ft_atof(char *str);
|
||||
long double ft_atodec(char *str);
|
||||
char *ft_itoa(int n);
|
||||
char *ft_itoa(int n);
|
||||
int ft_itob(int d);
|
||||
char *ft_itoba(unsigned long long d, size_t e);
|
||||
int ft_btoi(int i, int e);
|
||||
@ -161,7 +158,6 @@ char *ft_lftoa(long double n);
|
||||
int ft_ldeclen(long double n);
|
||||
int ft_islneg(long long n);
|
||||
char *ft_dtoa(long double n);
|
||||
int ft_cntarg(char **argv);
|
||||
int ft_isallbyte(char *str, char byte);
|
||||
char *ft_getpwd(char **envp, int slash);
|
||||
|
||||
|
@ -21,14 +21,13 @@ int ft_atoi(char *str)
|
||||
r = 0;
|
||||
c = 0;
|
||||
n = 1;
|
||||
if (str == NULL)
|
||||
return (0);
|
||||
while ((str[c] == 32) || (str[c] > 8 && str[c] < 14))
|
||||
c++;
|
||||
if (str[c] == '-' || str[c] == '+')
|
||||
{
|
||||
if (str[c] == '-')
|
||||
if (str[c++] == '-')
|
||||
n = -1;
|
||||
c++;
|
||||
}
|
||||
while (str[c] >= '0' && str[c] <= '9')
|
||||
{
|
||||
r = 10 * r + (str[c] - '0');
|
||||
|
@ -1,12 +1,12 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* :::::::: */
|
||||
/* ft_atou.c :+: :+: :+: */
|
||||
/* ft_atou.c |o_o || | */
|
||||
/* +:+ */
|
||||
/* By: djonker <marvin@codam.nl> +#+ */
|
||||
/* +#+ */
|
||||
/* Created: 2020/11/01 19:08:11 by djonker #+# #+# */
|
||||
/* Updated: 2023/02/07 00:36:46 by houtworm ### ########.fr */
|
||||
/* Updated: 2023/03/05 21:13:18 by houtworm \___)=(___/ */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -26,5 +26,6 @@ unsigned long long ft_atou(char *str)
|
||||
r = 10 * r + (str[c] - '0');
|
||||
c++;
|
||||
}
|
||||
free (str);
|
||||
return (r);
|
||||
}
|
||||
|
@ -1,12 +1,12 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* :::::::: */
|
||||
/* ft_bzero.c :+: :+: :+: */
|
||||
/* ft_bzero.c |o_o || | */
|
||||
/* +:+ */
|
||||
/* By: djonker <marvin@codam.nl> +#+ */
|
||||
/* +#+ */
|
||||
/* Created: 2020/11/01 08:35:25 by djonker #+# #+# */
|
||||
/* Updated: 2023/02/07 00:36:47 by houtworm ### ########.fr */
|
||||
/* Updated: 2023/02/22 02:01:25 by djonker \___)=(___/ */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -16,6 +16,8 @@ void ft_bzero(void *s, size_t n)
|
||||
{
|
||||
char *p;
|
||||
|
||||
if (!s || n <= 0)
|
||||
return ;
|
||||
p = s;
|
||||
while (n)
|
||||
{
|
||||
|
@ -1,12 +1,12 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* :::::::: */
|
||||
/* ft_calloc.c :+: :+: :+: */
|
||||
/* ft_calloc.c |o_o || | */
|
||||
/* +:+ */
|
||||
/* By: djonker <marvin@codam.nl> +#+ */
|
||||
/* +#+ */
|
||||
/* Created: 2020/11/01 21:20:32 by djonker #+# #+# */
|
||||
/* Updated: 2023/02/07 00:36:47 by houtworm ### ########.fr */
|
||||
/* Updated: 2023/02/25 16:18:01 by houtworm \___)=(___/ */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: houtworm <codam@houtworm.net> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/02/07 00:38:26 by houtworm #+# #+# */
|
||||
/* Updated: 2023/02/15 02:38:53 by djonker \___)=(___/ */
|
||||
/* Updated: 2023/02/21 01:43:17 by houtworm \___)=(___/ */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
@ -1,12 +1,12 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* :::::::: */
|
||||
/* ft_frearr.c |o_o || | */
|
||||
/* ft_frearr.c :+: :+: :+: */
|
||||
/* +:+ */
|
||||
/* By: djonker <marvin@codam.nl> +#+ */
|
||||
/* +#+ */
|
||||
/* Created: 2020/12/11 21:54:13 by djonker #+# #+# */
|
||||
/* Updated: 2023/02/19 19:37:54 by djonker \___)=(___/ */
|
||||
/* Updated: 2023/02/07 00:39:42 by houtworm ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: houtworm <codam@houtworm.net> // \ \ __| | | \ \/ / */
|
||||
/* (| | )|_| |_| |> < */
|
||||
/* Created: 2023/02/17 02:40:22 by houtworm /'\_ _/`\__|\__,_/_/\_\ */
|
||||
/* Updated: 2023/02/17 02:54:29 by houtworm \___)=(___/ */
|
||||
/* Updated: 2023/02/17 02:55:28 by houtworm \___)=(___/ */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
@ -1,12 +1,12 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_isallbyte.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: houtworm <codam@houtworm.net> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/02/15 17:08:40 by houtworm #+# #+# */
|
||||
/* Updated: 2023/02/15 17:08:45 by houtworm ### ########.fr */
|
||||
/* .--. _ */
|
||||
/* ft_isallbyte.c |o_o || | */
|
||||
/* |:_/ || |_ _ ___ __ */
|
||||
/* By: houtworm <codam@houtworm.net> // \ \ __| | | \ \/ / */
|
||||
/* (| | )|_| |_| |> < */
|
||||
/* Created: 2023/02/21 01:43:42 by houtworm /'\_ _/`\__|\__,_/_/\_\ */
|
||||
/* Updated: 2023/02/21 01:43:44 by houtworm \___)=(___/ */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
@ -1,12 +1,12 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* :::::::: */
|
||||
/* ft_itob.c :+: :+: :+: */
|
||||
/* ft_itob.c |o_o || | */
|
||||
/* +:+ */
|
||||
/* By: djonker <marvin@codam.nl> +#+ */
|
||||
/* +#+ */
|
||||
/* Created: 2021/01/04 04:42:54 by djonker #+# #+# */
|
||||
/* Updated: 2023/02/07 00:40:06 by houtworm ### ########.fr */
|
||||
/* Updated: 2023/03/07 05:07:51 by houtworm \___)=(___/ */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -28,5 +28,6 @@ int ft_itob(int d)
|
||||
s[i] = '\0';
|
||||
r = ft_revstr(s);
|
||||
i = ft_atoi(r);
|
||||
free(r);
|
||||
return (i);
|
||||
}
|
||||
|
@ -1,12 +1,12 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* :::::::: */
|
||||
/* ft_itoh.c :+: :+: :+: */
|
||||
/* ft_itoh.c |o_o || | */
|
||||
/* +:+ */
|
||||
/* By: djonker <marvin@codam.nl> +#+ */
|
||||
/* +#+ */
|
||||
/* Created: 2021/01/31 03:00:29 by djonker #+# #+# */
|
||||
/* Updated: 2023/02/07 00:40:09 by houtworm ### ########.fr */
|
||||
/* Updated: 2023/03/05 20:33:06 by houtworm \___)=(___/ */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
@ -1,12 +1,12 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* :::::::: */
|
||||
/* ft_itozh.c :+: :+: :+: */
|
||||
/* ft_itozh.c |o_o || | */
|
||||
/* +:+ */
|
||||
/* By: djonker <marvin@codam.nl> +#+ */
|
||||
/* +#+ */
|
||||
/* Created: 2021/01/31 03:00:29 by djonker #+# #+# */
|
||||
/* Updated: 2023/02/07 00:40:26 by houtworm ### ########.fr */
|
||||
/* Updated: 2023/03/07 05:15:26 by houtworm \___)=(___/ */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
@ -1,12 +1,12 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* :::::::: */
|
||||
/* ft_lstadd_back.c :+: :+: :+: */
|
||||
/* ft_lstadd_back.c |o_o || | */
|
||||
/* +:+ */
|
||||
/* By: djonker <marvin@codam.nl> +#+ */
|
||||
/* +#+ */
|
||||
/* Created: 2020/11/13 18:48:54 by djonker #+# #+# */
|
||||
/* Updated: 2023/02/07 00:40:30 by houtworm ### ########.fr */
|
||||
/* Updated: 2023/03/03 19:09:28 by houtworm \___)=(___/ */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -16,7 +16,7 @@ void ft_lstadd_back(t_list **lst, t_list *new)
|
||||
{
|
||||
t_list *l;
|
||||
|
||||
if (lst)
|
||||
if (lst && new)
|
||||
{
|
||||
if (*lst)
|
||||
{
|
||||
|
@ -1,12 +1,12 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* :::::::: */
|
||||
/* ft_lstadd_front.c :+: :+: :+: */
|
||||
/* ft_lstadd_front.c |o_o || | */
|
||||
/* +:+ */
|
||||
/* By: djonker <marvin@codam.nl> +#+ */
|
||||
/* +#+ */
|
||||
/* Created: 2020/11/13 04:38:37 by djonker #+# #+# */
|
||||
/* Updated: 2023/02/07 00:40:30 by houtworm ### ########.fr */
|
||||
/* Updated: 2023/03/03 16:12:15 by houtworm \___)=(___/ */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -14,7 +14,7 @@
|
||||
|
||||
void ft_lstadd_front(t_list **lst, t_list *new)
|
||||
{
|
||||
if (lst)
|
||||
if (lst && new)
|
||||
{
|
||||
if (*lst)
|
||||
new->next = *lst;
|
||||
|
@ -1,12 +1,12 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* :::::::: */
|
||||
/* ft_lstclear.c :+: :+: :+: */
|
||||
/* ft_lstclear.c |o_o || | */
|
||||
/* +:+ */
|
||||
/* By: djonker <marvin@codam.nl> +#+ */
|
||||
/* +#+ */
|
||||
/* Created: 2020/11/13 19:12:41 by djonker #+# #+# */
|
||||
/* Updated: 2023/02/07 00:40:30 by houtworm ### ########.fr */
|
||||
/* Updated: 2023/03/04 01:50:59 by houtworm \___)=(___/ */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -15,25 +15,15 @@
|
||||
void ft_lstclear(t_list **lst, void (*del)(void*))
|
||||
{
|
||||
t_list *t;
|
||||
int i;
|
||||
|
||||
i = 0;
|
||||
t = NULL;
|
||||
if (!del)
|
||||
if (lst)
|
||||
{
|
||||
while (t->next != NULL)
|
||||
{
|
||||
free(lst[i]);
|
||||
i++;
|
||||
}
|
||||
free(t);
|
||||
}
|
||||
if (!del || !lst || !*lst)
|
||||
return ;
|
||||
while (lst && *lst)
|
||||
while (*lst)
|
||||
{
|
||||
t = (*lst)->next;
|
||||
ft_lstdelone(*lst, del);
|
||||
*lst = t;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,12 +1,12 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* :::::::: */
|
||||
/* ft_lstiter.c :+: :+: :+: */
|
||||
/* ft_lstiter.c |o_o || | */
|
||||
/* +:+ */
|
||||
/* By: djonker <marvin@codam.nl> +#+ */
|
||||
/* +#+ */
|
||||
/* Created: 2020/11/13 19:15:47 by djonker #+# #+# */
|
||||
/* Updated: 2023/02/07 00:40:34 by houtworm ### ########.fr */
|
||||
/* Updated: 2023/03/04 15:30:35 by houtworm \___)=(___/ */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -14,7 +14,7 @@
|
||||
|
||||
void ft_lstiter(t_list *lst, void (*f)(void *))
|
||||
{
|
||||
if (!f)
|
||||
if (!f || lst == NULL)
|
||||
return ;
|
||||
while (lst)
|
||||
{
|
||||
|
@ -1,12 +1,12 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* :::::::: */
|
||||
/* ft_lstlast.c :+: :+: :+: */
|
||||
/* ft_lstlast.c |o_o || | */
|
||||
/* +:+ */
|
||||
/* By: djonker <marvin@codam.nl> +#+ */
|
||||
/* +#+ */
|
||||
/* Created: 2020/11/13 18:45:02 by djonker #+# #+# */
|
||||
/* Updated: 2023/02/07 00:40:34 by houtworm ### ########.fr */
|
||||
/* Updated: 2023/03/03 18:08:43 by houtworm \___)=(___/ */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
@ -1,12 +1,12 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* :::::::: */
|
||||
/* ft_lstmap.c :+: :+: :+: */
|
||||
/* ft_lstmap.c |o_o || | */
|
||||
/* +:+ */
|
||||
/* By: djonker <marvin@codam.nl> +#+ */
|
||||
/* +#+ */
|
||||
/* Created: 2020/11/13 19:30:13 by djonker #+# #+# */
|
||||
/* Updated: 2023/02/07 00:40:34 by houtworm ### ########.fr */
|
||||
/* Updated: 2023/03/04 16:07:56 by houtworm \___)=(___/ */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -20,7 +20,7 @@ t_list *ft_lstmap(t_list *lst, void *(*f)(void *), void (*del)(void *))
|
||||
|
||||
r = NULL;
|
||||
t = NULL;
|
||||
while (lst)
|
||||
while (lst && f)
|
||||
{
|
||||
if (f(lst->content))
|
||||
{
|
||||
|
@ -1,12 +1,12 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* :::::::: */
|
||||
/* ft_lstsize.c :+: :+: :+: */
|
||||
/* ft_lstsize.c |o_o || | */
|
||||
/* +:+ */
|
||||
/* By: djonker <marvin@codam.nl> +#+ */
|
||||
/* +#+ */
|
||||
/* Created: 2020/11/13 18:27:52 by djonker #+# #+# */
|
||||
/* Updated: 2023/02/07 00:40:35 by houtworm ### ########.fr */
|
||||
/* Updated: 2023/03/03 17:20:28 by houtworm \___)=(___/ */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: djonker <marvin@codam.nl> +#+ */
|
||||
/* +#+ */
|
||||
/* Created: 2020/11/01 08:38:54 by djonker #+# #+# */
|
||||
/* Updated: 2023/02/07 00:40:38 by houtworm ### ########.fr */
|
||||
/* Updated: 2023/02/24 20:52:37 by houtworm ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -18,6 +18,10 @@ void *ft_memccpy(void *dst, const void *src, int c, size_t n)
|
||||
unsigned const char *s;
|
||||
unsigned char u;
|
||||
|
||||
if (!dst || !src)
|
||||
return (NULL);
|
||||
if (u > ft_strlen(dst))
|
||||
u = ft_strlen(dst);
|
||||
d = dst;
|
||||
s = src;
|
||||
u = c;
|
||||
|
@ -1,12 +1,12 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* :::::::: */
|
||||
/* ft_memchr.c :+: :+: :+: */
|
||||
/* ft_memchr.c |o_o || | */
|
||||
/* +:+ */
|
||||
/* By: djonker <marvin@codam.nl> +#+ */
|
||||
/* +#+ */
|
||||
/* Created: 2020/11/01 08:35:56 by djonker #+# #+# */
|
||||
/* Updated: 2023/02/07 00:40:39 by houtworm ### ########.fr */
|
||||
/* Updated: 2023/02/27 05:12:02 by houtworm \___)=(___/ */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -17,6 +17,8 @@ void *ft_memchr(const void *s, int c, size_t n)
|
||||
unsigned char *p;
|
||||
unsigned char t;
|
||||
|
||||
if (!s)
|
||||
return (NULL);
|
||||
t = (unsigned char)c;
|
||||
p = (unsigned char *)s;
|
||||
while (n > 0)
|
||||
|
@ -1,12 +1,12 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* :::::::: */
|
||||
/* ft_memcmp.c :+: :+: :+: */
|
||||
/* ft_memcmp.c |o_o || | */
|
||||
/* +:+ */
|
||||
/* By: djonker <marvin@codam.nl> +#+ */
|
||||
/* +#+ */
|
||||
/* Created: 2020/11/01 08:41:32 by djonker #+# #+# */
|
||||
/* Updated: 2023/02/07 00:40:39 by houtworm ### ########.fr */
|
||||
/* Updated: 2023/02/28 15:22:59 by houtworm \___)=(___/ */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -17,6 +17,10 @@ int ft_memcmp(const void *s1, const void *s2, size_t n)
|
||||
const unsigned char *p1;
|
||||
const unsigned char *p2;
|
||||
|
||||
if (!s1 && !s2)
|
||||
return (0);
|
||||
if (!s1 || !s2)
|
||||
return (1);
|
||||
p1 = s1;
|
||||
p2 = s2;
|
||||
while (n)
|
||||
|
@ -1,12 +1,12 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* :::::::: */
|
||||
/* ft_memcpy.c :+: :+: :+: */
|
||||
/* ft_memcpy.c |o_o || | */
|
||||
/* +:+ */
|
||||
/* By: djonker <marvin@codam.nl> +#+ */
|
||||
/* +#+ */
|
||||
/* Created: 2020/11/11 16:13:52 by djonker #+# #+# */
|
||||
/* Updated: 2023/02/07 00:40:39 by houtworm ### ########.fr */
|
||||
/* Updated: 2023/03/01 18:06:11 by houtworm \___)=(___/ */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -18,16 +18,20 @@ void *ft_memcpy(void *dst, const void *src, size_t n)
|
||||
const char *s;
|
||||
long unsigned int i;
|
||||
|
||||
i = 0;
|
||||
if (!dst)
|
||||
return (dst);
|
||||
d = dst;
|
||||
s = src;
|
||||
if (dst != NULL || src != NULL)
|
||||
if (!src)
|
||||
{
|
||||
*d = '\0';
|
||||
return (dst);
|
||||
}
|
||||
s = src;
|
||||
i = 0;
|
||||
while (n > i)
|
||||
{
|
||||
d[i] = s[i];
|
||||
i++;
|
||||
}
|
||||
}
|
||||
return (dst);
|
||||
}
|
||||
|
@ -1,12 +1,12 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* :::::::: */
|
||||
/* ft_memmove.c :+: :+: :+: */
|
||||
/* ft_memmove.c |o_o || | */
|
||||
/* +:+ */
|
||||
/* By: djonker <marvin@codam.nl> +#+ */
|
||||
/* +#+ */
|
||||
/* Created: 2020/11/01 08:45:04 by djonker #+# #+# */
|
||||
/* Updated: 2023/02/07 00:40:39 by houtworm ### ########.fr */
|
||||
/* Updated: 2023/03/03 12:19:05 by houtworm \___)=(___/ */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -18,7 +18,7 @@ void *ft_memmove(void *dst, const void *src, size_t len)
|
||||
const char *s;
|
||||
int i;
|
||||
|
||||
if (dst == NULL && src == NULL)
|
||||
if (dst == NULL || src == NULL)
|
||||
return ((void *)dst);
|
||||
i = 0;
|
||||
d = dst;
|
||||
|
@ -1,12 +1,12 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* :::::::: */
|
||||
/* ft_memset.c :+: :+: :+: */
|
||||
/* ft_memset.c |o_o || | */
|
||||
/* +:+ */
|
||||
/* By: djonker <marvin@codam.nl> +#+ */
|
||||
/* +#+ */
|
||||
/* Created: 2020/11/01 08:42:45 by djonker #+# #+# */
|
||||
/* Updated: 2023/02/07 00:40:39 by houtworm ### ########.fr */
|
||||
/* Updated: 2023/02/28 20:13:47 by houtworm \___)=(___/ */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -16,6 +16,8 @@ void *ft_memset(void *s, int c, size_t n)
|
||||
{
|
||||
char *p;
|
||||
|
||||
if (!s)
|
||||
return (s);
|
||||
p = s;
|
||||
while (n > 0)
|
||||
{
|
||||
|
@ -1,12 +1,12 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* :::::::: */
|
||||
/* ft_putendl.c :+: :+: :+: */
|
||||
/* ft_putendl.c |o_o || | */
|
||||
/* +:+ */
|
||||
/* By: djonker <marvin@codam.nl> +#+ */
|
||||
/* +#+ */
|
||||
/* Created: 2020/11/13 04:00:47 by djonker #+# #+# */
|
||||
/* Updated: 2023/02/07 00:40:43 by houtworm ### ########.fr */
|
||||
/* Updated: 2023/02/23 20:14:17 by houtworm \___)=(___/ */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
@ -1,12 +1,12 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* :::::::: */
|
||||
/* ft_revstr.c :+: :+: :+: */
|
||||
/* ft_revstr.c |o_o || | */
|
||||
/* +:+ */
|
||||
/* By: djonker <marvin@codam.nl> +#+ */
|
||||
/* +#+ */
|
||||
/* Created: 2021/01/18 11:54:50 by djonker #+# #+# */
|
||||
/* Updated: 2023/02/07 00:40:48 by houtworm ### ########.fr */
|
||||
/* Updated: 2023/03/05 20:39:52 by houtworm \___)=(___/ */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -14,10 +14,11 @@
|
||||
|
||||
char *ft_revstr(char *s)
|
||||
{
|
||||
char r[1000];
|
||||
char *r;
|
||||
int is;
|
||||
int ir;
|
||||
|
||||
r = ft_calloc(8 * (ft_strlen(s) + 1), 1);
|
||||
is = ft_strlen(s) - 1;
|
||||
ir = 0;
|
||||
while (is >= 0)
|
||||
@ -28,5 +29,5 @@ char *ft_revstr(char *s)
|
||||
}
|
||||
r[ir] = '\0';
|
||||
s = r;
|
||||
return (s);
|
||||
return (r);
|
||||
}
|
||||
|
@ -1,12 +1,12 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* .--. _ */
|
||||
/* ft_strchr.c :+: :+: :+: */
|
||||
/* ft_strchr.c |o_o || | */
|
||||
/* |:_/ || |_ _ ___ __ */
|
||||
/* By: djonker <djonker@student.codam.nl> // \ \ __| | | \ \/ / */
|
||||
/* (| | )|_| |_| |> < */
|
||||
/* Created: 2022/11/22 13:34:05 by djonker /'\_ _/`\__|\__,_/_/\_\ */
|
||||
/* Updated: 2023/02/07 00:40:50 by houtworm ### ########.fr */
|
||||
/* Updated: 2023/03/01 06:08:13 by houtworm \___)=(___/ */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -14,6 +14,8 @@
|
||||
|
||||
char *ft_strchr(const char *s, int c)
|
||||
{
|
||||
if (!s)
|
||||
return (0);
|
||||
while (*s)
|
||||
{
|
||||
if (c == *s)
|
||||
|
@ -1,12 +1,12 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* :::::::: */
|
||||
/* ft_strjoin.c :+: :+: :+: */
|
||||
/* ft_strjoin.c |o_o || | */
|
||||
/* +:+ */
|
||||
/* By: djonker <marvin@codam.nl> +#+ */
|
||||
/* +#+ */
|
||||
/* Created: 2020/11/11 16:17:34 by djonker #+# #+# */
|
||||
/* Updated: 2023/02/07 00:40:50 by houtworm ### ########.fr */
|
||||
/* Updated: 2023/03/03 13:40:55 by houtworm \___)=(___/ */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -18,8 +18,10 @@ char *ft_strjoin(char const *s1, char const *s2)
|
||||
int c2;
|
||||
char *r;
|
||||
|
||||
c1 = 0;
|
||||
c2 = 0;
|
||||
c1 = -1;
|
||||
c2 = -1;
|
||||
if (s1 == NULL && s2 == NULL)
|
||||
return (NULL);
|
||||
if (s1 == NULL)
|
||||
return (ft_malstr((char *)s2, '\0'));
|
||||
if (s2 == NULL)
|
||||
@ -27,16 +29,10 @@ char *ft_strjoin(char const *s1, char const *s2)
|
||||
r = ft_calloc(ft_strlen((char *)s1) + ft_strlen((char *)s2) + 1, 1);
|
||||
if (r == NULL)
|
||||
return (r);
|
||||
while (c1 < (int)ft_strlen((char *)s1))
|
||||
{
|
||||
while (++c1 < (int)ft_strlen((char *)s1))
|
||||
r[c1] = s1[c1];
|
||||
c1++;
|
||||
}
|
||||
while (c2 < (int)ft_strlen((char *)s2))
|
||||
{
|
||||
while (++c2 < (int)ft_strlen((char *)s2))
|
||||
r[c1 + c2] = s2[c2];
|
||||
c2++;
|
||||
}
|
||||
r[c1 + c2] = '\0';
|
||||
return (r);
|
||||
}
|
||||
|
@ -1,12 +1,12 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* :::::::: */
|
||||
/* ft_strlcat.c :+: :+: :+: */
|
||||
/* ft_strlcat.c |o_o || | */
|
||||
/* +:+ */
|
||||
/* By: djonker <marvin@codam.nl> +#+ */
|
||||
/* +#+ */
|
||||
/* Created: 2020/11/01 09:55:53 by djonker #+# #+# */
|
||||
/* Updated: 2023/02/07 00:40:51 by houtworm ### ########.fr */
|
||||
/* Updated: 2023/03/03 13:56:46 by houtworm \___)=(___/ */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -23,6 +23,8 @@ size_t ft_strlcat(char *dst, const char *src, size_t dstsize)
|
||||
sl = 0;
|
||||
if (dstsize == 0)
|
||||
return (r);
|
||||
if (!src)
|
||||
return (dl);
|
||||
if (dstsize < dl)
|
||||
r = r + dstsize;
|
||||
else
|
||||
|
@ -1,12 +1,12 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* :::::::: */
|
||||
/* ft_strncmp.c :+: :+: :+: */
|
||||
/* ft_strncmp.c |o_o || | */
|
||||
/* +:+ */
|
||||
/* By: djonker <marvin@codam.nl> +#+ */
|
||||
/* +#+ */
|
||||
/* Created: 2020/11/01 19:09:01 by djonker #+# #+# */
|
||||
/* Updated: 2023/02/07 00:41:12 by houtworm ### ########.fr */
|
||||
/* Updated: 2023/03/03 14:28:11 by houtworm \___)=(___/ */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -14,6 +14,10 @@
|
||||
|
||||
int ft_strncmp(char *s1, char *s2, unsigned int n)
|
||||
{
|
||||
if (s1 == NULL && s2 == NULL)
|
||||
return (0);
|
||||
if (s1 == NULL || s2 == NULL)
|
||||
return (1);
|
||||
if (n == 0)
|
||||
return (0);
|
||||
while (n)
|
||||
|
@ -1,12 +1,12 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* :::::::: */
|
||||
/* ft_strnstr.c :+: :+: :+: */
|
||||
/* ft_strnstr.c |o_o || | */
|
||||
/* +:+ */
|
||||
/* By: djonker <marvin@codam.nl> +#+ */
|
||||
/* +#+ */
|
||||
/* Created: 2020/11/11 16:14:33 by djonker #+# #+# */
|
||||
/* Updated: 2023/02/07 00:41:13 by houtworm ### ########.fr */
|
||||
/* Updated: 2023/03/03 14:31:13 by houtworm \___)=(___/ */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -17,6 +17,8 @@ char *ft_strnstr(const char *h, const char *n, size_t len)
|
||||
long unsigned int ih;
|
||||
int in;
|
||||
|
||||
if (h == NULL || n == NULL)
|
||||
return (NULL);
|
||||
ih = 0;
|
||||
if (!*n)
|
||||
return ((char *)&h[ih]);
|
||||
|
@ -1,12 +1,12 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* :::::::: */
|
||||
/* ft_strrchr.c :+: :+: :+: */
|
||||
/* ft_strrchr.c |o_o || | */
|
||||
/* +:+ */
|
||||
/* By: djonker <marvin@codam.nl> +#+ */
|
||||
/* +#+ */
|
||||
/* Created: 2020/11/11 16:14:50 by djonker #+# #+# */
|
||||
/* Updated: 2023/02/07 00:41:13 by houtworm ### ########.fr */
|
||||
/* Updated: 2023/03/03 14:52:43 by houtworm \___)=(___/ */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -16,13 +16,13 @@ char *ft_strrchr(const char *s, int c)
|
||||
{
|
||||
char *p;
|
||||
|
||||
p = (char *) 0;
|
||||
while (1)
|
||||
if (!s)
|
||||
return (NULL);
|
||||
p = NULL;
|
||||
while (*s != '\0')
|
||||
{
|
||||
if (*s == c)
|
||||
p = (char *)s;
|
||||
if (*s == 0)
|
||||
break ;
|
||||
s++;
|
||||
}
|
||||
return (p);
|
||||
|
@ -1,12 +1,12 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* :::::::: */
|
||||
/* ft_strupp.c :+: :+: :+: */
|
||||
/* ft_strupp.c |o_o || | */
|
||||
/* +:+ */
|
||||
/* By: djonker <marvin@codam.nl> +#+ */
|
||||
/* +#+ */
|
||||
/* Created: 2021/01/31 05:49:38 by djonker #+# #+# */
|
||||
/* Updated: 2023/02/07 00:41:13 by houtworm ### ########.fr */
|
||||
/* Updated: 2023/03/05 20:46:08 by houtworm \___)=(___/ */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -14,16 +14,16 @@
|
||||
|
||||
char *ft_strupp(char *s)
|
||||
{
|
||||
char r[5000];
|
||||
char *r;
|
||||
int i;
|
||||
|
||||
i = 0;
|
||||
r = ft_calloc(8 * (ft_strlen(s) + 1), 1);
|
||||
while (s[i])
|
||||
{
|
||||
r[i] = ft_toupper(s[i]);
|
||||
i++;
|
||||
}
|
||||
r[i] = '\0';
|
||||
s = r;
|
||||
return (s);
|
||||
free(s);
|
||||
return (r);
|
||||
}
|
||||
|
1132
libft/test.sh
Executable file
1132
libft/test.sh
Executable file
File diff suppressed because it is too large
Load Diff
35
libft/tests/bonus/lstadd_back/test1.c
Normal file
35
libft/tests/bonus/lstadd_back/test1.c
Normal file
@ -0,0 +1,35 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* :::::::: */
|
||||
/* test1.c |o_o || | */
|
||||
/* +:+ */
|
||||
/* By: djonker <djonker@student.codam.nl> +#+ */
|
||||
/* +#+ */
|
||||
/* Created: 2020/11/14 21:06:17 by djonker #+# #+# */
|
||||
/* Updated: 2023/02/27 01:03:32 by houtworm \___)=(___/ */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "../../tmp/libft.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
int r;
|
||||
t_list **list;
|
||||
t_list *element[2];
|
||||
char *str[2];
|
||||
|
||||
str[0] = strdup("Hallo1");
|
||||
str[1] = strdup("Hallo2");
|
||||
element[0] = ft_lstnew(str[0]);
|
||||
element[1] = ft_lstnew(str[1]);
|
||||
list = &element[0];
|
||||
ft_lstadd_back(list, element[1]);
|
||||
r = 0;
|
||||
if (strncmp(element[0]->next->content, "Hallo2", 6))
|
||||
r = 1;
|
||||
ft_lstclear(list, &free);
|
||||
return (r);
|
||||
}
|
40
libft/tests/bonus/lstadd_back/test2.c
Normal file
40
libft/tests/bonus/lstadd_back/test2.c
Normal file
@ -0,0 +1,40 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* :::::::: */
|
||||
/* test2.c |o_o || | */
|
||||
/* +:+ */
|
||||
/* By: djonker <djonker@student.codam.nl> +#+ */
|
||||
/* +#+ */
|
||||
/* Created: 2020/11/14 21:06:17 by djonker #+# #+# */
|
||||
/* Updated: 2023/03/03 18:52:35 by houtworm \___)=(___/ */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "../../tmp/libft.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
int r;
|
||||
t_list **list;
|
||||
t_list *element[3];
|
||||
char *str[3];
|
||||
|
||||
str[0] = strdup("Hallo1");
|
||||
str[1] = strdup("Hallo2");
|
||||
str[2] = strdup("Hallo3");
|
||||
element[0] = ft_lstnew(str[0]);
|
||||
element[1] = ft_lstnew(str[1]);
|
||||
element[2] = ft_lstnew(str[2]);
|
||||
list = &element[0];
|
||||
ft_lstadd_back(list, element[1]);
|
||||
ft_lstadd_back(list, element[2]);
|
||||
r = 0;
|
||||
if (strncmp(element[0]->next->content, "Hallo2", 6))
|
||||
r = 1;
|
||||
if (strncmp(element[1]->next->content, "Hallo3", 6))
|
||||
r = 1;
|
||||
ft_lstclear(list, &free);
|
||||
return (r);
|
||||
}
|
38
libft/tests/bonus/lstadd_back/test3.c
Normal file
38
libft/tests/bonus/lstadd_back/test3.c
Normal file
@ -0,0 +1,38 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* :::::::: */
|
||||
/* test3.c |o_o || | */
|
||||
/* +:+ */
|
||||
/* By: djonker <djonker@student.codam.nl> +#+ */
|
||||
/* +#+ */
|
||||
/* Created: 2020/11/14 21:06:17 by djonker #+# #+# */
|
||||
/* Updated: 2023/03/04 02:09:08 by houtworm \___)=(___/ */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "../../tmp/libft.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
int r;
|
||||
t_list **list;
|
||||
t_list *element[3];
|
||||
char *str[3];
|
||||
|
||||
str[0] = strdup("Hallo1");
|
||||
str[1] = strdup("Hallo2");
|
||||
str[2] = strdup("Hallo3");
|
||||
element[0] = ft_lstnew(str[0]);
|
||||
element[1] = ft_lstnew(str[1]);
|
||||
element[2] = ft_lstnew(str[2]);
|
||||
list = &element[0];
|
||||
ft_lstadd_back(list, element[1]);
|
||||
ft_lstdelone(element[1], &free);
|
||||
ft_lstadd_back(list, element[2]);
|
||||
r = 0;
|
||||
if (strncmp((*list)->next->next->content, "Hallo3", 6))
|
||||
r = 1;
|
||||
return (r);
|
||||
}
|
34
libft/tests/bonus/lstadd_back/test4.c
Normal file
34
libft/tests/bonus/lstadd_back/test4.c
Normal file
@ -0,0 +1,34 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* :::::::: */
|
||||
/* test4.c |o_o || | */
|
||||
/* +:+ */
|
||||
/* By: djonker <djonker@student.codam.nl> +#+ */
|
||||
/* +#+ */
|
||||
/* Created: 2020/11/14 21:06:17 by djonker #+# #+# */
|
||||
/* Updated: 2023/03/04 01:11:14 by houtworm \___)=(___/ */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "../../tmp/libft.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
int r;
|
||||
t_list **list;
|
||||
t_list *element[2];
|
||||
char *str[2];
|
||||
|
||||
str[0] = strdup("Hallo1");
|
||||
element[0] = ft_lstnew(str[0]);
|
||||
list = NULL;
|
||||
ft_lstadd_back(list, element[0]);
|
||||
r = 0;
|
||||
if (list)
|
||||
r = 1;
|
||||
free (str[0]);
|
||||
free (element[0]);
|
||||
return (r);
|
||||
}
|
33
libft/tests/bonus/lstadd_back/test5.c
Normal file
33
libft/tests/bonus/lstadd_back/test5.c
Normal file
@ -0,0 +1,33 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* :::::::: */
|
||||
/* test5.c |o_o || | */
|
||||
/* +:+ */
|
||||
/* By: djonker <djonker@student.codam.nl> +#+ */
|
||||
/* +#+ */
|
||||
/* Created: 2020/11/14 21:06:17 by djonker #+# #+# */
|
||||
/* Updated: 2023/03/03 19:04:41 by houtworm \___)=(___/ */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "../../tmp/libft.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
int r;
|
||||
t_list **list;
|
||||
t_list *element[1];
|
||||
char *str[1];
|
||||
|
||||
str[0] = strdup("Hallo");
|
||||
element[0] = ft_lstnew(str[0]);
|
||||
list = &element[0];
|
||||
ft_lstadd_back(list, element[0]);
|
||||
r = 0;
|
||||
if (element[0]->next)
|
||||
r = 1;
|
||||
ft_lstclear(list, &free);
|
||||
return (r);
|
||||
}
|
35
libft/tests/bonus/lstadd_front/test1.c
Normal file
35
libft/tests/bonus/lstadd_front/test1.c
Normal file
@ -0,0 +1,35 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* :::::::: */
|
||||
/* test1.c |o_o || | */
|
||||
/* +:+ */
|
||||
/* By: djonker <djonker@student.codam.nl> +#+ */
|
||||
/* +#+ */
|
||||
/* Created: 2020/11/14 21:06:17 by djonker #+# #+# */
|
||||
/* Updated: 2023/02/27 01:03:39 by houtworm \___)=(___/ */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "../../tmp/libft.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
int r;
|
||||
t_list **list;
|
||||
t_list *element[2];
|
||||
char *str[2];
|
||||
|
||||
str[0] = strdup("Hallo1");
|
||||
str[1] = strdup("Hallo2");
|
||||
element[0] = ft_lstnew(str[0]);
|
||||
element[1] = ft_lstnew(str[1]);
|
||||
list = &element[1];
|
||||
ft_lstadd_front(list, element[0]);
|
||||
r = 0;
|
||||
if (strncmp(element[0]->next->content, "Hallo2", 6))
|
||||
r = 1;
|
||||
ft_lstclear(list, &free);
|
||||
return (r);
|
||||
}
|
40
libft/tests/bonus/lstadd_front/test2.c
Normal file
40
libft/tests/bonus/lstadd_front/test2.c
Normal file
@ -0,0 +1,40 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* :::::::: */
|
||||
/* test2.c |o_o || | */
|
||||
/* +:+ */
|
||||
/* By: djonker <djonker@student.codam.nl> +#+ */
|
||||
/* +#+ */
|
||||
/* Created: 2020/11/14 21:06:17 by djonker #+# #+# */
|
||||
/* Updated: 2023/03/03 15:48:12 by houtworm \___)=(___/ */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "../../tmp/libft.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
int r;
|
||||
t_list **list;
|
||||
t_list *element[3];
|
||||
char *str[3];
|
||||
|
||||
str[0] = strdup("Hallo1");
|
||||
str[1] = strdup("Hallo2");
|
||||
str[2] = strdup("Hallo3");
|
||||
element[0] = ft_lstnew(str[0]);
|
||||
element[1] = ft_lstnew(str[1]);
|
||||
element[2] = ft_lstnew(str[2]);
|
||||
list = &element[2];
|
||||
ft_lstadd_front(list, element[1]);
|
||||
ft_lstadd_front(list, element[0]);
|
||||
r = 0;
|
||||
if (strncmp((*list)->next->content, "Hallo2", 6))
|
||||
r = 1;
|
||||
if (strncmp((*list)->next->next->content, "Hallo3", 6))
|
||||
r = 1;
|
||||
ft_lstclear(list, &free);
|
||||
return (r);
|
||||
}
|
41
libft/tests/bonus/lstadd_front/test3.c
Normal file
41
libft/tests/bonus/lstadd_front/test3.c
Normal file
@ -0,0 +1,41 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* :::::::: */
|
||||
/* test3.c |o_o || | */
|
||||
/* +:+ */
|
||||
/* By: djonker <djonker@student.codam.nl> +#+ */
|
||||
/* +#+ */
|
||||
/* Created: 2020/11/14 21:06:17 by djonker #+# #+# */
|
||||
/* Updated: 2023/03/03 18:35:12 by houtworm \___)=(___/ */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "../../tmp/libft.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
int r;
|
||||
t_list **list;
|
||||
t_list *element[3];
|
||||
char *str[3];
|
||||
|
||||
str[0] = strdup("Hallo1");
|
||||
str[1] = strdup("Hallo2");
|
||||
str[2] = strdup("Hallo3");
|
||||
element[0] = ft_lstnew(str[0]);
|
||||
element[1] = ft_lstnew(str[1]);
|
||||
element[2] = ft_lstnew(str[2]);
|
||||
list = &element[2];
|
||||
ft_lstadd_front(list, element[1]);
|
||||
list = &element[2];
|
||||
ft_lstadd_front(list, element[0]);
|
||||
r = 0;
|
||||
if (strncmp((*list)->next->content, "Hallo2", 6))
|
||||
r = 1;
|
||||
if (strncmp((*list)->next->next->content, "Hallo3", 6))
|
||||
r = 1;
|
||||
ft_lstclear(list, &free);
|
||||
return (r);
|
||||
}
|
34
libft/tests/bonus/lstadd_front/test4.c
Normal file
34
libft/tests/bonus/lstadd_front/test4.c
Normal file
@ -0,0 +1,34 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* :::::::: */
|
||||
/* test4.c |o_o || | */
|
||||
/* +:+ */
|
||||
/* By: djonker <djonker@student.codam.nl> +#+ */
|
||||
/* +#+ */
|
||||
/* Created: 2020/11/14 21:06:17 by djonker #+# #+# */
|
||||
/* Updated: 2023/03/03 18:56:02 by houtworm \___)=(___/ */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "../../tmp/libft.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
int r;
|
||||
t_list **list;
|
||||
t_list *element[1];
|
||||
char *str[1];
|
||||
|
||||
str[0] = strdup("Hallo1");
|
||||
element[0] = ft_lstnew(str[0]);
|
||||
list = NULL;
|
||||
ft_lstadd_front(list, element[0]);
|
||||
r = 0;
|
||||
if (list)
|
||||
r = 1;
|
||||
free(str[0]);
|
||||
free(element[0]);
|
||||
return (r);
|
||||
}
|
34
libft/tests/bonus/lstadd_front/test5.c
Normal file
34
libft/tests/bonus/lstadd_front/test5.c
Normal file
@ -0,0 +1,34 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* :::::::: */
|
||||
/* test5.c |o_o || | */
|
||||
/* +:+ */
|
||||
/* By: djonker <djonker@student.codam.nl> +#+ */
|
||||
/* +#+ */
|
||||
/* Created: 2020/11/14 21:06:17 by djonker #+# #+# */
|
||||
/* Updated: 2023/03/03 16:05:17 by houtworm \___)=(___/ */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "../../tmp/libft.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
int r;
|
||||
t_list **list;
|
||||
t_list *element[1];
|
||||
char *str[1];
|
||||
|
||||
str[0] = strdup("Hallo1");
|
||||
element[0] = ft_lstnew(str[0]);
|
||||
list = &element[0];
|
||||
ft_lstadd_front(list, NULL);
|
||||
r = 0;
|
||||
if (element[0]->next)
|
||||
r = 1;
|
||||
free(str[0]);
|
||||
free(element[0]);
|
||||
return (r);
|
||||
}
|
33
libft/tests/bonus/lstclear/test1.c
Normal file
33
libft/tests/bonus/lstclear/test1.c
Normal file
@ -0,0 +1,33 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* :::::::: */
|
||||
/* test1.c |o_o || | */
|
||||
/* +:+ */
|
||||
/* By: djonker <djonker@student.codam.nl> +#+ */
|
||||
/* +#+ */
|
||||
/* Created: 2020/11/14 21:06:17 by djonker #+# #+# */
|
||||
/* Updated: 2023/03/04 02:09:57 by houtworm \___)=(___/ */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "../../tmp/libft.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
int r;
|
||||
t_list **list;
|
||||
t_list *element[2];
|
||||
char *str[2];
|
||||
|
||||
str[0] = strdup("Hallo1");
|
||||
element[0] = ft_lstnew(str[0]);
|
||||
list = &element[0];
|
||||
r = 0;
|
||||
ft_lstclear(list, NULL);
|
||||
if (*list != NULL)
|
||||
r = 1;
|
||||
free(str[0]);
|
||||
return (r);
|
||||
}
|
37
libft/tests/bonus/lstclear/test2.c
Normal file
37
libft/tests/bonus/lstclear/test2.c
Normal file
@ -0,0 +1,37 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* :::::::: */
|
||||
/* test2.c |o_o || | */
|
||||
/* +:+ */
|
||||
/* By: djonker <djonker@student.codam.nl> +#+ */
|
||||
/* +#+ */
|
||||
/* Created: 2020/11/14 21:06:17 by djonker #+# #+# */
|
||||
/* Updated: 2023/03/04 17:52:32 by houtworm \___)=(___/ */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "../../tmp/libft.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
int r;
|
||||
t_list **list;
|
||||
t_list *element[2];
|
||||
char *str[2];
|
||||
|
||||
str[0] = strdup("Hallo1");
|
||||
str[1] = strdup("Hallo2");
|
||||
element[0] = ft_lstnew(str[0]);
|
||||
element[1] = ft_lstnew(str[1]);
|
||||
list = &element[1];
|
||||
ft_lstadd_front(list, element[0]);
|
||||
r = 0;
|
||||
ft_lstclear(list, NULL);
|
||||
if (*list != NULL)
|
||||
r = 1;
|
||||
free(str[0]);
|
||||
free(str[1]);
|
||||
return (r);
|
||||
}
|
39
libft/tests/bonus/lstclear/test3.c
Normal file
39
libft/tests/bonus/lstclear/test3.c
Normal file
@ -0,0 +1,39 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* :::::::: */
|
||||
/* test3.c |o_o || | */
|
||||
/* +:+ */
|
||||
/* By: djonker <djonker@student.codam.nl> +#+ */
|
||||
/* +#+ */
|
||||
/* Created: 2020/11/14 21:06:17 by djonker #+# #+# */
|
||||
/* Updated: 2023/03/04 01:40:00 by houtworm \___)=(___/ */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "../../tmp/libft.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
int r;
|
||||
t_list **list;
|
||||
t_list *element[3];
|
||||
char *str[3];
|
||||
|
||||
str[0] = strdup("Hallo1");
|
||||
str[1] = strdup("Hallo2");
|
||||
str[2] = strdup("Hallo3");
|
||||
element[0] = ft_lstnew(str[0]);
|
||||
element[1] = ft_lstnew(str[1]);
|
||||
element[2] = ft_lstnew(str[2]);
|
||||
list = &element[2];
|
||||
ft_lstadd_front(list, element[1]);
|
||||
ft_lstadd_front(list, element[0]);
|
||||
ft_lstdelone(element[1], NULL);
|
||||
r = 0;
|
||||
ft_lstclear(list, NULL);
|
||||
if (*list != NULL)
|
||||
r = 1;
|
||||
return (r);
|
||||
}
|
35
libft/tests/bonus/lstclear/test4.c
Normal file
35
libft/tests/bonus/lstclear/test4.c
Normal file
@ -0,0 +1,35 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* :::::::: */
|
||||
/* test1.c |o_o || | */
|
||||
/* +:+ */
|
||||
/* By: djonker <djonker@student.codam.nl> +#+ */
|
||||
/* +#+ */
|
||||
/* Created: 2020/11/14 21:06:17 by djonker #+# #+# */
|
||||
/* Updated: 2023/02/27 05:14:21 by houtworm \___)=(___/ */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "../../tmp/libft.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
int r;
|
||||
t_list **list;
|
||||
t_list *element[2];
|
||||
char *str[2];
|
||||
|
||||
str[0] = strdup("Hallo1");
|
||||
str[1] = strdup("Hallo2");
|
||||
element[0] = ft_lstnew(str[0]);
|
||||
element[1] = ft_lstnew(str[1]);
|
||||
list = &element[1];
|
||||
ft_lstadd_front(list, element[0]);
|
||||
r = 0;
|
||||
ft_lstclear(list, &free);
|
||||
if (*list != NULL)
|
||||
r = 1;
|
||||
return (r);
|
||||
}
|
28
libft/tests/bonus/lstclear/test5.c
Normal file
28
libft/tests/bonus/lstclear/test5.c
Normal file
@ -0,0 +1,28 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* :::::::: */
|
||||
/* test5.c |o_o || | */
|
||||
/* +:+ */
|
||||
/* By: djonker <djonker@student.codam.nl> +#+ */
|
||||
/* +#+ */
|
||||
/* Created: 2020/11/14 21:06:17 by djonker #+# #+# */
|
||||
/* Updated: 2023/03/04 01:58:06 by houtworm \___)=(___/ */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "../../tmp/libft.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
int r;
|
||||
t_list **list;
|
||||
|
||||
list = NULL;
|
||||
r = 0;
|
||||
ft_lstclear(list, &free);
|
||||
if (list != NULL)
|
||||
r = 1;
|
||||
return (r);
|
||||
}
|
50
libft/tests/bonus/lstdelone/test1.c
Normal file
50
libft/tests/bonus/lstdelone/test1.c
Normal file
@ -0,0 +1,50 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* :::::::: */
|
||||
/* test1.c |o_o || | */
|
||||
/* +:+ */
|
||||
/* By: djonker <djonker@student.codam.nl> +#+ */
|
||||
/* +#+ */
|
||||
/* Created: 2020/11/14 21:06:17 by djonker #+# #+# */
|
||||
/* Updated: 2023/03/04 02:09:32 by houtworm \___)=(___/ */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "../../tmp/libft.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
int compare(void *a, void *b)
|
||||
{
|
||||
if (a == NULL && b == NULL)
|
||||
return (1);
|
||||
return (0);
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
int r;
|
||||
t_list **list;
|
||||
t_list *element[4];
|
||||
char *str[3];
|
||||
|
||||
str[0] = strdup("Hallo1");
|
||||
str[1] = strdup("Hallo2");
|
||||
str[2] = strdup("Hallo3");
|
||||
element[0] = ft_lstnew(str[0]);
|
||||
element[1] = ft_lstnew(str[1]);
|
||||
element[2] = ft_lstnew(str[2]);
|
||||
element[3] = NULL;
|
||||
list = &element[0];
|
||||
ft_lstadd_back(list, element[1]);
|
||||
ft_lstadd_back(list, element[2]);
|
||||
r = 0;
|
||||
ft_lstdelone(element[2], NULL);
|
||||
r = compare(element[2], element[3]);
|
||||
free (str[0]);
|
||||
free (str[1]);
|
||||
free (str[2]);
|
||||
free (element[0]);
|
||||
free (element[1]);
|
||||
return (r);
|
||||
}
|
50
libft/tests/bonus/lstdelone/test2.c
Normal file
50
libft/tests/bonus/lstdelone/test2.c
Normal file
@ -0,0 +1,50 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* :::::::: */
|
||||
/* test2.c |o_o || | */
|
||||
/* +:+ */
|
||||
/* By: djonker <djonker@student.codam.nl> +#+ */
|
||||
/* +#+ */
|
||||
/* Created: 2020/11/14 21:06:17 by djonker #+# #+# */
|
||||
/* Updated: 2023/03/04 00:07:41 by houtworm \___)=(___/ */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "../../tmp/libft.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
int compare(void *a, void *b)
|
||||
{
|
||||
if (a == NULL && b == NULL)
|
||||
return (1);
|
||||
return (0);
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
int r;
|
||||
t_list **list;
|
||||
t_list *element[4];
|
||||
char *str[3];
|
||||
|
||||
str[0] = strdup("Hallo1");
|
||||
str[1] = strdup("Hallo2");
|
||||
str[2] = strdup("Hallo3");
|
||||
element[0] = ft_lstnew(str[0]);
|
||||
element[1] = ft_lstnew(str[1]);
|
||||
element[2] = ft_lstnew(str[2]);
|
||||
element[3] = NULL;
|
||||
list = &element[0];
|
||||
ft_lstadd_back(list, element[1]);
|
||||
ft_lstadd_back(list, element[2]);
|
||||
r = 0;
|
||||
ft_lstdelone(element[0], NULL);
|
||||
r = compare(element[0], element[3]);
|
||||
free (str[0]);
|
||||
free (str[1]);
|
||||
free (str[2]);
|
||||
free (element[1]);
|
||||
free (element[2]);
|
||||
return (r);
|
||||
}
|
50
libft/tests/bonus/lstdelone/test3.c
Normal file
50
libft/tests/bonus/lstdelone/test3.c
Normal file
@ -0,0 +1,50 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* :::::::: */
|
||||
/* test3.c |o_o || | */
|
||||
/* +:+ */
|
||||
/* By: djonker <djonker@student.codam.nl> +#+ */
|
||||
/* +#+ */
|
||||
/* Created: 2020/11/14 21:06:17 by djonker #+# #+# */
|
||||
/* Updated: 2023/03/04 00:10:48 by houtworm \___)=(___/ */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "../../tmp/libft.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
int compare(void *a, void *b)
|
||||
{
|
||||
if (a == NULL && b == NULL)
|
||||
return (1);
|
||||
return (0);
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
int r;
|
||||
t_list **list;
|
||||
t_list *element[4];
|
||||
char *str[3];
|
||||
|
||||
str[0] = strdup("Hallo1");
|
||||
str[1] = strdup("Hallo2");
|
||||
str[2] = strdup("Hallo3");
|
||||
element[0] = ft_lstnew(str[0]);
|
||||
element[1] = ft_lstnew(str[1]);
|
||||
element[2] = ft_lstnew(str[2]);
|
||||
element[3] = NULL;
|
||||
list = &element[0];
|
||||
ft_lstadd_back(list, element[1]);
|
||||
ft_lstadd_back(list, element[2]);
|
||||
r = 0;
|
||||
r = compare(element[1], element[3]);
|
||||
ft_lstdelone((*list)->next, NULL);
|
||||
free (str[0]);
|
||||
free (str[1]);
|
||||
free (str[2]);
|
||||
free (element[0]);
|
||||
free (element[2]);
|
||||
return (r);
|
||||
}
|
31
libft/tests/bonus/lstdelone/test4.c
Normal file
31
libft/tests/bonus/lstdelone/test4.c
Normal file
@ -0,0 +1,31 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* :::::::: */
|
||||
/* test4.c |o_o || | */
|
||||
/* +:+ */
|
||||
/* By: djonker <djonker@student.codam.nl> +#+ */
|
||||
/* +#+ */
|
||||
/* Created: 2020/11/14 21:06:17 by djonker #+# #+# */
|
||||
/* Updated: 2023/03/03 19:40:55 by houtworm \___)=(___/ */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "../../tmp/libft.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
int r;
|
||||
t_list **list;
|
||||
t_list *element[1];
|
||||
char *str[1];
|
||||
|
||||
str[0] = strdup("Hallo1");
|
||||
element[0] = ft_lstnew(str[0]);
|
||||
list = &element[0];
|
||||
r = 0;
|
||||
ft_lstdelone(element[0], NULL);
|
||||
free(str[0]);
|
||||
return (r);
|
||||
}
|
30
libft/tests/bonus/lstdelone/test5.c
Normal file
30
libft/tests/bonus/lstdelone/test5.c
Normal file
@ -0,0 +1,30 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* :::::::: */
|
||||
/* test5.c |o_o || | */
|
||||
/* +:+ */
|
||||
/* By: djonker <djonker@student.codam.nl> +#+ */
|
||||
/* +#+ */
|
||||
/* Created: 2020/11/14 21:06:17 by djonker #+# #+# */
|
||||
/* Updated: 2023/03/03 19:39:44 by houtworm \___)=(___/ */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "../../tmp/libft.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
int r;
|
||||
t_list **list;
|
||||
t_list *element[1];
|
||||
char *str[1];
|
||||
|
||||
str[0] = strdup("Hallo1");
|
||||
element[0] = ft_lstnew(str[0]);
|
||||
list = &element[0];
|
||||
r = 0;
|
||||
ft_lstdelone(element[0], &free);
|
||||
return (r);
|
||||
}
|
39
libft/tests/bonus/lstiter/test1.c
Normal file
39
libft/tests/bonus/lstiter/test1.c
Normal file
@ -0,0 +1,39 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* :::::::: */
|
||||
/* test1.c |o_o || | */
|
||||
/* +:+ */
|
||||
/* By: djonker <djonker@student.codam.nl> +#+ */
|
||||
/* +#+ */
|
||||
/* Created: 2020/11/14 21:06:17 by djonker #+# #+# */
|
||||
/* Updated: 2023/03/04 17:52:52 by houtworm \___)=(___/ */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "../../tmp/libft.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
void func(void *content)
|
||||
{
|
||||
memset(content, 'a', 3);
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
int r;
|
||||
t_list **list;
|
||||
t_list *element[1];
|
||||
char *str[1];
|
||||
|
||||
str[0] = strdup("Hallo1");
|
||||
element[0] = ft_lstnew(str[0]);
|
||||
list = &element[0];
|
||||
ft_lstiter(*list, &func);
|
||||
r = 0;
|
||||
if (strncmp(str[0], "aaalo1", 6))
|
||||
r = 1;
|
||||
free(str[0]);
|
||||
free(*list);
|
||||
return (r);
|
||||
}
|
44
libft/tests/bonus/lstiter/test2.c
Normal file
44
libft/tests/bonus/lstiter/test2.c
Normal file
@ -0,0 +1,44 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* :::::::: */
|
||||
/* test2.c |o_o || | */
|
||||
/* +:+ */
|
||||
/* By: djonker <djonker@student.codam.nl> +#+ */
|
||||
/* +#+ */
|
||||
/* Created: 2020/11/14 21:06:17 by djonker #+# #+# */
|
||||
/* Updated: 2023/03/04 17:53:15 by houtworm \___)=(___/ */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "../../tmp/libft.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
void func(void *content)
|
||||
{
|
||||
memset(content, 'a', 3);
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
int r;
|
||||
t_list **list;
|
||||
t_list *element[2];
|
||||
char *str[2];
|
||||
|
||||
str[0] = strdup("Hallo1");
|
||||
str[1] = strdup("Hallo2");
|
||||
element[0] = ft_lstnew(str[0]);
|
||||
element[1] = ft_lstnew(str[1]);
|
||||
list = &element[0];
|
||||
ft_lstadd_back(list, element[1]);
|
||||
ft_lstiter(*list, &func);
|
||||
r = 0;
|
||||
if (strncmp(str[0], "aaalo1", 6) || strncmp(str[1], "aaalo2", 6))
|
||||
r = 1;
|
||||
free(str[0]);
|
||||
free(str[1]);
|
||||
free((*list)->next);
|
||||
free(*list);
|
||||
return (r);
|
||||
}
|
48
libft/tests/bonus/lstiter/test3.c
Normal file
48
libft/tests/bonus/lstiter/test3.c
Normal file
@ -0,0 +1,48 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* :::::::: */
|
||||
/* test3.c |o_o || | */
|
||||
/* +:+ */
|
||||
/* By: djonker <djonker@student.codam.nl> +#+ */
|
||||
/* +#+ */
|
||||
/* Created: 2020/11/14 21:06:17 by djonker #+# #+# */
|
||||
/* Updated: 2023/03/04 15:31:09 by houtworm \___)=(___/ */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "../../tmp/libft.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
void func(void *content)
|
||||
{
|
||||
memset(content, 'a', 3);
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
int r;
|
||||
t_list **list;
|
||||
t_list *element[3];
|
||||
char *str[3];
|
||||
|
||||
str[0] = strdup("Hallo1");
|
||||
str[1] = strdup("Hallo2");
|
||||
str[2] = strdup("Hallo3");
|
||||
element[0] = ft_lstnew(str[0]);
|
||||
element[1] = ft_lstnew(str[1]);
|
||||
element[2] = ft_lstnew(str[2]);
|
||||
list = &element[0];
|
||||
ft_lstadd_back(list, element[1]);
|
||||
ft_lstadd_back(list, element[2]);
|
||||
ft_lstdelone(element[1], &free);
|
||||
ft_lstiter(*list, &func);
|
||||
r = 0;
|
||||
if (strncmp(str[0], "aaalo1", 6) || strncmp(str[2], "Hallo3", 6))
|
||||
r = 1;
|
||||
free(element[0]);
|
||||
free(element[2]);
|
||||
free(str[0]);
|
||||
free(str[2]);
|
||||
return (r);
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user