reorganise parse_input

This commit is contained in:
Hugo LAMY
2019-04-24 13:53:33 +02:00
parent ef84335727
commit 8d9afa579d
4 changed files with 31 additions and 28 deletions

View File

@@ -6,7 +6,7 @@
# By: vmanzoni <vmanzoni@student.42.fr> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2019/03/01 13:24:35 by vmanzoni #+# #+# #
# Updated: 2019/04/23 15:16:05 by vmanzoni ### ########.fr #
# Updated: 2019/04/24 13:49:48 by hulamy ### ########.fr #
# #
# **************************************************************************** #

View File

@@ -6,7 +6,7 @@
/* By: hulamy <hulamy@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/04/14 15:20:53 by hulamy #+# #+# */
/* Updated: 2019/04/24 13:38:22 by hulamy ### ########.fr */
/* Updated: 2019/04/24 13:45:53 by hulamy ### ########.fr */
/* */
/* ************************************************************************** */
@@ -33,7 +33,7 @@
** then it fills it and its reverse into the list
*/
int fill_list(char line[], t_fillist *list)
void fill_list(char line[], t_fillist *list)
{
unsigned short tmp;
int i;
@@ -57,7 +57,6 @@ int fill_list(char line[], t_fillist *list)
list->tibirtet |= 1;
tmp >>= 1;
}
return (0);
}
/*

View File

@@ -6,7 +6,7 @@
/* By: vmanzoni <vmanzoni@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/03/01 13:34:46 by vmanzoni #+# #+# */
/* Updated: 2019/04/24 13:02:34 by hulamy ### ########.fr */
/* Updated: 2019/04/24 13:46:32 by hulamy ### ########.fr */
/* */
/* ************************************************************************** */
@@ -44,6 +44,5 @@ int check_file_errors(char *file);
int check_tetri_errors(char *tetri);
int check_tetri_errors_proxy(char *tetri);
int add_to_list(char *square, t_fillist **list);
int fill_list(char *line, t_fillist *list);
#endif

View File

@@ -6,23 +6,28 @@
/* By: vmanzoni <vmanzoni@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/04/15 14:48:14 by vmanzoni #+# #+# */
/* Updated: 2019/04/24 12:52:26 by hulamy ### ########.fr */
/* Updated: 2019/04/24 13:48:21 by hulamy ### ########.fr */
/* */
/* ************************************************************************** */
#include "fillit.h"
void print_short(short octet)
{
unsigned int i;
/*
** DELETE BEFORE EVAL
** Function that print a short in bites
*/
i = 1 << 15;
while (i)
{
(octet & i) ? printf("1") : printf("0");
i >>= 1;
}
}
//void print_short(short octet)
//{
// unsigned int i;
//
// i = 1 << 15;
// while (i)
// {
// (octet & i) ? printf("1") : printf("0");
// i >>= 1;
// }
//}
/*
** Function that parse a file and put each tetrimino in a linked list
@@ -36,7 +41,7 @@ void parse_input(char *input)
int j;
i = 0;
printf("%s", input);
// printf("%s", input);
while (input[i])
{
j = 0;
@@ -46,20 +51,20 @@ void parse_input(char *input)
if (check_tetri_errors(tetri))
print_error("Error: Tetrimino not valid.");
add_to_list(tetri, &list);
printf("added to list !!\n");
// printf("added to list !!\n");
while (input[i] && input[i] != '.' && input[i] != '#')
i++;
}
/* DEBUG PART - Print each tetribit*/
while (list != NULL)
{
printf("%i\n", list->tetribit);
print_short(list->tetribit);
printf("\n");
print_short(list->tibirtet);
printf("\n");
list = list->next;
}
// while (list != NULL)
// {
// printf("%i\n", list->tetribit);
// print_short(list->tetribit);
// printf("\n");
// print_short(list->tibirtet);
// printf("\n");
// list = list->next;
// }
}
/*