added basic checks
This commit is contained in:
parent
42d03c95aa
commit
b26803cb1b
14
Makefile
14
Makefile
@ -6,7 +6,7 @@
|
|||||||
# By: houtworm <codam@houtworm.net> +#+ #
|
# By: houtworm <codam@houtworm.net> +#+ #
|
||||||
# +#+ #
|
# +#+ #
|
||||||
# Created: 2023/10/26 10:46:29 by houtworm #+# #+# #
|
# Created: 2023/10/26 10:46:29 by houtworm #+# #+# #
|
||||||
# Updated: 2023/10/26 16:56:54 by houtworm ######## odam.nl #
|
# Updated: 2023/10/26 17:30:17 by houtworm ######## odam.nl #
|
||||||
# #
|
# #
|
||||||
# **************************************************************************** #
|
# **************************************************************************** #
|
||||||
|
|
||||||
@ -15,25 +15,28 @@ CC =gcc
|
|||||||
FC =-Wall -Werror -Wextra -Wunreachable-code -Ofast -g #-fsanitize=address
|
FC =-Wall -Werror -Wextra -Wunreachable-code -Ofast -g #-fsanitize=address
|
||||||
HEAD =-I ./include -I $(MLX)/include
|
HEAD =-I ./include -I $(MLX)/include
|
||||||
RM =rm -rf
|
RM =rm -rf
|
||||||
LIB =libft/libft.a mlx/build/libmlx42.a -ldl -lglfw -pthread -lm
|
LIB =libft/libft.a getnextline/get_next_line.a mlx/build/libmlx42.a -ldl -lglfw -pthread -lm
|
||||||
SRC =src/main.c\
|
SRC =src/main.c\
|
||||||
src/init.c\
|
src/init.c\
|
||||||
src/parse.c\
|
src/parse.c\
|
||||||
src/keys.c\
|
src/keys.c\
|
||||||
src/draw.c
|
src/draw.c\
|
||||||
|
src/error.c
|
||||||
OBJ =$(SRC:src/%.c=obj/%.o)
|
OBJ =$(SRC:src/%.c=obj/%.o)
|
||||||
|
|
||||||
all: libft mlx/build/mlx42.a $(NAME)
|
all: libft getnextline mlx/build/mlx42.a $(NAME)
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
@$(RM) obj
|
@$(RM) obj
|
||||||
@$(MAKE) -C libft clean > /dev/null
|
@$(MAKE) -C libft clean > /dev/null
|
||||||
|
@$(MAKE) -C getnextline clean > /dev/null
|
||||||
@$(MAKE) -C mlx/build clean > /dev/null
|
@$(MAKE) -C mlx/build clean > /dev/null
|
||||||
@printf "\e[1;35mCleaned Object Files\n\e[0;00m"
|
@printf "\e[1;35mCleaned Object Files\n\e[0;00m"
|
||||||
|
|
||||||
fclean: clean
|
fclean: clean
|
||||||
@$(RM) $(NAME) mlx/build > /dev/null
|
@$(RM) $(NAME) mlx/build > /dev/null
|
||||||
@$(MAKE) -C libft fclean > /dev/null
|
@$(MAKE) -C libft fclean > /dev/null
|
||||||
|
@$(MAKE) -C getnextline fclean > /dev/null
|
||||||
@printf "\e[1;31mCleaned Executables\n\e[0;00m"
|
@printf "\e[1;31mCleaned Executables\n\e[0;00m"
|
||||||
|
|
||||||
re: fclean all
|
re: fclean all
|
||||||
@ -51,6 +54,9 @@ $(NAME): $(OBJ)
|
|||||||
libft:
|
libft:
|
||||||
@$(MAKE) -C libft all
|
@$(MAKE) -C libft all
|
||||||
|
|
||||||
|
getnextline:
|
||||||
|
@$(MAKE) -C getnextline all
|
||||||
|
|
||||||
mlx/build/mlx42.a:
|
mlx/build/mlx42.a:
|
||||||
@cmake -S mlx -B mlx/build
|
@cmake -S mlx -B mlx/build
|
||||||
@$(MAKE) -C mlx/build -j4
|
@$(MAKE) -C mlx/build -j4
|
||||||
|
13
config.cub
Normal file
13
config.cub
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
F 220,100,0
|
||||||
|
C 225,30,0
|
||||||
|
|
||||||
|
NO ./path_to_the_north_texture
|
||||||
|
EA ./path_to_the_east_texture
|
||||||
|
SO ./path_to_the_south_texture
|
||||||
|
WE ./path_to_the_west_texture
|
||||||
|
|
||||||
|
111111
|
||||||
|
100101
|
||||||
|
101001
|
||||||
|
1100N1
|
||||||
|
111111
|
7
cub3d.h
7
cub3d.h
@ -6,7 +6,7 @@
|
|||||||
/* By: houtworm <codam@houtworm.net> +#+ */
|
/* By: houtworm <codam@houtworm.net> +#+ */
|
||||||
/* +#+ */
|
/* +#+ */
|
||||||
/* Created: 2023/10/26 10:46:35 by houtworm #+# #+# */
|
/* Created: 2023/10/26 10:46:35 by houtworm #+# #+# */
|
||||||
/* Updated: 2023/10/26 16:56:10 by houtworm ######## odam.nl */
|
/* Updated: 2023/10/26 17:25:30 by houtworm ######## odam.nl */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -15,7 +15,9 @@
|
|||||||
|
|
||||||
# include <unistd.h>
|
# include <unistd.h>
|
||||||
# include <math.h>
|
# include <math.h>
|
||||||
|
# include <fcntl.h>
|
||||||
# include "libft/libft.h"
|
# include "libft/libft.h"
|
||||||
|
# include "getnextline/get_next_line.h"
|
||||||
# include "mlx/include/MLX42/MLX42.h"
|
# include "mlx/include/MLX42/MLX42.h"
|
||||||
|
|
||||||
typedef struct s_varlist
|
typedef struct s_varlist
|
||||||
@ -34,6 +36,7 @@ typedef struct s_varlist
|
|||||||
t_varlist initvarlist(void);
|
t_varlist initvarlist(void);
|
||||||
// parse.c
|
// parse.c
|
||||||
char **ft_getmap(void);
|
char **ft_getmap(void);
|
||||||
|
t_varlist ft_parseconfigfile(t_varlist vl, char *filename);
|
||||||
// keys.c
|
// keys.c
|
||||||
void ft_movementkeys(t_varlist *vl);
|
void ft_movementkeys(t_varlist *vl);
|
||||||
void keyhook(mlx_key_data_t kd, void *param);
|
void keyhook(mlx_key_data_t kd, void *param);
|
||||||
@ -41,4 +44,6 @@ void scrollhook(double xdelta, double ydelta, void *param);
|
|||||||
void resizehook(int x, int y, void *param);
|
void resizehook(int x, int y, void *param);
|
||||||
// draw.c
|
// draw.c
|
||||||
void ft_drawnextframe(t_varlist *vl);
|
void ft_drawnextframe(t_varlist *vl);
|
||||||
|
// error.c
|
||||||
|
int ft_errorexit(char *reason, char *function, int code);
|
||||||
#endif
|
#endif
|
||||||
|
44
getnextline/Makefile
Normal file
44
getnextline/Makefile
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
# **************************************************************************** #
|
||||||
|
# #
|
||||||
|
# .--. _ #
|
||||||
|
# Makefile |o_o || | #
|
||||||
|
# |:_/ || |_ _ ___ __ #
|
||||||
|
# By: djonker <djonker@student.codam.nl> // \ \ __| | | \ \/ / #
|
||||||
|
# (| | )|_| |_| |> < #
|
||||||
|
# Created: 2021/05/27 01:24:02 by djonker /'\_ _/`\__|\__,_/_/\_\ #
|
||||||
|
# Updated: 2023/02/20 20:37:06 by houtworm \___)=(___/ #
|
||||||
|
# #
|
||||||
|
# **************************************************************************** #
|
||||||
|
|
||||||
|
NAME =get_next_line.a
|
||||||
|
CC =gcc
|
||||||
|
FC =-Wall -Werror -Wextra
|
||||||
|
RM =rm -f
|
||||||
|
SRC =src/get_next_line.c\
|
||||||
|
src/get_next_line_utils.c
|
||||||
|
OBJ =$(SRC:src/%.c=obj/%.o)
|
||||||
|
FAR =ar -crs
|
||||||
|
|
||||||
|
all: $(NAME)
|
||||||
|
|
||||||
|
bonus: $(NAME)
|
||||||
|
|
||||||
|
clean:
|
||||||
|
@$(RM) -r obj
|
||||||
|
@printf "\e[1;35mCleaned Object Files\n\e[0;00m"
|
||||||
|
|
||||||
|
fclean: clean
|
||||||
|
@$(RM) $(NAME)
|
||||||
|
@printf "\e[1;31mCleaned Executables\n\e[0;00m"
|
||||||
|
|
||||||
|
re: fclean all
|
||||||
|
|
||||||
|
$(OBJ): $(SRC)
|
||||||
|
@mkdir -p $(dir $@)
|
||||||
|
@printf "\e[1;34mBuilding $@\n\e[0;00m"
|
||||||
|
@$(CC) $(CFLAGS) -c $(@:obj/%.o=src/%.c) -o $@
|
||||||
|
|
||||||
|
$(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"
|
22
getnextline/Readme.md
Normal file
22
getnextline/Readme.md
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
# Project Name
|
||||||
|
Get Next Line is a very handy function that keeps feeding you the next line of a file descriptor
|
||||||
|
|
||||||
|
---
|
||||||
|
## Todo
|
||||||
|
#### Remove the struct for some extra speed
|
||||||
|
|
||||||
|
---
|
||||||
|
## Usage
|
||||||
|
1. Simply clone or download the repository
|
||||||
|
2. Run `make` in the cloned directory
|
||||||
|
3. You can include the get_next_line.a into your own programs
|
||||||
|
|
||||||
|
---
|
||||||
|
## Tester
|
||||||
|
#### Usage
|
||||||
|
1. Download test.sh and the tests folder to your GNL directory
|
||||||
|
2. Make the file executable `chmod +x test.sh`
|
||||||
|
3. Run `./test.sh` to start the test
|
||||||
|
|
||||||
|
---
|
||||||
|
[This project is part of the studies at 42](https://42.fr/en/homepage/)
|
41
getnextline/get_next_line.h
Normal file
41
getnextline/get_next_line.h
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* :::::::: */
|
||||||
|
/* get_next_line.h |o_o || | */
|
||||||
|
/* +:+ */
|
||||||
|
/* By: djonker <marvin@codam.nl> +#+ */
|
||||||
|
/* +#+ */
|
||||||
|
/* Created: 2020/12/19 06:09:11 by djonker #+# #+# */
|
||||||
|
/* Updated: 2023/03/09 03:26:07 by houtworm \___)=(___/ */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#ifndef GET_NEXT_LINE_H
|
||||||
|
# define GET_NEXT_LINE_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);
|
||||||
|
int findnewline(struct s_gnl *strct);
|
||||||
|
int newline(struct s_gnl *strct, char **line);
|
||||||
|
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(char *str);
|
||||||
|
void gnl_bzero(void *s, size_t n);
|
||||||
|
char *gnl_strjoin(char const *s1, char const *s2);
|
||||||
|
|
||||||
|
#endif
|
114
getnextline/src/get_next_line.c
Normal file
114
getnextline/src/get_next_line.c
Normal file
@ -0,0 +1,114 @@
|
|||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* :::::::: */
|
||||||
|
/* get_next_line.c |o_o || | */
|
||||||
|
/* +:+ */
|
||||||
|
/* By: djonker <marvin@codam.nl> +#+ */
|
||||||
|
/* +#+ */
|
||||||
|
/* Created: 2021/03/15 22:51:05 by djonker #+# #+# */
|
||||||
|
/* Updated: 2023/02/20 20:32:05 by houtworm \___)=(___/ */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#include "../get_next_line.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));
|
||||||
|
}
|
103
getnextline/src/get_next_line_utils.c
Normal file
103
getnextline/src/get_next_line_utils.c
Normal file
@ -0,0 +1,103 @@
|
|||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* :::::::: */
|
||||||
|
/* get_next_line_utils.c :+: :+: :+: */
|
||||||
|
/* +:+ */
|
||||||
|
/* By: djonker <marvin@codam.nl> +#+ */
|
||||||
|
/* +#+ */
|
||||||
|
/* Created: 2021/04/05 07:45:24 by djonker #+# #+# */
|
||||||
|
/* Updated: 2023/02/07 00:54:10 by houtworm ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#include "../get_next_line.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/11 08:07:29 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 | grep -v ccls)
|
||||||
|
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/ | grep -v ccls) > 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);
|
||||||
|
}
|
21
src/error.c
Normal file
21
src/error.c
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* :::::::: */
|
||||||
|
/* error.c :+: :+: */
|
||||||
|
/* +:+ */
|
||||||
|
/* By: houtworm <codam@houtworm.net> +#+ */
|
||||||
|
/* +#+ */
|
||||||
|
/* Created: 2023/10/26 17:13:58 by houtworm #+# #+# */
|
||||||
|
/* Updated: 2023/10/26 17:16:06 by houtworm ######## odam.nl */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#include "../cub3d.h"
|
||||||
|
|
||||||
|
int ft_errorexit(char *reason, char *function, int code)
|
||||||
|
{
|
||||||
|
ft_putstr("Error: ");
|
||||||
|
ft_putstr(reason);
|
||||||
|
ft_putendl(function);
|
||||||
|
exit(code);
|
||||||
|
}
|
@ -6,7 +6,7 @@
|
|||||||
/* By: houtworm <codam@houtworm.net> +#+ */
|
/* By: houtworm <codam@houtworm.net> +#+ */
|
||||||
/* +#+ */
|
/* +#+ */
|
||||||
/* Created: 2023/10/26 16:49:12 by houtworm #+# #+# */
|
/* Created: 2023/10/26 16:49:12 by houtworm #+# #+# */
|
||||||
/* Updated: 2023/10/26 16:49:14 by houtworm ######## odam.nl */
|
/* Updated: 2023/10/26 17:19:28 by houtworm ######## odam.nl */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -20,9 +20,7 @@ t_varlist initvarlist(void)
|
|||||||
vl.h = 600;
|
vl.h = 600;
|
||||||
vl.mlx = mlx_init(vl.w, vl.h, "Cub3D", true);
|
vl.mlx = mlx_init(vl.w, vl.h, "Cub3D", true);
|
||||||
if (!vl.mlx)
|
if (!vl.mlx)
|
||||||
exit (1);
|
ft_errorexit("MLX failed to init", "initvarlist", 1);
|
||||||
vl.img = mlx_new_image(vl.mlx, vl.w, vl.h);
|
vl.img = mlx_new_image(vl.mlx, vl.w, vl.h);
|
||||||
vl.map = ft_getmap();
|
|
||||||
// we should validate the map here
|
|
||||||
return (vl);
|
return (vl);
|
||||||
}
|
}
|
||||||
|
13
src/main.c
13
src/main.c
@ -6,7 +6,7 @@
|
|||||||
/* By: houtworm <codam@houtworm.net> +#+ */
|
/* By: houtworm <codam@houtworm.net> +#+ */
|
||||||
/* +#+ */
|
/* +#+ */
|
||||||
/* Created: 2023/10/26 14:13:07 by houtworm #+# #+# */
|
/* Created: 2023/10/26 14:13:07 by houtworm #+# #+# */
|
||||||
/* Updated: 2023/10/26 16:54:42 by houtworm ######## odam.nl */
|
/* Updated: 2023/10/26 17:39:01 by houtworm ######## odam.nl */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -22,7 +22,7 @@ void mainloop(void *param)
|
|||||||
ft_movementkeys(vl);
|
ft_movementkeys(vl);
|
||||||
ft_drawnextframe(vl);
|
ft_drawnextframe(vl);
|
||||||
if (!vl->img || (mlx_image_to_window(vl->mlx, vl->img, 0, 0) < 0))
|
if (!vl->img || (mlx_image_to_window(vl->mlx, vl->img, 0, 0) < 0))
|
||||||
exit (1);
|
ft_errorexit("image to window failed ", "mainloop", 1);
|
||||||
ft_putendl("frame");
|
ft_putendl("frame");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -31,11 +31,14 @@ int main(int argc, char **argv)
|
|||||||
t_varlist vl;
|
t_varlist vl;
|
||||||
|
|
||||||
if (argc > 2)
|
if (argc > 2)
|
||||||
exit(2);
|
ft_errorexit("Too many arguments", "main", 2);
|
||||||
argv = argv;
|
|
||||||
vl = initvarlist();
|
vl = initvarlist();
|
||||||
|
if (argc == 2)
|
||||||
|
vl = ft_parseconfigfile(vl, argv[1]);
|
||||||
|
else
|
||||||
|
ft_errorexit("Please include a .cub file ", "main", 2); // we could start with a menu here
|
||||||
if (!vl.img || (mlx_image_to_window(vl.mlx, vl.img, 0, 0) < 0))
|
if (!vl.img || (mlx_image_to_window(vl.mlx, vl.img, 0, 0) < 0))
|
||||||
exit (1);
|
ft_errorexit("image failed to window ", "main", 1);
|
||||||
mlx_key_hook(vl.mlx, &keyhook, &vl);
|
mlx_key_hook(vl.mlx, &keyhook, &vl);
|
||||||
mlx_resize_hook(vl.mlx, &resizehook, &vl);
|
mlx_resize_hook(vl.mlx, &resizehook, &vl);
|
||||||
mlx_scroll_hook(vl.mlx, &scrollhook, &vl);
|
mlx_scroll_hook(vl.mlx, &scrollhook, &vl);
|
||||||
|
60
src/map.c
Normal file
60
src/map.c
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* :::::::: */
|
||||||
|
/* map.c :+: :+: */
|
||||||
|
/* +:+ */
|
||||||
|
/* By: houtworm <codam@houtworm.net> +#+ */
|
||||||
|
/* +#+ */
|
||||||
|
/* Created: 2023/10/26 17:33:50 by houtworm #+# #+# */
|
||||||
|
/* Updated: 2023/10/26 17:34:02 by houtworm ######## odam.nl */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#include "../cub3d.h"
|
||||||
|
|
||||||
|
char **ft_getmap(void)
|
||||||
|
{
|
||||||
|
int y;
|
||||||
|
int x;
|
||||||
|
char **map;
|
||||||
|
char localmap[24][24] = {
|
||||||
|
{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
|
||||||
|
{1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
|
||||||
|
{1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
|
||||||
|
{1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
|
||||||
|
{1,0,0,0,0,0,1,1,1,1,1,0,0,0,0,1,0,1,0,1,0,0,0,1},
|
||||||
|
{1,0,0,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1},
|
||||||
|
{1,0,0,0,0,0,1,0,0,0,1,0,0,0,0,1,0,0,0,1,0,0,0,1},
|
||||||
|
{1,0,0,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1},
|
||||||
|
{1,0,0,0,0,0,1,1,0,1,1,0,0,0,0,1,0,1,0,1,0,0,0,1},
|
||||||
|
{1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
|
||||||
|
{1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
|
||||||
|
{1,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,1},
|
||||||
|
{1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
|
||||||
|
{1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
|
||||||
|
{1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
|
||||||
|
{1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
|
||||||
|
{1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
|
||||||
|
{1,1,0,1,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
|
||||||
|
{1,1,0,0,0,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
|
||||||
|
{1,1,0,1,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
|
||||||
|
{1,1,0,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
|
||||||
|
{1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
|
||||||
|
{1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
|
||||||
|
{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}
|
||||||
|
};
|
||||||
|
map = ft_calloc(24, 8);
|
||||||
|
y = 0;
|
||||||
|
while (y < 24)
|
||||||
|
{
|
||||||
|
map[y] = ft_calloc(24, 8);
|
||||||
|
x = 0;
|
||||||
|
while (x < 24)
|
||||||
|
{
|
||||||
|
map[y][x] = localmap[y][x];
|
||||||
|
x++;
|
||||||
|
}
|
||||||
|
y++;
|
||||||
|
}
|
||||||
|
return (map);
|
||||||
|
}
|
54
src/parse.c
54
src/parse.c
@ -6,55 +6,23 @@
|
|||||||
/* By: houtworm <codam@houtworm.net> +#+ */
|
/* By: houtworm <codam@houtworm.net> +#+ */
|
||||||
/* +#+ */
|
/* +#+ */
|
||||||
/* Created: 2023/10/26 16:48:55 by houtworm #+# #+# */
|
/* Created: 2023/10/26 16:48:55 by houtworm #+# #+# */
|
||||||
/* Updated: 2023/10/26 16:49:07 by houtworm ######## odam.nl */
|
/* Updated: 2023/10/26 17:33:49 by houtworm ######## odam.nl */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "../cub3d.h"
|
#include "../cub3d.h"
|
||||||
|
|
||||||
char **ft_getmap(void)
|
t_varlist ft_parseconfigfile(t_varlist vl, char *filename)
|
||||||
{
|
{
|
||||||
int y;
|
int fd;
|
||||||
int x;
|
char *line;
|
||||||
char **map;
|
|
||||||
char localmap[24][24] = {
|
fd = open(filename, O_RDONLY);
|
||||||
{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
|
if (fd == -1)
|
||||||
{1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
|
ft_errorexit("file does not exist", "parseconfigfile", 1);
|
||||||
{1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
|
while (get_next_line(fd, &line))
|
||||||
{1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
|
|
||||||
{1,0,0,0,0,0,1,1,1,1,1,0,0,0,0,1,0,1,0,1,0,0,0,1},
|
|
||||||
{1,0,0,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1},
|
|
||||||
{1,0,0,0,0,0,1,0,0,0,1,0,0,0,0,1,0,0,0,1,0,0,0,1},
|
|
||||||
{1,0,0,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1},
|
|
||||||
{1,0,0,0,0,0,1,1,0,1,1,0,0,0,0,1,0,1,0,1,0,0,0,1},
|
|
||||||
{1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
|
|
||||||
{1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
|
|
||||||
{1,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,1},
|
|
||||||
{1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
|
|
||||||
{1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
|
|
||||||
{1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
|
|
||||||
{1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
|
|
||||||
{1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
|
|
||||||
{1,1,0,1,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
|
|
||||||
{1,1,0,0,0,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
|
|
||||||
{1,1,0,1,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
|
|
||||||
{1,1,0,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
|
|
||||||
{1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
|
|
||||||
{1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
|
|
||||||
{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}
|
|
||||||
};
|
|
||||||
map = ft_calloc(24, 8);
|
|
||||||
y = 0;
|
|
||||||
while (y < 24)
|
|
||||||
{
|
{
|
||||||
map[y] = ft_calloc(24, 8);
|
free(line);
|
||||||
x = 0;
|
|
||||||
while (x < 24)
|
|
||||||
{
|
|
||||||
map[y][x] = localmap[y][x];
|
|
||||||
x++;
|
|
||||||
}
|
|
||||||
y++;
|
|
||||||
}
|
}
|
||||||
return (map);
|
return (vl);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user