check_tetri_error WORKING + Parser

This commit is contained in:
Manzovince
2019-04-14 23:02:29 +02:00
parent 9d8940e6a5
commit 1e42ba9fbe
7 changed files with 43 additions and 30 deletions

View File

@@ -6,19 +6,20 @@
/* By: vmanzoni <vmanzoni@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/03/01 13:29:05 by vmanzoni #+# #+# */
/* Updated: 2019/04/14 21:37:23 by vmanzoni ### ########.fr */
/* Updated: 2019/04/14 22:57:14 by vmanzoni ### ########.fr */
/* */
/* ************************************************************************** */
#include "fillit.h"
/*
** Function that display error message *s on fd
** Function that display error message *s on fd and exit program
*/
void print_error(char *s)
{
write(2, s, strlen(s));
exit(1);
}
/*
@@ -41,8 +42,8 @@ int check_file_errors(char *file)
return (1);
if (file[i] == '\n')
line_nbr++;
if (file[i] == '\n' && file[i+1] == '\n')
return (1);
// if (file[i] == '\n' && file[i+2] != '.' && file[i+2] != '#')
// return (1);
i++;
}
if (line_nbr < 4 || line_nbr > 129)
@@ -61,17 +62,18 @@ int check_tetri_errors(char *tetri)
dot = 0;
while (tetri[i])
{
if (tetri[i] = '#')
if (tetri[i] == '#')
htg++;
else if (tetri[i] = '.')
else if (tetri[i] == '.')
dot++;
i++;
}
if (htg != 4 || dot != 12 || check_tetri_errors2(tetri))
return (1);
return (0);
}
/*
int check_tetri_errors2(char *tetri)
{
int i;
@@ -79,11 +81,13 @@ int check_tetri_errors2(char *tetri)
i = 0;
while (tetri[i])
{
if (tetri[i] == '#')
{
}
if (tetri[i] == '.' || tetri[i] == '\n')
i++;
else if (tetri[i] == '#' && (tetri[i + 1] == '#' || tetri[i - 1] == '#'
|| tetri[i + 5] == '#' || tetri[i - 5] == '#'))
i++;
else
return (1);
}
return (0);
}
*/