예제 #1
0
파일: totheleft.c 프로젝트: Quevlahr/2048
static int		ft_moveleft(int *tab, int nb, int change)
{
	int			j;
	int			save_j;

	j = 0;
	save_j = -1;
	while (save_j == -1 && j < nb)
	{
		while (save_j < 0 && j < nb)
		{
			if (tab[j] == 0)
				save_j = j;
			j++;
		}
		while (save_j >= 0 && j < nb)
		{
			if (tab[j] != 0)
				change = ft_helper(tab, &j, &save_j);
			else
				j++;
		}
	}
	return (change);
}
예제 #2
0
int		ft_read(t_data *data, const int fd, char **line)
{
	char	buf[BUFF_SIZE + 1];

	while ((data->ret = read(fd, buf, BUFF_SIZE)) > 0)
	{
		buf[data->ret] = '\0';
		if (!(data->rest))
			data->rest = ft_strdup("");
		data->str = ft_strjoin(data->rest, buf);
		ft_strdel(&(data->rest));
		if (ft_find(data, line) == 1)
			return (1);
	}
	if (data->ret == -1)
	{
		if (data->rest)
			ft_strdel(&(data->rest));
		return (-1);
	}
	if (data->ret == 0 && data->rest)
		return (ft_helper(data, line));
	return (0);
}